Ignore:
Timestamp:
May 18, 2015, 11:20:23 AM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
51587aa
Parents:
a32b204
Message:

licencing: third groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/Expression.h

    ra32b204 r0dd3a2f  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Expression.h,v 1.31 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// Expression.h --
     8//
     9// Author           : Richard C. Bilson
     10// Created On       : Mon May 18 07:44:20 2015
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon May 18 08:46:15 2015
     13// Update Count     : 3
     14//
    715
    816#ifndef EXPRESSION_H
     
    1523#include "Constant.h"
    1624
    17 
    18 class Expression
    19 {
    20 public:
    21     Expression(Expression *_aname = 0 );
    22     Expression( const Expression &other );
    23     virtual ~Expression();
    24 
    25     std::list<Type *>& get_results() { return results; }
    26     void add_result(Type *t);
    27 
    28     TypeSubstitution *get_env() const { return env; }
    29     void set_env( TypeSubstitution *newValue ) { env = newValue; }
    30     Expression *get_argName() const { return argName; }
    31     void set_argName( Expression *name ) { argName = name; }
    32 
    33     virtual Expression *clone() const = 0;
    34     virtual void accept( Visitor &v ) = 0;
    35     virtual Expression *acceptMutator( Mutator &m ) = 0;
    36     virtual void print( std::ostream &os, int indent = 0 ) const;
    37    
    38 protected:
    39     std::list<Type *> results;
    40     TypeSubstitution *env;
    41     Expression* argName; // if expression is used as an argument, it can be "designated" by this name
     25class Expression {
     26  public:
     27        Expression(Expression *_aname = 0 );
     28        Expression( const Expression &other );
     29        virtual ~Expression();
     30
     31        std::list<Type *>& get_results() { return results; }
     32        void add_result(Type *t);
     33
     34        TypeSubstitution *get_env() const { return env; }
     35        void set_env( TypeSubstitution *newValue ) { env = newValue; }
     36        Expression *get_argName() const { return argName; }
     37        void set_argName( Expression *name ) { argName = name; }
     38
     39        virtual Expression *clone() const = 0;
     40        virtual void accept( Visitor &v ) = 0;
     41        virtual Expression *acceptMutator( Mutator &m ) = 0;
     42        virtual void print( std::ostream &os, int indent = 0 ) const;
     43  protected:
     44        std::list<Type *> results;
     45        TypeSubstitution *env;
     46        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
    4247};
    4348
    4449// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration,
    4550// but subject to decay-to-pointer and type parameter renaming
    46 struct ParamEntry
    47 {
    48     ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {}
    49     ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ) {}
    50     ParamEntry( const ParamEntry &other );
    51     ~ParamEntry();
    52     ParamEntry &operator=( const ParamEntry &other );
    53 
    54     UniqueId decl;
    55     Type *actualType;
    56     Type *formalType;
    57     Expression* expr;
     51
     52struct ParamEntry {
     53        ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {}
     54        ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ) {}
     55        ParamEntry( const ParamEntry &other );
     56        ~ParamEntry();
     57        ParamEntry &operator=( const ParamEntry &other );
     58
     59        UniqueId decl;
     60        Type *actualType;
     61        Type *formalType;
     62        Expression* expr;
    5863};
    5964
     
    6267// ApplicationExpr represents the application of a function to a set of parameters.  This is the
    6368// result of running an UntypedExpr through the expression analyzer.
    64 class ApplicationExpr : public Expression
    65 {
    66 public:
    67     ApplicationExpr( Expression *function );
    68     ApplicationExpr( const ApplicationExpr &other );
    69     virtual ~ApplicationExpr();
    70 
    71     Expression *get_function() const { return function; }
    72     void set_function( Expression *newValue ) { function = newValue; }
    73     std::list<Expression *>& get_args() { return args; }
    74     InferredParams &get_inferParams() { return inferParams; }
    75 
    76     virtual ApplicationExpr *clone() const { return new ApplicationExpr( *this ); }
    77     virtual void accept( Visitor &v ) { v.visit( this ); }
    78     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    79     virtual void print( std::ostream &os, int indent = 0 ) const;
    80    
    81 private:
    82     Expression *function;
    83     std::list<Expression *> args;
    84     InferredParams inferParams;
     69
     70class ApplicationExpr : public Expression {
     71  public:
     72        ApplicationExpr( Expression *function );
     73        ApplicationExpr( const ApplicationExpr &other );
     74        virtual ~ApplicationExpr();
     75
     76        Expression *get_function() const { return function; }
     77        void set_function( Expression *newValue ) { function = newValue; }
     78        std::list<Expression *>& get_args() { return args; }
     79        InferredParams &get_inferParams() { return inferParams; }
     80
     81        virtual ApplicationExpr *clone() const { return new ApplicationExpr( *this ); }
     82        virtual void accept( Visitor &v ) { v.visit( this ); }
     83        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     84        virtual void print( std::ostream &os, int indent = 0 ) const;
     85  private:
     86        Expression *function;
     87        std::list<Expression *> args;
     88        InferredParams inferParams;
    8589};
    8690
     
    8892// particular overload for the function name has not yet been determined.  Most operators are
    8993// converted into functional form automatically, to permit operator overloading.
    90 class UntypedExpr : public Expression
    91 {
    92 public:
    93     UntypedExpr( Expression *function, Expression *_aname = 0 );
    94     UntypedExpr( const UntypedExpr &other );
    95     UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = 0 );
    96     virtual ~UntypedExpr();
    97 
    98     Expression *get_function() const { return function; }
    99     void set_function( Expression *newValue ) { function = newValue; }
    100 
    101     void set_args( std::list<Expression *> &listArgs ) { args = listArgs; }
    102     std::list<Expression*>::iterator begin_args() { return args.begin(); }
    103     std::list<Expression*>::iterator end_args() { return args.end(); }
    104     std::list<Expression*>& get_args() { return args; }
    105 
    106     virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); }
    107     virtual void accept( Visitor &v ) { v.visit( this ); }
    108     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    109     virtual void print( std::ostream &os, int indent = 0 ) const;
    110     virtual void printArgs(std::ostream &os, int indent = 0) const;
    111    
    112 private:
    113    
    114     Expression *function;
    115     std::list<Expression*> args;
     94
     95class UntypedExpr : public Expression {
     96  public:
     97        UntypedExpr( Expression *function, Expression *_aname = 0 );
     98        UntypedExpr( const UntypedExpr &other );
     99        UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = 0 );
     100        virtual ~UntypedExpr();
     101
     102        Expression *get_function() const { return function; }
     103        void set_function( Expression *newValue ) { function = newValue; }
     104
     105        void set_args( std::list<Expression *> &listArgs ) { args = listArgs; }
     106        std::list<Expression*>::iterator begin_args() { return args.begin(); }
     107        std::list<Expression*>::iterator end_args() { return args.end(); }
     108        std::list<Expression*>& get_args() { return args; }
     109
     110        virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); }
     111        virtual void accept( Visitor &v ) { v.visit( this ); }
     112        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     113        virtual void print( std::ostream &os, int indent = 0 ) const;
     114        virtual void printArgs(std::ostream &os, int indent = 0) const;
     115  private:
     116        Expression *function;
     117        std::list<Expression*> args;
    116118};
    117119
    118120// this class contains a name whose meaning is still not determined
    119 class NameExpr : public Expression
    120 {
    121 public:
    122     NameExpr( std::string name, Expression *_aname = 0 );
    123     NameExpr( const NameExpr &other );
    124     virtual ~NameExpr();
    125 
    126     std::string get_name() const { return name; }
    127     void set_name( std::string newValue ) { name = newValue; }
    128 
    129     virtual NameExpr *clone() const { return new NameExpr( *this ); }
    130     virtual void accept( Visitor &v ) { v.visit( this ); }
    131     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    132     virtual void print( std::ostream &os, int indent = 0 ) const;
    133    
    134 private:
    135    
    136     std::string name;
     121class NameExpr : public Expression {
     122  public:
     123        NameExpr( std::string name, Expression *_aname = 0 );
     124        NameExpr( const NameExpr &other );
     125        virtual ~NameExpr();
     126
     127        std::string get_name() const { return name; }
     128        void set_name( std::string newValue ) { name = newValue; }
     129
     130        virtual NameExpr *clone() const { return new NameExpr( *this ); }
     131        virtual void accept( Visitor &v ) { v.visit( this ); }
     132        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     133        virtual void print( std::ostream &os, int indent = 0 ) const;
     134  private:
     135        std::string name;
    137136};
    138137
     
    141140
    142141// AddressExpr represents a address-of expression, e.g. &e
    143 class AddressExpr : public Expression
    144 {
    145 public:
    146     AddressExpr( Expression *arg, Expression *_aname = 0 );
    147     AddressExpr( const AddressExpr &other );
    148     virtual ~AddressExpr();
    149 
    150     Expression *get_arg() const { return arg; }
    151     void set_arg(Expression *newValue ) { arg = newValue; }
    152 
    153     virtual AddressExpr *clone() const { return new AddressExpr( *this ); }
    154     virtual void accept( Visitor &v ) { v.visit( this ); }
    155     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    156     virtual void print( std::ostream &os, int indent = 0 ) const;
    157    
    158 private:
    159     Expression *arg;
    160 };
    161 
    162 class LabelAddressExpr : public Expression
    163 {
    164 public:
    165     LabelAddressExpr( Expression *arg );
    166     LabelAddressExpr( const AddressExpr &other );
    167     virtual ~LabelAddressExpr();
    168 
    169     Expression *get_arg() const { return arg; }
    170     void set_arg(Expression *newValue ) { arg = newValue; }
    171 
    172     virtual LabelAddressExpr *clone() const { return new LabelAddressExpr( *this ); }
    173     virtual void accept( Visitor &v ) { v.visit( this ); }
    174     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    175     virtual void print( std::ostream &os, int indent = 0 ) const;
    176    
    177 private:
    178     Expression *arg;
     142class AddressExpr : public Expression {
     143  public:
     144        AddressExpr( Expression *arg, Expression *_aname = 0 );
     145        AddressExpr( const AddressExpr &other );
     146        virtual ~AddressExpr();
     147
     148        Expression *get_arg() const { return arg; }
     149        void set_arg(Expression *newValue ) { arg = newValue; }
     150
     151        virtual AddressExpr *clone() const { return new AddressExpr( *this ); }
     152        virtual void accept( Visitor &v ) { v.visit( this ); }
     153        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     154        virtual void print( std::ostream &os, int indent = 0 ) const;
     155  private:
     156        Expression *arg;
     157};
     158
     159class LabelAddressExpr : public Expression {
     160  public:
     161        LabelAddressExpr( Expression *arg );
     162        LabelAddressExpr( const AddressExpr &other );
     163        virtual ~LabelAddressExpr();
     164
     165        Expression *get_arg() const { return arg; }
     166        void set_arg(Expression *newValue ) { arg = newValue; }
     167
     168        virtual LabelAddressExpr *clone() const { return new LabelAddressExpr( *this ); }
     169        virtual void accept( Visitor &v ) { v.visit( this ); }
     170        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     171        virtual void print( std::ostream &os, int indent = 0 ) const;
     172  private:
     173        Expression *arg;
    179174};
    180175
    181176// CastExpr represents a type cast expression, e.g. (int)e
    182 class CastExpr : public Expression
    183 {
    184 public:
    185     CastExpr( Expression *arg, Expression *_aname = 0 );
    186     CastExpr( Expression *arg, Type *toType, Expression *_aname = 0 );
    187     CastExpr( const CastExpr &other );
    188     virtual ~CastExpr();
    189 
    190     Expression *get_arg() const { return arg; }
    191     void set_arg(Expression *newValue ) { arg = newValue; }
    192 
    193     virtual CastExpr *clone() const { return new CastExpr( *this ); }
    194     virtual void accept( Visitor &v ) { v.visit( this ); }
    195     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    196     virtual void print( std::ostream &os, int indent = 0 ) const;
    197    
    198 private:
    199     Expression *arg;
    200 };
    201 
    202 // UntypedMemberExpr represents a member selection operation, e.g. q.p
    203 // before processing by the expression analyzer
    204 class UntypedMemberExpr : public Expression
    205 {
    206 public:
    207     UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = 0 );
    208     UntypedMemberExpr( const UntypedMemberExpr &other );
    209     virtual ~UntypedMemberExpr();
    210 
    211     std::string get_member() const { return member; }
    212     void set_member( const std::string &newValue ) { member = newValue; }
    213     Expression *get_aggregate() const { return aggregate; }
    214     void set_aggregate( Expression *newValue ) { aggregate = newValue; }
    215 
    216     virtual UntypedMemberExpr *clone() const { return new UntypedMemberExpr( *this ); }
    217     virtual void accept( Visitor &v ) { v.visit( this ); }
    218     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    219     virtual void print( std::ostream &os, int indent = 0 ) const;
    220    
    221 private:
    222     std::string member;
    223     Expression *aggregate;
    224 };
    225 
    226 // MemberExpr represents a member selection operation, e.g. q.p
    227 // after processing by the expression analyzer
    228 class MemberExpr : public Expression
    229 {
    230 public:
    231     MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = 0 );
    232     MemberExpr( const MemberExpr &other );
    233     virtual ~MemberExpr();
    234 
    235     DeclarationWithType *get_member() const { return member; }
    236     void set_member( DeclarationWithType *newValue ) { member = newValue; }
    237     Expression *get_aggregate() const { return aggregate; }
    238     void set_aggregate( Expression *newValue ) { aggregate = newValue; }
    239 
    240     virtual MemberExpr *clone() const { return new MemberExpr( *this ); }
    241     virtual void accept( Visitor &v ) { v.visit( this ); }
    242     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    243     virtual void print( std::ostream &os, int indent = 0 ) const;
    244    
    245 private:
    246     DeclarationWithType *member;
    247     Expression *aggregate;
     177class CastExpr : public Expression {
     178  public:
     179        CastExpr( Expression *arg, Expression *_aname = 0 );
     180        CastExpr( Expression *arg, Type *toType, Expression *_aname = 0 );
     181        CastExpr( const CastExpr &other );
     182        virtual ~CastExpr();
     183
     184        Expression *get_arg() const { return arg; }
     185        void set_arg(Expression *newValue ) { arg = newValue; }
     186
     187        virtual CastExpr *clone() const { return new CastExpr( *this ); }
     188        virtual void accept( Visitor &v ) { v.visit( this ); }
     189        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     190        virtual void print( std::ostream &os, int indent = 0 ) const;
     191  private:
     192        Expression *arg;
     193};
     194
     195// UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer
     196class UntypedMemberExpr : public Expression {
     197  public:
     198        UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = 0 );
     199        UntypedMemberExpr( const UntypedMemberExpr &other );
     200        virtual ~UntypedMemberExpr();
     201
     202        std::string get_member() const { return member; }
     203        void set_member( const std::string &newValue ) { member = newValue; }
     204        Expression *get_aggregate() const { return aggregate; }
     205        void set_aggregate( Expression *newValue ) { aggregate = newValue; }
     206
     207        virtual UntypedMemberExpr *clone() const { return new UntypedMemberExpr( *this ); }
     208        virtual void accept( Visitor &v ) { v.visit( this ); }
     209        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     210        virtual void print( std::ostream &os, int indent = 0 ) const;
     211  private:
     212        std::string member;
     213        Expression *aggregate;
     214};
     215
     216// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
     217class MemberExpr : public Expression {
     218  public:
     219        MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = 0 );
     220        MemberExpr( const MemberExpr &other );
     221        virtual ~MemberExpr();
     222
     223        DeclarationWithType *get_member() const { return member; }
     224        void set_member( DeclarationWithType *newValue ) { member = newValue; }
     225        Expression *get_aggregate() const { return aggregate; }
     226        void set_aggregate( Expression *newValue ) { aggregate = newValue; }
     227
     228        virtual MemberExpr *clone() const { return new MemberExpr( *this ); }
     229        virtual void accept( Visitor &v ) { v.visit( this ); }
     230        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     231        virtual void print( std::ostream &os, int indent = 0 ) const;
     232  private:
     233        DeclarationWithType *member;
     234        Expression *aggregate;
    248235};
    249236
    250237// VariableExpr represents an expression that simply refers to the value of a named variable
    251 class VariableExpr : public Expression
    252 {
    253 public:
    254     VariableExpr( DeclarationWithType *var, Expression *_aname = 0 );
    255     VariableExpr( const VariableExpr &other );
    256     virtual ~VariableExpr();
    257 
    258     DeclarationWithType *get_var() const { return var; }
    259     void set_var( DeclarationWithType *newValue ) { var = newValue; }
    260 
    261     virtual VariableExpr *clone() const { return new VariableExpr( *this ); }
    262     virtual void accept( Visitor &v ) { v.visit( this ); }
    263     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    264     virtual void print( std::ostream &os, int indent = 0 ) const;
    265    
    266 private:
    267     DeclarationWithType *var;
     238class VariableExpr : public Expression {
     239  public:
     240        VariableExpr( DeclarationWithType *var, Expression *_aname = 0 );
     241        VariableExpr( const VariableExpr &other );
     242        virtual ~VariableExpr();
     243
     244        DeclarationWithType *get_var() const { return var; }
     245        void set_var( DeclarationWithType *newValue ) { var = newValue; }
     246
     247        virtual VariableExpr *clone() const { return new VariableExpr( *this ); }
     248        virtual void accept( Visitor &v ) { v.visit( this ); }
     249        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     250        virtual void print( std::ostream &os, int indent = 0 ) const;
     251  private:
     252        DeclarationWithType *var;
    268253};
    269254
    270255// ConstantExpr represents an expression that simply refers to the value of a constant
    271 class ConstantExpr : public Expression
    272 {
    273 public:
    274     ConstantExpr( Constant constant, Expression *_aname = 0 );
    275     ConstantExpr( const ConstantExpr &other );
    276     virtual ~ConstantExpr();
    277 
    278     Constant *get_constant() { return &constant; }
    279     void set_constant( const Constant &newValue ) { constant = newValue; }
    280 
    281     virtual ConstantExpr *clone() const { return new ConstantExpr( *this ); }
    282     virtual void accept( Visitor &v ) { v.visit( this ); }
    283     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    284     virtual void print( std::ostream &os, int indent = 0 ) const;
    285    
    286 private:
    287     Constant constant;
     256class ConstantExpr : public Expression {
     257  public:
     258        ConstantExpr( Constant constant, Expression *_aname = 0 );
     259        ConstantExpr( const ConstantExpr &other );
     260        virtual ~ConstantExpr();
     261
     262        Constant *get_constant() { return &constant; }
     263        void set_constant( const Constant &newValue ) { constant = newValue; }
     264
     265        virtual ConstantExpr *clone() const { return new ConstantExpr( *this ); }
     266        virtual void accept( Visitor &v ) { v.visit( this ); }
     267        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     268        virtual void print( std::ostream &os, int indent = 0 ) const;
     269  private:
     270        Constant constant;
    288271};
    289272
    290273// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4)
    291 class SizeofExpr : public Expression
    292 {
    293 public:
    294     SizeofExpr( Expression *expr, Expression *_aname = 0 );
    295     SizeofExpr( const SizeofExpr &other );
    296     SizeofExpr( Type *type, Expression *_aname = 0 );
    297     virtual ~SizeofExpr();
    298 
    299     Expression *get_expr() const { return expr; }
    300     void set_expr( Expression *newValue ) { expr = newValue; }
    301     Type *get_type() const { return type; }
    302     void set_type( Type *newValue ) { type = newValue; }
    303     bool get_isType() const { return isType; }
    304     void set_isType( bool newValue ) { isType = newValue; }
    305 
    306     virtual SizeofExpr *clone() const { return new SizeofExpr( *this ); }
    307     virtual void accept( Visitor &v ) { v.visit( this ); }
    308     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    309     virtual void print( std::ostream &os, int indent = 0 ) const;
    310    
    311 private:
    312     Expression *expr;
    313     Type *type;
    314     bool isType;
     274class SizeofExpr : public Expression {
     275  public:
     276        SizeofExpr( Expression *expr, Expression *_aname = 0 );
     277        SizeofExpr( const SizeofExpr &other );
     278        SizeofExpr( Type *type, Expression *_aname = 0 );
     279        virtual ~SizeofExpr();
     280
     281        Expression *get_expr() const { return expr; }
     282        void set_expr( Expression *newValue ) { expr = newValue; }
     283        Type *get_type() const { return type; }
     284        void set_type( Type *newValue ) { type = newValue; }
     285        bool get_isType() const { return isType; }
     286        void set_isType( bool newValue ) { isType = newValue; }
     287
     288        virtual SizeofExpr *clone() const { return new SizeofExpr( *this ); }
     289        virtual void accept( Visitor &v ) { v.visit( this ); }
     290        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     291        virtual void print( std::ostream &os, int indent = 0 ) const;
     292  private:
     293        Expression *expr;
     294        Type *type;
     295        bool isType;
    315296};
    316297
    317298// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    318 class AttrExpr : public Expression
    319 {
    320 public:
    321     AttrExpr(Expression *attr, Expression *expr, Expression *_aname = 0 );
    322     AttrExpr( const AttrExpr &other );
    323     AttrExpr( Expression *attr, Type *type, Expression *_aname = 0 );
    324     virtual ~AttrExpr();
    325 
    326     Expression *get_attr() const { return attr; }
    327     void set_attr( Expression *newValue ) { attr = newValue; }
    328     Expression *get_expr() const { return expr; }
    329     void set_expr( Expression *newValue ) { expr = newValue; }
    330     Type *get_type() const { return type; }
    331     void set_type( Type *newValue ) { type = newValue; }
    332     bool get_isType() const { return isType; }
    333     void set_isType( bool newValue ) { isType = newValue; }
    334 
    335     virtual AttrExpr *clone() const { return new AttrExpr( *this ); }
    336     virtual void accept( Visitor &v ) { v.visit( this ); }
    337     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    338     virtual void print( std::ostream &os, int indent = 0 ) const;
    339    
    340 private:
    341     Expression *attr;
    342     Expression *expr;
    343     Type *type;
    344     bool isType;
     299class AttrExpr : public Expression {
     300  public:
     301        AttrExpr(Expression *attr, Expression *expr, Expression *_aname = 0 );
     302        AttrExpr( const AttrExpr &other );
     303        AttrExpr( Expression *attr, Type *type, Expression *_aname = 0 );
     304        virtual ~AttrExpr();
     305
     306        Expression *get_attr() const { return attr; }
     307        void set_attr( Expression *newValue ) { attr = newValue; }
     308        Expression *get_expr() const { return expr; }
     309        void set_expr( Expression *newValue ) { expr = newValue; }
     310        Type *get_type() const { return type; }
     311        void set_type( Type *newValue ) { type = newValue; }
     312        bool get_isType() const { return isType; }
     313        void set_isType( bool newValue ) { isType = newValue; }
     314
     315        virtual AttrExpr *clone() const { return new AttrExpr( *this ); }
     316        virtual void accept( Visitor &v ) { v.visit( this ); }
     317        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     318        virtual void print( std::ostream &os, int indent = 0 ) const;
     319  private:
     320        Expression *attr;
     321        Expression *expr;
     322        Type *type;
     323        bool isType;
    345324};
    346325
    347326// LogicalExpr represents a short-circuit boolean expression (&& or ||)
    348 class LogicalExpr : public Expression
    349 {
    350 public:
    351     LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = 0 );
    352     LogicalExpr( const LogicalExpr &other );
    353     virtual ~LogicalExpr();
    354 
    355     bool get_isAnd() const { return isAnd; }
    356     Expression *get_arg1() { return arg1; }
    357     void set_arg1( Expression *newValue ) { arg1 = newValue; }
    358     Expression *get_arg2() const { return arg2; }
    359     void set_arg2( Expression *newValue ) { arg2 = newValue; }
    360 
    361     virtual LogicalExpr *clone() const { return new LogicalExpr( *this ); }
    362     virtual void accept( Visitor &v ) { v.visit( this ); }
    363     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    364     virtual void print( std::ostream &os, int indent = 0 ) const;
    365    
    366 private:
    367     Expression *arg1;
    368     Expression *arg2;
    369     bool isAnd;
     327class LogicalExpr : public Expression {
     328  public:
     329        LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = 0 );
     330        LogicalExpr( const LogicalExpr &other );
     331        virtual ~LogicalExpr();
     332
     333        bool get_isAnd() const { return isAnd; }
     334        Expression *get_arg1() { return arg1; }
     335        void set_arg1( Expression *newValue ) { arg1 = newValue; }
     336        Expression *get_arg2() const { return arg2; }
     337        void set_arg2( Expression *newValue ) { arg2 = newValue; }
     338
     339        virtual LogicalExpr *clone() const { return new LogicalExpr( *this ); }
     340        virtual void accept( Visitor &v ) { v.visit( this ); }
     341        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     342        virtual void print( std::ostream &os, int indent = 0 ) const;
     343  private:
     344        Expression *arg1;
     345        Expression *arg2;
     346        bool isAnd;
    370347};
    371348
    372349// ConditionalExpr represents the three-argument conditional ( p ? a : b )
    373 class ConditionalExpr : public Expression
    374 {
    375 public:
    376     ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = 0 );
    377     ConditionalExpr( const ConditionalExpr &other );
    378     virtual ~ConditionalExpr();
    379 
    380     Expression *get_arg1() const { return arg1; }
    381     void set_arg1( Expression *newValue ) { arg1 = newValue; }
    382     Expression *get_arg2() const { return arg2; }
    383     void set_arg2( Expression *newValue ) { arg2 = newValue; }
    384     Expression *get_arg3() const { return arg3; }
    385     void set_arg3( Expression *newValue ) { arg3 = newValue; }
    386 
    387     virtual ConditionalExpr *clone() const { return new ConditionalExpr( *this ); }
    388     virtual void accept( Visitor &v ) { v.visit( this ); }
    389     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    390     virtual void print( std::ostream &os, int indent = 0 ) const;
    391    
    392 private:
    393     Expression *arg1;
    394     Expression *arg2;
    395     Expression *arg3;
     350class ConditionalExpr : public Expression {
     351  public:
     352        ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = 0 );
     353        ConditionalExpr( const ConditionalExpr &other );
     354        virtual ~ConditionalExpr();
     355
     356        Expression *get_arg1() const { return arg1; }
     357        void set_arg1( Expression *newValue ) { arg1 = newValue; }
     358        Expression *get_arg2() const { return arg2; }
     359        void set_arg2( Expression *newValue ) { arg2 = newValue; }
     360        Expression *get_arg3() const { return arg3; }
     361        void set_arg3( Expression *newValue ) { arg3 = newValue; }
     362
     363        virtual ConditionalExpr *clone() const { return new ConditionalExpr( *this ); }
     364        virtual void accept( Visitor &v ) { v.visit( this ); }
     365        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     366        virtual void print( std::ostream &os, int indent = 0 ) const;
     367  private:
     368        Expression *arg1;
     369        Expression *arg2;
     370        Expression *arg3;
    396371};
    397372
    398373// CommaExpr represents the sequence operator ( a, b )
    399 class CommaExpr : public Expression
    400 {
    401 public:
    402     CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = 0 );
    403     CommaExpr( const CommaExpr &other );
    404     virtual ~CommaExpr();
    405 
    406     Expression *get_arg1() const { return arg1; }
    407     void set_arg1( Expression *newValue ) { arg1 = newValue; }
    408     Expression *get_arg2() const { return arg2; }
    409     void set_arg2( Expression *newValue ) { arg2 = newValue; }
    410 
    411     virtual CommaExpr *clone() const { return new CommaExpr( *this ); }
    412     virtual void accept( Visitor &v ) { v.visit( this ); }
    413     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    414     virtual void print( std::ostream &os, int indent = 0 ) const;
    415    
    416 private:
    417     Expression *arg1;
    418     Expression *arg2;
     374class CommaExpr : public Expression {
     375  public:
     376        CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = 0 );
     377        CommaExpr( const CommaExpr &other );
     378        virtual ~CommaExpr();
     379
     380        Expression *get_arg1() const { return arg1; }
     381        void set_arg1( Expression *newValue ) { arg1 = newValue; }
     382        Expression *get_arg2() const { return arg2; }
     383        void set_arg2( Expression *newValue ) { arg2 = newValue; }
     384
     385        virtual CommaExpr *clone() const { return new CommaExpr( *this ); }
     386        virtual void accept( Visitor &v ) { v.visit( this ); }
     387        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     388        virtual void print( std::ostream &os, int indent = 0 ) const;
     389  private:
     390        Expression *arg1;
     391        Expression *arg2;
    419392};
    420393
    421394// TupleExpr represents a tuple expression ( [a, b, c] )
    422 class TupleExpr : public Expression
    423 {
    424 public:
    425     TupleExpr( Expression *_aname = 0 );
    426     TupleExpr( const TupleExpr &other );
    427     virtual ~TupleExpr();
    428 
    429     void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
    430     std::list<Expression*>& get_exprs() { return exprs; }
    431 
    432     virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
    433     virtual void accept( Visitor &v ) { v.visit( this ); }
    434     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    435     virtual void print( std::ostream &os, int indent = 0 ) const;
    436    
    437 private:
    438     std::list<Expression*> exprs;
     395class TupleExpr : public Expression {
     396  public:
     397        TupleExpr( Expression *_aname = 0 );
     398        TupleExpr( const TupleExpr &other );
     399        virtual ~TupleExpr();
     400
     401        void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
     402        std::list<Expression*>& get_exprs() { return exprs; }
     403
     404        virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
     405        virtual void accept( Visitor &v ) { v.visit( this ); }
     406        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     407        virtual void print( std::ostream &os, int indent = 0 ) const;
     408  private:
     409        std::list<Expression*> exprs;
    439410};
    440411
    441412// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
    442 class SolvedTupleExpr : public Expression
    443 {
    444 public:
    445 
    446     SolvedTupleExpr( Expression *_aname = 0 ) : Expression( _aname ) {}
    447     SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = 0 );
    448     SolvedTupleExpr( const SolvedTupleExpr &other );
    449     virtual ~SolvedTupleExpr() {}
    450 
    451     std::list<Expression*> &get_exprs() { return exprs; }
    452 
    453     virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
    454     virtual void accept( Visitor &v ) { v.visit( this ); }
    455     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    456     virtual void print( std::ostream &os, int indent = 0 ) const;
    457 private:
    458     std::list<Expression*> exprs;
     413class SolvedTupleExpr : public Expression {
     414  public:
     415        SolvedTupleExpr( Expression *_aname = 0 ) : Expression( _aname ) {}
     416        SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = 0 );
     417        SolvedTupleExpr( const SolvedTupleExpr &other );
     418        virtual ~SolvedTupleExpr() {}
     419
     420        std::list<Expression*> &get_exprs() { return exprs; }
     421
     422        virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
     423        virtual void accept( Visitor &v ) { v.visit( this ); }
     424        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     425        virtual void print( std::ostream &os, int indent = 0 ) const;
     426  private:
     427        std::list<Expression*> exprs;
    459428};
    460429
    461430// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
    462 class TypeExpr : public Expression
    463 {
    464 public:
    465     TypeExpr( Type *type );
    466     TypeExpr( const TypeExpr &other );
    467     virtual ~TypeExpr();
    468 
    469     Type *get_type() const { return type; }
    470     void set_type( Type *newValue ) { type = newValue; }
    471 
    472     virtual TypeExpr *clone() const { return new TypeExpr( *this ); }
    473     virtual void accept( Visitor &v ) { v.visit( this ); }
    474     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    475     virtual void print( std::ostream &os, int indent = 0 ) const;
    476    
    477 private:
    478     Type *type;
     431class TypeExpr : public Expression {
     432  public:
     433        TypeExpr( Type *type );
     434        TypeExpr( const TypeExpr &other );
     435        virtual ~TypeExpr();
     436
     437        Type *get_type() const { return type; }
     438        void set_type( Type *newValue ) { type = newValue; }
     439
     440        virtual TypeExpr *clone() const { return new TypeExpr( *this ); }
     441        virtual void accept( Visitor &v ) { v.visit( this ); }
     442        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     443        virtual void print( std::ostream &os, int indent = 0 ) const;
     444  private:
     445        Type *type;
    479446};
    480447
    481448// ValofExpr represents a GCC 'lambda expression'
    482 class UntypedValofExpr : public Expression
    483 {
    484 public:
    485     UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {}
    486     virtual ~UntypedValofExpr() {}
    487 
    488     Expression *get_value();
    489     Statement *get_body() const { return body; }
    490 
    491     virtual UntypedValofExpr *clone() const { return new UntypedValofExpr( *this ); }
    492     virtual void accept( Visitor &v ) { v.visit( this ); }
    493     virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    494     virtual void print( std::ostream &os, int indent = 0 ) const;
    495    
    496 private:
    497     Statement *body;
    498 };
    499 
    500 
    501 #endif /* #ifndef EXPRESSION_H */
    502 
    503 /*
    504     Local Variables:
    505     mode: c++
    506     End:
    507 */
     449class UntypedValofExpr : public Expression {
     450  public:
     451        UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {}
     452        virtual ~UntypedValofExpr() {}
     453
     454        Expression *get_value();
     455        Statement *get_body() const { return body; }
     456
     457        virtual UntypedValofExpr *clone() const { return new UntypedValofExpr( *this ); }
     458        virtual void accept( Visitor &v ) { v.visit( this ); }
     459        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     460        virtual void print( std::ostream &os, int indent = 0 ) const;
     461  private:
     462        Statement *body;
     463};
     464
     465#endif // EXPRESSION_H
     466
     467// Local Variables: //
     468// tab-width: 4 //
     469// mode: c++ //
     470// compile-command: "make install" //
     471// End: //
Note: See TracChangeset for help on using the changeset viewer.