Changeset 9a705dc8 for src/SynTree
- Timestamp:
- Apr 19, 2018, 5:18:46 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, with_gc
- Children:
- da9d79b
- Parents:
- 60ba456
- Location:
- src/SynTree
- Files:
-
- 5 edited
-
Expression.cc (modified) (1 diff)
-
Expression.h (modified) (2 diffs)
-
Mutator.h (modified) (1 diff)
-
SynTree.h (modified) (1 diff)
-
Visitor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r60ba456 r9a705dc8 299 299 } 300 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(); 327 Expression::print( os, indent ); 328 } 329 301 330 VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) { 302 331 set_result(toType); -
src/SynTree/Expression.h
r60ba456 r9a705dc8 192 192 CastExpr( Expression * arg, bool isGenerated = true ); 193 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 194 195 CastExpr( const CastExpr & other ); 195 196 virtual ~CastExpr(); … … 199 200 200 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 ); } 201 222 virtual void accept( Visitor & v ) { v.visit( this ); } 202 223 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } -
src/SynTree/Mutator.h
r60ba456 r9a705dc8 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
r60ba456 r9a705dc8 69 69 class LabelAddressExpr; 70 70 class CastExpr; 71 class KeywordCastExpr; 71 72 class VirtualCastExpr; 72 73 class MemberExpr; -
src/SynTree/Visitor.h
r60ba456 r9a705dc8 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.