Changeset b3f252a for src/SynTree
- Timestamp:
- Sep 7, 2017, 10:36:35 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e0886db
- Parents:
- 871cdb4 (diff), 416cc86 (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. - Location:
- src/SynTree
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddressExpr.cc
r871cdb4 rb3f252a 70 70 } 71 71 72 LabelAddressExpr::LabelAddressExpr( const Label &arg ) : arg( arg ) { 73 // label address always has type void * 74 result = new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ); 75 } 76 LabelAddressExpr::LabelAddressExpr( const LabelAddressExpr & other ) : Expression( other ), arg( other.arg ) {} 77 LabelAddressExpr::~LabelAddressExpr() {} 78 79 void LabelAddressExpr::print( std::ostream & os, int indent ) const { 80 os << "Address of label:" << std::endl << std::string( indent+2, ' ' ) << arg; 81 } 82 72 83 // Local Variables: // 73 84 // tab-width: 4 // -
src/SynTree/Declaration.h
r871cdb4 rb3f252a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Aug 14 10:15:00201713 // Update Count : 1 2811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 3 19:24:06 2017 13 // Update Count : 131 14 14 // 15 15 … … 82 82 int scopeLevel = 0; 83 83 84 ConstantExpr*asmName;84 Expression *asmName; 85 85 std::list< Attribute * > attributes; 86 86 … … 97 97 DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; } 98 98 99 ConstantExpr*get_asmName() const { return asmName; }100 DeclarationWithType * set_asmName( ConstantExpr*newValue ) { asmName = newValue; return this; }99 Expression *get_asmName() const { return asmName; } 100 DeclarationWithType * set_asmName( Expression *newValue ) { asmName = newValue; return this; } 101 101 102 102 std::list< Attribute * >& get_attributes() { return attributes; } -
src/SynTree/Expression.h
r871cdb4 rb3f252a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Aug 8 11:54:00201713 // Update Count : 4 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 3 19:23:46 2017 13 // Update Count : 48 14 14 // 15 15 16 #pragma once 16 17 … … 24 25 #include "Constant.h" // for Constant 25 26 #include "Initializer.h" // for Designation (ptr only), Initializer 27 #include "Label.h" // for Label 26 28 #include "Mutator.h" // for Mutator 27 29 #include "SynTree.h" // for UniqueId … … 171 173 }; 172 174 173 // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack 175 // GCC &&label 176 // https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Labels-as-Values.html 174 177 class LabelAddressExpr : public Expression { 175 178 public: 176 Expression *arg;177 178 LabelAddressExpr( Expression *arg );179 Label arg; 180 181 LabelAddressExpr( const Label &arg ); 179 182 LabelAddressExpr( const LabelAddressExpr & other ); 180 183 virtual ~LabelAddressExpr(); 181 182 Expression * get_arg() const { return arg; }183 void set_arg(Expression * newValue ) { arg = newValue; }184 184 185 185 virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); } … … 538 538 public: 539 539 Expression * inout; 540 ConstantExpr* constraint;540 Expression * constraint; 541 541 Expression * operand; 542 542 543 AsmExpr( Expression * inout, ConstantExpr* constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}543 AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 544 544 AsmExpr( const AsmExpr & other ); 545 545 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; … … 548 548 void set_inout( Expression * newValue ) { inout = newValue; } 549 549 550 ConstantExpr* get_constraint() const { return constraint; }551 void set_constraint( ConstantExpr* newValue ) { constraint = newValue; }550 Expression * get_constraint() const { return constraint; } 551 void set_constraint( Expression * newValue ) { constraint = newValue; } 552 552 553 553 Expression * get_operand() const { return operand; } -
src/SynTree/Mutator.cc
r871cdb4 rb3f252a 246 246 labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) ); 247 247 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) ); 248 labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );249 248 return labelAddressExpr; 250 249 } … … 538 537 Type * Mutator::mutate( TraitInstType *aggregateUseType ) { 539 538 handleReferenceToType( aggregateUseType ); 540 mutateAll( aggregateUseType->get_members(), *this );541 539 return aggregateUseType; 542 540 } -
src/SynTree/ReferenceToType.cc
r871cdb4 rb3f252a 132 132 std::string TraitInstType::typeString() const { return "trait"; } 133 133 134 TraitInstType::TraitInstType( const TraitInstType &other ) : Parent( other ) { 135 cloneAll( other.members, members ); 134 TraitInstType::TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes ) : Parent( tq, baseTrait->name, attributes ), baseTrait( baseTrait ) {} 135 136 TraitInstType::TraitInstType( const TraitInstType &other ) : Parent( other ), baseTrait( other.baseTrait ) { 136 137 } 137 138 138 139 TraitInstType::~TraitInstType() { 139 deleteAll( members );140 140 } 141 141 -
src/SynTree/Statement.cc
r871cdb4 rb3f252a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 17 16:17:20201713 // Update Count : 6 712 // Last Modified On : Sun Sep 3 20:46:44 2017 13 // Update Count : 68 14 14 // 15 15 … … 52 52 53 53 54 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr*instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}54 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} 55 55 56 56 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { … … 89 89 90 90 BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) : 91 Statement( labels ), originalTarget( target ), target( target ), computedTarget( NULL), type( type ) {91 Statement( labels ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 92 92 //actually this is a syntactic error signaled by the parser 93 if ( type == BranchStmt::Goto && target.empty() ) 93 if ( type == BranchStmt::Goto && target.empty() ) { 94 94 throw SemanticError("goto without target"); 95 } 95 96 } 96 97 97 98 BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) : 98 99 Statement( labels ), computedTarget( computedTarget ), type( type ) { 99 if ( type != BranchStmt::Goto || computedTarget == 0 )100 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { 100 101 throw SemanticError("Computed target not valid in branch statement"); 102 } 101 103 } 102 104 103 105 void BranchStmt::print( std::ostream &os, int indent ) const { 104 106 os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ; 107 if ( target != "" ) os << string( indent+2, ' ' ) << "with target: " << target << endl; 108 if ( originalTarget != "" ) os << string( indent+2, ' ' ) << "with original target: " << originalTarget << endl; 109 if ( computedTarget != nullptr ) os << string( indent+2, ' ' ) << "with computed target: " << computedTarget << endl; 105 110 } 106 111 -
src/SynTree/Statement.h
r871cdb4 rb3f252a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 17 15:37:53201713 // Update Count : 7 212 // Last Modified On : Sun Sep 3 20:46:46 2017 13 // Update Count : 77 14 14 // 15 15 … … 98 98 public: 99 99 bool voltile; 100 ConstantExpr*instruction;100 Expression *instruction; 101 101 std::list<Expression *> output, input; 102 102 std::list<ConstantExpr *> clobber; 103 103 std::list<Label> gotolabels; 104 104 105 AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );105 AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 106 106 AsmStmt( const AsmStmt &other ); 107 107 virtual ~AsmStmt(); … … 109 109 bool get_voltile() { return voltile; } 110 110 void set_voltile( bool newValue ) { voltile = newValue; } 111 ConstantExpr *get_instruction() { return instruction; }112 void set_instruction( ConstantExpr *newValue ) { instruction = newValue; }113 std::list<Expression *> & get_output() { return output; }114 void set_output( const std::list<Expression *> & newValue ) { output = newValue; }115 std::list<Expression *> & get_input() { return input; }111 Expression * get_instruction() { return instruction; } 112 void set_instruction( Expression * newValue ) { instruction = newValue; } 113 std::list<Expression *> & get_output() { return output; } 114 void set_output( const std::list<Expression *> & newValue ) { output = newValue; } 115 std::list<Expression *> & get_input() { return input; } 116 116 void set_input( const std::list<Expression *> &newValue ) { input = newValue; } 117 std::list<ConstantExpr *> & get_clobber() { return clobber; }117 std::list<ConstantExpr *> & get_clobber() { return clobber; } 118 118 void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; } 119 std::list<Label> & get_gotolabels() { return gotolabels; }119 std::list<Label> & get_gotolabels() { return gotolabels; } 120 120 void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; } 121 121 122 virtual AsmStmt * clone() const { return new AsmStmt( *this ); }123 virtual void accept( Visitor & v ) { v.visit( this ); }124 virtual Statement * acceptMutator( Mutator &m ) { return m.mutate( this ); }125 virtual void print( std::ostream & os, int indent = 0 ) const;122 virtual AsmStmt * clone() const { return new AsmStmt( *this ); } 123 virtual void accept( Visitor & v ) { v.visit( this ); } 124 virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); } 125 virtual void print( std::ostream & os, int indent = 0 ) const; 126 126 }; 127 127 -
src/SynTree/Type.h
r871cdb4 rb3f252a 471 471 typedef ReferenceToType Parent; 472 472 public: 473 // this member is filled in by the validate pass, which instantiates the members of the correponding 474 // aggregate with the actual type parameters specified for this use of the context 475 std::list< Declaration* > members; 476 477 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 473 // this decl is not "owned" by the trait inst; it is merely a pointer to elsewhere in the tree, 474 // where the trait used in this type is actually defined 475 TraitDecl * baseTrait = nullptr; 476 477 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 478 TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 478 479 TraitInstType( const TraitInstType & other ); 479 480 ~TraitInstType(); 480 481 std::list< Declaration* >& get_members() { return members; }482 481 483 482 virtual bool isComplete() const; -
src/SynTree/TypeSubstitution.h
r871cdb4 rb3f252a 177 177 void applySubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actual, MemberIterator memberBegin, MemberIterator memberEnd, OutputIterator out ) { 178 178 TypeSubstitution sub = TypeSubstitution( formalBegin, formalEnd, actual ); 179 for ( std::list< Declaration* >::iteratori = memberBegin; i != memberEnd; ++i ) {179 for ( auto i = memberBegin; i != memberEnd; ++i ) { 180 180 sub.apply( *i ); 181 181 *out++ = *i; -
src/SynTree/Visitor.cc
r871cdb4 rb3f252a 205 205 void Visitor::visit( LabelAddressExpr *labAddressExpr ) { 206 206 maybeAccept( labAddressExpr->get_result(), *this ); 207 maybeAccept( labAddressExpr->get_arg(), *this );208 207 } 209 208 … … 429 428 void Visitor::visit( TraitInstType *aggregateUseType ) { 430 429 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) ); 431 acceptAll( aggregateUseType->get_members(), *this );432 430 } 433 431
Note:
See TracChangeset
for help on using the changeset viewer.