Changeset c5d7701


Ignore:
Timestamp:
Jun 14, 2018, 5:34:39 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
704d11e
Parents:
29f9e20
Message:

Add QualifiedType? node

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    r29f9e20 rc5d7701  
    133133        virtual void visit( ArrayType * arrayType ) override final;
    134134        virtual void visit( ReferenceType * referenceType ) override final;
     135        virtual void visit( QualifiedType * qualType ) override final;
    135136        virtual void visit( FunctionType * functionType ) override final;
    136137        virtual void visit( StructInstType * aggregateUseType ) override final;
     
    233234        virtual Type * mutate( ArrayType * arrayType ) override final;
    234235        virtual Type * mutate( ReferenceType * referenceType ) override final;
     236        virtual Type * mutate( QualifiedType * qualType ) override final;
    235237        virtual Type * mutate( FunctionType * functionType ) override final;
    236238        virtual Type * mutate( StructInstType * aggregateUseType ) override final;
  • src/Common/PassVisitor.impl.h

    r29f9e20 rc5d7701  
    22622262
    22632263//--------------------------------------------------------------------------
     2264// QualifiedType
     2265template< typename pass_type >
     2266void PassVisitor< pass_type >::visit( QualifiedType * node ) {
     2267        VISIT_START( node );
     2268
     2269        maybeAccept_impl( node->forall, *this );
     2270        maybeAccept_impl( node->types, *this );
     2271
     2272        VISIT_END( node );
     2273}
     2274
     2275template< typename pass_type >
     2276Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
     2277        MUTATE_START( node );
     2278
     2279        maybeMutate_impl( node->forall, *this );
     2280        maybeMutate_impl( node->types, *this );
     2281
     2282        MUTATE_END( Type, node );
     2283}
     2284
     2285//--------------------------------------------------------------------------
    22642286// FunctionType
    22652287template< typename pass_type >
  • src/Parser/DeclarationNode.cc

    r29f9e20 rc5d7701  
    253253        return newnode;
    254254} // DeclarationNode::newFromTypedef
     255
     256DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) {
     257        return child;
     258        // return parent->add_last( child );
     259}
    255260
    256261DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
  • src/Parser/ParseNode.h

    r29f9e20 rc5d7701  
    231231        static DeclarationNode * newForall( DeclarationNode * );
    232232        static DeclarationNode * newFromTypedef( const std::string * );
     233        static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * );
    233234        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    234235        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
  • src/Parser/parser.yy

    r29f9e20 rc5d7701  
    17941794                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    17951795        | type_name '.' TYPEDEFname
    1796                 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     1796                { $$ = DeclarationNode::newQualifiedType( $1, DeclarationNode::newFromTypedef( $3 ) ); }
    17971797        | typegen_name
    17981798        | '.' typegen_name
    17991799                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    18001800        | type_name '.' typegen_name
    1801                 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     1801                { $$ = DeclarationNode::newQualifiedType( $1, $3 ); }
    18021802        ;
    18031803
  • src/SynTree/Mutator.h

    r29f9e20 rc5d7701  
    101101        virtual Type * mutate( ArrayType * arrayType ) = 0;
    102102        virtual Type * mutate( ReferenceType * refType ) = 0;
     103        virtual Type * mutate( QualifiedType * qualType ) = 0;
    103104        virtual Type * mutate( FunctionType * functionType ) = 0;
    104105        virtual Type * mutate( StructInstType * aggregateUseType ) = 0;
  • src/SynTree/SynTree.h

    r29f9e20 rc5d7701  
    110110class ArrayType;
    111111class ReferenceType;
     112class QualifiedType;
    112113class FunctionType;
    113114class ReferenceToType;
  • src/SynTree/Type.cc

    r29f9e20 rc5d7701  
    105105}
    106106
     107
     108QualifiedType::QualifiedType( const Type::Qualifiers & tq, const std::list< Type * > & types ) : Type( tq, {} ), types( types ) {
     109}
     110
     111QualifiedType::QualifiedType( const QualifiedType & other ) : Type( other ) {
     112        cloneAll( other.types, types );
     113}
     114
     115QualifiedType::~QualifiedType() {
     116        deleteAll( types );
     117}
     118
     119void QualifiedType::print( std::ostream & os, Indenter indent ) const {
     120        os << "Qualified Type: ";
     121        printAll( types, os, indent+1 );
     122        Type::print( os, indent+1 );
     123}
     124
     125
    107126// Empty Variable declarations:
    108127const Type::FuncSpecifiers noFuncSpecifiers;
  • src/SynTree/Type.h

    r29f9e20 rc5d7701  
    315315};
    316316
     317class QualifiedType : public Type {
     318public:
     319        std::list<Type *> types;
     320
     321        QualifiedType( const Type::Qualifiers & tq, const std::list< Type * > & types );
     322        QualifiedType( const QualifiedType & tq );
     323        virtual ~QualifiedType();
     324
     325        virtual QualifiedType *clone() const override { return new QualifiedType( *this ); }
     326        virtual void accept( Visitor & v ) override { v.visit( this ); }
     327        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     328        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     329};
     330
    317331class ReferenceType : public Type {
    318332public:
  • src/SynTree/Visitor.h

    r29f9e20 rc5d7701  
    103103        virtual void visit( ArrayType * arrayType ) = 0;
    104104        virtual void visit( ReferenceType * refType ) = 0;
     105        virtual void visit( QualifiedType * qualType ) = 0;
    105106        virtual void visit( FunctionType * functionType ) = 0;
    106107        virtual void visit( StructInstType * aggregateUseType ) = 0;
Note: See TracChangeset for help on using the changeset viewer.