| 1 |
|
| 2 |
/* Compiler implementation of the D programming language |
| 3 |
* Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved |
| 4 |
* written by Walter Bright |
| 5 |
* https://www.digitalmars.com |
| 6 |
* Distributed under the Boost Software License, Version 1.0. |
| 7 |
* https://www.boost.org/LICENSE_1_0.txt |
| 8 |
* https://github.com/dlang/dmd/blob/master/src/dmd/expression.h |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include "ast_node.h" |
| 14 |
#include "globals.h" |
| 15 |
#include "arraytypes.h" |
| 16 |
#include "visitor.h" |
| 17 |
#include "tokens.h" |
| 18 |
|
| 19 |
#include "root/complex_t.h" |
| 20 |
#include "root/dcompat.h" |
| 21 |
#include "root/optional.h" |
| 22 |
|
| 23 |
class Type; |
| 24 |
class TypeVector; |
| 25 |
struct Scope; |
| 26 |
class TupleDeclaration; |
| 27 |
class VarDeclaration; |
| 28 |
class FuncDeclaration; |
| 29 |
class FuncLiteralDeclaration; |
| 30 |
class CtorDeclaration; |
| 31 |
class Dsymbol; |
| 32 |
class ScopeDsymbol; |
| 33 |
class Expression; |
| 34 |
class Declaration; |
| 35 |
class StructDeclaration; |
| 36 |
class TemplateInstance; |
| 37 |
class TemplateDeclaration; |
| 38 |
class ClassDeclaration; |
| 39 |
class OverloadSet; |
| 40 |
class StringExp; |
| 41 |
class InterpExp; |
| 42 |
class LoweredAssignExp; |
| 43 |
class StaticForeach; |
| 44 |
#ifdef IN_GCC |
| 45 |
typedef union tree_node Symbol; |
| 46 |
#else |
| 47 |
struct Symbol; // back end symbol |
| 48 |
#endif |
| 49 |
|
| 50 |
namespace dmd |
| 51 |
{ |
| 52 |
// in expressionsem.d |
| 53 |
Expression *expressionSemantic(Expression *e, Scope *sc); |
| 54 |
void lowerNonArrayAggregate(StaticForeach *sfe, Scope *sc); |
| 55 |
// in typesem.d |
| 56 |
Expression *defaultInit(Type *mt, Loc loc, const bool isCfile = false); |
| 57 |
|
| 58 |
// Entry point for CTFE. |
| 59 |
// A compile-time result is required. Give an error if not possible |
| 60 |
Expression *ctfeInterpret(Expression *e); |
| 61 |
void expandTuples(Expressions *exps, Identifiers *names = nullptr); |
| 62 |
Expression *optimize(Expression *exp, int result, bool keepLvalue = false); |
| 63 |
} |
| 64 |
|
| 65 |
typedef unsigned char OwnedBy; |
| 66 |
enum |
| 67 |
{ |
| 68 |
OWNEDcode, // normal code expression in AST |
| 69 |
OWNEDctfe, // value expression for CTFE |
| 70 |
OWNEDcache // constant value cached for CTFE |
| 71 |
}; |
| 72 |
|
| 73 |
#define WANTvalue 0 // default |
| 74 |
#define WANTexpand 1 // expand const/immutable variables if possible |
| 75 |
|
| 76 |
class Expression : public ASTNode |
| 77 |
{ |
| 78 |
public: |
| 79 |
Type *type; // !=NULL means that semantic() has been run |
| 80 |
Loc loc; // file location |
| 81 |
EXP op; // to minimize use of dynamic_cast |
| 82 |
uint8_t bitFields; |
| 83 |
|
| 84 |
bool parens() const; |
| 85 |
bool parens(bool v); |
| 86 |
bool rvalue() const; |
| 87 |
bool rvalue(bool v); |
| 88 |
|
| 89 |
size_t size() const; |
| 90 |
static void _init(); |
| 91 |
virtual Expression *syntaxCopy(); |
| 92 |
|
| 93 |
// kludge for template.isExpression() |
| 94 |
DYNCAST dyncast() const override final { return DYNCAST_EXPRESSION; } |
| 95 |
|
| 96 |
const char* toChars() const final override; |
| 97 |
|
| 98 |
virtual dinteger_t toInteger(); |
| 99 |
virtual uinteger_t toUInteger(); |
| 100 |
virtual real_t toReal(); |
| 101 |
virtual real_t toImaginary(); |
| 102 |
virtual complex_t toComplex(); |
| 103 |
virtual StringExp *toStringExp(); |
| 104 |
virtual bool isLvalue(); |
| 105 |
virtual bool checkType(); |
| 106 |
Expression *addressOf(); |
| 107 |
Expression *deref(); |
| 108 |
|
| 109 |
int isConst(); |
| 110 |
virtual bool isIdentical(const Expression *e) const; |
| 111 |
virtual Optional<bool> toBool(); |
| 112 |
virtual bool hasCode() |
| 113 |
{ |
| 114 |
return true; |
| 115 |
} |
| 116 |
|
| 117 |
IntegerExp* isIntegerExp(); |
| 118 |
ErrorExp* isErrorExp(); |
| 119 |
VoidInitExp* isVoidInitExp(); |
| 120 |
RealExp* isRealExp(); |
| 121 |
ComplexExp* isComplexExp(); |
| 122 |
IdentifierExp* isIdentifierExp(); |
| 123 |
DollarExp* isDollarExp(); |
| 124 |
DsymbolExp* isDsymbolExp(); |
| 125 |
ThisExp* isThisExp(); |
| 126 |
SuperExp* isSuperExp(); |
| 127 |
NullExp* isNullExp(); |
| 128 |
StringExp* isStringExp(); |
| 129 |
InterpExp* isInterpExp(); |
| 130 |
TupleExp* isTupleExp(); |
| 131 |
ArrayLiteralExp* isArrayLiteralExp(); |
| 132 |
AssocArrayLiteralExp* isAssocArrayLiteralExp(); |
| 133 |
StructLiteralExp* isStructLiteralExp(); |
| 134 |
TypeExp* isTypeExp(); |
| 135 |
ScopeExp* isScopeExp(); |
| 136 |
TemplateExp* isTemplateExp(); |
| 137 |
NewExp* isNewExp(); |
| 138 |
NewAnonClassExp* isNewAnonClassExp(); |
| 139 |
SymOffExp* isSymOffExp(); |
| 140 |
VarExp* isVarExp(); |
| 141 |
OverExp* isOverExp(); |
| 142 |
FuncExp* isFuncExp(); |
| 143 |
DeclarationExp* isDeclarationExp(); |
| 144 |
TypeidExp* isTypeidExp(); |
| 145 |
TraitsExp* isTraitsExp(); |
| 146 |
HaltExp* isHaltExp(); |
| 147 |
IsExp* isIsExp(); |
| 148 |
MixinExp* isMixinExp(); |
| 149 |
ImportExp* isImportExp(); |
| 150 |
AssertExp* isAssertExp(); |
| 151 |
DotIdExp* isDotIdExp(); |
| 152 |
DotTemplateExp* isDotTemplateExp(); |
| 153 |
DotVarExp* isDotVarExp(); |
| 154 |
DotTemplateInstanceExp* isDotTemplateInstanceExp(); |
| 155 |
DelegateExp* isDelegateExp(); |
| 156 |
DotTypeExp* isDotTypeExp(); |
| 157 |
CallExp* isCallExp(); |
| 158 |
AddrExp* isAddrExp(); |
| 159 |
PtrExp* isPtrExp(); |
| 160 |
NegExp* isNegExp(); |
| 161 |
UAddExp* isUAddExp(); |
| 162 |
ComExp* isComExp(); |
| 163 |
NotExp* isNotExp(); |
| 164 |
DeleteExp* isDeleteExp(); |
| 165 |
CastExp* isCastExp(); |
| 166 |
VectorExp* isVectorExp(); |
| 167 |
VectorArrayExp* isVectorArrayExp(); |
| 168 |
SliceExp* isSliceExp(); |
| 169 |
ArrayLengthExp* isArrayLengthExp(); |
| 170 |
ArrayExp* isArrayExp(); |
| 171 |
DotExp* isDotExp(); |
| 172 |
CommaExp* isCommaExp(); |
| 173 |
IntervalExp* isIntervalExp(); |
| 174 |
DelegatePtrExp* isDelegatePtrExp(); |
| 175 |
DelegateFuncptrExp* isDelegateFuncptrExp(); |
| 176 |
IndexExp* isIndexExp(); |
| 177 |
PostExp* isPostExp(); |
| 178 |
PreExp* isPreExp(); |
| 179 |
AssignExp* isAssignExp(); |
| 180 |
ConstructExp* isConstructExp(); |
| 181 |
BlitExp* isBlitExp(); |
| 182 |
AddAssignExp* isAddAssignExp(); |
| 183 |
MinAssignExp* isMinAssignExp(); |
| 184 |
MulAssignExp* isMulAssignExp(); |
| 185 |
DivAssignExp* isDivAssignExp(); |
| 186 |
ModAssignExp* isModAssignExp(); |
| 187 |
AndAssignExp* isAndAssignExp(); |
| 188 |
OrAssignExp* isOrAssignExp(); |
| 189 |
XorAssignExp* isXorAssignExp(); |
| 190 |
PowAssignExp* isPowAssignExp(); |
| 191 |
ShlAssignExp* isShlAssignExp(); |
| 192 |
ShrAssignExp* isShrAssignExp(); |
| 193 |
UshrAssignExp* isUshrAssignExp(); |
| 194 |
CatAssignExp* isCatAssignExp(); |
| 195 |
CatElemAssignExp* isCatElemAssignExp(); |
| 196 |
CatDcharAssignExp* isCatDcharAssignExp(); |
| 197 |
AddExp* isAddExp(); |
| 198 |
MinExp* isMinExp(); |
| 199 |
CatExp* isCatExp(); |
| 200 |
MulExp* isMulExp(); |
| 201 |
DivExp* isDivExp(); |
| 202 |
ModExp* isModExp(); |
| 203 |
PowExp* isPowExp(); |
| 204 |
ShlExp* isShlExp(); |
| 205 |
ShrExp* isShrExp(); |
| 206 |
UshrExp* isUshrExp(); |
| 207 |
AndExp* isAndExp(); |
| 208 |
OrExp* isOrExp(); |
| 209 |
XorExp* isXorExp(); |
| 210 |
LogicalExp* isLogicalExp(); |
| 211 |
InExp* isInExp(); |
| 212 |
RemoveExp* isRemoveExp(); |
| 213 |
EqualExp* isEqualExp(); |
| 214 |
IdentityExp* isIdentityExp(); |
| 215 |
CondExp* isCondExp(); |
| 216 |
GenericExp* isGenericExp(); |
| 217 |
DefaultInitExp* isDefaultInitExp(); |
| 218 |
FileInitExp* isFileInitExp(); |
| 219 |
LineInitExp* isLineInitExp(); |
| 220 |
ModuleInitExp* isModuleInitExp(); |
| 221 |
FuncInitExp* isFuncInitExp(); |
| 222 |
PrettyFuncInitExp* isPrettyFuncInitExp(); |
| 223 |
ClassReferenceExp* isClassReferenceExp(); |
| 224 |
ThrownExceptionExp* isThrownExceptionExp(); |
| 225 |
UnaExp* isUnaExp(); |
| 226 |
BinExp* isBinExp(); |
| 227 |
BinAssignExp* isBinAssignExp(); |
| 228 |
LoweredAssignExp* isLoweredAssignExp(); |
| 229 |
|
| 230 |
void accept(Visitor *v) override { v->visit(this); } |
| 231 |
}; |
| 232 |
|
| 233 |
class IntegerExp final : public Expression |
| 234 |
{ |
| 235 |
public: |
| 236 |
dinteger_t value; |
| 237 |
|
| 238 |
static IntegerExp *create(Loc loc, dinteger_t value, Type *type); |
| 239 |
bool equals(const RootObject * const o) const override; |
| 240 |
dinteger_t toInteger() override; |
| 241 |
real_t toReal() override; |
| 242 |
real_t toImaginary() override; |
| 243 |
complex_t toComplex() override; |
| 244 |
Optional<bool> toBool() override; |
| 245 |
void accept(Visitor *v) override { v->visit(this); } |
| 246 |
dinteger_t getInteger() { return value; } |
| 247 |
template<int v> |
| 248 |
static IntegerExp literal(); |
| 249 |
}; |
| 250 |
|
| 251 |
class ErrorExp final : public Expression |
| 252 |
{ |
| 253 |
public: |
| 254 |
void accept(Visitor *v) override { v->visit(this); } |
| 255 |
|
| 256 |
static ErrorExp *errorexp; // handy shared value |
| 257 |
}; |
| 258 |
|
| 259 |
class RealExp final : public Expression |
| 260 |
{ |
| 261 |
public: |
| 262 |
real_t value; |
| 263 |
|
| 264 |
static RealExp *create(Loc loc, real_t value, Type *type); |
| 265 |
bool equals(const RootObject * const o) const override; |
| 266 |
bool isIdentical(const Expression *e) const override; |
| 267 |
dinteger_t toInteger() override; |
| 268 |
uinteger_t toUInteger() override; |
| 269 |
real_t toReal() override; |
| 270 |
real_t toImaginary() override; |
| 271 |
complex_t toComplex() override; |
| 272 |
Optional<bool> toBool() override; |
| 273 |
void accept(Visitor *v) override { v->visit(this); } |
| 274 |
}; |
| 275 |
|
| 276 |
class ComplexExp final : public Expression |
| 277 |
{ |
| 278 |
public: |
| 279 |
complex_t value; |
| 280 |
|
| 281 |
static ComplexExp *create(Loc loc, complex_t value, Type *type); |
| 282 |
bool equals(const RootObject * const o) const override; |
| 283 |
bool isIdentical(const Expression *e) const override; |
| 284 |
dinteger_t toInteger() override; |
| 285 |
uinteger_t toUInteger() override; |
| 286 |
real_t toReal() override; |
| 287 |
real_t toImaginary() override; |
| 288 |
complex_t toComplex() override; |
| 289 |
Optional<bool> toBool() override; |
| 290 |
void accept(Visitor *v) override { v->visit(this); } |
| 291 |
}; |
| 292 |
|
| 293 |
class IdentifierExp : public Expression |
| 294 |
{ |
| 295 |
public: |
| 296 |
Identifier *ident; |
| 297 |
|
| 298 |
static IdentifierExp *create(Loc loc, Identifier *ident); |
| 299 |
bool isLvalue() override final; |
| 300 |
void accept(Visitor *v) override { v->visit(this); } |
| 301 |
}; |
| 302 |
|
| 303 |
class DollarExp final : public IdentifierExp |
| 304 |
{ |
| 305 |
public: |
| 306 |
void accept(Visitor *v) override { v->visit(this); } |
| 307 |
}; |
| 308 |
|
| 309 |
class DsymbolExp final : public Expression |
| 310 |
{ |
| 311 |
public: |
| 312 |
Dsymbol *s; |
| 313 |
d_bool hasOverloads; |
| 314 |
|
| 315 |
DsymbolExp *syntaxCopy() override; |
| 316 |
bool isLvalue() override; |
| 317 |
void accept(Visitor *v) override { v->visit(this); } |
| 318 |
}; |
| 319 |
|
| 320 |
class ThisExp : public Expression |
| 321 |
{ |
| 322 |
public: |
| 323 |
VarDeclaration *var; |
| 324 |
|
| 325 |
ThisExp *syntaxCopy() override; |
| 326 |
Optional<bool> toBool() override; |
| 327 |
bool isLvalue() override; |
| 328 |
|
| 329 |
void accept(Visitor *v) override { v->visit(this); } |
| 330 |
}; |
| 331 |
|
| 332 |
class SuperExp final : public ThisExp |
| 333 |
{ |
| 334 |
public: |
| 335 |
void accept(Visitor *v) override { v->visit(this); } |
| 336 |
}; |
| 337 |
|
| 338 |
class NullExp final : public Expression |
| 339 |
{ |
| 340 |
public: |
| 341 |
bool equals(const RootObject * const o) const override; |
| 342 |
Optional<bool> toBool() override; |
| 343 |
StringExp *toStringExp() override; |
| 344 |
void accept(Visitor *v) override { v->visit(this); } |
| 345 |
}; |
| 346 |
|
| 347 |
class StringExp final : public Expression |
| 348 |
{ |
| 349 |
public: |
| 350 |
utf8_t postfix; // 'c', 'w', 'd' |
| 351 |
OwnedBy ownedByCtfe; |
| 352 |
void *string; // char, wchar, dchar, or long data |
| 353 |
size_t len; // number of chars, wchars, or dchars |
| 354 |
unsigned char sz; // 1: char, 2: wchar, 4: dchar |
| 355 |
d_bool committed; // if type is committed |
| 356 |
d_bool hexString; // if string is parsed from a hex string literal |
| 357 |
|
| 358 |
static StringExp *create(Loc loc, const char *s); |
| 359 |
static StringExp *create(Loc loc, const void *s, d_size_t len); |
| 360 |
bool equals(const RootObject * const o) const override; |
| 361 |
char32_t getCodeUnit(d_size_t i) const; |
| 362 |
dinteger_t getIndex(d_size_t i) const; |
| 363 |
StringExp *toStringExp() override; |
| 364 |
Optional<bool> toBool() override; |
| 365 |
bool isLvalue() override; |
| 366 |
void accept(Visitor *v) override { v->visit(this); } |
| 367 |
size_t numberOfCodeUnits(int tynto = 0) const; |
| 368 |
void writeTo(void* dest, bool zero, int tyto = 0) const; |
| 369 |
}; |
| 370 |
|
| 371 |
class InterpExp final : public Expression |
| 372 |
{ |
| 373 |
public: |
| 374 |
utf8_t postfix; // 'c', 'w', 'd' |
| 375 |
OwnedBy ownedByCtfe; |
| 376 |
void* interpolatedSet; |
| 377 |
|
| 378 |
void accept(Visitor* v) override { v->visit(this); } |
| 379 |
}; |
| 380 |
|
| 381 |
// Tuple |
| 382 |
|
| 383 |
class TupleExp final : public Expression |
| 384 |
{ |
| 385 |
public: |
| 386 |
Expression *e0; // side-effect part |
| 387 |
/* Tuple-field access may need to take out its side effect part. |
| 388 |
* For example: |
| 389 |
* foo().tupleof |
| 390 |
* is rewritten as: |
| 391 |
* (ref __tup = foo(); tuple(__tup.field0, __tup.field1, ...)) |
| 392 |
* The declaration of temporary variable __tup will be stored in TupleExp::e0. |
| 393 |
*/ |
| 394 |
Expressions *exps; |
| 395 |
|
| 396 |
static TupleExp *create(Loc loc, Expressions *exps); |
| 397 |
TupleExp *syntaxCopy() override; |
| 398 |
bool equals(const RootObject * const o) const override; |
| 399 |
|
| 400 |
void accept(Visitor *v) override { v->visit(this); } |
| 401 |
}; |
| 402 |
|
| 403 |
class ArrayLiteralExp final : public Expression |
| 404 |
{ |
| 405 |
public: |
| 406 |
OwnedBy ownedByCtfe; |
| 407 |
d_bool onstack; |
| 408 |
Expression *basis; |
| 409 |
Expressions *elements; |
| 410 |
|
| 411 |
static ArrayLiteralExp *create(Loc loc, Expressions *elements); |
| 412 |
ArrayLiteralExp *syntaxCopy() override; |
| 413 |
bool equals(const RootObject * const o) const override; |
| 414 |
Expression *getElement(d_size_t i); |
| 415 |
Optional<bool> toBool() override; |
| 416 |
StringExp *toStringExp() override; |
| 417 |
|
| 418 |
void accept(Visitor *v) override { v->visit(this); } |
| 419 |
}; |
| 420 |
|
| 421 |
class AssocArrayLiteralExp final : public Expression |
| 422 |
{ |
| 423 |
public: |
| 424 |
OwnedBy ownedByCtfe; |
| 425 |
Expressions *keys; |
| 426 |
Expressions *values; |
| 427 |
Expression* lowering; |
| 428 |
|
| 429 |
bool equals(const RootObject * const o) const override; |
| 430 |
AssocArrayLiteralExp *syntaxCopy() override; |
| 431 |
Optional<bool> toBool() override; |
| 432 |
|
| 433 |
void accept(Visitor *v) override { v->visit(this); } |
| 434 |
}; |
| 435 |
|
| 436 |
class StructLiteralExp final : public Expression |
| 437 |
{ |
| 438 |
public: |
| 439 |
uint8_t bitFields; |
| 440 |
|
| 441 |
// if this is true, use the StructDeclaration's init symbol |
| 442 |
bool useStaticInit() const; |
| 443 |
bool useStaticInit(bool v); |
| 444 |
// used when moving instances to indicate `this is this.origin` |
| 445 |
bool isOriginal() const; |
| 446 |
bool isOriginal(bool v); |
| 447 |
OwnedBy ownedByCtfe() const; |
| 448 |
OwnedBy ownedByCtfe(OwnedBy v); |
| 449 |
|
| 450 |
/** anytime when recursive function is calling, 'stageflags' marks with bit flag of |
| 451 |
* current stage and unmarks before return from this function. |
| 452 |
* 'inlinecopy' uses similar 'stageflags' and from multiple evaluation 'doInline' |
| 453 |
* (with infinite recursion) of this expression. |
| 454 |
*/ |
| 455 |
uint8_t stageflags; |
| 456 |
|
| 457 |
StructDeclaration *sd; // which aggregate this is for |
| 458 |
Expressions *elements; // parallels sd->fields[] with NULL entries for fields to skip |
| 459 |
Type *stype; // final type of result (can be different from sd's type) |
| 460 |
|
| 461 |
union |
| 462 |
{ |
| 463 |
Symbol *sym; // back end symbol to initialize with literal (used as a Symbol*) |
| 464 |
|
| 465 |
// those fields need to prevent a infinite recursion when one field of struct initialized with 'this' pointer. |
| 466 |
StructLiteralExp *inlinecopy; |
| 467 |
}; |
| 468 |
|
| 469 |
/** pointer to the origin instance of the expression. |
| 470 |
* once a new expression is created, origin is set to 'this'. |
| 471 |
* anytime when an expression copy is created, 'origin' pointer is set to |
| 472 |
* 'origin' pointer value of the original expression. |
| 473 |
*/ |
| 474 |
StructLiteralExp *origin; |
| 475 |
|
| 476 |
|
| 477 |
static StructLiteralExp *create(Loc loc, StructDeclaration *sd, void *elements, Type *stype = nullptr); |
| 478 |
bool equals(const RootObject * const o) const override; |
| 479 |
StructLiteralExp *syntaxCopy() override; |
| 480 |
|
| 481 |
void accept(Visitor *v) override { v->visit(this); } |
| 482 |
}; |
| 483 |
|
| 484 |
class TypeExp final : public Expression |
| 485 |
{ |
| 486 |
public: |
| 487 |
TypeExp *syntaxCopy() override; |
| 488 |
bool checkType() override; |
| 489 |
void accept(Visitor *v) override { v->visit(this); } |
| 490 |
}; |
| 491 |
|
| 492 |
class ScopeExp final : public Expression |
| 493 |
{ |
| 494 |
public: |
| 495 |
ScopeDsymbol *sds; |
| 496 |
|
| 497 |
ScopeExp *syntaxCopy() override; |
| 498 |
bool checkType() override; |
| 499 |
void accept(Visitor *v) override { v->visit(this); } |
| 500 |
}; |
| 501 |
|
| 502 |
class TemplateExp final : public Expression |
| 503 |
{ |
| 504 |
public: |
| 505 |
TemplateDeclaration *td; |
| 506 |
FuncDeclaration *fd; |
| 507 |
|
| 508 |
bool isLvalue() override; |
| 509 |
bool checkType() override; |
| 510 |
void accept(Visitor *v) override { v->visit(this); } |
| 511 |
}; |
| 512 |
|
| 513 |
class NewExp final : public Expression |
| 514 |
{ |
| 515 |
public: |
| 516 |
/* newtype(arguments) |
| 517 |
*/ |
| 518 |
Expression *thisexp; // if !NULL, 'this' for class being allocated |
| 519 |
Type *newtype; |
| 520 |
Expressions *arguments; // Array of Expression's |
| 521 |
Identifiers *names; // Array of names corresponding to expressions |
| 522 |
Expression *placement; // if !NULL, placement expression |
| 523 |
|
| 524 |
Expression *argprefix; // expression to be evaluated just before arguments[] |
| 525 |
|
| 526 |
CtorDeclaration *member; // constructor function |
| 527 |
d_bool onstack; // allocate on stack |
| 528 |
d_bool thrownew; // this NewExp is the expression of a ThrowStatement |
| 529 |
|
| 530 |
Expression *lowering; // lowered druntime hook: `_d_newclass` |
| 531 |
|
| 532 |
static NewExp *create(Loc loc, Expression *placement, Expression *thisexp, Type *newtype, Expressions *arguments); |
| 533 |
NewExp *syntaxCopy() override; |
| 534 |
|
| 535 |
void accept(Visitor *v) override { v->visit(this); } |
| 536 |
}; |
| 537 |
|
| 538 |
class NewAnonClassExp final : public Expression |
| 539 |
{ |
| 540 |
public: |
| 541 |
/* class baseclasses { } (arguments) |
| 542 |
*/ |
| 543 |
Expression *thisexp; // if !NULL, 'this' for class being allocated |
| 544 |
ClassDeclaration *cd; // class being instantiated |
| 545 |
Expressions *arguments; // Array of Expression's to call class constructor |
| 546 |
Expression *placement; // if !NULL, placement expression |
| 547 |
|
| 548 |
NewAnonClassExp *syntaxCopy() override; |
| 549 |
void accept(Visitor *v) override { v->visit(this); } |
| 550 |
}; |
| 551 |
|
| 552 |
class SymbolExp : public Expression |
| 553 |
{ |
| 554 |
public: |
| 555 |
Declaration *var; |
| 556 |
Dsymbol *originalScope; |
| 557 |
d_bool hasOverloads; |
| 558 |
|
| 559 |
void accept(Visitor *v) override { v->visit(this); } |
| 560 |
}; |
| 561 |
|
| 562 |
// Offset from symbol |
| 563 |
|
| 564 |
class SymOffExp final : public SymbolExp |
| 565 |
{ |
| 566 |
public: |
| 567 |
dinteger_t offset; |
| 568 |
|
| 569 |
Optional<bool> toBool() override; |
| 570 |
|
| 571 |
void accept(Visitor *v) override { v->visit(this); } |
| 572 |
}; |
| 573 |
|
| 574 |
// Variable |
| 575 |
|
| 576 |
class VarExp final : public SymbolExp |
| 577 |
{ |
| 578 |
public: |
| 579 |
d_bool delegateWasExtracted; |
| 580 |
static VarExp *create(Loc loc, Declaration *var, bool hasOverloads = true); |
| 581 |
bool equals(const RootObject * const o) const override; |
| 582 |
bool isLvalue() override; |
| 583 |
|
| 584 |
void accept(Visitor *v) override { v->visit(this); } |
| 585 |
}; |
| 586 |
|
| 587 |
// Overload Set |
| 588 |
|
| 589 |
class OverExp final : public Expression |
| 590 |
{ |
| 591 |
public: |
| 592 |
OverloadSet *vars; |
| 593 |
|
| 594 |
bool isLvalue() override; |
| 595 |
void accept(Visitor *v) override { v->visit(this); } |
| 596 |
}; |
| 597 |
|
| 598 |
// Function/Delegate literal |
| 599 |
|
| 600 |
class FuncExp final : public Expression |
| 601 |
{ |
| 602 |
public: |
| 603 |
FuncLiteralDeclaration *fd; |
| 604 |
TemplateDeclaration *td; |
| 605 |
TOK tok; |
| 606 |
|
| 607 |
bool equals(const RootObject * const o) const override; |
| 608 |
FuncExp *syntaxCopy() override; |
| 609 |
bool checkType() override; |
| 610 |
|
| 611 |
void accept(Visitor *v) override { v->visit(this); } |
| 612 |
}; |
| 613 |
|
| 614 |
// Declaration of a symbol |
| 615 |
|
| 616 |
// D grammar allows declarations only as statements. However in AST representation |
| 617 |
// it can be part of any expression. This is used, for example, during internal |
| 618 |
// syntax re-writes to inject hidden symbols. |
| 619 |
class DeclarationExp final : public Expression |
| 620 |
{ |
| 621 |
public: |
| 622 |
Dsymbol *declaration; |
| 623 |
|
| 624 |
DeclarationExp *syntaxCopy() override; |
| 625 |
|
| 626 |
bool hasCode() override; |
| 627 |
|
| 628 |
void accept(Visitor *v) override { v->visit(this); } |
| 629 |
}; |
| 630 |
|
| 631 |
class TypeidExp final : public Expression |
| 632 |
{ |
| 633 |
public: |
| 634 |
RootObject *obj; |
| 635 |
|
| 636 |
TypeidExp *syntaxCopy() override; |
| 637 |
void accept(Visitor *v) override { v->visit(this); } |
| 638 |
}; |
| 639 |
|
| 640 |
class TraitsExp final : public Expression |
| 641 |
{ |
| 642 |
public: |
| 643 |
Identifier *ident; |
| 644 |
Objects *args; |
| 645 |
|
| 646 |
TraitsExp *syntaxCopy() override; |
| 647 |
void accept(Visitor *v) override { v->visit(this); } |
| 648 |
}; |
| 649 |
|
| 650 |
class HaltExp final : public Expression |
| 651 |
{ |
| 652 |
public: |
| 653 |
void accept(Visitor *v) override { v->visit(this); } |
| 654 |
}; |
| 655 |
|
| 656 |
class IsExp final : public Expression |
| 657 |
{ |
| 658 |
public: |
| 659 |
/* is(targ id tok tspec) |
| 660 |
* is(targ id == tok2) |
| 661 |
*/ |
| 662 |
Type *targ; |
| 663 |
Identifier *id; // can be NULL |
| 664 |
Type *tspec; // can be NULL |
| 665 |
TemplateParameters *parameters; |
| 666 |
TOK tok; // ':' or '==' |
| 667 |
TOK tok2; // 'struct', 'union', etc. |
| 668 |
|
| 669 |
IsExp *syntaxCopy() override; |
| 670 |
void accept(Visitor *v) override { v->visit(this); } |
| 671 |
}; |
| 672 |
|
| 673 |
/****************************************************************/ |
| 674 |
|
| 675 |
class UnaExp : public Expression |
| 676 |
{ |
| 677 |
public: |
| 678 |
Expression *e1; |
| 679 |
|
| 680 |
UnaExp *syntaxCopy() override; |
| 681 |
|
| 682 |
void accept(Visitor *v) override { v->visit(this); } |
| 683 |
}; |
| 684 |
|
| 685 |
class BinExp : public Expression |
| 686 |
{ |
| 687 |
public: |
| 688 |
Expression *e1; |
| 689 |
Expression *e2; |
| 690 |
|
| 691 |
BinExp *syntaxCopy() override; |
| 692 |
|
| 693 |
void accept(Visitor *v) override { v->visit(this); } |
| 694 |
}; |
| 695 |
|
| 696 |
class BinAssignExp : public BinExp |
| 697 |
{ |
| 698 |
public: |
| 699 |
bool isLvalue() override final; |
| 700 |
void accept(Visitor *v) override { v->visit(this); } |
| 701 |
}; |
| 702 |
|
| 703 |
/****************************************************************/ |
| 704 |
|
| 705 |
class MixinExp final : public UnaExp |
| 706 |
{ |
| 707 |
public: |
| 708 |
void accept(Visitor *v) override { v->visit(this); } |
| 709 |
}; |
| 710 |
|
| 711 |
class ImportExp final : public UnaExp |
| 712 |
{ |
| 713 |
public: |
| 714 |
void accept(Visitor *v) override { v->visit(this); } |
| 715 |
}; |
| 716 |
|
| 717 |
class AssertExp final : public UnaExp |
| 718 |
{ |
| 719 |
public: |
| 720 |
Expression *msg; |
| 721 |
|
| 722 |
AssertExp *syntaxCopy() override; |
| 723 |
|
| 724 |
void accept(Visitor *v) override { v->visit(this); } |
| 725 |
}; |
| 726 |
|
| 727 |
class ThrowExp final : public UnaExp |
| 728 |
{ |
| 729 |
public: |
| 730 |
ThrowExp *syntaxCopy() override; |
| 731 |
|
| 732 |
void accept(Visitor *v) override { v->visit(this); } |
| 733 |
}; |
| 734 |
|
| 735 |
class DotIdExp final : public UnaExp |
| 736 |
{ |
| 737 |
public: |
| 738 |
Identifier *ident; |
| 739 |
d_bool noderef; // true if the result of the expression will never be dereferenced |
| 740 |
d_bool wantsym; // do not replace Symbol with its initializer during semantic() |
| 741 |
d_bool arrow; // ImportC: if -> instead of . |
| 742 |
|
| 743 |
static DotIdExp *create(Loc loc, Expression *e, Identifier *ident); |
| 744 |
void accept(Visitor *v) override { v->visit(this); } |
| 745 |
}; |
| 746 |
|
| 747 |
class DotTemplateExp final : public UnaExp |
| 748 |
{ |
| 749 |
public: |
| 750 |
TemplateDeclaration *td; |
| 751 |
|
| 752 |
bool checkType() override; |
| 753 |
void accept(Visitor *v) override { v->visit(this); } |
| 754 |
}; |
| 755 |
|
| 756 |
class DotVarExp final : public UnaExp |
| 757 |
{ |
| 758 |
public: |
| 759 |
Declaration *var; |
| 760 |
d_bool hasOverloads; |
| 761 |
|
| 762 |
bool isLvalue() override; |
| 763 |
void accept(Visitor *v) override { v->visit(this); } |
| 764 |
}; |
| 765 |
|
| 766 |
class DotTemplateInstanceExp final : public UnaExp |
| 767 |
{ |
| 768 |
public: |
| 769 |
TemplateInstance *ti; |
| 770 |
|
| 771 |
DotTemplateInstanceExp *syntaxCopy() override; |
| 772 |
bool checkType() override; |
| 773 |
void accept(Visitor *v) override { v->visit(this); } |
| 774 |
}; |
| 775 |
|
| 776 |
class DelegateExp final : public UnaExp |
| 777 |
{ |
| 778 |
public: |
| 779 |
FuncDeclaration *func; |
| 780 |
d_bool hasOverloads; |
| 781 |
VarDeclaration *vthis2; // container for multi-context |
| 782 |
|
| 783 |
|
| 784 |
void accept(Visitor *v) override { v->visit(this); } |
| 785 |
}; |
| 786 |
|
| 787 |
class DotTypeExp final : public UnaExp |
| 788 |
{ |
| 789 |
public: |
| 790 |
Dsymbol *sym; // symbol that represents a type |
| 791 |
|
| 792 |
void accept(Visitor *v) override { v->visit(this); } |
| 793 |
}; |
| 794 |
|
| 795 |
struct ArgumentList final |
| 796 |
{ |
| 797 |
Expressions* arguments; |
| 798 |
Identifiers* names; |
| 799 |
ArgumentList() : |
| 800 |
arguments(), |
| 801 |
names() |
| 802 |
{ |
| 803 |
} |
| 804 |
ArgumentList(Expressions* arguments, Identifiers* names = nullptr) : |
| 805 |
arguments(arguments), |
| 806 |
names(names) |
| 807 |
{} |
| 808 |
}; |
| 809 |
|
| 810 |
class CallExp final : public UnaExp |
| 811 |
{ |
| 812 |
public: |
| 813 |
Expressions *arguments; // function arguments |
| 814 |
Identifiers *names; |
| 815 |
FuncDeclaration *f; // symbol to call |
| 816 |
d_bool directcall; // true if a virtual call is devirtualized |
| 817 |
d_bool inDebugStatement; // true if this was in a debug statement |
| 818 |
d_bool ignoreAttributes; // don't enforce attributes (e.g. call @gc function in @nogc code) |
| 819 |
d_bool isUfcsRewrite; // the first argument was pushed in here by a UFCS rewrite |
| 820 |
VarDeclaration *vthis2; // container for multi-context |
| 821 |
|
| 822 |
static CallExp *create(Loc loc, Expression *e, Expressions *exps); |
| 823 |
static CallExp *create(Loc loc, Expression *e); |
| 824 |
static CallExp *create(Loc loc, Expression *e, Expression *earg1); |
| 825 |
static CallExp *create(Loc loc, FuncDeclaration *fd, Expression *earg1); |
| 826 |
|
| 827 |
CallExp *syntaxCopy() override; |
| 828 |
bool isLvalue() override; |
| 829 |
|
| 830 |
void accept(Visitor *v) override { v->visit(this); } |
| 831 |
}; |
| 832 |
|
| 833 |
class AddrExp final : public UnaExp |
| 834 |
{ |
| 835 |
public: |
| 836 |
void accept(Visitor *v) override { v->visit(this); } |
| 837 |
}; |
| 838 |
|
| 839 |
class PtrExp final : public UnaExp |
| 840 |
{ |
| 841 |
public: |
| 842 |
bool isLvalue() override; |
| 843 |
|
| 844 |
void accept(Visitor *v) override { v->visit(this); } |
| 845 |
}; |
| 846 |
|
| 847 |
class NegExp final : public UnaExp |
| 848 |
{ |
| 849 |
public: |
| 850 |
void accept(Visitor *v) override { v->visit(this); } |
| 851 |
}; |
| 852 |
|
| 853 |
class UAddExp final : public UnaExp |
| 854 |
{ |
| 855 |
public: |
| 856 |
void accept(Visitor *v) override { v->visit(this); } |
| 857 |
}; |
| 858 |
|
| 859 |
class ComExp final : public UnaExp |
| 860 |
{ |
| 861 |
public: |
| 862 |
void accept(Visitor *v) override { v->visit(this); } |
| 863 |
}; |
| 864 |
|
| 865 |
class NotExp final : public UnaExp |
| 866 |
{ |
| 867 |
public: |
| 868 |
void accept(Visitor *v) override { v->visit(this); } |
| 869 |
}; |
| 870 |
|
| 871 |
class DeleteExp final : public UnaExp |
| 872 |
{ |
| 873 |
public: |
| 874 |
d_bool isRAII; |
| 875 |
void accept(Visitor *v) override { v->visit(this); } |
| 876 |
}; |
| 877 |
|
| 878 |
class CastExp final : public UnaExp |
| 879 |
{ |
| 880 |
public: |
| 881 |
// Possible to cast to one type while painting to another type |
| 882 |
Type *to; // type to cast to |
| 883 |
unsigned char mod; // MODxxxxx |
| 884 |
d_bool trusted; // assume cast is safe |
| 885 |
|
| 886 |
CastExp *syntaxCopy() override; |
| 887 |
bool isLvalue() override; |
| 888 |
|
| 889 |
void accept(Visitor *v) override { v->visit(this); } |
| 890 |
}; |
| 891 |
|
| 892 |
class VectorExp final : public UnaExp |
| 893 |
{ |
| 894 |
public: |
| 895 |
TypeVector *to; // the target vector type before semantic() |
| 896 |
unsigned dim; // number of elements in the vector |
| 897 |
OwnedBy ownedByCtfe; |
| 898 |
|
| 899 |
static VectorExp *create(Loc loc, Expression *e, Type *t); |
| 900 |
VectorExp *syntaxCopy() override; |
| 901 |
void accept(Visitor *v) override { v->visit(this); } |
| 902 |
}; |
| 903 |
|
| 904 |
class VectorArrayExp final : public UnaExp |
| 905 |
{ |
| 906 |
public: |
| 907 |
bool isLvalue() override; |
| 908 |
void accept(Visitor *v) override { v->visit(this); } |
| 909 |
}; |
| 910 |
|
| 911 |
class SliceExp final : public UnaExp |
| 912 |
{ |
| 913 |
public: |
| 914 |
Expression *upr; // NULL if implicit 0 |
| 915 |
Expression *lwr; // NULL if implicit [length - 1] |
| 916 |
VarDeclaration *lengthVar; |
| 917 |
|
| 918 |
bool upperIsInBounds() const; // true if upr <= e1.length |
| 919 |
bool upperIsInBounds(bool v); |
| 920 |
bool lowerIsLessThanUpper() const; // true if lwr <= upr |
| 921 |
bool lowerIsLessThanUpper(bool v); |
| 922 |
bool arrayop() const; // an array operation, rather than a slice |
| 923 |
bool arrayop(bool v); |
| 924 |
private: |
| 925 |
uint8_t bitFields; |
| 926 |
|
| 927 |
public: |
| 928 |
SliceExp *syntaxCopy() override; |
| 929 |
bool isLvalue() override; |
| 930 |
Optional<bool> toBool() override; |
| 931 |
|
| 932 |
void accept(Visitor *v) override { v->visit(this); } |
| 933 |
}; |
| 934 |
|
| 935 |
class ArrayLengthExp final : public UnaExp |
| 936 |
{ |
| 937 |
public: |
| 938 |
void accept(Visitor *v) override { v->visit(this); } |
| 939 |
}; |
| 940 |
|
| 941 |
class IntervalExp final : public Expression |
| 942 |
{ |
| 943 |
public: |
| 944 |
Expression *lwr; |
| 945 |
Expression *upr; |
| 946 |
|
| 947 |
IntervalExp *syntaxCopy() override; |
| 948 |
void accept(Visitor *v) override { v->visit(this); } |
| 949 |
}; |
| 950 |
|
| 951 |
class DelegatePtrExp final : public UnaExp |
| 952 |
{ |
| 953 |
public: |
| 954 |
bool isLvalue() override; |
| 955 |
void accept(Visitor *v) override { v->visit(this); } |
| 956 |
}; |
| 957 |
|
| 958 |
class DelegateFuncptrExp final : public UnaExp |
| 959 |
{ |
| 960 |
public: |
| 961 |
bool isLvalue() override; |
| 962 |
void accept(Visitor *v) override { v->visit(this); } |
| 963 |
}; |
| 964 |
|
| 965 |
// e1[a0,a1,a2,a3,...] |
| 966 |
|
| 967 |
class ArrayExp final : public UnaExp |
| 968 |
{ |
| 969 |
public: |
| 970 |
Expressions *arguments; // Array of Expression's |
| 971 |
size_t currentDimension; // for opDollar |
| 972 |
VarDeclaration *lengthVar; |
| 973 |
|
| 974 |
ArrayExp *syntaxCopy() override; |
| 975 |
bool isLvalue() override; |
| 976 |
|
| 977 |
void accept(Visitor *v) override { v->visit(this); } |
| 978 |
}; |
| 979 |
|
| 980 |
/****************************************************************/ |
| 981 |
|
| 982 |
class DotExp final : public BinExp |
| 983 |
{ |
| 984 |
public: |
| 985 |
void accept(Visitor *v) override { v->visit(this); } |
| 986 |
}; |
| 987 |
|
| 988 |
class CommaExp final : public BinExp |
| 989 |
{ |
| 990 |
public: |
| 991 |
d_bool isGenerated; |
| 992 |
d_bool allowCommaExp; |
| 993 |
bool isLvalue() override; |
| 994 |
Optional<bool> toBool() override; |
| 995 |
void accept(Visitor *v) override { v->visit(this); } |
| 996 |
}; |
| 997 |
|
| 998 |
class IndexExp final : public BinExp |
| 999 |
{ |
| 1000 |
public: |
| 1001 |
VarDeclaration *lengthVar; |
| 1002 |
d_bool modifiable; |
| 1003 |
d_bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1 |
| 1004 |
|
| 1005 |
IndexExp *syntaxCopy() override; |
| 1006 |
bool isLvalue() override; |
| 1007 |
|
| 1008 |
void accept(Visitor *v) override { v->visit(this); } |
| 1009 |
}; |
| 1010 |
|
| 1011 |
/* For both i++ and i-- |
| 1012 |
*/ |
| 1013 |
class PostExp final : public BinExp |
| 1014 |
{ |
| 1015 |
public: |
| 1016 |
void accept(Visitor *v) override { v->visit(this); } |
| 1017 |
}; |
| 1018 |
|
| 1019 |
/* For both ++i and --i |
| 1020 |
*/ |
| 1021 |
class PreExp final : public UnaExp |
| 1022 |
{ |
| 1023 |
public: |
| 1024 |
void accept(Visitor *v) override { v->visit(this); } |
| 1025 |
}; |
| 1026 |
|
| 1027 |
enum class MemorySet |
| 1028 |
{ |
| 1029 |
none = 0, // simple assignment |
| 1030 |
blockAssign = 1, // setting the contents of an array |
| 1031 |
referenceInit = 2 // setting the reference of STCref variable |
| 1032 |
}; |
| 1033 |
|
| 1034 |
class AssignExp : public BinExp |
| 1035 |
{ |
| 1036 |
public: |
| 1037 |
MemorySet memset; |
| 1038 |
|
| 1039 |
bool isLvalue() override final; |
| 1040 |
|
| 1041 |
void accept(Visitor *v) override { v->visit(this); } |
| 1042 |
}; |
| 1043 |
|
| 1044 |
class ConstructExp final : public AssignExp |
| 1045 |
{ |
| 1046 |
public: |
| 1047 |
void accept(Visitor *v) override { v->visit(this); } |
| 1048 |
}; |
| 1049 |
|
| 1050 |
class LoweredAssignExp final : public AssignExp |
| 1051 |
{ |
| 1052 |
public: |
| 1053 |
Expression *lowering; |
| 1054 |
|
| 1055 |
void accept(Visitor *v) override { v->visit(this); } |
| 1056 |
}; |
| 1057 |
|
| 1058 |
class BlitExp final : public AssignExp |
| 1059 |
{ |
| 1060 |
public: |
| 1061 |
void accept(Visitor *v) override { v->visit(this); } |
| 1062 |
}; |
| 1063 |
|
| 1064 |
class AddAssignExp final : public BinAssignExp |
| 1065 |
{ |
| 1066 |
public: |
| 1067 |
void accept(Visitor *v) override { v->visit(this); } |
| 1068 |
}; |
| 1069 |
|
| 1070 |
class MinAssignExp final : public BinAssignExp |
| 1071 |
{ |
| 1072 |
public: |
| 1073 |
void accept(Visitor *v) override { v->visit(this); } |
| 1074 |
}; |
| 1075 |
|
| 1076 |
class MulAssignExp final : public BinAssignExp |
| 1077 |
{ |
| 1078 |
public: |
| 1079 |
void accept(Visitor *v) override { v->visit(this); } |
| 1080 |
}; |
| 1081 |
|
| 1082 |
class DivAssignExp final : public BinAssignExp |
| 1083 |
{ |
| 1084 |
public: |
| 1085 |
void accept(Visitor *v) override { v->visit(this); } |
| 1086 |
}; |
| 1087 |
|
| 1088 |
class ModAssignExp final : public BinAssignExp |
| 1089 |
{ |
| 1090 |
public: |
| 1091 |
void accept(Visitor *v) override { v->visit(this); } |
| 1092 |
}; |
| 1093 |
|
| 1094 |
class AndAssignExp final : public BinAssignExp |
| 1095 |
{ |
| 1096 |
public: |
| 1097 |
void accept(Visitor *v) override { v->visit(this); } |
| 1098 |
}; |
| 1099 |
|
| 1100 |
class OrAssignExp final : public BinAssignExp |
| 1101 |
{ |
| 1102 |
public: |
| 1103 |
void accept(Visitor *v) override { v->visit(this); } |
| 1104 |
}; |
| 1105 |
|
| 1106 |
class XorAssignExp final : public BinAssignExp |
| 1107 |
{ |
| 1108 |
public: |
| 1109 |
void accept(Visitor *v) override { v->visit(this); } |
| 1110 |
}; |
| 1111 |
|
| 1112 |
class PowAssignExp final : public BinAssignExp |
| 1113 |
{ |
| 1114 |
public: |
| 1115 |
void accept(Visitor *v) override { v->visit(this); } |
| 1116 |
}; |
| 1117 |
|
| 1118 |
class ShlAssignExp final : public BinAssignExp |
| 1119 |
{ |
| 1120 |
public: |
| 1121 |
void accept(Visitor *v) override { v->visit(this); } |
| 1122 |
}; |
| 1123 |
|
| 1124 |
class ShrAssignExp final : public BinAssignExp |
| 1125 |
{ |
| 1126 |
public: |
| 1127 |
void accept(Visitor *v) override { v->visit(this); } |
| 1128 |
}; |
| 1129 |
|
| 1130 |
class UshrAssignExp final : public BinAssignExp |
| 1131 |
{ |
| 1132 |
public: |
| 1133 |
void accept(Visitor *v) override { v->visit(this); } |
| 1134 |
}; |
| 1135 |
|
| 1136 |
class CatAssignExp : public BinAssignExp |
| 1137 |
{ |
| 1138 |
public: |
| 1139 |
Expression *lowering; // lowered druntime hook `_d_arrayappend{cTX,T}` |
| 1140 |
|
| 1141 |
void accept(Visitor *v) override { v->visit(this); } |
| 1142 |
}; |
| 1143 |
|
| 1144 |
class CatElemAssignExp final : public CatAssignExp |
| 1145 |
{ |
| 1146 |
public: |
| 1147 |
void accept(Visitor *v) override { v->visit(this); } |
| 1148 |
}; |
| 1149 |
|
| 1150 |
class CatDcharAssignExp final : public CatAssignExp |
| 1151 |
{ |
| 1152 |
public: |
| 1153 |
void accept(Visitor *v) override { v->visit(this); } |
| 1154 |
}; |
| 1155 |
|
| 1156 |
class AddExp final : public BinExp |
| 1157 |
{ |
| 1158 |
public: |
| 1159 |
void accept(Visitor *v) override { v->visit(this); } |
| 1160 |
}; |
| 1161 |
|
| 1162 |
class MinExp final : public BinExp |
| 1163 |
{ |
| 1164 |
public: |
| 1165 |
void accept(Visitor *v) override { v->visit(this); } |
| 1166 |
}; |
| 1167 |
|
| 1168 |
class CatExp final : public BinExp |
| 1169 |
{ |
| 1170 |
public: |
| 1171 |
Expression *lowering; // call to druntime hook `_d_arraycatnTX` |
| 1172 |
|
| 1173 |
void accept(Visitor *v) override { v->visit(this); } |
| 1174 |
}; |
| 1175 |
|
| 1176 |
class MulExp final : public BinExp |
| 1177 |
{ |
| 1178 |
public: |
| 1179 |
void accept(Visitor *v) override { v->visit(this); } |
| 1180 |
}; |
| 1181 |
|
| 1182 |
class DivExp final : public BinExp |
| 1183 |
{ |
| 1184 |
public: |
| 1185 |
void accept(Visitor *v) override { v->visit(this); } |
| 1186 |
}; |
| 1187 |
|
| 1188 |
class ModExp final : public BinExp |
| 1189 |
{ |
| 1190 |
public: |
| 1191 |
void accept(Visitor *v) override { v->visit(this); } |
| 1192 |
}; |
| 1193 |
|
| 1194 |
class PowExp final : public BinExp |
| 1195 |
{ |
| 1196 |
public: |
| 1197 |
void accept(Visitor *v) override { v->visit(this); } |
| 1198 |
}; |
| 1199 |
|
| 1200 |
class ShlExp final : public BinExp |
| 1201 |
{ |
| 1202 |
public: |
| 1203 |
void accept(Visitor *v) override { v->visit(this); } |
| 1204 |
}; |
| 1205 |
|
| 1206 |
class ShrExp final : public BinExp |
| 1207 |
{ |
| 1208 |
public: |
| 1209 |
void accept(Visitor *v) override { v->visit(this); } |
| 1210 |
}; |
| 1211 |
|
| 1212 |
class UshrExp final : public BinExp |
| 1213 |
{ |
| 1214 |
public: |
| 1215 |
void accept(Visitor *v) override { v->visit(this); } |
| 1216 |
}; |
| 1217 |
|
| 1218 |
class AndExp final : public BinExp |
| 1219 |
{ |
| 1220 |
public: |
| 1221 |
void accept(Visitor *v) override { v->visit(this); } |
| 1222 |
}; |
| 1223 |
|
| 1224 |
class OrExp final : public BinExp |
| 1225 |
{ |
| 1226 |
public: |
| 1227 |
void accept(Visitor *v) override { v->visit(this); } |
| 1228 |
}; |
| 1229 |
|
| 1230 |
class XorExp final : public BinExp |
| 1231 |
{ |
| 1232 |
public: |
| 1233 |
void accept(Visitor *v) override { v->visit(this); } |
| 1234 |
}; |
| 1235 |
|
| 1236 |
class LogicalExp final : public BinExp |
| 1237 |
{ |
| 1238 |
public: |
| 1239 |
void accept(Visitor *v) override { v->visit(this); } |
| 1240 |
}; |
| 1241 |
|
| 1242 |
class CmpExp final : public BinExp |
| 1243 |
{ |
| 1244 |
public: |
| 1245 |
void accept(Visitor *v) override { v->visit(this); } |
| 1246 |
}; |
| 1247 |
|
| 1248 |
class InExp final : public BinExp |
| 1249 |
{ |
| 1250 |
public: |
| 1251 |
void accept(Visitor *v) override { v->visit(this); } |
| 1252 |
}; |
| 1253 |
|
| 1254 |
class RemoveExp final : public BinExp |
| 1255 |
{ |
| 1256 |
public: |
| 1257 |
void accept(Visitor *v) override { v->visit(this); } |
| 1258 |
}; |
| 1259 |
|
| 1260 |
// == and != |
| 1261 |
|
| 1262 |
class EqualExp final : public BinExp |
| 1263 |
{ |
| 1264 |
public: |
| 1265 |
void accept(Visitor *v) override { v->visit(this); } |
| 1266 |
}; |
| 1267 |
|
| 1268 |
// is and !is |
| 1269 |
|
| 1270 |
class IdentityExp final : public BinExp |
| 1271 |
{ |
| 1272 |
public: |
| 1273 |
void accept(Visitor *v) override { v->visit(this); } |
| 1274 |
}; |
| 1275 |
|
| 1276 |
/****************************************************************/ |
| 1277 |
|
| 1278 |
class CondExp final : public BinExp |
| 1279 |
{ |
| 1280 |
public: |
| 1281 |
Expression *econd; |
| 1282 |
|
| 1283 |
CondExp *syntaxCopy() override; |
| 1284 |
bool isLvalue() override; |
| 1285 |
|
| 1286 |
void accept(Visitor *v) override { v->visit(this); } |
| 1287 |
}; |
| 1288 |
|
| 1289 |
class GenericExp final : Expression |
| 1290 |
{ |
| 1291 |
Expression *cntlExp; |
| 1292 |
Types *types; |
| 1293 |
Expressions *exps; |
| 1294 |
|
| 1295 |
GenericExp *syntaxCopy() override; |
| 1296 |
|
| 1297 |
void accept(Visitor *v) override { v->visit(this); } |
| 1298 |
}; |
| 1299 |
|
| 1300 |
/****************************************************************/ |
| 1301 |
|
| 1302 |
class DefaultInitExp : public Expression |
| 1303 |
{ |
| 1304 |
public: |
| 1305 |
void accept(Visitor *v) override { v->visit(this); } |
| 1306 |
}; |
| 1307 |
|
| 1308 |
class FileInitExp final : public DefaultInitExp |
| 1309 |
{ |
| 1310 |
public: |
| 1311 |
void accept(Visitor *v) override { v->visit(this); } |
| 1312 |
}; |
| 1313 |
|
| 1314 |
class LineInitExp final : public DefaultInitExp |
| 1315 |
{ |
| 1316 |
public: |
| 1317 |
void accept(Visitor *v) override { v->visit(this); } |
| 1318 |
}; |
| 1319 |
|
| 1320 |
class ModuleInitExp final : public DefaultInitExp |
| 1321 |
{ |
| 1322 |
public: |
| 1323 |
void accept(Visitor *v) override { v->visit(this); } |
| 1324 |
}; |
| 1325 |
|
| 1326 |
class FuncInitExp final : public DefaultInitExp |
| 1327 |
{ |
| 1328 |
public: |
| 1329 |
void accept(Visitor *v) override { v->visit(this); } |
| 1330 |
}; |
| 1331 |
|
| 1332 |
class PrettyFuncInitExp final : public DefaultInitExp |
| 1333 |
{ |
| 1334 |
public: |
| 1335 |
void accept(Visitor *v) override { v->visit(this); } |
| 1336 |
}; |
| 1337 |
|
| 1338 |
/****************************************************************/ |
| 1339 |
|
| 1340 |
class ObjcClassReferenceExp final : public Expression |
| 1341 |
{ |
| 1342 |
public: |
| 1343 |
ClassDeclaration* classDeclaration; |
| 1344 |
|
| 1345 |
void accept(Visitor *v) override { v->visit(this); } |
| 1346 |
}; |