Changeset dbc733e for src/SynTree
- Timestamp:
- Sep 1, 2017, 9:53:19 PM (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:
- f43df73
- Parents:
- ba2a68b (diff), b0dfbc4 (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:
-
- 5 edited
-
AddressExpr.cc (modified) (1 diff)
-
Expression.h (modified) (2 diffs)
-
Mutator.cc (modified) (1 diff)
-
Statement.cc (modified) (1 diff)
-
Visitor.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddressExpr.cc
rba2a68b rdbc733e 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/Expression.h
rba2a68b rdbc733e 24 24 #include "Constant.h" // for Constant 25 25 #include "Initializer.h" // for Designation (ptr only), Initializer 26 #include "Label.h" // for Label 26 27 #include "Mutator.h" // for Mutator 27 28 #include "SynTree.h" // for UniqueId … … 173 174 }; 174 175 175 // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack 176 // GCC &&label 177 // https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Labels-as-Values.html 176 178 class LabelAddressExpr : public Expression { 177 179 public: 178 Expression *arg;179 180 LabelAddressExpr( Expression *arg );180 Label arg; 181 182 LabelAddressExpr( const Label &arg ); 181 183 LabelAddressExpr( const LabelAddressExpr & other ); 182 184 virtual ~LabelAddressExpr(); 183 184 Expression * get_arg() const { return arg; }185 void set_arg(Expression * newValue ) { arg = newValue; }186 185 187 186 virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); } -
src/SynTree/Mutator.cc
rba2a68b rdbc733e 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 } -
src/SynTree/Statement.cc
rba2a68b rdbc733e 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/Visitor.cc
rba2a68b rdbc733e 205 205 void Visitor::visit( LabelAddressExpr *labAddressExpr ) { 206 206 maybeAccept( labAddressExpr->get_result(), *this ); 207 maybeAccept( labAddressExpr->get_arg(), *this );208 207 } 209 208
Note:
See TracChangeset
for help on using the changeset viewer.