source: src/SynTree/ApplicationExpr.cc @ 1aa4b71

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 1aa4b71 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
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
[51b7345]16#include <cassert>
17
18#include "Expression.h"
19#include "Declaration.h"
20#include "Type.h"
21#include "TypeSubstitution.h"
[d3b7937]22#include "Common/utility.h"
[906e24d]23#include "ResolvExpr/typeops.h"
[51b7345]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;
[2c57025]32        // xxx - this looks like a memory leak
[0dd3a2f]33        actualType = maybeClone( other.actualType );
34        formalType = maybeClone( other.formalType );
35        expr = maybeClone( other.expr );
36        return *this;
[51b7345]37}
38
[0dd3a2f]39ParamEntry::~ParamEntry() {
40        delete actualType;
41        delete formalType;
42        delete expr;
[51b7345]43}
44
[0dd3a2f]45ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
[906e24d]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() );
[51b7345]52}
53
[0dd3a2f]54ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) :
55                Expression( other ), function( maybeClone( other.function ) ), inferParams( other.inferParams ) {
56        cloneAll( other.args, args );
[51b7345]57}
58
[0dd3a2f]59ApplicationExpr::~ApplicationExpr() {
60        delete function;
61        deleteAll( args );
[51b7345]62}
63
[0dd3a2f]64void ApplicationExpr::print( std::ostream &os, int indent ) const {
[9554d9b]65        os << "Application of" << std::endl << std::string(indent+2, ' ');
[0dd3a2f]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 );
[51b7345]80}
81
[0dd3a2f]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.