Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    r9a705dc8 r68f9c43  
    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();
    4443        ParamEntry & operator=( const ParamEntry & other );
    4544
     
    5352/// Expression is the root type for all expressions
    5453class Expression : public BaseSyntaxNode {
     54  protected:
     55        virtual ~Expression();
     56
    5557  public:
    5658        Type * result;
     
    6163        Expression();
    6264        Expression( const Expression & other );
    63         virtual ~Expression();
    6465
    6566        Type *& get_result() { return result; }
     
    8990        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    9091        ApplicationExpr( const ApplicationExpr & other );
    91         virtual ~ApplicationExpr();
    9292
    9393        Expression * get_function() const { return function; }
     
    111111        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    112112        UntypedExpr( const UntypedExpr & other );
    113         virtual ~UntypedExpr();
    114113
    115114        Expression * get_function() const { return function; }
     
    136135        NameExpr( std::string name );
    137136        NameExpr( const NameExpr & other );
    138         virtual ~NameExpr();
    139137
    140138        const std::string & get_name() const { return name; }
     
    157155        AddressExpr( Expression * arg );
    158156        AddressExpr( const AddressExpr & other );
    159         virtual ~AddressExpr();
    160157
    161158        Expression * get_arg() const { return arg; }
     
    176173        LabelAddressExpr( const Label &arg );
    177174        LabelAddressExpr( const LabelAddressExpr & other );
    178         virtual ~LabelAddressExpr();
    179175
    180176        virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); }
     
    188184  public:
    189185        Expression * arg;
    190         bool isGenerated = true; // whether this cast appeared in the source program
    191 
    192         CastExpr( Expression * arg, bool isGenerated = true );
    193         CastExpr( Expression * arg, Type * toType, bool isGenerated = true );
    194         CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor
     186
     187        CastExpr( Expression * arg );
     188        CastExpr( Expression * arg, Type * toType );
    195189        CastExpr( const CastExpr & other );
    196         virtual ~CastExpr();
    197190
    198191        Expression * get_arg() const { return arg; }
     
    205198};
    206199
    207 /// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t
    208 class KeywordCastExpr : public Expression {
    209 public:
    210         Expression * arg;
    211         enum Target {
    212                 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
    213         } target;
    214 
    215         KeywordCastExpr( Expression * arg, Target target );
    216         KeywordCastExpr( const KeywordCastExpr & other );
    217         virtual ~KeywordCastExpr();
    218 
    219         const std::string & targetString() const;
    220 
    221         virtual KeywordCastExpr * clone() const { return new KeywordCastExpr( * this ); }
    222         virtual void accept( Visitor & v ) { v.visit( this ); }
    223         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    224         virtual void print( std::ostream & os, Indenter indent = {} ) const;
    225 };
    226 
    227200/// VirtualCastExpr repersents a virtual dynamic cast, e.g. (virtual exception)e
    228201class VirtualCastExpr : public Expression {
     
    232205        VirtualCastExpr( Expression * arg, Type * toType );
    233206        VirtualCastExpr( const VirtualCastExpr & other );
    234         virtual ~VirtualCastExpr();
    235207
    236208        Expression * get_arg() const { return arg; }
     
    251223        UntypedMemberExpr( Expression * member, Expression * aggregate );
    252224        UntypedMemberExpr( const UntypedMemberExpr & other );
    253         virtual ~UntypedMemberExpr();
    254225
    255226        Expression * get_member() const { return member; }
     
    273244        MemberExpr( DeclarationWithType * member, Expression * aggregate );
    274245        MemberExpr( const MemberExpr & other );
    275         virtual ~MemberExpr();
    276246
    277247        DeclarationWithType * get_member() const { return member; }
     
    294264        VariableExpr( DeclarationWithType * var );
    295265        VariableExpr( const VariableExpr & other );
    296         virtual ~VariableExpr();
    297266
    298267        DeclarationWithType * get_var() const { return var; }
     
    314283        ConstantExpr( Constant constant );
    315284        ConstantExpr( const ConstantExpr & other );
    316         virtual ~ConstantExpr();
    317285
    318286        Constant * get_constant() { return & constant; }
     
    338306        SizeofExpr( const SizeofExpr & other );
    339307        SizeofExpr( Type * type );
    340         virtual ~SizeofExpr();
    341308
    342309        Expression * get_expr() const { return expr; }
     
    363330        AlignofExpr( const AlignofExpr & other );
    364331        AlignofExpr( Type * type );
    365         virtual ~AlignofExpr();
    366332
    367333        Expression * get_expr() const { return expr; }
     
    386352        UntypedOffsetofExpr( Type * type, const std::string & member );
    387353        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
    388         virtual ~UntypedOffsetofExpr();
    389354
    390355        std::string get_member() const { return member; }
     
    407372        OffsetofExpr( Type * type, DeclarationWithType * member );
    408373        OffsetofExpr( const OffsetofExpr & other );
    409         virtual ~OffsetofExpr();
    410374
    411375        Type * get_type() const { return type; }
     
    427391        OffsetPackExpr( StructInstType * type );
    428392        OffsetPackExpr( const OffsetPackExpr & other );
    429         virtual ~OffsetPackExpr();
    430393
    431394        StructInstType * get_type() const { return type; }
     
    449412        AttrExpr( const AttrExpr & other );
    450413        AttrExpr( Expression * attr, Type * type );
    451         virtual ~AttrExpr();
    452414
    453415        Expression * get_attr() const { return attr; }
     
    474436        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true );
    475437        LogicalExpr( const LogicalExpr & other );
    476         virtual ~LogicalExpr();
    477438
    478439        bool get_isAnd() const { return isAnd; }
     
    500461        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 );
    501462        ConditionalExpr( const ConditionalExpr & other );
    502         virtual ~ConditionalExpr();
    503463
    504464        Expression * get_arg1() const { return arg1; }
     
    523483        CommaExpr( Expression * arg1, Expression * arg2 );
    524484        CommaExpr( const CommaExpr & other );
    525         virtual ~CommaExpr();
    526485
    527486        Expression * get_arg1() const { return arg1; }
     
    543502        TypeExpr( Type * type );
    544503        TypeExpr( const TypeExpr & other );
    545         virtual ~TypeExpr();
    546504
    547505        Type * get_type() const { return type; }
     
    563521        AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    564522        AsmExpr( const AsmExpr & other );
    565         virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    566523
    567524        Expression * get_inout() const { return inout; }
     
    585542/// along with a set of copy constructor calls, one for each argument.
    586543class ImplicitCopyCtorExpr : public Expression {
     544protected:
     545        virtual ~ImplicitCopyCtorExpr();
     546
    587547public:
    588548        ApplicationExpr * callExpr;
     
    593553        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    594554        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
    595         virtual ~ImplicitCopyCtorExpr();
    596555
    597556        ApplicationExpr * get_callExpr() const { return callExpr; }
     
    615574        ConstructorExpr( Expression * callExpr );
    616575        ConstructorExpr( const ConstructorExpr & other );
    617         ~ConstructorExpr();
    618576
    619577        Expression * get_callExpr() const { return callExpr; }
     
    633591        CompoundLiteralExpr( Type * type, Initializer * initializer );
    634592        CompoundLiteralExpr( const CompoundLiteralExpr & other );
    635         virtual ~CompoundLiteralExpr();
    636593
    637594        Initializer * get_initializer() const { return initializer; }
     
    670627        UntypedTupleExpr( const std::list< Expression * > & exprs );
    671628        UntypedTupleExpr( const UntypedTupleExpr & other );
    672         virtual ~UntypedTupleExpr();
    673629
    674630        std::list<Expression*>& get_exprs() { return exprs; }
     
    687643        TupleExpr( const std::list< Expression * > & exprs );
    688644        TupleExpr( const TupleExpr & other );
    689         virtual ~TupleExpr();
    690645
    691646        std::list<Expression*>& get_exprs() { return exprs; }
     
    705660        TupleIndexExpr( Expression * tuple, unsigned int index );
    706661        TupleIndexExpr( const TupleIndexExpr & other );
    707         virtual ~TupleIndexExpr();
    708662
    709663        Expression * get_tuple() const { return tuple; }
     
    725679        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls );
    726680        TupleAssignExpr( const TupleAssignExpr & other );
    727         virtual ~TupleAssignExpr();
    728681
    729682        TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; }
     
    745698        StmtExpr( CompoundStmt * statements );
    746699        StmtExpr( const StmtExpr & other );
    747         virtual ~StmtExpr();
    748700
    749701        CompoundStmt * get_statements() const { return statements; }
     
    770722        UniqueExpr( Expression * expr, long long idVal = -1 );
    771723        UniqueExpr( const UniqueExpr & other );
    772         ~UniqueExpr();
    773724
    774725        Expression * get_expr() const { return expr; }
     
    800751        InitAlternative( const InitAlternative & other );
    801752        InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it
    802         ~InitAlternative();
    803753};
    804754
     
    810760        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    811761        UntypedInitExpr( const UntypedInitExpr & other );
    812         ~UntypedInitExpr();
    813762
    814763        Expression * get_expr() const { return expr; }
     
    830779        InitExpr( Expression * expr, Designation * designation );
    831780        InitExpr( const InitExpr & other );
    832         ~InitExpr();
    833781
    834782        Expression * get_expr() const { return expr; }
     
    852800        DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
    853801        DeletedExpr( const DeletedExpr & other );
    854         ~DeletedExpr();
    855802
    856803        virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
Note: See TracChangeset for help on using the changeset viewer.