source: src/SynTree/ApplicationExpr.cc @ 3205495

new-envwith_gc
Last change on this file since 3205495 was 8d7bef2, checked in by Aaron Moss <a3moss@…>, 7 years ago

First compiling build of CFA-CC with GC

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[0dd3a2f]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[89231bc]7// ApplicationExpr.cc.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[89231bc]11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Apr 26 12:41:06 2016
[0dd3a2f]13// Update Count     : 4
14//
15
[e3e16bc]16#include <cassert>               // for strict_dynamic_cast, assert
[ea6332d]17#include <list>                  // for list
18#include <map>                   // for _Rb_tree_const_iterator, map, map<>:...
19#include <ostream>               // for operator<<, ostream, basic_ostream
20#include <string>                // for operator<<, string, char_traits
21#include <utility>               // for pair
[51b7345]22
[ea6332d]23#include "Common/utility.h"      // for maybeClone, cloneAll, deleteAll, pri...
24#include "Declaration.h"         // for Declaration
25#include "Expression.h"          // for ParamEntry, ApplicationExpr, Expression
26#include "ResolvExpr/typeops.h"  // for extractResultType
27#include "Type.h"                // for Type, PointerType, FunctionType
[51b7345]28
[0dd3a2f]29ParamEntry::ParamEntry( const ParamEntry &other ) :
[6c3a988f]30                decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ), inferParams( new InferredParams( *other.inferParams ) ) {
[51b7345]31}
32
[0dd3a2f]33ParamEntry &ParamEntry::operator=( const ParamEntry &other ) {
34        if ( &other == this ) return *this;
35        decl = other.decl;
[2c57025]36        // xxx - this looks like a memory leak
[0dd3a2f]37        actualType = maybeClone( other.actualType );
38        formalType = maybeClone( other.formalType );
39        expr = maybeClone( other.expr );
[6c3a988f]40        *inferParams = *other.inferParams;
[0dd3a2f]41        return *this;
[51b7345]42}
43
[f19339e]44ApplicationExpr::ApplicationExpr( Expression *funcExpr, const std::list<Expression *> & args ) : function( funcExpr ), args( args ) {
[e3e16bc]45        PointerType *pointer = strict_dynamic_cast< PointerType* >( funcExpr->get_result() );
46        FunctionType *function = strict_dynamic_cast< FunctionType* >( pointer->get_base() );
[906e24d]47
48        set_result( ResolvExpr::extractResultType( function ) );
49
[d29fa5f]50        assert( result );
[51b7345]51}
52
[0dd3a2f]53ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) :
[df626eb]54                Expression( other ), function( maybeClone( other.function ) ) {
[0dd3a2f]55        cloneAll( other.args, args );
[51b7345]56}
57
[50377a4]58void ApplicationExpr::print( std::ostream &os, Indenter indent ) const {
59        os << "Application of" << std::endl << indent+1;
60        function->print( os, indent+1 );
61        os << std::endl;
[6c3a988f]62        if ( ! args.empty() ) {
[50377a4]63                os << indent << "... to arguments" << std::endl;
64                printAll( args, os, indent+1 );
[6c3a988f]65        } // if
[0dd3a2f]66        Expression::print( os, indent );
[51b7345]67}
68
[0dd3a2f]69// Local Variables: //
70// tab-width: 4 //
71// mode: c++ //
72// compile-command: "make install" //
73// End: //
Note: See TracBrowser for help on using the repository browser.