Changeset e6d39fe for src/SynTree
- Timestamp:
- Apr 20, 2018, 9:04:41 AM (7 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, with_gc
- Children:
- 22bdc34
- Parents:
- 9181f1d (diff), 88f15ae (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
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r9181f1d re6d39fe 271 271 } 272 272 273 CastExpr::CastExpr( Expression *arg _, Type *toType ) : Expression(), arg(arg_) {273 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 274 274 set_result(toType); 275 275 } 276 276 277 CastExpr::CastExpr( Expression *arg _ ) : Expression(), arg(arg_) {277 CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 278 278 set_result( new VoidType( Type::Qualifiers() ) ); 279 279 } 280 280 281 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {281 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) { 282 282 } 283 283 … … 296 296 result->print( os, indent+1 ); 297 297 } // if 298 Expression::print( os, indent ); 299 } 300 301 KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) { 302 } 303 304 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) { 305 } 306 307 KeywordCastExpr::~KeywordCastExpr() { 308 delete arg; 309 } 310 311 const std::string & KeywordCastExpr::targetString() const { 312 static const std::string targetStrs[] = { 313 "coroutine", "thread", "monitor" 314 }; 315 static_assert( 316 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 317 "Each KeywordCastExpr::Target should have a corresponding string representation" 318 ); 319 return targetStrs[(unsigned long)target]; 320 } 321 322 void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const { 323 os << "Keyword Cast of:" << std::endl << indent+1; 324 arg->print(os, indent+1); 325 os << std::endl << indent << "... to: "; 326 os << targetString(); 298 327 Expression::print( os, indent ); 299 328 } -
src/SynTree/Expression.h
r9181f1d re6d39fe 188 188 public: 189 189 Expression * arg; 190 191 CastExpr( Expression * arg ); 192 CastExpr( Expression * arg, Type * toType ); 190 bool isGenerated = true; // whether this cast appeared in the source program 191 192 CastExpr( Expression * arg, bool isGenerated = true ); 193 CastExpr( Expression * arg, Type * toType, bool isGenerated = true ); 194 CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor 193 195 CastExpr( const CastExpr & other ); 194 196 virtual ~CastExpr(); … … 198 200 199 201 virtual CastExpr * clone() const { return new CastExpr( * this ); } 202 virtual void accept( Visitor & v ) { v.visit( this ); } 203 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 204 virtual void print( std::ostream & os, Indenter indent = {} ) const; 205 }; 206 207 /// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t 208 class KeywordCastExpr : public Expression { 209 public: 210 Expression * arg; 211 enum Target { 212 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS 213 } target; 214 215 KeywordCastExpr( Expression * arg, Target target ); 216 KeywordCastExpr( const KeywordCastExpr & other ); 217 virtual ~KeywordCastExpr(); 218 219 const std::string & targetString() const; 220 221 virtual KeywordCastExpr * clone() const { return new KeywordCastExpr( * this ); } 200 222 virtual void accept( Visitor & v ) { v.visit( this ); } 201 223 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } -
src/SynTree/Mutator.h
r9181f1d re6d39fe 59 59 virtual Expression * mutate( UntypedExpr * untypedExpr ) = 0; 60 60 virtual Expression * mutate( NameExpr * nameExpr ) = 0; 61 virtual Expression * mutate( AddressExpr * castExpr ) = 0;61 virtual Expression * mutate( AddressExpr * addrExpr ) = 0; 62 62 virtual Expression * mutate( LabelAddressExpr * labAddressExpr ) = 0; 63 63 virtual Expression * mutate( CastExpr * castExpr ) = 0; 64 virtual Expression * mutate( KeywordCastExpr * castExpr ) = 0; 64 65 virtual Expression * mutate( VirtualCastExpr * castExpr ) = 0; 65 66 virtual Expression * mutate( UntypedMemberExpr * memberExpr ) = 0; -
src/SynTree/SynTree.h
r9181f1d re6d39fe 69 69 class LabelAddressExpr; 70 70 class CastExpr; 71 class KeywordCastExpr; 71 72 class VirtualCastExpr; 72 73 class MemberExpr; -
src/SynTree/Visitor.h
r9181f1d re6d39fe 62 62 virtual void visit( NameExpr * nameExpr ) = 0; 63 63 virtual void visit( CastExpr * castExpr ) = 0; 64 virtual void visit( KeywordCastExpr * castExpr ) = 0; 64 65 virtual void visit( VirtualCastExpr * castExpr ) = 0; 65 66 virtual void visit( AddressExpr * addressExpr ) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.