Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.h

    r68f9c43 r9a705dc8  
    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();
    4344        ParamEntry & operator=( const ParamEntry & other );
    4445
     
    5253/// Expression is the root type for all expressions
    5354class Expression : public BaseSyntaxNode {
    54   protected:
    55         virtual ~Expression();
    56 
    5755  public:
    5856        Type * result;
     
    6361        Expression();
    6462        Expression( const Expression & other );
     63        virtual ~Expression();
    6564
    6665        Type *& get_result() { return result; }
     
    9089        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    9190        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();
    113114
    114115        Expression * get_function() const { return function; }
     
    135136        NameExpr( std::string name );
    136137        NameExpr( const NameExpr & other );
     138        virtual ~NameExpr();
    137139
    138140        const std::string & get_name() const { return name; }
     
    155157        AddressExpr( Expression * arg );
    156158        AddressExpr( const AddressExpr & other );
     159        virtual ~AddressExpr();
    157160
    158161        Expression * get_arg() const { return arg; }
     
    173176        LabelAddressExpr( const Label &arg );
    174177        LabelAddressExpr( const LabelAddressExpr & other );
     178        virtual ~LabelAddressExpr();
    175179
    176180        virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); }
     
    184188  public:
    185189        Expression * arg;
    186 
    187         CastExpr( Expression * arg );
    188         CastExpr( Expression * arg, Type * toType );
     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
    189195        CastExpr( const CastExpr & other );
     196        virtual ~CastExpr();
    190197
    191198        Expression * get_arg() const { return arg; }
     
    198205};
    199206
     207/// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t
     208class KeywordCastExpr : public Expression {
     209public:
     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
    200227/// VirtualCastExpr repersents a virtual dynamic cast, e.g. (virtual exception)e
    201228class VirtualCastExpr : public Expression {
     
    205232        VirtualCastExpr( Expression * arg, Type * toType );
    206233        VirtualCastExpr( const VirtualCastExpr & other );
     234        virtual ~VirtualCastExpr();
    207235
    208236        Expression * get_arg() const { return arg; }
     
    223251        UntypedMemberExpr( Expression * member, Expression * aggregate );
    224252        UntypedMemberExpr( const UntypedMemberExpr & other );
     253        virtual ~UntypedMemberExpr();
    225254
    226255        Expression * get_member() const { return member; }
     
    244273        MemberExpr( DeclarationWithType * member, Expression * aggregate );
    245274        MemberExpr( const MemberExpr & other );
     275        virtual ~MemberExpr();
    246276
    247277        DeclarationWithType * get_member() const { return member; }
     
    264294        VariableExpr( DeclarationWithType * var );
    265295        VariableExpr( const VariableExpr & other );
     296        virtual ~VariableExpr();
    266297
    267298        DeclarationWithType * get_var() const { return var; }
     
    283314        ConstantExpr( Constant constant );
    284315        ConstantExpr( const ConstantExpr & other );
     316        virtual ~ConstantExpr();
    285317
    286318        Constant * get_constant() { return & constant; }
     
    306338        SizeofExpr( const SizeofExpr & other );
    307339        SizeofExpr( Type * type );
     340        virtual ~SizeofExpr();
    308341
    309342        Expression * get_expr() const { return expr; }
     
    330363        AlignofExpr( const AlignofExpr & other );
    331364        AlignofExpr( Type * type );
     365        virtual ~AlignofExpr();
    332366
    333367        Expression * get_expr() const { return expr; }
     
    352386        UntypedOffsetofExpr( Type * type, const std::string & member );
    353387        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
     388        virtual ~UntypedOffsetofExpr();
    354389
    355390        std::string get_member() const { return member; }
     
    372407        OffsetofExpr( Type * type, DeclarationWithType * member );
    373408        OffsetofExpr( const OffsetofExpr & other );
     409        virtual ~OffsetofExpr();
    374410
    375411        Type * get_type() const { return type; }
     
    391427        OffsetPackExpr( StructInstType * type );
    392428        OffsetPackExpr( const OffsetPackExpr & other );
     429        virtual ~OffsetPackExpr();
    393430
    394431        StructInstType * get_type() const { return type; }
     
    412449        AttrExpr( const AttrExpr & other );
    413450        AttrExpr( Expression * attr, Type * type );
     451        virtual ~AttrExpr();
    414452
    415453        Expression * get_attr() const { return attr; }
     
    436474        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true );
    437475        LogicalExpr( const LogicalExpr & other );
     476        virtual ~LogicalExpr();
    438477
    439478        bool get_isAnd() const { return isAnd; }
     
    461500        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 );
    462501        ConditionalExpr( const ConditionalExpr & other );
     502        virtual ~ConditionalExpr();
    463503
    464504        Expression * get_arg1() const { return arg1; }
     
    483523        CommaExpr( Expression * arg1, Expression * arg2 );
    484524        CommaExpr( const CommaExpr & other );
     525        virtual ~CommaExpr();
    485526
    486527        Expression * get_arg1() const { return arg1; }
     
    502543        TypeExpr( Type * type );
    503544        TypeExpr( const TypeExpr & other );
     545        virtual ~TypeExpr();
    504546
    505547        Type * get_type() const { return type; }
     
    521563        AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    522564        AsmExpr( const AsmExpr & other );
     565        virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    523566
    524567        Expression * get_inout() const { return inout; }
     
    542585/// along with a set of copy constructor calls, one for each argument.
    543586class ImplicitCopyCtorExpr : public Expression {
    544 protected:
    545         virtual ~ImplicitCopyCtorExpr();
    546 
    547587public:
    548588        ApplicationExpr * callExpr;
     
    553593        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    554594        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
     595        virtual ~ImplicitCopyCtorExpr();
    555596
    556597        ApplicationExpr * get_callExpr() const { return callExpr; }
     
    574615        ConstructorExpr( Expression * callExpr );
    575616        ConstructorExpr( const ConstructorExpr & other );
     617        ~ConstructorExpr();
    576618
    577619        Expression * get_callExpr() const { return callExpr; }
     
    591633        CompoundLiteralExpr( Type * type, Initializer * initializer );
    592634        CompoundLiteralExpr( const CompoundLiteralExpr & other );
     635        virtual ~CompoundLiteralExpr();
    593636
    594637        Initializer * get_initializer() const { return initializer; }
     
    627670        UntypedTupleExpr( const std::list< Expression * > & exprs );
    628671        UntypedTupleExpr( const UntypedTupleExpr & other );
     672        virtual ~UntypedTupleExpr();
    629673
    630674        std::list<Expression*>& get_exprs() { return exprs; }
     
    643687        TupleExpr( const std::list< Expression * > & exprs );
    644688        TupleExpr( const TupleExpr & other );
     689        virtual ~TupleExpr();
    645690
    646691        std::list<Expression*>& get_exprs() { return exprs; }
     
    660705        TupleIndexExpr( Expression * tuple, unsigned int index );
    661706        TupleIndexExpr( const TupleIndexExpr & other );
     707        virtual ~TupleIndexExpr();
    662708
    663709        Expression * get_tuple() const { return tuple; }
     
    679725        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls );
    680726        TupleAssignExpr( const TupleAssignExpr & other );
     727        virtual ~TupleAssignExpr();
    681728
    682729        TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; }
     
    698745        StmtExpr( CompoundStmt * statements );
    699746        StmtExpr( const StmtExpr & other );
     747        virtual ~StmtExpr();
    700748
    701749        CompoundStmt * get_statements() const { return statements; }
     
    722770        UniqueExpr( Expression * expr, long long idVal = -1 );
    723771        UniqueExpr( const UniqueExpr & other );
     772        ~UniqueExpr();
    724773
    725774        Expression * get_expr() const { return expr; }
     
    751800        InitAlternative( const InitAlternative & other );
    752801        InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it
     802        ~InitAlternative();
    753803};
    754804
     
    760810        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    761811        UntypedInitExpr( const UntypedInitExpr & other );
     812        ~UntypedInitExpr();
    762813
    763814        Expression * get_expr() const { return expr; }
     
    779830        InitExpr( Expression * expr, Designation * designation );
    780831        InitExpr( const InitExpr & other );
     832        ~InitExpr();
    781833
    782834        Expression * get_expr() const { return expr; }
     
    800852        DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
    801853        DeletedExpr( const DeletedExpr & other );
     854        ~DeletedExpr();
    802855
    803856        virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
Note: See TracChangeset for help on using the changeset viewer.