Changeset afc1045 for src/GenPoly/Box.cc


Ignore:
Timestamp:
Apr 5, 2016, 3:31:09 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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
Message:

Hoist OffsetPackExpr? to top level expression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rb3f9a0cb rafc1045  
    214214                };
    215215
    216                 class OffsetPackExpr;  // forward declaration so that it can be mutated by Pass2
    217 
    218216                /// * Moves polymorphic returns in function types to pointer-type parameters
    219217                /// * adds type size and assertion parameters to parameter lists
     
    232230                        virtual Expression *mutate( AlignofExpr *alignofExpr );
    233231                        virtual Expression *mutate( OffsetofExpr *offsetofExpr );
    234                                 Expression *mutate( OffsetPackExpr *offsetPackExpr );
     232                        virtual Expression *mutate( OffsetPackExpr *offsetPackExpr );
    235233
    236234                        virtual void doBeginScope();
     
    248246                        ScopedSet< std::string > knownLayouts;          ///< Set of generic type layouts known in the current scope, indexed by sizeofName
    249247                        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 Pass2
    253                 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 class
    269                                 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;
    291248                };
    292249
Note: See TracChangeset for help on using the changeset viewer.