Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b7c89aa
Parents:
f9feab8 (diff), 305581d (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' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    rf9feab8 r90152a4  
    4141        ParamEntry( UniqueId decl, Type * actualType, Type * formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ), inferParams( new InferredParams ) {}
    4242        ParamEntry( const ParamEntry & other );
     43        ParamEntry( ParamEntry && other );
    4344        ~ParamEntry();
    4445        ParamEntry & operator=( const ParamEntry & other );
     46        ParamEntry & operator=( ParamEntry && other );
    4547
    4648        UniqueId decl;
     
    7476        InferredParams & get_inferParams() { return inferParams; }
    7577
     78        // move other's inferParams to this
     79        void spliceInferParams( Expression * other );
     80
    7681        virtual Expression * clone() const override = 0;
    7782        virtual void accept( Visitor & v ) override = 0;
     
    188193  public:
    189194        Expression * arg;
    190 
    191         CastExpr( Expression * arg );
    192         CastExpr( Expression * arg, Type * toType );
     195        bool isGenerated = true; // whether this cast appeared in the source program
     196
     197        CastExpr( Expression * arg, bool isGenerated = true );
     198        CastExpr( Expression * arg, Type * toType, bool isGenerated = true );
     199        CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor
    193200        CastExpr( const CastExpr & other );
    194201        virtual ~CastExpr();
     
    198205
    199206        virtual CastExpr * clone() const { return new CastExpr( * this ); }
     207        virtual void accept( Visitor & v ) { v.visit( this ); }
     208        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     209        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     210};
     211
     212/// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t
     213class KeywordCastExpr : public Expression {
     214public:
     215        Expression * arg;
     216        enum Target {
     217                Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
     218        } target;
     219
     220        KeywordCastExpr( Expression * arg, Target target );
     221        KeywordCastExpr( const KeywordCastExpr & other );
     222        virtual ~KeywordCastExpr();
     223
     224        const std::string & targetString() const;
     225
     226        virtual KeywordCastExpr * clone() const { return new KeywordCastExpr( * this ); }
    200227        virtual void accept( Visitor & v ) { v.visit( this ); }
    201228        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     
    295322
    296323        Constant * get_constant() { return & constant; }
     324        const Constant * get_constant() const { return & constant; }
    297325        void set_constant( const Constant & newValue ) { constant = newValue; }
     326
     327        long long int intValue() const;
    298328
    299329        virtual ConstantExpr * clone() const { return new ConstantExpr( * this ); }
     
    725755        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
    726756
     757        // call to set the result type of this StmtExpr based on its body
     758        void computeResult();
     759
    727760        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    728761        std::list< Expression * > & get_dtors() { return dtors; }
     
    816849};
    817850
     851/// expression that contains a deleted identifier - should never make it past the resolver.
     852class DeletedExpr : public Expression {
     853public:
     854        Expression * expr;
     855        BaseSyntaxNode * deleteStmt;
     856
     857        DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
     858        DeletedExpr( const DeletedExpr & other );
     859        ~DeletedExpr();
     860
     861        virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
     862        virtual void accept( Visitor & v ) { v.visit( this ); }
     863        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     864        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     865};
     866
     867/// expression wrapping the use of a default argument - should never make it past the resolver.
     868class DefaultArgExpr : public Expression {
     869public:
     870        Expression * expr;
     871
     872        DefaultArgExpr( Expression * expr );
     873        DefaultArgExpr( const DefaultArgExpr & other );
     874        ~DefaultArgExpr();
     875
     876        virtual DefaultArgExpr * clone() const { return new DefaultArgExpr( * this ); }
     877        virtual void accept( Visitor & v ) { v.visit( this ); }
     878        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     879        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     880};
     881
     882/// C11 _Generic expression
     883class GenericExpr : public Expression {
     884public:
     885        struct Association {
     886                Type * type = nullptr;
     887                Expression * expr = nullptr;
     888                bool isDefault = false;
     889
     890                Association( Type * type, Expression * expr );
     891                Association( Expression * expr );
     892                Association( const Association & other );
     893                Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it
     894                ~Association();
     895        };
     896
     897        Expression * control;
     898        std::list<Association> associations;
     899
     900        GenericExpr( Expression * control, const std::list<Association> & assoc );
     901        GenericExpr( const GenericExpr & other );
     902        virtual ~GenericExpr();
     903
     904        virtual GenericExpr * clone() const { return new GenericExpr( * this ); }
     905        virtual void accept( Visitor & v ) { v.visit( this ); }
     906        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     907        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     908};
     909
    818910// Local Variables: //
    819911// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.