Ignore:
Timestamp:
Sep 1, 2022, 1:27:52 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
12df6fe
Parents:
def751f
Message:

Fix up the QualifiedNameExpr?. It should now work on both old AST and new AST. There are some known bugs to fix so make all-tests will fail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    rdef751f rb0d9ff7  
    166166class QualifiedNameExpr : public Expression {
    167167  public:
    168         Type * type; // Convert to [parent] QualifiedNameExpr
    169         std::string name; // Convert from NameExpr
    170 
    171         QualifiedNameExpr( Type * type, std::string name):
    172                 Expression(), type(type), name(name) {
    173                 std::cout << "Making QualifiedNameExpr" << std::endl;
    174                 print( std::cout );
    175         }
    176         QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type(other.type), name(other.name) {
    177 
    178         }
     168        Declaration * type_decl;
     169        std::string name;
     170        DeclarationWithType * var;
     171
     172        QualifiedNameExpr( Declaration * decl, std::string name): Expression(), type_decl(decl), name(name) {}
     173        QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name), var(other.var) {}
     174        DeclarationWithType * get_var() const { return var; }
     175        void set_var( DeclarationWithType * newValue ) { var = newValue; }
     176
    179177        virtual ~QualifiedNameExpr() {
    180                 delete type;
     178                delete var;
     179                delete type_decl;
    181180        }
    182181
     
    184183                return new QualifiedNameExpr( * this );
    185184        }
    186         virtual void accept( Visitor & v ) override { (void)v; }
    187         virtual void accept( Visitor & v ) const override { (void)v; }
    188         virtual Expression * acceptMutator( Mutator & m ) override { (void) m;return nullptr; }
     185        virtual void accept( Visitor & v ) override { v.visit(this); }
     186        virtual void accept( Visitor & v ) const override { v.visit(this); }
     187        virtual Expression * acceptMutator( Mutator & m ) override {
     188                return m.mutate( this );
     189        }
     190       
    189191        virtual void print( std::ostream & os, Indenter indent = {} ) const override {
    190                 type->print( os, indent );
    191                 std::cout << name << std::endl;
     192                type_decl->print( os, indent );
     193                os << name << std::endl;
    192194        }
    193195};
Note: See TracChangeset for help on using the changeset viewer.