source: src/SynTree/ApplicationExpr.cc @ cd623a4

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since cd623a4 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: seventh groups of files

  • Property mode set to 100644
File size: 2.6 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//
7// ApplicationExpr.cc.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon May 18 07:54:17 2015
13// Update Count     : 4
14//
15
[51b7345]16#include <cassert>
17
18#include "Expression.h"
19#include "Declaration.h"
20#include "Type.h"
21#include "TypeSubstitution.h"
22#include "utility.h"
23
24
[0dd3a2f]25ParamEntry::ParamEntry( const ParamEntry &other ) :
26                decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ) {
[51b7345]27}
28
[0dd3a2f]29ParamEntry &ParamEntry::operator=( const ParamEntry &other ) {
30        if ( &other == this ) return *this;
31        decl = other.decl;
32        actualType = maybeClone( other.actualType );
33        formalType = maybeClone( other.formalType );
34        expr = maybeClone( other.expr );
35        return *this;
[51b7345]36}
37
[0dd3a2f]38ParamEntry::~ParamEntry() {
39        delete actualType;
40        delete formalType;
41        delete expr;
[51b7345]42}
43
[0dd3a2f]44ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
45        PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() );
46        assert( pointer );
47        FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
48        assert( function );
49       
50        for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {
51                get_results().push_back( (*i)->get_type()->clone() );
52        } // for
[51b7345]53}
54
[0dd3a2f]55ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) :
56                Expression( other ), function( maybeClone( other.function ) ), inferParams( other.inferParams ) {
57        cloneAll( other.args, args );
[51b7345]58}
59
[0dd3a2f]60ApplicationExpr::~ApplicationExpr() {
61        delete function;
62        deleteAll( args );
[51b7345]63}
64
[0dd3a2f]65void ApplicationExpr::print( std::ostream &os, int indent ) const {
66        os << std::string( indent, ' ' ) << "Application of" << std::endl;
67        function->print( os, indent+2 );
68        if ( ! args.empty() ) {
69                os << std::string( indent, ' ' ) << "to arguments" << std::endl;
70                printAll( args, os, indent+2 );
71        } // if
72        if ( ! inferParams.empty() ) {
73                os << std::string(indent, ' ') << "with inferred parameters:" << std::endl;
74                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
75                        os << std::string(indent+2, ' ');
76                        Declaration::declFromId( i->second.decl )->printShort( os, indent+2 );
77                        os << std::endl;
78                } // for
79        } // if
80        Expression::print( os, indent );
[51b7345]81}
82
[0dd3a2f]83// Local Variables: //
84// tab-width: 4 //
85// mode: c++ //
86// compile-command: "make install" //
87// End: //
Note: See TracBrowser for help on using the repository browser.