Changeset ce8c12f for src/SynTree
- Timestamp:
- May 15, 2017, 11:30:26 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:
- d36c117
- Parents:
- 65aca88
- Location:
- src/SynTree
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddressExpr.cc
r65aca88 rce8c12f 20 20 AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) { 21 21 if ( arg->has_result() ) { 22 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) ); 22 if ( ReferenceType * refType = dynamic_cast< ReferenceType * > ( arg->get_result() ) ) { 23 // xxx - very temporary, make &ref look like ** 24 set_result( new PointerType( Type::Qualifiers( Type::Lvalue ), refType->get_base()->clone() ) ); 25 } else { 26 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) ); 27 } 23 28 } 24 29 } -
src/SynTree/Mutator.cc
r65aca88 rce8c12f 462 462 } 463 463 464 Type *Mutator::mutate( ReferenceType *refType ) { 465 mutateAll( refType->get_forall(), *this ); 466 refType->set_base( maybeMutate( refType->get_base(), *this ) ); 467 return refType; 468 } 469 464 470 Type *Mutator::mutate( FunctionType *functionType ) { 465 471 mutateAll( functionType->get_forall(), *this ); -
src/SynTree/Mutator.h
r65aca88 rce8c12f 91 91 virtual Type* mutate( PointerType *pointerType ); 92 92 virtual Type* mutate( ArrayType *arrayType ); 93 virtual Type* mutate( ReferenceType *refType ); 93 94 virtual Type* mutate( FunctionType *functionType ); 94 95 virtual Type* mutate( StructInstType *aggregateUseType ); -
src/SynTree/SynTree.h
r65aca88 rce8c12f 99 99 class PointerType; 100 100 class ArrayType; 101 class ReferenceType; 101 102 class FunctionType; 102 103 class ReferenceToType; -
src/SynTree/Type.h
r65aca88 rce8c12f 249 249 bool is_array() const { return isStatic || isVarLen || dimension; } 250 250 251 virtual bool isComplete() const { return ! isVarLen; } 252 251 253 virtual PointerType *clone() const { return new PointerType( *this ); } 252 254 virtual void accept( Visitor & v ) { v.visit( this ); } … … 290 292 }; 291 293 294 class ReferenceType : public Type { 295 public: 296 ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 297 ReferenceType( const ReferenceType & ); 298 virtual ~ReferenceType(); 299 300 Type *get_base() { return base; } 301 void set_base( Type *newValue ) { base = newValue; } 302 303 virtual ReferenceType *clone() const { return new ReferenceType( *this ); } 304 virtual void accept( Visitor & v ) { v.visit( this ); } 305 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 306 virtual void print( std::ostream & os, int indent = 0 ) const; 307 private: 308 Type *base; 309 unsigned int level = 0; 310 }; 311 292 312 class FunctionType : public Type { 293 313 public: -
src/SynTree/Visitor.cc
r65aca88 rce8c12f 354 354 void Visitor::visit( PointerType *pointerType ) { 355 355 acceptAll( pointerType->get_forall(), *this ); 356 // xxx - should PointerType visit/mutate dimension? 356 357 maybeAccept( pointerType->get_base(), *this ); 357 358 } … … 361 362 maybeAccept( arrayType->get_dimension(), *this ); 362 363 maybeAccept( arrayType->get_base(), *this ); 364 } 365 366 void Visitor::visit( ReferenceType *refType ) { 367 acceptAll( refType->get_forall(), *this ); 368 maybeAccept( refType->get_base(), *this ); 363 369 } 364 370 -
src/SynTree/Visitor.h
r65aca88 rce8c12f 94 94 virtual void visit( PointerType *pointerType ); 95 95 virtual void visit( ArrayType *arrayType ); 96 virtual void visit( ReferenceType *refType ); 96 97 virtual void visit( FunctionType *functionType ); 97 98 virtual void visit( StructInstType *aggregateUseType ); … … 163 164 } // if 164 165 } catch( SemanticError &e ) { 165 e.set_location( (*i)->location ); 166 e.set_location( (*i)->location ); 166 167 errors.append( e ); 167 168 } // try -
src/SynTree/module.mk
r65aca88 rce8c12f 20 20 SynTree/PointerType.cc \ 21 21 SynTree/ArrayType.cc \ 22 SynTree/ReferenceType.cc \ 22 23 SynTree/FunctionType.cc \ 23 24 SynTree/ReferenceToType.cc \
Note:
See TracChangeset
for help on using the changeset viewer.