Ignore:
Timestamp:
Nov 29, 2016, 3:30:59 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8e5724e
Parents:
3a2128f (diff), 9129a84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Conflicts:

src/Parser/parser.cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    r3a2128f r1f44196  
    3232        virtual ~Expression();
    3333
    34         std::list<Type *>& get_results() { return results; }
    35         void add_result( Type *t );
     34        Type *& get_result() { return result; }
     35        void set_result( Type *newValue ) { result = newValue; }
     36        bool has_result() const { return result != nullptr; }
    3637
    3738        TypeSubstitution *get_env() const { return env; }
     
    4748        virtual void print( std::ostream &os, int indent = 0 ) const;
    4849  protected:
    49         std::list<Type *> results;
     50        Type * result;
    5051        TypeSubstitution *env;
    5152        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
     
    9899class UntypedExpr : public Expression {
    99100  public:
    100         UntypedExpr( Expression *function, Expression *_aname = nullptr );
     101        UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr );
    101102        UntypedExpr( const UntypedExpr &other );
    102         UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr );
    103103        virtual ~UntypedExpr();
    104104
     
    111111        std::list<Expression*>& get_args() { return args; }
    112112
     113        static UntypedExpr * createDeref( Expression * arg );
     114        static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 );
     115
    113116        virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); }
    114117        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    200203class UntypedMemberExpr : public Expression {
    201204  public:
    202         UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr );
     205        UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr );
    203206        UntypedMemberExpr( const UntypedMemberExpr &other );
    204207        virtual ~UntypedMemberExpr();
    205208
    206         std::string get_member() const { return member; }
    207         void set_member( const std::string &newValue ) { member = newValue; }
     209        Expression * get_member() const { return member; }
     210        void set_member( Expression * newValue ) { member = newValue; }
    208211        Expression *get_aggregate() const { return aggregate; }
    209212        void set_aggregate( Expression *newValue ) { aggregate = newValue; }
     
    214217        virtual void print( std::ostream &os, int indent = 0 ) const;
    215218  private:
    216         std::string member;
     219        Expression *member;
    217220        Expression *aggregate;
    218221};
     
    483486};
    484487
    485 /// TupleExpr represents a tuple expression ( [a, b, c] )
    486 class TupleExpr : public Expression {
    487   public:
    488         TupleExpr( Expression *_aname = nullptr );
    489         TupleExpr( const TupleExpr &other );
    490         virtual ~TupleExpr();
    491 
    492         void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
    493         std::list<Expression*>& get_exprs() { return exprs; }
    494 
    495         virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
    496         virtual void accept( Visitor &v ) { v.visit( this ); }
    497         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    498         virtual void print( std::ostream &os, int indent = 0 ) const;
    499   private:
    500         std::list<Expression*> exprs;
    501 };
    502 
    503 /// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
    504 class SolvedTupleExpr : public Expression {
    505   public:
    506         SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {}
    507         SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr );
    508         SolvedTupleExpr( const SolvedTupleExpr &other );
    509         virtual ~SolvedTupleExpr() {}
    510 
    511         std::list<Expression*> &get_exprs() { return exprs; }
    512 
    513         virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
    514         virtual void accept( Visitor &v ) { v.visit( this ); }
    515         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    516         virtual void print( std::ostream &os, int indent = 0 ) const;
    517   private:
    518         std::list<Expression*> exprs;
    519 };
    520 
    521488/// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
    522489class TypeExpr : public Expression {
     
    618585        CompoundLiteralExpr( Type * type, Initializer * initializer );
    619586        CompoundLiteralExpr( const CompoundLiteralExpr &other );
    620         ~CompoundLiteralExpr();
     587        virtual ~CompoundLiteralExpr();
    621588
    622589        Type * get_type() const { return type; }
     
    670637  private:
    671638        Expression *low, *high;
     639};
     640
     641/// TupleExpr represents a tuple expression ( [a, b, c] )
     642class TupleExpr : public Expression {
     643  public:
     644        TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr );
     645        TupleExpr( const TupleExpr &other );
     646        virtual ~TupleExpr();
     647
     648        void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
     649        std::list<Expression*>& get_exprs() { return exprs; }
     650
     651        virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
     652        virtual void accept( Visitor &v ) { v.visit( this ); }
     653        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     654        virtual void print( std::ostream &os, int indent = 0 ) const;
     655  private:
     656        std::list<Expression*> exprs;
     657};
     658
     659/// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer
     660class TupleIndexExpr : public Expression {
     661  public:
     662        TupleIndexExpr( Expression * tuple, unsigned int index );
     663        TupleIndexExpr( const TupleIndexExpr &other );
     664        virtual ~TupleIndexExpr();
     665
     666        Expression * get_tuple() const { return tuple; }
     667        int get_index() const { return index; }
     668        TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; }
     669        TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; }
     670
     671        virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); }
     672        virtual void accept( Visitor &v ) { v.visit( this ); }
     673        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     674        virtual void print( std::ostream &os, int indent = 0 ) const;
     675  private:
     676        Expression * tuple;
     677        unsigned int index;
     678};
     679
     680/// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer
     681class MemberTupleExpr : public Expression {
     682  public:
     683        MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );
     684        MemberTupleExpr( const MemberTupleExpr &other );
     685        virtual ~MemberTupleExpr();
     686
     687        Expression * get_member() const { return member; }
     688        Expression * get_aggregate() const { return aggregate; }
     689        MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; }
     690        MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; }
     691
     692        virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); }
     693        virtual void accept( Visitor &v ) { v.visit( this ); }
     694        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     695        virtual void print( std::ostream &os, int indent = 0 ) const;
     696  private:
     697        Expression * member;
     698        Expression * aggregate;
     699};
     700
     701/// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression
     702class TupleAssignExpr : public Expression {
     703  public:
     704        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
     705        TupleAssignExpr( const TupleAssignExpr &other );
     706        virtual ~TupleAssignExpr();
     707
     708        std::list< Expression * > & get_assigns() { return assigns; }
     709        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     710
     711        virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); }
     712        virtual void accept( Visitor &v ) { v.visit( this ); }
     713        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     714        virtual void print( std::ostream &os, int indent = 0 ) const;
     715  private:
     716        std::list< Expression * > assigns; // assignment expressions that use tempDecls
     717        std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs
     718};
     719
     720/// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; })
     721class StmtExpr : public Expression {
     722public:
     723        StmtExpr( CompoundStmt *statements );
     724        StmtExpr( const StmtExpr & other );
     725        virtual ~StmtExpr();
     726
     727        CompoundStmt * get_statements() const { return statements; }
     728        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
     729
     730        virtual StmtExpr *clone() const { return new StmtExpr( *this ); }
     731        virtual void accept( Visitor &v ) { v.visit( this ); }
     732        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     733        virtual void print( std::ostream &os, int indent = 0 ) const;
     734private:
     735        CompoundStmt * statements;
     736};
     737
     738class UniqueExpr : public Expression {
     739public:
     740        UniqueExpr( Expression * expr, long long idVal = -1 );
     741        UniqueExpr( const UniqueExpr & other );
     742        ~UniqueExpr();
     743
     744        Expression * get_expr() const { return expr; }
     745        UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
     746
     747        ObjectDecl * get_object() const { return object; }
     748        UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; }
     749
     750        VariableExpr * get_var() const { return var; }
     751        UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; }
     752
     753        int get_id() const { return id; }
     754
     755        virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); }
     756        virtual void accept( Visitor &v ) { v.visit( this ); }
     757        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     758        virtual void print( std::ostream &os, int indent = 0 ) const;
     759private:
     760        Expression * expr;
     761        ObjectDecl * object;
     762        VariableExpr * var;
     763        int id;
     764        static long long count;
    672765};
    673766
Note: See TracChangeset for help on using the changeset viewer.