source: src/SynTree/ApplicationExpr.cc @ 4c8621ac

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 4c8621ac was 2c57025, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

add support for built-in sized trait which decouples size/alignment information from otype parameters, add test for sized trait

  • Property mode set to 100644
File size: 2.6 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        // xxx - this looks like a memory leak
33        actualType = maybeClone( other.actualType );
34        formalType = maybeClone( other.formalType );
35        expr = maybeClone( other.expr );
36        return *this;
37}
38
39ParamEntry::~ParamEntry() {
40        delete actualType;
41        delete formalType;
42        delete expr;
43}
44
45ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
46        PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
47        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
48
49        set_result( ResolvExpr::extractResultType( function ) );
50
51        assert( has_result() );
52}
53
54ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) :
55                Expression( other ), function( maybeClone( other.function ) ), inferParams( other.inferParams ) {
56        cloneAll( other.args, args );
57}
58
59ApplicationExpr::~ApplicationExpr() {
60        delete function;
61        deleteAll( args );
62}
63
64void ApplicationExpr::print( std::ostream &os, int indent ) const {
65        os << "Application of" << std::endl << std::string(indent+2, ' ');
66        function->print( os, indent+2 );
67        if ( ! args.empty() ) {
68                os << std::string( indent, ' ' ) << "to arguments" << std::endl;
69                printAll( args, os, indent+2 );
70        } // if
71        if ( ! inferParams.empty() ) {
72                os << std::string(indent, ' ') << "with inferred parameters:" << std::endl;
73                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
74                        os << std::string(indent+2, ' ');
75                        Declaration::declFromId( i->second.decl )->printShort( os, indent+2 );
76                        os << std::endl;
77                } // for
78        } // if
79        Expression::print( os, indent );
80}
81
82// Local Variables: //
83// tab-width: 4 //
84// mode: c++ //
85// compile-command: "make install" //
86// End: //
Note: See TracBrowser for help on using the repository browser.