Changeset afc1045
- Timestamp:
- Apr 5, 2016, 3:31:09 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- d75038c
- Parents:
- b3f9a0cb
- Location:
- src
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rb3f9a0cb rafc1045 455 455 456 456 void CodeGenerator::visit( UntypedOffsetofExpr *offsetofExpr ) { 457 assert( false );457 assert( false && "UntypedOffsetofExpr should not reach code generation" ); 458 458 } 459 459 … … 464 464 output << ", " << mangleName( offsetofExpr->get_member() ); 465 465 output << ")"; 466 } 467 468 void CodeGenerator::visit( OffsetPackExpr *offsetPackExpr ) { 469 assert( false && "OffsetPackExpr should not reach code generation" ); 466 470 } 467 471 -
src/CodeGen/CodeGenerator.h
rb3f9a0cb rafc1045 65 65 virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 66 66 virtual void visit( OffsetofExpr *offsetofExpr ); 67 virtual void visit( OffsetPackExpr *offsetPackExpr ); 67 68 virtual void visit( LogicalExpr *logicalExpr ); 68 69 virtual void visit( ConditionalExpr *conditionalExpr ); -
src/GenPoly/Box.cc
rb3f9a0cb rafc1045 214 214 }; 215 215 216 class OffsetPackExpr; // forward declaration so that it can be mutated by Pass2217 218 216 /// * Moves polymorphic returns in function types to pointer-type parameters 219 217 /// * adds type size and assertion parameters to parameter lists … … 232 230 virtual Expression *mutate( AlignofExpr *alignofExpr ); 233 231 virtual Expression *mutate( OffsetofExpr *offsetofExpr ); 234 232 virtual Expression *mutate( OffsetPackExpr *offsetPackExpr ); 235 233 236 234 virtual void doBeginScope(); … … 248 246 ScopedSet< std::string > knownLayouts; ///< Set of generic type layouts known in the current scope, indexed by sizeofName 249 247 ScopedSet< std::string > knownOffsets; ///< Set of non-generic types for which the offset array exists in the current scope, indexed by offsetofName 250 };251 252 /// Special internal expression for offset arrays inserted by Pass1 and replaced by Pass2253 class OffsetPackExpr : public Expression {254 public:255 OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 ) : Expression( aname_ ), type( type_ ) {256 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );257 }258 259 OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}260 virtual ~OffsetPackExpr() { delete type; }261 262 StructInstType *get_type() const { return type; }263 void set_type( StructInstType *newValue ) { type = newValue; }264 265 virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); }266 virtual void accept( Visitor &v ) { /* do nothing */ }267 virtual Expression *acceptMutator( Mutator &m ) {268 // only act if the mutator is a Pass2, which knows about this class269 if ( Pass2 *m2 = dynamic_cast< Pass2* >( &m ) ) {270 return m2->mutate( this );271 } else {272 return this;273 }274 }275 276 virtual void print( std::ostream &os, int indent = 0 ) const {277 os << std::string( indent, ' ' ) << "Offset pack expression on ";278 279 if ( type ) {280 type->print(os, indent + 2);281 } else {282 os << "<NULL>";283 }284 285 os << std::endl;286 Expression::print( os, indent );287 }288 289 private:290 StructInstType *type;291 248 }; 292 249 -
src/InitTweak/InitModel.h
rb3f9a0cb rafc1045 75 75 void visit( UntypedOffsetofExpr * ) { throw 0; } 76 76 void visit( OffsetofExpr * ) { throw 0; } 77 void visit( OffsetPackExpr * ) { throw 0; } 77 78 void visit( AttrExpr * ) { throw 0; } 78 79 void visit( LogicalExpr * ) { throw 0; } -
src/ResolvExpr/AlternativeFinder.cc
rb3f9a0cb rafc1045 848 848 } 849 849 850 void AlternativeFinder::visit( OffsetPackExpr *offsetPackExpr ) { 851 alternatives.push_back( Alternative( offsetPackExpr->clone(), env, Cost::zero ) ); 852 } 853 850 854 void AlternativeFinder::resolveAttr( DeclarationWithType *funcDecl, FunctionType *function, Type *argType, const TypeEnvironment &env ) { 851 855 // assume no polymorphism -
src/ResolvExpr/AlternativeFinder.h
rb3f9a0cb rafc1045 59 59 virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 60 60 virtual void visit( OffsetofExpr *offsetofExpr ); 61 virtual void visit( OffsetPackExpr *offsetPackExpr ); 61 62 virtual void visit( AttrExpr *attrExpr ); 62 63 virtual void visit( LogicalExpr *logicalExpr ); -
src/SymTab/Indexer.cc
rb3f9a0cb rafc1045 344 344 maybeAccept( offsetofExpr->get_type(), *this ); 345 345 maybeAccept( offsetofExpr->get_member(), *this ); 346 } 347 348 void Indexer::visit( OffsetPackExpr *offsetPackExpr ) { 349 acceptAllNewScope( offsetPackExpr->get_results(), *this ); 350 maybeAccept( offsetPackExpr->get_type(), *this ); 346 351 } 347 352 -
src/SymTab/Indexer.h
rb3f9a0cb rafc1045 59 59 virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 60 60 virtual void visit( OffsetofExpr *offsetofExpr ); 61 virtual void visit( OffsetPackExpr *offsetPackExpr ); 61 62 virtual void visit( AttrExpr *attrExpr ); 62 63 virtual void visit( LogicalExpr *logicalExpr ); -
src/SynTree/Expression.cc
rb3f9a0cb rafc1045 222 222 } 223 223 224 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 225 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 226 } 227 228 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 229 230 OffsetPackExpr::~OffsetPackExpr() { delete type; } 231 232 void OffsetPackExpr::print( std::ostream &os, int indent ) const { 233 os << std::string( indent, ' ' ) << "Offset pack expression on "; 234 235 if ( type ) { 236 type->print(os, indent + 2); 237 } else { 238 os << "<NULL>"; 239 } 240 241 os << std::endl; 242 Expression::print( os, indent ); 243 } 244 224 245 AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) : 225 246 Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) { -
src/SynTree/Expression.h
rb3f9a0cb rafc1045 362 362 }; 363 363 364 /// Expression representing a pack of field-offsets for a generic type 365 class OffsetPackExpr : public Expression { 366 public: 367 OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 ); 368 OffsetPackExpr( const OffsetPackExpr &other ); 369 virtual ~OffsetPackExpr(); 370 371 StructInstType *get_type() const { return type; } 372 void set_type( StructInstType *newValue ) { type = newValue; } 373 374 virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); } 375 virtual void accept( Visitor &v ) { v.visit( this ); } 376 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 377 378 virtual void print( std::ostream &os, int indent = 0 ) const; 379 380 private: 381 StructInstType *type; 382 }; 383 364 384 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined) 365 385 class AttrExpr : public Expression { -
src/SynTree/Mutator.cc
rb3f9a0cb rafc1045 274 274 } 275 275 276 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 277 mutateAll( offsetPackExpr->get_results(), *this ); 278 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); 279 return offsetPackExpr; 280 } 281 276 282 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 277 283 mutateAll( attrExpr->get_results(), *this ); -
src/SynTree/Mutator.h
rb3f9a0cb rafc1045 67 67 virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr ); 68 68 virtual Expression* mutate( OffsetofExpr *offsetofExpr ); 69 virtual Expression* mutate( OffsetPackExpr *offsetPackExpr ); 69 70 virtual Expression* mutate( AttrExpr *attrExpr ); 70 71 virtual Expression* mutate( LogicalExpr *logicalExpr ); -
src/SynTree/SynTree.h
rb3f9a0cb rafc1045 72 72 class UntypedOffsetofExpr; 73 73 class OffsetofExpr; 74 class OffsetPackExpr; 74 75 class AttrExpr; 75 76 class LogicalExpr; -
src/SynTree/Visitor.cc
rb3f9a0cb rafc1045 230 230 } 231 231 232 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) { 233 acceptAll( offsetPackExpr->get_results(), *this ); 234 maybeAccept( offsetPackExpr->get_type(), *this ); 235 } 236 232 237 void Visitor::visit( AttrExpr *attrExpr ) { 233 238 acceptAll( attrExpr->get_results(), *this ); -
src/SynTree/Visitor.h
rb3f9a0cb rafc1045 67 67 virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 68 68 virtual void visit( OffsetofExpr *offsetofExpr ); 69 virtual void visit( OffsetPackExpr *offsetPackExpr ); 69 70 virtual void visit( AttrExpr *attrExpr ); 70 71 virtual void visit( LogicalExpr *logicalExpr ); -
src/Tuples/FlattenTuple.cc
rb3f9a0cb rafc1045 49 49 void FlattenTuple::CollectArgs::visit( UntypedOffsetofExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 50 50 void FlattenTuple::CollectArgs::visit( OffsetofExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 51 void FlattenTuple::CollectArgs::visit( OffsetPackExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 51 52 void FlattenTuple::CollectArgs::visit( AttrExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 52 53 void FlattenTuple::CollectArgs::visit( LogicalExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } -
src/Tuples/FlattenTuple.h
rb3f9a0cb rafc1045 45 45 virtual void visit( UntypedOffsetofExpr * ); 46 46 virtual void visit( OffsetofExpr * ); 47 virtual void visit( OffsetPackExpr * ); 47 48 virtual void visit( AttrExpr * ); 48 49 virtual void visit( LogicalExpr * );
Note: See TracChangeset
for help on using the changeset viewer.