Changeset 25a054f
- Timestamp:
- Jan 19, 2016, 4:46:04 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:
- e551c69
- Parents:
- 1194734
- Location:
- src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r1194734 r25a054f 443 443 } 444 444 445 void CodeGenerator::visit( AlignofExpr * sizeofExpr ) {445 void CodeGenerator::visit( AlignofExpr *alignofExpr ) { 446 446 // use GCC extension to avoid bumping std to C11 447 447 output << "__alignof__("; 448 if ( sizeofExpr->get_isType() ) { 449 output << genType( sizeofExpr->get_type(), "" ); 450 } else { 451 sizeofExpr->get_expr()->accept( *this ); 452 } // if 448 if ( alignofExpr->get_isType() ) { 449 output << genType( alignofExpr->get_type(), "" ); 450 } else { 451 alignofExpr->get_expr()->accept( *this ); 452 } // if 453 output << ")"; 454 } 455 456 void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) { 457 // use GCC builtin 458 output << "__builtin_offsetof("; 459 output << genType( offsetofExpr->get_type(), "" ); 460 output << ", "; 461 offsetofExpr->get_member()->accept( *this ); 453 462 output << ")"; 454 463 } -
src/CodeGen/CodeGenerator.h
r1194734 r25a054f 61 61 virtual void visit( SizeofExpr *sizeofExpr ); 62 62 virtual void visit( AlignofExpr *alignofExpr ); 63 virtual void visit( OffsetofExpr *offsetofExpr ); 63 64 virtual void visit( LogicalExpr *logicalExpr ); 64 65 virtual void visit( ConditionalExpr *conditionalExpr ); -
src/InitTweak/InitModel.h
r1194734 r25a054f 73 73 void visit( SizeofExpr * ) { throw 0; } 74 74 void visit( AlignofExpr * ) { throw 0; } 75 void visit( OffsetofExpr * ) { throw 0; } 75 76 void visit( AttrExpr * ) { throw 0; } 76 77 void visit( LogicalExpr * ) { throw 0; } -
src/ResolvExpr/AlternativeFinder.cc
r1194734 r25a054f 811 811 } 812 812 813 void AlternativeFinder::visit( OffsetofExpr *offsetofExpr ) { 814 alternatives.push_back( Alternative( offsetofExpr->clone(), env, Cost::zero ) ); 815 } 816 813 817 void AlternativeFinder::resolveAttr( DeclarationWithType *funcDecl, FunctionType *function, Type *argType, const TypeEnvironment &env ) { 814 818 // assume no polymorphism -
src/ResolvExpr/AlternativeFinder.h
r1194734 r25a054f 56 56 virtual void visit( ConstantExpr *constantExpr ); 57 57 virtual void visit( SizeofExpr *sizeofExpr ); 58 virtual void visit( AlignofExpr *sizeofExpr ); 58 virtual void visit( AlignofExpr *alignofExpr ); 59 virtual void visit( OffsetofExpr *offsetofExpr ); 59 60 virtual void visit( AttrExpr *attrExpr ); 60 61 virtual void visit( LogicalExpr *logicalExpr ); -
src/SymTab/Indexer.cc
r1194734 r25a054f 225 225 maybeAccept( alignofExpr->get_expr(), *this ); 226 226 } 227 } 228 229 void Indexer::visit( OffsetofExpr *offsetofExpr ) { 230 acceptAllNewScope( offsetofExpr->get_results(), *this ); 231 maybeAccept( offsetofExpr->get_type(), *this ); 232 maybeAccept( offsetofExpr->get_member(), *this ); 227 233 } 228 234 -
src/SymTab/Indexer.h
r1194734 r25a054f 55 55 virtual void visit( SizeofExpr *sizeofExpr ); 56 56 virtual void visit( AlignofExpr *alignofExpr ); 57 virtual void visit( OffsetofExpr *offsetofExpr ); 57 58 virtual void visit( AttrExpr *attrExpr ); 58 59 virtual void visit( LogicalExpr *logicalExpr ); -
src/SynTree/Expression.cc
r1194734 r25a054f 163 163 } 164 164 165 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) : 166 Expression( _aname ), type(type_), member(member_) { 167 add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) ); 168 } 169 170 OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) : 171 Expression( other ), type( maybeClone( other.type ) ), member( maybeClone( other.member ) ) {} 172 173 OffsetofExpr::~OffsetofExpr() { 174 delete type; 175 delete member; 176 } 177 178 void OffsetofExpr::print( std::ostream &os, int indent) const { 179 os << std::string( indent, ' ' ) << "Offsetof Expression on member "; 180 181 if ( member ) { 182 os << member->get_name(); 183 } else { 184 os << "<NULL>"; 185 } 186 187 os << " of "; 188 189 if ( type ) { 190 type->print(os, indent + 2); 191 } else { 192 os << "<NULL>"; 193 } 194 195 os << std::endl; 196 Expression::print( os, indent ); 197 } 198 165 199 AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) : 166 200 Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) { -
src/SynTree/Expression.h
r1194734 r25a054f 319 319 }; 320 320 321 /// OffsetofExpr represents an offsetof expression 322 class OffsetofExpr : public Expression { 323 public: 324 OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = 0 ); 325 OffsetofExpr( const OffsetofExpr &other ); 326 virtual ~OffsetofExpr(); 327 328 Type *get_type() const { return type; } 329 void set_type( Type *newValue ) { type = newValue; } 330 DeclarationWithType *get_member() const { return member; } 331 void set_member( DeclarationWithType *newValue ) { member = newValue; } 332 333 virtual OffsetofExpr *clone() const { return new OffsetofExpr( *this ); } 334 virtual void accept( Visitor &v ) { v.visit( this ); } 335 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 336 virtual void print( std::ostream &os, int indent = 0 ) const; 337 private: 338 Type *type; 339 DeclarationWithType *member; 340 }; 341 321 342 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined) 322 343 class AttrExpr : public Expression { -
src/SynTree/Mutator.cc
r1194734 r25a054f 261 261 } 262 262 263 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 264 mutateAll( offsetofExpr->get_results(), *this ); 265 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 266 offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) ); 267 return offsetofExpr; 268 } 269 263 270 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 264 271 mutateAll( attrExpr->get_results(), *this ); -
src/SynTree/Mutator.h
r1194734 r25a054f 65 65 virtual Expression* mutate( SizeofExpr *sizeofExpr ); 66 66 virtual Expression* mutate( AlignofExpr *alignofExpr ); 67 virtual Expression* mutate( OffsetofExpr *offsetofExpr ); 67 68 virtual Expression* mutate( AttrExpr *attrExpr ); 68 69 virtual Expression* mutate( LogicalExpr *logicalExpr ); -
src/SynTree/SynTree.h
r1194734 r25a054f 70 70 class SizeofExpr; 71 71 class AlignofExpr; 72 class OffsetofExpr; 72 73 class AttrExpr; 73 74 class LogicalExpr; -
src/SynTree/Visitor.cc
r1194734 r25a054f 219 219 } 220 220 221 void Visitor::visit( OffsetofExpr *offsetofExpr ) { 222 acceptAll( offsetofExpr->get_results(), *this ); 223 maybeAccept( offsetofExpr->get_type(), *this ); 224 maybeAccept( offsetofExpr->get_member(), *this ); 225 } 226 221 227 void Visitor::visit( AttrExpr *attrExpr ) { 222 228 acceptAll( attrExpr->get_results(), *this ); -
src/SynTree/Visitor.h
r1194734 r25a054f 65 65 virtual void visit( SizeofExpr *sizeofExpr ); 66 66 virtual void visit( AlignofExpr *alignofExpr ); 67 virtual void visit( OffsetofExpr *offsetofExpr ); 67 68 virtual void visit( AttrExpr *attrExpr ); 68 69 virtual void visit( LogicalExpr *logicalExpr ); -
src/Tuples/FlattenTuple.cc
r1194734 r25a054f 47 47 void FlattenTuple::CollectArgs::visit( SizeofExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 48 48 void FlattenTuple::CollectArgs::visit( AlignofExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 49 void FlattenTuple::CollectArgs::visit( OffsetofExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 49 50 void FlattenTuple::CollectArgs::visit( AttrExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } 50 51 void FlattenTuple::CollectArgs::visit( LogicalExpr *expr ) { currentArgs.insert( currentArgs.end(), expr ); } -
src/Tuples/FlattenTuple.h
r1194734 r25a054f 43 43 virtual void visit( SizeofExpr * ); 44 44 virtual void visit( AlignofExpr * ); 45 virtual void visit( OffsetofExpr * ); 45 46 virtual void visit( AttrExpr * ); 46 47 virtual void visit( LogicalExpr * );
Note: See TracChangeset
for help on using the changeset viewer.