Changeset c194661


Ignore:
Timestamp:
Jun 20, 2018, 11:23:42 AM (3 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
0b3b2ae
Parents:
9a7a3b6
Message:

Reorganize QualifiedType? node

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/GenType.cc

    r9a7a3b6 rc194661  
    4848                void postvisit( ZeroType * zeroType );
    4949                void postvisit( OneType * oneType );
     50                void postvisit( GlobalScopeType * globalType );
    5051                void postvisit( TraitInstType * inst );
    5152                void postvisit( TypeofType * typeof );
     53                void postvisit( QualifiedType * qualType );
    5254
    5355          private:
     
    291293        }
    292294
     295        void GenType::postvisit( GlobalScopeType * globalType ) {
     296                assertf( ! genC, "Global scope type should not reach code generation." );
     297                handleQualifiers( globalType );
     298        }
     299
    293300        void GenType::postvisit( TraitInstType * inst ) {
    294301                assertf( ! genC, "Trait types should not reach code generation." );
     
    307314        }
    308315
     316        void GenType::postvisit( QualifiedType * qualType ) {
     317                assertf( ! genC, "Qualified types should not reach code generation." );
     318                std::ostringstream os;
     319                os << genType( qualType->parent, "", pretty, genC, lineMarks ) << "." << genType( qualType->child, "", pretty, genC, lineMarks );
     320                typeString = os.str();
     321                handleQualifiers( qualType );
     322        }
     323
    309324        void GenType::handleQualifiers( Type * type ) {
    310325                if ( type->get_const() ) {
  • src/Common/PassVisitor.impl.h

    r9a7a3b6 rc194661  
    22682268
    22692269        maybeAccept_impl( node->forall, *this );
    2270         maybeAccept_impl( node->types, *this );
     2270        maybeAccept_impl( node->parent, *this );
     2271        maybeAccept_impl( node->child, *this );
    22712272
    22722273        VISIT_END( node );
     
    22782279
    22792280        maybeMutate_impl( node->forall, *this );
    2280         maybeMutate_impl( node->types, *this );
     2281        maybeMutate_impl( node->parent, *this );
     2282        maybeMutate_impl( node->child, *this );
    22812283
    22822284        MUTATE_END( Type, node );
  • src/Parser/DeclarationNode.cc

    r9a7a3b6 rc194661  
    261261
    262262DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) {
    263         return child;
    264         // return parent->add_last( child );
     263        DeclarationNode * newnode = new DeclarationNode;
     264        newnode->type = new TypeData( TypeData::Qualified );
     265        newnode->type->qualified.parent = parent->type;
     266        newnode->type->qualified.child = child->type;
     267        parent->type = nullptr;
     268        child->type = nullptr;
     269        delete parent;
     270        delete child;
     271        return newnode;
    265272}
    266273
  • src/Parser/TypeData.cc

    r9a7a3b6 rc194661  
    9999          case Builtin:
    100100                // builtin = new Builtin_t;
     101                case Qualified:
     102                qualified.parent = nullptr;
     103                qualified.child = nullptr;
    101104                break;
    102105        } // switch
     
    167170                // delete builtin;
    168171                break;
     172          case Qualified:
     173                delete qualified.parent;
     174                delete qualified.child;
    169175        } // switch
    170176} // TypeData::~TypeData
     
    240246                assert( builtintype == DeclarationNode::Zero || builtintype == DeclarationNode::One );
    241247                newtype->builtintype = builtintype;
     248                break;
     249                case Qualified:
     250                newtype->qualified.parent = maybeClone( qualified.parent );
     251                newtype->qualified.child = maybeClone( qualified.child );
    242252                break;
    243253        } // switch
     
    468478                return new EnumInstType( buildQualifiers( td ), "" );
    469479          case TypeData::SymbolicInst:
    470                 return buildSymbolicInst( td );;
     480                return buildSymbolicInst( td );
    471481          case TypeData::Tuple:
    472482                return buildTuple( td );
     
    483493                        return new VarArgsType( buildQualifiers( td ) );
    484494                }
     495          case TypeData::GlobalScope:
     496                return new GlobalScopeType();
     497                case TypeData::Qualified:
     498                return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
    485499          case TypeData::Symbolic:
    486500          case TypeData::Enum:
     
    488502                assert( false );
    489503        } // switch
     504
    490505        return nullptr;
    491506} // typebuild
  • src/Parser/TypeData.h

    r9a7a3b6 rc194661  
    2727struct TypeData {
    2828        enum Kind { Basic, Pointer, Array, Reference, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
    29                                 SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Unknown };
     29                                SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Qualified, Unknown };
    3030
    3131        struct Aggregate_t {
     
    7575        };
    7676
     77        struct Qualified_t { // qualified type S.T
     78                TypeData * parent;
     79                TypeData * child;
     80        };
     81
    7782        CodeLocation location;
    7883
     
    9499        Function_t function;
    95100        Symbolic_t symbolic;
     101        Qualified_t qualified;
    96102        DeclarationNode * tuple;
    97103        ExpressionNode * typeexpr;
  • src/SynTree/Type.cc

    r9a7a3b6 rc194661  
    106106
    107107
    108 QualifiedType::QualifiedType( const Type::Qualifiers & tq, const std::list< Type * > & types ) : Type( tq, {} ), types( types ) {
     108QualifiedType::QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ) : Type( tq, {} ), parent( parent ), child( child ) {
    109109}
    110110
    111 QualifiedType::QualifiedType( const QualifiedType & other ) : Type( other ) {
    112         cloneAll( other.types, types );
     111QualifiedType::QualifiedType( const QualifiedType & other ) : Type( other ), parent( maybeClone( other.parent ) ), child( maybeClone( other.child ) ) {
    113112}
    114113
    115114QualifiedType::~QualifiedType() {
    116         deleteAll( types );
     115        delete parent;
     116        delete child;
    117117}
    118118
    119119void QualifiedType::print( std::ostream & os, Indenter indent ) const {
    120120        os << "Qualified Type: " << endl;
    121         printAll( types, os, indent+1 );
     121        os << indent+1;
     122        parent->print( os, indent+1 );
     123        os << endl << indent+1;
     124        child->print( os, indent+1 );
     125        os << endl;
    122126        Type::print( os, indent+1 );
    123127}
  • src/SynTree/Type.h

    r9a7a3b6 rc194661  
    317317class QualifiedType : public Type {
    318318public:
    319         std::list<Type *> types;
    320 
    321         QualifiedType( const Type::Qualifiers & tq, const std::list< Type * > & types );
     319        Type * parent;
     320        Type * child;
     321
     322        QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child );
    322323        QualifiedType( const QualifiedType & tq );
    323324        virtual ~QualifiedType();
Note: See TracChangeset for help on using the changeset viewer.