Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    r0f79853 rdf626eb  
    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 );
    4443        ~ParamEntry();
    4544        ParamEntry & operator=( const ParamEntry & other );
    46         ParamEntry & operator=( ParamEntry && other );
    4745
    4846        UniqueId decl;
     
    7674        InferredParams & get_inferParams() { return inferParams; }
    7775
    78         // move other's inferParams to this
    79         void spliceInferParams( Expression * other );
    80 
    8176        virtual Expression * clone() const override = 0;
    8277        virtual void accept( Visitor & v ) override = 0;
     
    193188  public:
    194189        Expression * arg;
    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
     190
     191        CastExpr( Expression * arg );
     192        CastExpr( Expression * arg, Type * toType );
    200193        CastExpr( const CastExpr & other );
    201194        virtual ~CastExpr();
     
    205198
    206199        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
    213 class KeywordCastExpr : public Expression {
    214 public:
    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 ); }
    227200        virtual void accept( Visitor & v ) { v.visit( this ); }
    228201        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     
    322295
    323296        Constant * get_constant() { return & constant; }
    324         const Constant * get_constant() const { return & constant; }
    325297        void set_constant( const Constant & newValue ) { constant = newValue; }
    326 
    327         long long int intValue() const;
    328298
    329299        virtual ConstantExpr * clone() const { return new ConstantExpr( * this ); }
     
    755725        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
    756726
    757         // call to set the result type of this StmtExpr based on its body
    758         void computeResult();
    759 
    760727        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    761728        std::list< Expression * > & get_dtors() { return dtors; }
     
    849816};
    850817
    851 /// expression that contains a deleted identifier - should never make it past the resolver.
    852 class DeletedExpr : public Expression {
    853 public:
    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.
    868 class DefaultArgExpr : public Expression {
    869 public:
    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
    883 class GenericExpr : public Expression {
    884 public:
    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 
    910818// Local Variables: //
    911819// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.