Changeset 4ee1efb for src/SynTree
- Timestamp:
- Oct 26, 2017, 11:23:26 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 136ccd7
- Parents:
- 0b9be4d (diff), 598f50e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Rob Schluntz <rschlunt@…> (10/26/17 10:43:08)
- git-committer:
- Rob Schluntz <rschlunt@…> (10/26/17 11:23:26)
- Location:
- src/SynTree
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/ApplicationExpr.cc
r0b9be4d r4ee1efb 59 59 60 60 ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) : 61 Expression( other ), function( maybeClone( other.function ) ) , inferParams( other.inferParams ){61 Expression( other ), function( maybeClone( other.function ) ) { 62 62 cloneAll( other.args, args ); 63 63 } … … 66 66 delete function; 67 67 deleteAll( args ); 68 }69 70 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {71 if ( ! inferParams.empty() ) {72 os << indent << "with inferred parameters " << level << ":" << std::endl;73 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {74 os << indent+1;75 Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );76 os << std::endl;77 printInferParams( *i->second.inferParams, os, indent+1, level+1 );78 } // for79 } // if80 68 } 81 69 … … 88 76 printAll( args, os, indent+1 ); 89 77 } // if 90 printInferParams( inferParams, os, indent+1, 0 );91 78 Expression::print( os, indent ); 92 79 } -
src/SynTree/Expression.cc
r0b9be4d r4ee1efb 33 33 #include "GenPoly/Lvalue.h" 34 34 35 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) { 36 if ( ! inferParams.empty() ) { 37 os << indent << "with inferred parameters " << level << ":" << std::endl; 38 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) { 39 os << indent+1; 40 Declaration::declFromId( i->second.decl )->printShort( os, indent+1 ); 41 os << std::endl; 42 printInferParams( *i->second.inferParams, os, indent+1, level+1 ); 43 } // for 44 } // if 45 } 46 35 47 Expression::Expression() : result( 0 ), env( 0 ) {} 36 48 37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ) {49 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) { 38 50 } 39 51 … … 44 56 45 57 void Expression::print( std::ostream &os, Indenter indent ) const { 58 printInferParams( inferParams, os, indent+1, 0 ); 59 46 60 if ( env ) { 47 61 os << std::endl << indent << "... with environment:" << std::endl; -
src/SynTree/Expression.h
r0b9be4d r4ee1efb 31 31 32 32 33 /// Expression is the root type for all expressions34 class Expression : public BaseSyntaxNode{35 public:36 Type * result;37 TypeSubstitution * env;38 bool extension = false;39 40 Expression();41 Expression( const Expression & other );42 virtual ~Expression();43 44 Type *& get_result() { return result; }45 const Type * get_result() const { return result; }46 void set_result( Type * newValue ) { result = newValue; }47 48 TypeSubstitution * get_env() const { return env; }49 void set_env( TypeSubstitution * newValue ) { env = newValue; }50 bool get_extension() const { return extension; }51 Expression * set_extension( bool exten ) { extension = exten; return this; }52 53 virtual Expression * clone() const override = 0;54 virtual void accept( Visitor & v ) override = 0;55 virtual Expression * acceptMutator( Mutator & m ) override = 0;56 virtual void print( std::ostream & os, Indenter indent = {} ) const override;57 };58 59 33 struct ParamEntry; 60 34 … … 73 47 Type * actualType; 74 48 Type * formalType; 75 Expression * expr;49 Expression * expr; 76 50 std::unique_ptr< InferredParams > inferParams; 51 }; 52 53 /// Expression is the root type for all expressions 54 class Expression : public BaseSyntaxNode { 55 public: 56 Type * result; 57 TypeSubstitution * env; 58 bool extension = false; 59 InferredParams inferParams; 60 61 Expression(); 62 Expression( const Expression & other ); 63 virtual ~Expression(); 64 65 Type *& get_result() { return result; } 66 const Type * get_result() const { return result; } 67 void set_result( Type * newValue ) { result = newValue; } 68 69 TypeSubstitution * get_env() const { return env; } 70 void set_env( TypeSubstitution * newValue ) { env = newValue; } 71 bool get_extension() const { return extension; } 72 Expression * set_extension( bool exten ) { extension = exten; return this; } 73 74 InferredParams & get_inferParams() { return inferParams; } 75 76 virtual Expression * clone() const override = 0; 77 virtual void accept( Visitor & v ) override = 0; 78 virtual Expression * acceptMutator( Mutator & m ) override = 0; 79 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 77 80 }; 78 81 … … 83 86 Expression * function; 84 87 std::list<Expression *> args; 85 InferredParams inferParams;86 88 87 89 ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); … … 92 94 void set_function( Expression * newValue ) { function = newValue; } 93 95 std::list<Expression *>& get_args() { return args; } 94 InferredParams & get_inferParams() { return inferParams; }95 96 96 97 virtual ApplicationExpr * clone() const { return new ApplicationExpr( * this ); } -
src/SynTree/Type.h
r0b9be4d r4ee1efb 298 298 void set_isStatic( bool newValue ) { isStatic = newValue; } 299 299 300 virtual bool isComplete() const override { return ! isVarLen; } 300 // array types are complete if they have a dimension expression or are 301 // VLAs ('*' in parameter declaration), and incomplete otherwise. 302 // See 6.7.6.2 303 virtual bool isComplete() const override { return dimension || isVarLen; } 301 304 302 305 virtual ArrayType *clone() const override { return new ArrayType( *this ); }
Note: See TracChangeset
for help on using the changeset viewer.