| [0dd3a2f] | 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 | // | 
|---|
| [3be261a] | 7 | // Expression.h -- | 
|---|
| [0dd3a2f] | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Mon May 18 07:44:20 2015 | 
|---|
| [312029a] | 11 | // Last Modified By : Peter A. Buhr | 
|---|
|  | 12 | // Last Modified On : Wed Dec 11 16:50:19 2019 | 
|---|
|  | 13 | // Update Count     : 60 | 
|---|
| [0dd3a2f] | 14 | // | 
|---|
| [e612146c] | 15 |  | 
|---|
| [6b0b624] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [ea6332d] | 18 | #include <iosfwd>                 // for ostream | 
|---|
|  | 19 | #include <list>                   // for list, list<>::iterator | 
|---|
|  | 20 | #include <map>                    // for map, map<>::value_compare | 
|---|
|  | 21 | #include <memory>                 // for allocator, unique_ptr | 
|---|
|  | 22 | #include <string>                 // for string | 
|---|
| [0b00df0] | 23 | #include <vector>                 // for vector | 
|---|
| [ea6332d] | 24 |  | 
|---|
|  | 25 | #include "BaseSyntaxNode.h"       // for BaseSyntaxNode | 
|---|
|  | 26 | #include "Constant.h"             // for Constant | 
|---|
|  | 27 | #include "Initializer.h"          // for Designation (ptr only), Initializer | 
|---|
| [5809461] | 28 | #include "Label.h"                // for Label | 
|---|
| [ea6332d] | 29 | #include "Mutator.h"              // for Mutator | 
|---|
| [312029a] | 30 | #include "Declaration.h"          // for Aggregate | 
|---|
| [ea6332d] | 31 | #include "SynTree.h"              // for UniqueId | 
|---|
|  | 32 | #include "Visitor.h"              // for Visitor | 
|---|
| [294647b] | 33 |  | 
|---|
| [51b73452] | 34 |  | 
|---|
| [df626eb] | 35 | struct ParamEntry; | 
|---|
|  | 36 |  | 
|---|
|  | 37 | typedef std::map< UniqueId, ParamEntry > InferredParams; | 
|---|
|  | 38 |  | 
|---|
|  | 39 | /// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration, | 
|---|
|  | 40 | /// but subject to decay-to-pointer and type parameter renaming | 
|---|
|  | 41 | struct ParamEntry { | 
|---|
| [462a7c7] | 42 | ParamEntry(): decl( 0 ), declptr( nullptr ), actualType( nullptr ), formalType( nullptr ), expr( nullptr ) {} | 
|---|
|  | 43 | ParamEntry( UniqueId decl, Declaration * declptr, Type * actualType, Type * formalType, Expression* expr ); | 
|---|
| [df626eb] | 44 | ParamEntry( const ParamEntry & other ); | 
|---|
| [4d6d62e] | 45 | ParamEntry( ParamEntry && other ); | 
|---|
| [df626eb] | 46 | ~ParamEntry(); | 
|---|
| [4d6d62e] | 47 | ParamEntry & operator=( ParamEntry && other ); | 
|---|
| [df626eb] | 48 |  | 
|---|
| [aaeacf4] | 49 | UniqueId const decl; | 
|---|
|  | 50 | Declaration * const declptr; | 
|---|
|  | 51 | Type * const actualType; | 
|---|
|  | 52 | Type * const formalType; | 
|---|
| [df626eb] | 53 | Expression * expr; | 
|---|
|  | 54 | }; | 
|---|
|  | 55 |  | 
|---|
| [47534159] | 56 | /// Expression is the root type for all expressions | 
|---|
| [df626eb] | 57 | class Expression : public BaseSyntaxNode { | 
|---|
| [0dd3a2f] | 58 | public: | 
|---|
| [65cdc1e] | 59 | Type * result; | 
|---|
|  | 60 | TypeSubstitution * env; | 
|---|
|  | 61 | bool extension = false; | 
|---|
| [0b00df0] | 62 | InferredParams inferParams;       ///< Post-resolution inferred parameter slots | 
|---|
|  | 63 | std::vector<UniqueId> resnSlots;  ///< Pre-resolution inferred parameter slots | 
|---|
| [0e315a5] | 64 |  | 
|---|
| [0b00df0] | 65 | // xxx - should turn inferParams+resnSlots into a union to save some memory | 
|---|
| [65cdc1e] | 66 |  | 
|---|
| [bf4b4cf] | 67 | Expression(); | 
|---|
| [5ded739] | 68 | Expression( const Expression & other ); | 
|---|
| [0dd3a2f] | 69 | virtual ~Expression(); | 
|---|
|  | 70 |  | 
|---|
| [906e24d] | 71 | Type *& get_result() { return result; } | 
|---|
| [fbcde64] | 72 | const Type * get_result() const { return result; } | 
|---|
| [5ded739] | 73 | void set_result( Type * newValue ) { result = newValue; } | 
|---|
| [14388c1] | 74 | virtual bool get_lvalue() const; | 
|---|
| [0dd3a2f] | 75 |  | 
|---|
| [5ded739] | 76 | TypeSubstitution * get_env() const { return env; } | 
|---|
|  | 77 | void set_env( TypeSubstitution * newValue ) { env = newValue; } | 
|---|
| [e04ef3a] | 78 | bool get_extension() const { return extension; } | 
|---|
| [8e9cbb2] | 79 | Expression * set_extension( bool exten ) { extension = exten; return this; } | 
|---|
| [0dd3a2f] | 80 |  | 
|---|
| [cdb990a] | 81 | // move other's inferParams to this | 
|---|
|  | 82 | void spliceInferParams( Expression * other ); | 
|---|
|  | 83 |  | 
|---|
| [fa16264] | 84 | virtual Expression * clone() const override = 0; | 
|---|
|  | 85 | virtual void accept( Visitor & v ) override = 0; | 
|---|
| [7870799] | 86 | virtual void accept( Visitor & v ) const override = 0; | 
|---|
| [fa16264] | 87 | virtual Expression * acceptMutator( Mutator & m ) override = 0; | 
|---|
| [50377a4] | 88 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 89 | }; | 
|---|
|  | 90 |  | 
|---|
| [9706554] | 91 | /// ApplicationExpr represents the application of a function to a set of parameters.  This is the result of running an | 
|---|
|  | 92 | /// UntypedExpr through the expression analyzer. | 
|---|
| [0dd3a2f] | 93 | class ApplicationExpr : public Expression { | 
|---|
|  | 94 | public: | 
|---|
| [65cdc1e] | 95 | Expression * function; | 
|---|
| [871cdb4] | 96 | std::list<Expression *> args; | 
|---|
| [65cdc1e] | 97 |  | 
|---|
| [a5f0529] | 98 | ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); | 
|---|
| [5ded739] | 99 | ApplicationExpr( const ApplicationExpr & other ); | 
|---|
| [0dd3a2f] | 100 | virtual ~ApplicationExpr(); | 
|---|
|  | 101 |  | 
|---|
| [14388c1] | 102 | bool get_lvalue() const final; | 
|---|
|  | 103 |  | 
|---|
| [5ded739] | 104 | Expression * get_function() const { return function; } | 
|---|
|  | 105 | void set_function( Expression * newValue ) { function = newValue; } | 
|---|
| [0dd3a2f] | 106 | std::list<Expression *>& get_args() { return args; } | 
|---|
|  | 107 |  | 
|---|
| [7870799] | 108 | virtual ApplicationExpr * clone() const override { return new ApplicationExpr( * this ); } | 
|---|
|  | 109 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 110 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 111 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 112 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 113 | }; | 
|---|
|  | 114 |  | 
|---|
| [9706554] | 115 | /// UntypedExpr represents the application of a function to a set of parameters, but where the particular overload for | 
|---|
|  | 116 | /// the function name has not yet been determined.  Most operators are converted into functional form automatically, to | 
|---|
|  | 117 | /// permit operator overloading. | 
|---|
| [0dd3a2f] | 118 | class UntypedExpr : public Expression { | 
|---|
|  | 119 | public: | 
|---|
| [65cdc1e] | 120 | Expression * function; | 
|---|
|  | 121 | std::list<Expression*> args; | 
|---|
|  | 122 |  | 
|---|
| [bf4b4cf] | 123 | UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); | 
|---|
| [5ded739] | 124 | UntypedExpr( const UntypedExpr & other ); | 
|---|
| [0dd3a2f] | 125 | virtual ~UntypedExpr(); | 
|---|
|  | 126 |  | 
|---|
| [14388c1] | 127 | bool get_lvalue() const final; | 
|---|
|  | 128 |  | 
|---|
| [5ded739] | 129 | Expression * get_function() const { return function; } | 
|---|
|  | 130 | void set_function( Expression * newValue ) { function = newValue; } | 
|---|
| [0dd3a2f] | 131 |  | 
|---|
|  | 132 | std::list<Expression*>::iterator begin_args() { return args.begin(); } | 
|---|
|  | 133 | std::list<Expression*>::iterator end_args() { return args.end(); } | 
|---|
|  | 134 | std::list<Expression*>& get_args() { return args; } | 
|---|
|  | 135 |  | 
|---|
| [b3b2077] | 136 | static UntypedExpr * createDeref( Expression * arg ); | 
|---|
|  | 137 | static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 ); | 
|---|
|  | 138 |  | 
|---|
| [7870799] | 139 | virtual UntypedExpr * clone() const override { return new UntypedExpr( * this ); } | 
|---|
|  | 140 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 141 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 142 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 143 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 144 | }; | 
|---|
|  | 145 |  | 
|---|
| [47534159] | 146 | /// NameExpr contains a name whose meaning is still not determined | 
|---|
| [0dd3a2f] | 147 | class NameExpr : public Expression { | 
|---|
|  | 148 | public: | 
|---|
| [65cdc1e] | 149 | std::string name; | 
|---|
|  | 150 |  | 
|---|
| [bf4b4cf] | 151 | NameExpr( std::string name ); | 
|---|
| [5ded739] | 152 | NameExpr( const NameExpr & other ); | 
|---|
| [0dd3a2f] | 153 | virtual ~NameExpr(); | 
|---|
|  | 154 |  | 
|---|
| [5ded739] | 155 | const std::string & get_name() const { return name; } | 
|---|
| [0dd3a2f] | 156 | void set_name( std::string newValue ) { name = newValue; } | 
|---|
|  | 157 |  | 
|---|
| [7870799] | 158 | virtual NameExpr * clone() const override { return new NameExpr( * this ); } | 
|---|
|  | 159 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 160 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 161 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 162 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 163 | }; | 
|---|
|  | 164 |  | 
|---|
| [bbf17d5] | 165 | // [Qualifier].name; Qualifier is the type_name from the parser | 
|---|
|  | 166 | class QualifiedNameExpr : public Expression { | 
|---|
|  | 167 | public: | 
|---|
| [b0d9ff7] | 168 | Declaration * type_decl; | 
|---|
|  | 169 | std::string name; | 
|---|
| [bbf17d5] | 170 |  | 
|---|
| [b0d9ff7] | 171 | QualifiedNameExpr( Declaration * decl, std::string name): Expression(), type_decl(decl), name(name) {} | 
|---|
| [5408b59] | 172 | QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name) {} | 
|---|
| [bbf17d5] | 173 |  | 
|---|
|  | 174 | virtual ~QualifiedNameExpr() { | 
|---|
| [b0d9ff7] | 175 | delete type_decl; | 
|---|
| [bbf17d5] | 176 | } | 
|---|
|  | 177 |  | 
|---|
|  | 178 | virtual QualifiedNameExpr * clone() const override { | 
|---|
|  | 179 | return new QualifiedNameExpr( * this ); | 
|---|
|  | 180 | } | 
|---|
| [b0d9ff7] | 181 | virtual void accept( Visitor & v ) override { v.visit(this); } | 
|---|
|  | 182 | virtual void accept( Visitor & v ) const override { v.visit(this); } | 
|---|
|  | 183 | virtual Expression * acceptMutator( Mutator & m ) override { | 
|---|
|  | 184 | return m.mutate( this ); | 
|---|
|  | 185 | } | 
|---|
|  | 186 |  | 
|---|
| [bbf17d5] | 187 | virtual void print( std::ostream & os, Indenter indent = {} ) const override { | 
|---|
| [b0d9ff7] | 188 | type_decl->print( os, indent ); | 
|---|
|  | 189 | os << name << std::endl; | 
|---|
| [bbf17d5] | 190 | } | 
|---|
|  | 191 | }; | 
|---|
|  | 192 |  | 
|---|
| [d5631b3] | 193 | /// VariableExpr represents an expression that simply refers to the value of a named variable. | 
|---|
|  | 194 | /// Does not take ownership of var. | 
|---|
|  | 195 | class VariableExpr : public Expression { | 
|---|
|  | 196 | public: | 
|---|
|  | 197 | DeclarationWithType * var; | 
|---|
|  | 198 |  | 
|---|
|  | 199 | VariableExpr(); | 
|---|
|  | 200 | VariableExpr( DeclarationWithType * var ); | 
|---|
|  | 201 | VariableExpr( const VariableExpr & other ); | 
|---|
|  | 202 | virtual ~VariableExpr(); | 
|---|
|  | 203 |  | 
|---|
|  | 204 | bool get_lvalue() const final; | 
|---|
|  | 205 |  | 
|---|
|  | 206 | DeclarationWithType * get_var() const { return var; } | 
|---|
|  | 207 | void set_var( DeclarationWithType * newValue ) { var = newValue; } | 
|---|
|  | 208 |  | 
|---|
|  | 209 | static VariableExpr * functionPointer( FunctionDecl * decl ); | 
|---|
|  | 210 |  | 
|---|
|  | 211 | virtual VariableExpr * clone() const override { return new VariableExpr( * this ); } | 
|---|
|  | 212 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 213 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 214 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 215 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
|  | 216 | }; | 
|---|
|  | 217 |  | 
|---|
| [51b73452] | 218 | // The following classes are used to represent expression types that cannot be converted into | 
|---|
|  | 219 | // function-call format. | 
|---|
|  | 220 |  | 
|---|
| [5ded739] | 221 | /// AddressExpr represents a address-of expression, e.g. & e | 
|---|
| [0dd3a2f] | 222 | class AddressExpr : public Expression { | 
|---|
|  | 223 | public: | 
|---|
| [65cdc1e] | 224 | Expression * arg; | 
|---|
|  | 225 |  | 
|---|
| [bf4b4cf] | 226 | AddressExpr( Expression * arg ); | 
|---|
| [5ded739] | 227 | AddressExpr( const AddressExpr & other ); | 
|---|
| [0dd3a2f] | 228 | virtual ~AddressExpr(); | 
|---|
|  | 229 |  | 
|---|
| [5ded739] | 230 | Expression * get_arg() const { return arg; } | 
|---|
|  | 231 | void set_arg(Expression * newValue ) { arg = newValue; } | 
|---|
| [0dd3a2f] | 232 |  | 
|---|
| [7870799] | 233 | virtual AddressExpr * clone() const override { return new AddressExpr( * this ); } | 
|---|
|  | 234 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 235 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 236 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 237 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 238 | }; | 
|---|
|  | 239 |  | 
|---|
| [5809461] | 240 | // GCC &&label | 
|---|
|  | 241 | // https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Labels-as-Values.html | 
|---|
| [0dd3a2f] | 242 | class LabelAddressExpr : public Expression { | 
|---|
|  | 243 | public: | 
|---|
| [5809461] | 244 | Label arg; | 
|---|
| [65cdc1e] | 245 |  | 
|---|
| [5809461] | 246 | LabelAddressExpr( const Label &arg ); | 
|---|
| [5ded739] | 247 | LabelAddressExpr( const LabelAddressExpr & other ); | 
|---|
| [0dd3a2f] | 248 | virtual ~LabelAddressExpr(); | 
|---|
|  | 249 |  | 
|---|
| [7870799] | 250 | virtual LabelAddressExpr * clone() const override { return new LabelAddressExpr( * this ); } | 
|---|
|  | 251 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 252 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 253 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 254 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 255 | }; | 
|---|
|  | 256 |  | 
|---|
| [47534159] | 257 | /// CastExpr represents a type cast expression, e.g. (int)e | 
|---|
| [0dd3a2f] | 258 | class CastExpr : public Expression { | 
|---|
|  | 259 | public: | 
|---|
| [65cdc1e] | 260 | Expression * arg; | 
|---|
| [b81fd95] | 261 |  | 
|---|
|  | 262 | // Inidicates cast is introduced by the CFA type system. | 
|---|
|  | 263 | // true for casts that the resolver introduces to force a return type | 
|---|
|  | 264 | // false for casts from user code | 
|---|
|  | 265 | // false for casts from desugaring advanced CFA features into simpler CFA | 
|---|
|  | 266 | // example | 
|---|
|  | 267 | //   int * p;     // declaration | 
|---|
|  | 268 | //   (float *) p; // use, with subject cast | 
|---|
|  | 269 | // subject cast isGenerated means we are considering an interpretation with a type mismatch | 
|---|
|  | 270 | // subject cast not isGenerated means someone in charge wants it that way | 
|---|
|  | 271 | bool isGenerated = true; | 
|---|
| [65cdc1e] | 272 |  | 
|---|
| [46da46b] | 273 | enum CastKind { | 
|---|
|  | 274 | Default, // C | 
|---|
|  | 275 | Coerce, // reinterpret cast | 
|---|
|  | 276 | Return  // overload selection | 
|---|
|  | 277 | }; | 
|---|
|  | 278 |  | 
|---|
|  | 279 | CastKind kind = Default; | 
|---|
|  | 280 |  | 
|---|
|  | 281 | CastExpr( Expression * arg, bool isGenerated = true, CastKind kind = Default ); | 
|---|
|  | 282 | CastExpr( Expression * arg, Type * toType, bool isGenerated = true, CastKind kind = Default ); | 
|---|
| [9a705dc8] | 283 | CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor | 
|---|
| [5ded739] | 284 | CastExpr( const CastExpr & other ); | 
|---|
| [0dd3a2f] | 285 | virtual ~CastExpr(); | 
|---|
|  | 286 |  | 
|---|
| [14388c1] | 287 | bool get_lvalue() const final; | 
|---|
|  | 288 |  | 
|---|
| [5ded739] | 289 | Expression * get_arg() const { return arg; } | 
|---|
| [a5f0529] | 290 | void set_arg( Expression * newValue ) { arg = newValue; } | 
|---|
| [0dd3a2f] | 291 |  | 
|---|
| [7870799] | 292 | virtual CastExpr * clone() const override { return new CastExpr( * this ); } | 
|---|
|  | 293 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 294 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 295 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 296 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 297 | }; | 
|---|
|  | 298 |  | 
|---|
| [9a705dc8] | 299 | /// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t | 
|---|
|  | 300 | class KeywordCastExpr : public Expression { | 
|---|
|  | 301 | public: | 
|---|
|  | 302 | Expression * arg; | 
|---|
| [3b0c8cb] | 303 | struct Concrete { | 
|---|
|  | 304 | std::string field; | 
|---|
|  | 305 | std::string getter; | 
|---|
|  | 306 | }; | 
|---|
| [312029a] | 307 | AggregateDecl::Aggregate target; | 
|---|
| [3b0c8cb] | 308 | Concrete concrete_target; | 
|---|
| [9a705dc8] | 309 |  | 
|---|
| [312029a] | 310 | KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ); | 
|---|
| [4ef08f7] | 311 | KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target, const Concrete & concrete_target ); | 
|---|
| [9a705dc8] | 312 | KeywordCastExpr( const KeywordCastExpr & other ); | 
|---|
|  | 313 | virtual ~KeywordCastExpr(); | 
|---|
|  | 314 |  | 
|---|
| [312029a] | 315 | const char * targetString() const; | 
|---|
| [9a705dc8] | 316 |  | 
|---|
| [7870799] | 317 | virtual KeywordCastExpr * clone() const override { return new KeywordCastExpr( * this ); } | 
|---|
|  | 318 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 319 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 320 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 321 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [9a705dc8] | 322 | }; | 
|---|
|  | 323 |  | 
|---|
| [a5f0529] | 324 | /// VirtualCastExpr repersents a virtual dynamic cast, e.g. (virtual exception)e | 
|---|
|  | 325 | class VirtualCastExpr : public Expression { | 
|---|
|  | 326 | public: | 
|---|
| [5ded739] | 327 | Expression * arg; | 
|---|
| [65cdc1e] | 328 |  | 
|---|
| [a5f0529] | 329 | VirtualCastExpr( Expression * arg, Type * toType ); | 
|---|
|  | 330 | VirtualCastExpr( const VirtualCastExpr & other ); | 
|---|
|  | 331 | virtual ~VirtualCastExpr(); | 
|---|
|  | 332 |  | 
|---|
|  | 333 | Expression * get_arg() const { return arg; } | 
|---|
|  | 334 | void set_arg( Expression * newValue ) { arg = newValue; } | 
|---|
|  | 335 |  | 
|---|
| [7870799] | 336 | virtual VirtualCastExpr * clone() const override { return new VirtualCastExpr( * this ); } | 
|---|
|  | 337 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 338 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 339 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 340 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 341 | }; | 
|---|
|  | 342 |  | 
|---|
| [47534159] | 343 | /// UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer | 
|---|
| [0dd3a2f] | 344 | class UntypedMemberExpr : public Expression { | 
|---|
|  | 345 | public: | 
|---|
| [65cdc1e] | 346 | Expression * member; | 
|---|
|  | 347 | Expression * aggregate; | 
|---|
|  | 348 |  | 
|---|
| [bf4b4cf] | 349 | UntypedMemberExpr( Expression * member, Expression * aggregate ); | 
|---|
| [5ded739] | 350 | UntypedMemberExpr( const UntypedMemberExpr & other ); | 
|---|
| [0dd3a2f] | 351 | virtual ~UntypedMemberExpr(); | 
|---|
|  | 352 |  | 
|---|
| [849720f] | 353 | bool get_lvalue() const final; | 
|---|
|  | 354 |  | 
|---|
| [3b58d91] | 355 | Expression * get_member() const { return member; } | 
|---|
|  | 356 | void set_member( Expression * newValue ) { member = newValue; } | 
|---|
| [5ded739] | 357 | Expression * get_aggregate() const { return aggregate; } | 
|---|
|  | 358 | void set_aggregate( Expression * newValue ) { aggregate = newValue; } | 
|---|
| [0dd3a2f] | 359 |  | 
|---|
| [7870799] | 360 | virtual UntypedMemberExpr * clone() const override { return new UntypedMemberExpr( * this ); } | 
|---|
|  | 361 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 362 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 363 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 364 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 365 | }; | 
|---|
|  | 366 |  | 
|---|
| [4551a6e] | 367 | /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer. | 
|---|
|  | 368 | /// Does not take ownership of member. | 
|---|
| [0dd3a2f] | 369 | class MemberExpr : public Expression { | 
|---|
|  | 370 | public: | 
|---|
| [65cdc1e] | 371 | DeclarationWithType * member; | 
|---|
|  | 372 | Expression * aggregate; | 
|---|
|  | 373 |  | 
|---|
| [bf4b4cf] | 374 | MemberExpr( DeclarationWithType * member, Expression * aggregate ); | 
|---|
| [5ded739] | 375 | MemberExpr( const MemberExpr & other ); | 
|---|
| [0dd3a2f] | 376 | virtual ~MemberExpr(); | 
|---|
|  | 377 |  | 
|---|
| [14388c1] | 378 | bool get_lvalue() const final; | 
|---|
|  | 379 |  | 
|---|
| [5ded739] | 380 | DeclarationWithType * get_member() const { return member; } | 
|---|
|  | 381 | void set_member( DeclarationWithType * newValue ) { member = newValue; } | 
|---|
|  | 382 | Expression * get_aggregate() const { return aggregate; } | 
|---|
|  | 383 | void set_aggregate( Expression * newValue ) { aggregate = newValue; } | 
|---|
| [0dd3a2f] | 384 |  | 
|---|
| [7870799] | 385 | virtual MemberExpr * clone() const override { return new MemberExpr( * this ); } | 
|---|
|  | 386 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 387 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 388 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 389 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 390 | }; | 
|---|
|  | 391 |  | 
|---|
| [3be261a] | 392 | /// ConstantExpr represents an expression that simply refers to the value of a constant | 
|---|
| [0dd3a2f] | 393 | class ConstantExpr : public Expression { | 
|---|
|  | 394 | public: | 
|---|
| [65cdc1e] | 395 | Constant constant; | 
|---|
|  | 396 |  | 
|---|
| [bf4b4cf] | 397 | ConstantExpr( Constant constant ); | 
|---|
| [5ded739] | 398 | ConstantExpr( const ConstantExpr & other ); | 
|---|
| [0dd3a2f] | 399 | virtual ~ConstantExpr(); | 
|---|
|  | 400 |  | 
|---|
| [5ded739] | 401 | Constant * get_constant() { return & constant; } | 
|---|
| [ddb80bd] | 402 | const Constant * get_constant() const { return & constant; } | 
|---|
| [5ded739] | 403 | void set_constant( const Constant & newValue ) { constant = newValue; } | 
|---|
| [0dd3a2f] | 404 |  | 
|---|
| [ddb80bd] | 405 | long long int intValue() const; | 
|---|
|  | 406 |  | 
|---|
| [7870799] | 407 | virtual ConstantExpr * clone() const override { return new ConstantExpr( * this ); } | 
|---|
|  | 408 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 409 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 410 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 411 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 412 | }; | 
|---|
|  | 413 |  | 
|---|
| [47534159] | 414 | /// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4) | 
|---|
| [0dd3a2f] | 415 | class SizeofExpr : public Expression { | 
|---|
|  | 416 | public: | 
|---|
| [65cdc1e] | 417 | Expression * expr; | 
|---|
|  | 418 | Type * type; | 
|---|
|  | 419 | bool isType; | 
|---|
|  | 420 |  | 
|---|
| [bf4b4cf] | 421 | SizeofExpr( Expression * expr ); | 
|---|
| [5ded739] | 422 | SizeofExpr( const SizeofExpr & other ); | 
|---|
| [bf4b4cf] | 423 | SizeofExpr( Type * type ); | 
|---|
| [0dd3a2f] | 424 | virtual ~SizeofExpr(); | 
|---|
|  | 425 |  | 
|---|
| [5ded739] | 426 | Expression * get_expr() const { return expr; } | 
|---|
|  | 427 | void set_expr( Expression * newValue ) { expr = newValue; } | 
|---|
|  | 428 | Type * get_type() const { return type; } | 
|---|
|  | 429 | void set_type( Type * newValue ) { type = newValue; } | 
|---|
| [0dd3a2f] | 430 | bool get_isType() const { return isType; } | 
|---|
|  | 431 | void set_isType( bool newValue ) { isType = newValue; } | 
|---|
|  | 432 |  | 
|---|
| [7870799] | 433 | virtual SizeofExpr * clone() const override { return new SizeofExpr( * this ); } | 
|---|
|  | 434 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 435 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 436 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 437 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 438 | }; | 
|---|
|  | 439 |  | 
|---|
| [47534159] | 440 | /// AlignofExpr represents an alignof expression | 
|---|
|  | 441 | class AlignofExpr : public Expression { | 
|---|
|  | 442 | public: | 
|---|
| [65cdc1e] | 443 | Expression * expr; | 
|---|
|  | 444 | Type * type; | 
|---|
|  | 445 | bool isType; | 
|---|
|  | 446 |  | 
|---|
| [bf4b4cf] | 447 | AlignofExpr( Expression * expr ); | 
|---|
| [5ded739] | 448 | AlignofExpr( const AlignofExpr & other ); | 
|---|
| [bf4b4cf] | 449 | AlignofExpr( Type * type ); | 
|---|
| [47534159] | 450 | virtual ~AlignofExpr(); | 
|---|
|  | 451 |  | 
|---|
| [5ded739] | 452 | Expression * get_expr() const { return expr; } | 
|---|
|  | 453 | void set_expr( Expression * newValue ) { expr = newValue; } | 
|---|
|  | 454 | Type * get_type() const { return type; } | 
|---|
|  | 455 | void set_type( Type * newValue ) { type = newValue; } | 
|---|
| [47534159] | 456 | bool get_isType() const { return isType; } | 
|---|
|  | 457 | void set_isType( bool newValue ) { isType = newValue; } | 
|---|
|  | 458 |  | 
|---|
| [7870799] | 459 | virtual AlignofExpr * clone() const override { return new AlignofExpr( * this ); } | 
|---|
|  | 460 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 461 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 462 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 463 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [47534159] | 464 | }; | 
|---|
|  | 465 |  | 
|---|
| [2a4b088] | 466 | /// UntypedOffsetofExpr represents an offsetof expression before resolution | 
|---|
|  | 467 | class UntypedOffsetofExpr : public Expression { | 
|---|
|  | 468 | public: | 
|---|
| [65cdc1e] | 469 | Type * type; | 
|---|
|  | 470 | std::string member; | 
|---|
|  | 471 |  | 
|---|
| [bf4b4cf] | 472 | UntypedOffsetofExpr( Type * type, const std::string & member ); | 
|---|
| [5ded739] | 473 | UntypedOffsetofExpr( const UntypedOffsetofExpr & other ); | 
|---|
| [2a4b088] | 474 | virtual ~UntypedOffsetofExpr(); | 
|---|
|  | 475 |  | 
|---|
|  | 476 | std::string get_member() const { return member; } | 
|---|
| [5ded739] | 477 | void set_member( const std::string & newValue ) { member = newValue; } | 
|---|
|  | 478 | Type * get_type() const { return type; } | 
|---|
|  | 479 | void set_type( Type * newValue ) { type = newValue; } | 
|---|
|  | 480 |  | 
|---|
| [7870799] | 481 | virtual UntypedOffsetofExpr * clone() const override { return new UntypedOffsetofExpr( * this ); } | 
|---|
|  | 482 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 483 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 484 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 485 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [2a4b088] | 486 | }; | 
|---|
|  | 487 |  | 
|---|
| [25a054f] | 488 | /// OffsetofExpr represents an offsetof expression | 
|---|
|  | 489 | class OffsetofExpr : public Expression { | 
|---|
|  | 490 | public: | 
|---|
| [65cdc1e] | 491 | Type * type; | 
|---|
|  | 492 | DeclarationWithType * member; | 
|---|
|  | 493 |  | 
|---|
| [bf4b4cf] | 494 | OffsetofExpr( Type * type, DeclarationWithType * member ); | 
|---|
| [5ded739] | 495 | OffsetofExpr( const OffsetofExpr & other ); | 
|---|
| [25a054f] | 496 | virtual ~OffsetofExpr(); | 
|---|
|  | 497 |  | 
|---|
| [5ded739] | 498 | Type * get_type() const { return type; } | 
|---|
|  | 499 | void set_type( Type * newValue ) { type = newValue; } | 
|---|
|  | 500 | DeclarationWithType * get_member() const { return member; } | 
|---|
|  | 501 | void set_member( DeclarationWithType * newValue ) { member = newValue; } | 
|---|
|  | 502 |  | 
|---|
| [7870799] | 503 | virtual OffsetofExpr * clone() const override { return new OffsetofExpr( * this ); } | 
|---|
|  | 504 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 505 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 506 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 507 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [25a054f] | 508 | }; | 
|---|
|  | 509 |  | 
|---|
| [afc1045] | 510 | /// Expression representing a pack of field-offsets for a generic type | 
|---|
|  | 511 | class OffsetPackExpr : public Expression { | 
|---|
|  | 512 | public: | 
|---|
| [65cdc1e] | 513 | StructInstType * type; | 
|---|
|  | 514 |  | 
|---|
| [bf4b4cf] | 515 | OffsetPackExpr( StructInstType * type ); | 
|---|
| [5ded739] | 516 | OffsetPackExpr( const OffsetPackExpr & other ); | 
|---|
| [afc1045] | 517 | virtual ~OffsetPackExpr(); | 
|---|
|  | 518 |  | 
|---|
| [5ded739] | 519 | StructInstType * get_type() const { return type; } | 
|---|
|  | 520 | void set_type( StructInstType * newValue ) { type = newValue; } | 
|---|
| [afc1045] | 521 |  | 
|---|
| [7870799] | 522 | virtual OffsetPackExpr * clone() const override { return new OffsetPackExpr( * this ); } | 
|---|
|  | 523 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 524 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 525 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 526 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [afc1045] | 527 | }; | 
|---|
|  | 528 |  | 
|---|
| [47534159] | 529 | /// LogicalExpr represents a short-circuit boolean expression (&& or ||) | 
|---|
| [0dd3a2f] | 530 | class LogicalExpr : public Expression { | 
|---|
|  | 531 | public: | 
|---|
| [65cdc1e] | 532 | Expression * arg1; | 
|---|
|  | 533 | Expression * arg2; | 
|---|
|  | 534 |  | 
|---|
| [bf4b4cf] | 535 | LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true ); | 
|---|
| [5ded739] | 536 | LogicalExpr( const LogicalExpr & other ); | 
|---|
| [0dd3a2f] | 537 | virtual ~LogicalExpr(); | 
|---|
|  | 538 |  | 
|---|
|  | 539 | bool get_isAnd() const { return isAnd; } | 
|---|
| [5ded739] | 540 | Expression * get_arg1() { return arg1; } | 
|---|
|  | 541 | void set_arg1( Expression * newValue ) { arg1 = newValue; } | 
|---|
|  | 542 | Expression * get_arg2() const { return arg2; } | 
|---|
|  | 543 | void set_arg2( Expression * newValue ) { arg2 = newValue; } | 
|---|
|  | 544 |  | 
|---|
| [7870799] | 545 | virtual LogicalExpr * clone() const override { return new LogicalExpr( * this ); } | 
|---|
|  | 546 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 547 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 548 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 549 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [65cdc1e] | 550 |  | 
|---|
| [0dd3a2f] | 551 | private: | 
|---|
|  | 552 | bool isAnd; | 
|---|
| [51b73452] | 553 | }; | 
|---|
|  | 554 |  | 
|---|
| [47534159] | 555 | /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) | 
|---|
| [0dd3a2f] | 556 | class ConditionalExpr : public Expression { | 
|---|
|  | 557 | public: | 
|---|
| [65cdc1e] | 558 | Expression * arg1; | 
|---|
|  | 559 | Expression * arg2; | 
|---|
|  | 560 | Expression * arg3; | 
|---|
|  | 561 |  | 
|---|
| [bf4b4cf] | 562 | ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ); | 
|---|
| [5ded739] | 563 | ConditionalExpr( const ConditionalExpr & other ); | 
|---|
| [0dd3a2f] | 564 | virtual ~ConditionalExpr(); | 
|---|
|  | 565 |  | 
|---|
| [14388c1] | 566 | bool get_lvalue() const final; | 
|---|
|  | 567 |  | 
|---|
| [5ded739] | 568 | Expression * get_arg1() const { return arg1; } | 
|---|
|  | 569 | void set_arg1( Expression * newValue ) { arg1 = newValue; } | 
|---|
|  | 570 | Expression * get_arg2() const { return arg2; } | 
|---|
|  | 571 | void set_arg2( Expression * newValue ) { arg2 = newValue; } | 
|---|
|  | 572 | Expression * get_arg3() const { return arg3; } | 
|---|
|  | 573 | void set_arg3( Expression * newValue ) { arg3 = newValue; } | 
|---|
|  | 574 |  | 
|---|
| [7870799] | 575 | virtual ConditionalExpr * clone() const override { return new ConditionalExpr( * this ); } | 
|---|
|  | 576 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 577 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 578 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 579 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 580 | }; | 
|---|
|  | 581 |  | 
|---|
| [47534159] | 582 | /// CommaExpr represents the sequence operator ( a, b ) | 
|---|
| [0dd3a2f] | 583 | class CommaExpr : public Expression { | 
|---|
|  | 584 | public: | 
|---|
| [65cdc1e] | 585 | Expression * arg1; | 
|---|
|  | 586 | Expression * arg2; | 
|---|
|  | 587 |  | 
|---|
| [bf4b4cf] | 588 | CommaExpr( Expression * arg1, Expression * arg2 ); | 
|---|
| [5ded739] | 589 | CommaExpr( const CommaExpr & other ); | 
|---|
| [0dd3a2f] | 590 | virtual ~CommaExpr(); | 
|---|
|  | 591 |  | 
|---|
| [14388c1] | 592 | bool get_lvalue() const final; | 
|---|
|  | 593 |  | 
|---|
| [5ded739] | 594 | Expression * get_arg1() const { return arg1; } | 
|---|
|  | 595 | void set_arg1( Expression * newValue ) { arg1 = newValue; } | 
|---|
|  | 596 | Expression * get_arg2() const { return arg2; } | 
|---|
|  | 597 | void set_arg2( Expression * newValue ) { arg2 = newValue; } | 
|---|
| [0dd3a2f] | 598 |  | 
|---|
| [7870799] | 599 | virtual CommaExpr * clone() const override { return new CommaExpr( * this ); } | 
|---|
|  | 600 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 601 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 602 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 603 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 604 | }; | 
|---|
|  | 605 |  | 
|---|
| [47534159] | 606 | /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) | 
|---|
| [0dd3a2f] | 607 | class TypeExpr : public Expression { | 
|---|
|  | 608 | public: | 
|---|
| [65cdc1e] | 609 | Type * type; | 
|---|
|  | 610 |  | 
|---|
| [5ded739] | 611 | TypeExpr( Type * type ); | 
|---|
|  | 612 | TypeExpr( const TypeExpr & other ); | 
|---|
| [0dd3a2f] | 613 | virtual ~TypeExpr(); | 
|---|
|  | 614 |  | 
|---|
| [5ded739] | 615 | Type * get_type() const { return type; } | 
|---|
|  | 616 | void set_type( Type * newValue ) { type = newValue; } | 
|---|
| [0dd3a2f] | 617 |  | 
|---|
| [7870799] | 618 | virtual TypeExpr * clone() const override { return new TypeExpr( * this ); } | 
|---|
|  | 619 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 620 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 621 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
| [6e50a6b] | 622 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
|  | 623 | }; | 
|---|
|  | 624 |  | 
|---|
|  | 625 | /// DimensionExpr represents a type-system provided value used in an expression ( forrall([N]) ... N + 1 ) | 
|---|
|  | 626 | class DimensionExpr : public Expression { | 
|---|
|  | 627 | public: | 
|---|
|  | 628 | std::string name; | 
|---|
|  | 629 |  | 
|---|
|  | 630 | DimensionExpr( std::string name ); | 
|---|
|  | 631 | DimensionExpr( const DimensionExpr & other ); | 
|---|
|  | 632 | virtual ~DimensionExpr(); | 
|---|
|  | 633 |  | 
|---|
|  | 634 | const std::string & get_name() const { return name; } | 
|---|
|  | 635 | void set_name( std::string newValue ) { name = newValue; } | 
|---|
|  | 636 |  | 
|---|
|  | 637 | virtual DimensionExpr * clone() const override { return new DimensionExpr( * this ); } | 
|---|
|  | 638 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 639 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 640 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
| [7870799] | 641 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 642 | }; | 
|---|
|  | 643 |  | 
|---|
| [47534159] | 644 | /// AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result) | 
|---|
| [7f5566b] | 645 | class AsmExpr : public Expression { | 
|---|
|  | 646 | public: | 
|---|
| [665f432] | 647 | std::string inout; | 
|---|
| [e612146c] | 648 | Expression * constraint; | 
|---|
| [65cdc1e] | 649 | Expression * operand; | 
|---|
|  | 650 |  | 
|---|
| [665f432] | 651 | AsmExpr( const std::string * _inout, Expression * constraint, Expression * operand ) : inout( _inout ? *_inout : "" ), constraint( constraint ), operand( operand ) { delete _inout; } | 
|---|
| [3be261a] | 652 | AsmExpr( const AsmExpr & other ); | 
|---|
| [665f432] | 653 | virtual ~AsmExpr() { delete constraint; delete operand; }; | 
|---|
| [7f5566b] | 654 |  | 
|---|
| [7870799] | 655 | virtual AsmExpr * clone() const override { return new AsmExpr( * this ); } | 
|---|
|  | 656 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 657 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 658 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 659 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [65cdc1e] | 660 |  | 
|---|
| [7f5566b] | 661 | // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints | 
|---|
|  | 662 | }; | 
|---|
|  | 663 |  | 
|---|
| [db4ecc5] | 664 | /// ImplicitCopyCtorExpr represents the application of a function to a set of parameters, | 
|---|
|  | 665 | /// along with a set of copy constructor calls, one for each argument. | 
|---|
|  | 666 | class ImplicitCopyCtorExpr : public Expression { | 
|---|
|  | 667 | public: | 
|---|
| [2f86ddf] | 668 | ApplicationExpr * callExpr = nullptr; | 
|---|
| [65cdc1e] | 669 |  | 
|---|
| [db4ecc5] | 670 | ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); | 
|---|
|  | 671 | ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); | 
|---|
|  | 672 | virtual ~ImplicitCopyCtorExpr(); | 
|---|
|  | 673 |  | 
|---|
| [7870799] | 674 | virtual ImplicitCopyCtorExpr * clone() const override { return new ImplicitCopyCtorExpr( * this ); } | 
|---|
|  | 675 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 676 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 677 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 678 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [db4ecc5] | 679 | }; | 
|---|
|  | 680 |  | 
|---|
| [b6fe7e6] | 681 | /// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 }; | 
|---|
|  | 682 | class ConstructorExpr : public Expression { | 
|---|
|  | 683 | public: | 
|---|
| [65cdc1e] | 684 | Expression * callExpr; | 
|---|
|  | 685 |  | 
|---|
| [b6fe7e6] | 686 | ConstructorExpr( Expression * callExpr ); | 
|---|
|  | 687 | ConstructorExpr( const ConstructorExpr & other ); | 
|---|
|  | 688 | ~ConstructorExpr(); | 
|---|
| [0dd3a2f] | 689 |  | 
|---|
| [14388c1] | 690 | bool get_lvalue() const final; | 
|---|
|  | 691 |  | 
|---|
| [5ded739] | 692 | Expression * get_callExpr() const { return callExpr; } | 
|---|
|  | 693 | void set_callExpr( Expression * newValue ) { callExpr = newValue; } | 
|---|
| [0dd3a2f] | 694 |  | 
|---|
| [7870799] | 695 | virtual ConstructorExpr * clone() const override { return new ConstructorExpr( * this ); } | 
|---|
|  | 696 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 697 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 698 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 699 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 700 | }; | 
|---|
|  | 701 |  | 
|---|
| [630a82a] | 702 | /// CompoundLiteralExpr represents a C99 'compound literal' | 
|---|
|  | 703 | class CompoundLiteralExpr : public Expression { | 
|---|
|  | 704 | public: | 
|---|
| [65cdc1e] | 705 | Initializer * initializer; | 
|---|
|  | 706 |  | 
|---|
| [630a82a] | 707 | CompoundLiteralExpr( Type * type, Initializer * initializer ); | 
|---|
| [5ded739] | 708 | CompoundLiteralExpr( const CompoundLiteralExpr & other ); | 
|---|
| [3b58d91] | 709 | virtual ~CompoundLiteralExpr(); | 
|---|
| [630a82a] | 710 |  | 
|---|
| [14388c1] | 711 | bool get_lvalue() const final; | 
|---|
|  | 712 |  | 
|---|
| [630a82a] | 713 | Initializer * get_initializer() const { return initializer; } | 
|---|
|  | 714 | void set_initializer( Initializer * i ) { initializer = i; } | 
|---|
|  | 715 |  | 
|---|
| [7870799] | 716 | virtual CompoundLiteralExpr * clone() const override { return new CompoundLiteralExpr( * this ); } | 
|---|
|  | 717 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 718 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 719 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 720 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [630a82a] | 721 | }; | 
|---|
|  | 722 |  | 
|---|
| [b6fe7e6] | 723 | /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' | 
|---|
| [8688ce1] | 724 | class RangeExpr : public Expression { | 
|---|
|  | 725 | public: | 
|---|
| [65cdc1e] | 726 | Expression * low, * high; | 
|---|
|  | 727 |  | 
|---|
| [5ded739] | 728 | RangeExpr( Expression * low, Expression * high ); | 
|---|
|  | 729 | RangeExpr( const RangeExpr & other ); | 
|---|
| [8688ce1] | 730 |  | 
|---|
| [d9e2280] | 731 | Expression * get_low() const { return low; } | 
|---|
|  | 732 | Expression * get_high() const { return high; } | 
|---|
| [5ded739] | 733 | RangeExpr * set_low( Expression * low ) { RangeExpr::low = low; return this; } | 
|---|
|  | 734 | RangeExpr * set_high( Expression * high ) { RangeExpr::high = high; return this; } | 
|---|
| [8688ce1] | 735 |  | 
|---|
| [7870799] | 736 | virtual RangeExpr * clone() const override { return new RangeExpr( * this ); } | 
|---|
|  | 737 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 738 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 739 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 740 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [8688ce1] | 741 | }; | 
|---|
|  | 742 |  | 
|---|
| [907eccb] | 743 | /// UntypedTupleExpr represents a tuple expression ( [a, b, c] ) before resolution | 
|---|
|  | 744 | class UntypedTupleExpr : public Expression { | 
|---|
|  | 745 | public: | 
|---|
| [65cdc1e] | 746 | std::list<Expression*> exprs; | 
|---|
|  | 747 |  | 
|---|
| [bf4b4cf] | 748 | UntypedTupleExpr( const std::list< Expression * > & exprs ); | 
|---|
| [5ded739] | 749 | UntypedTupleExpr( const UntypedTupleExpr & other ); | 
|---|
| [907eccb] | 750 | virtual ~UntypedTupleExpr(); | 
|---|
|  | 751 |  | 
|---|
|  | 752 | std::list<Expression*>& get_exprs() { return exprs; } | 
|---|
|  | 753 |  | 
|---|
| [7870799] | 754 | virtual UntypedTupleExpr * clone() const override { return new UntypedTupleExpr( * this ); } | 
|---|
|  | 755 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 756 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 757 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 758 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [907eccb] | 759 | }; | 
|---|
|  | 760 |  | 
|---|
| [6eb8948] | 761 | /// TupleExpr represents a tuple expression ( [a, b, c] ) | 
|---|
|  | 762 | class TupleExpr : public Expression { | 
|---|
|  | 763 | public: | 
|---|
| [65cdc1e] | 764 | std::list<Expression*> exprs; | 
|---|
|  | 765 |  | 
|---|
| [bf4b4cf] | 766 | TupleExpr( const std::list< Expression * > & exprs ); | 
|---|
| [5ded739] | 767 | TupleExpr( const TupleExpr & other ); | 
|---|
| [6eb8948] | 768 | virtual ~TupleExpr(); | 
|---|
|  | 769 |  | 
|---|
| [3c7f01b] | 770 | bool get_lvalue() const final; | 
|---|
|  | 771 |  | 
|---|
| [6eb8948] | 772 | std::list<Expression*>& get_exprs() { return exprs; } | 
|---|
|  | 773 |  | 
|---|
| [7870799] | 774 | virtual TupleExpr * clone() const override { return new TupleExpr( * this ); } | 
|---|
|  | 775 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 776 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 777 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 778 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [6eb8948] | 779 | }; | 
|---|
|  | 780 |  | 
|---|
| [3b58d91] | 781 | /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer | 
|---|
|  | 782 | class TupleIndexExpr : public Expression { | 
|---|
|  | 783 | public: | 
|---|
| [65cdc1e] | 784 | Expression * tuple; | 
|---|
|  | 785 | unsigned int index; | 
|---|
|  | 786 |  | 
|---|
| [3b58d91] | 787 | TupleIndexExpr( Expression * tuple, unsigned int index ); | 
|---|
| [5ded739] | 788 | TupleIndexExpr( const TupleIndexExpr & other ); | 
|---|
| [3b58d91] | 789 | virtual ~TupleIndexExpr(); | 
|---|
|  | 790 |  | 
|---|
| [14388c1] | 791 | bool get_lvalue() const final; | 
|---|
|  | 792 |  | 
|---|
| [3b58d91] | 793 | Expression * get_tuple() const { return tuple; } | 
|---|
|  | 794 | int get_index() const { return index; } | 
|---|
| [5ded739] | 795 | TupleIndexExpr * set_tuple( Expression * newValue ) { tuple = newValue; return this; } | 
|---|
| [3b58d91] | 796 | TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; } | 
|---|
|  | 797 |  | 
|---|
| [7870799] | 798 | virtual TupleIndexExpr * clone() const override { return new TupleIndexExpr( * this ); } | 
|---|
|  | 799 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 800 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 801 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 802 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [3b58d91] | 803 | }; | 
|---|
|  | 804 |  | 
|---|
| [65660bd] | 805 | /// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression | 
|---|
| [6eb8948] | 806 | class TupleAssignExpr : public Expression { | 
|---|
| [3b58d91] | 807 | public: | 
|---|
| [65cdc1e] | 808 | StmtExpr * stmtExpr = nullptr; | 
|---|
|  | 809 |  | 
|---|
| [bf4b4cf] | 810 | TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls ); | 
|---|
| [5ded739] | 811 | TupleAssignExpr( const TupleAssignExpr & other ); | 
|---|
| [6eb8948] | 812 | virtual ~TupleAssignExpr(); | 
|---|
| [3b58d91] | 813 |  | 
|---|
| [d5556a3] | 814 | TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; } | 
|---|
|  | 815 | StmtExpr * get_stmtExpr() const { return stmtExpr; } | 
|---|
| [3b58d91] | 816 |  | 
|---|
| [7870799] | 817 | virtual TupleAssignExpr * clone() const override { return new TupleAssignExpr( * this ); } | 
|---|
|  | 818 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 819 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 820 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 821 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [20de6fb] | 822 |  | 
|---|
|  | 823 | friend class ConverterNewToOld; | 
|---|
|  | 824 | private: | 
|---|
|  | 825 | TupleAssignExpr( StmtExpr * stmts ); | 
|---|
| [3b58d91] | 826 | }; | 
|---|
|  | 827 |  | 
|---|
| [6eb8948] | 828 | /// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; }) | 
|---|
|  | 829 | class StmtExpr : public Expression { | 
|---|
|  | 830 | public: | 
|---|
| [65cdc1e] | 831 | CompoundStmt * statements; | 
|---|
|  | 832 | std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression | 
|---|
|  | 833 | std::list< Expression * > dtors; // destructor(s) for return variable(s) | 
|---|
|  | 834 |  | 
|---|
| [0e315a5] | 835 | // readonly | 
|---|
|  | 836 | ExprStmt * resultExpr = nullptr; | 
|---|
|  | 837 |  | 
|---|
| [5ded739] | 838 | StmtExpr( CompoundStmt * statements ); | 
|---|
| [6eb8948] | 839 | StmtExpr( const StmtExpr & other ); | 
|---|
|  | 840 | virtual ~StmtExpr(); | 
|---|
| [3b58d91] | 841 |  | 
|---|
| [5d00425] | 842 | bool get_lvalue() const final; | 
|---|
|  | 843 |  | 
|---|
| [6eb8948] | 844 | CompoundStmt * get_statements() const { return statements; } | 
|---|
|  | 845 | StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } | 
|---|
| [3b58d91] | 846 |  | 
|---|
| [5e2c348] | 847 | // call to set the result type of this StmtExpr based on its body | 
|---|
|  | 848 | void computeResult(); | 
|---|
|  | 849 |  | 
|---|
| [d5556a3] | 850 | std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } | 
|---|
|  | 851 | std::list< Expression * > & get_dtors() { return dtors; } | 
|---|
|  | 852 |  | 
|---|
| [7870799] | 853 | virtual StmtExpr * clone() const override { return new StmtExpr( * this ); } | 
|---|
|  | 854 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 855 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 856 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 857 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [3b58d91] | 858 | }; | 
|---|
|  | 859 |  | 
|---|
| [3c13c03] | 860 | class UniqueExpr : public Expression { | 
|---|
|  | 861 | public: | 
|---|
| [65cdc1e] | 862 | Expression * expr; | 
|---|
|  | 863 | ObjectDecl * object; | 
|---|
|  | 864 | VariableExpr * var; | 
|---|
|  | 865 |  | 
|---|
| [bf32bb8] | 866 | UniqueExpr( Expression * expr, long long idVal = -1 ); | 
|---|
| [3c13c03] | 867 | UniqueExpr( const UniqueExpr & other ); | 
|---|
|  | 868 | ~UniqueExpr(); | 
|---|
|  | 869 |  | 
|---|
| [141b786] | 870 | Expression * get_expr() const { return expr; } | 
|---|
|  | 871 | UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } | 
|---|
| [3c13c03] | 872 |  | 
|---|
| [141b786] | 873 | ObjectDecl * get_object() const { return object; } | 
|---|
|  | 874 | UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; } | 
|---|
|  | 875 |  | 
|---|
|  | 876 | VariableExpr * get_var() const { return var; } | 
|---|
|  | 877 | UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; } | 
|---|
| [77971f6] | 878 |  | 
|---|
| [bf32bb8] | 879 | int get_id() const { return id; } | 
|---|
|  | 880 |  | 
|---|
| [7870799] | 881 | virtual UniqueExpr * clone() const override { return new UniqueExpr( * this ); } | 
|---|
|  | 882 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 883 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 884 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 885 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [65cdc1e] | 886 |  | 
|---|
| [3c13c03] | 887 | private: | 
|---|
| [bf32bb8] | 888 | int id; | 
|---|
|  | 889 | static long long count; | 
|---|
| [3c13c03] | 890 | }; | 
|---|
|  | 891 |  | 
|---|
| [e4d829b] | 892 | struct InitAlternative { | 
|---|
|  | 893 | public: | 
|---|
|  | 894 | Type * type = nullptr; | 
|---|
|  | 895 | Designation * designation = nullptr; | 
|---|
|  | 896 | InitAlternative( Type * type, Designation * designation ); | 
|---|
|  | 897 | InitAlternative( const InitAlternative & other ); | 
|---|
|  | 898 | InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it | 
|---|
|  | 899 | ~InitAlternative(); | 
|---|
|  | 900 | }; | 
|---|
|  | 901 |  | 
|---|
|  | 902 | class UntypedInitExpr : public Expression { | 
|---|
|  | 903 | public: | 
|---|
| [65cdc1e] | 904 | Expression * expr; | 
|---|
|  | 905 | std::list<InitAlternative> initAlts; | 
|---|
|  | 906 |  | 
|---|
| [e4d829b] | 907 | UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ); | 
|---|
|  | 908 | UntypedInitExpr( const UntypedInitExpr & other ); | 
|---|
|  | 909 | ~UntypedInitExpr(); | 
|---|
|  | 910 |  | 
|---|
|  | 911 | Expression * get_expr() const { return expr; } | 
|---|
|  | 912 | UntypedInitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } | 
|---|
|  | 913 |  | 
|---|
|  | 914 | std::list<InitAlternative> & get_initAlts() { return initAlts; } | 
|---|
|  | 915 |  | 
|---|
| [7870799] | 916 | virtual UntypedInitExpr * clone() const override { return new UntypedInitExpr( * this ); } | 
|---|
|  | 917 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 918 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 919 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 920 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [e4d829b] | 921 | }; | 
|---|
|  | 922 |  | 
|---|
|  | 923 | class InitExpr : public Expression { | 
|---|
|  | 924 | public: | 
|---|
| [65cdc1e] | 925 | Expression * expr; | 
|---|
|  | 926 | Designation * designation; | 
|---|
|  | 927 |  | 
|---|
| [62423350] | 928 | InitExpr( Expression * expr, Designation * designation ); | 
|---|
| [e4d829b] | 929 | InitExpr( const InitExpr & other ); | 
|---|
|  | 930 | ~InitExpr(); | 
|---|
|  | 931 |  | 
|---|
|  | 932 | Expression * get_expr() const { return expr; } | 
|---|
|  | 933 | InitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } | 
|---|
|  | 934 |  | 
|---|
|  | 935 | Designation * get_designation() const { return designation; } | 
|---|
|  | 936 | InitExpr * set_designation( Designation * newValue ) { designation = newValue; return this; } | 
|---|
|  | 937 |  | 
|---|
| [7870799] | 938 | virtual InitExpr * clone() const override { return new InitExpr( * this ); } | 
|---|
|  | 939 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 940 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 941 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 942 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [e4d829b] | 943 | }; | 
|---|
|  | 944 |  | 
|---|
| [44b4114] | 945 | /// expression that contains a deleted identifier - should never make it past the resolver. | 
|---|
|  | 946 | class DeletedExpr : public Expression { | 
|---|
|  | 947 | public: | 
|---|
|  | 948 | Expression * expr; | 
|---|
| [e67991f] | 949 | Declaration * deleteStmt; | 
|---|
| [44b4114] | 950 |  | 
|---|
| [e67991f] | 951 | DeletedExpr( Expression * expr, Declaration * deleteStmt ); | 
|---|
| [44b4114] | 952 | DeletedExpr( const DeletedExpr & other ); | 
|---|
|  | 953 | ~DeletedExpr(); | 
|---|
|  | 954 |  | 
|---|
| [7870799] | 955 | virtual DeletedExpr * clone() const override { return new DeletedExpr( * this ); } | 
|---|
|  | 956 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 957 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 958 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 959 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [44b4114] | 960 | }; | 
|---|
|  | 961 |  | 
|---|
| [0f79853] | 962 | /// expression wrapping the use of a default argument - should never make it past the resolver. | 
|---|
|  | 963 | class DefaultArgExpr : public Expression { | 
|---|
|  | 964 | public: | 
|---|
|  | 965 | Expression * expr; | 
|---|
|  | 966 |  | 
|---|
|  | 967 | DefaultArgExpr( Expression * expr ); | 
|---|
|  | 968 | DefaultArgExpr( const DefaultArgExpr & other ); | 
|---|
|  | 969 | ~DefaultArgExpr(); | 
|---|
|  | 970 |  | 
|---|
| [7870799] | 971 | virtual DefaultArgExpr * clone() const override { return new DefaultArgExpr( * this ); } | 
|---|
|  | 972 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 973 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 974 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 975 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [0f79853] | 976 | }; | 
|---|
|  | 977 |  | 
|---|
| [d807ca28] | 978 | /// C11 _Generic expression | 
|---|
|  | 979 | class GenericExpr : public Expression { | 
|---|
|  | 980 | public: | 
|---|
|  | 981 | struct Association { | 
|---|
|  | 982 | Type * type = nullptr; | 
|---|
|  | 983 | Expression * expr = nullptr; | 
|---|
|  | 984 | bool isDefault = false; | 
|---|
|  | 985 |  | 
|---|
|  | 986 | Association( Type * type, Expression * expr ); | 
|---|
|  | 987 | Association( Expression * expr ); | 
|---|
|  | 988 | Association( const Association & other ); | 
|---|
|  | 989 | Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it | 
|---|
|  | 990 | ~Association(); | 
|---|
|  | 991 | }; | 
|---|
|  | 992 |  | 
|---|
|  | 993 | Expression * control; | 
|---|
|  | 994 | std::list<Association> associations; | 
|---|
|  | 995 |  | 
|---|
|  | 996 | GenericExpr( Expression * control, const std::list<Association> & assoc ); | 
|---|
|  | 997 | GenericExpr( const GenericExpr & other ); | 
|---|
|  | 998 | virtual ~GenericExpr(); | 
|---|
|  | 999 |  | 
|---|
| [7870799] | 1000 | virtual GenericExpr * clone() const override { return new GenericExpr( * this ); } | 
|---|
|  | 1001 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 1002 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 1003 | virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 1004 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [d807ca28] | 1005 | }; | 
|---|
|  | 1006 |  | 
|---|
| [0dd3a2f] | 1007 | // Local Variables: // | 
|---|
|  | 1008 | // tab-width: 4 // | 
|---|
|  | 1009 | // mode: c++ // | 
|---|
|  | 1010 | // compile-command: "make install" // | 
|---|
|  | 1011 | // End: // | 
|---|