source: src/SynTree/ApplicationExpr.cc @ d073e3c

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d073e3c was 906e24d, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

replace results list on Expressions with a single Type field

  • Property mode set to 100644
File size: 2.5 KB
Line 
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 : Rob Schluntz
12// Last Modified On : Tue Apr 26 12:41:06 2016
13// Update Count     : 4
14//
15
16#include <cassert>
17
18#include "Expression.h"
19#include "Declaration.h"
20#include "Type.h"
21#include "TypeSubstitution.h"
22#include "Common/utility.h"
23#include "ResolvExpr/typeops.h"
24
25ParamEntry::ParamEntry( const ParamEntry &other ) :
26                decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ) {
27}
28
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;
36}
37
38ParamEntry::~ParamEntry() {
39        delete actualType;
40        delete formalType;
41        delete expr;
42}
43
44ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
45        PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
46        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
47
48        set_result( ResolvExpr::extractResultType( function ) );
49
50        assert( has_result() );
51}
52
53ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) :
54                Expression( other ), function( maybeClone( other.function ) ), inferParams( other.inferParams ) {
55        cloneAll( other.args, args );
56}
57
58ApplicationExpr::~ApplicationExpr() {
59        delete function;
60        deleteAll( args );
61}
62
63void ApplicationExpr::print( std::ostream &os, int indent ) const {
64        os << "Application of" << std::endl << std::string(indent+2, ' ');
65        function->print( os, indent+2 );
66        if ( ! args.empty() ) {
67                os << std::string( indent, ' ' ) << "to arguments" << std::endl;
68                printAll( args, os, indent+2 );
69        } // if
70        if ( ! inferParams.empty() ) {
71                os << std::string(indent, ' ') << "with inferred parameters:" << std::endl;
72                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
73                        os << std::string(indent+2, ' ');
74                        Declaration::declFromId( i->second.decl )->printShort( os, indent+2 );
75                        os << std::endl;
76                } // for
77        } // if
78        Expression::print( os, indent );
79}
80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.