dmd.ctfeexpr
CTFE for expressions involving pointers, slices, array concatenation etc.
License
Source: ctfeexpr.d
Documentation: https://dlang.org/phobos/dmd_ctfeexpr.html
-
Declaration
class
ClassReferenceExp
: dmd.expression.Expression;A reference to a class, or an interface. We need this when we point to a base class (we must record what the type is).
-
Declaration
pure int
findFieldIndexByName
(const StructDeclarationsd
, const VarDeclarationv
);Same as getFieldIndex, but checks for a direct match with the VarDeclaration
Return Value
index of the field, or -1 if not found
-
Declaration
class
ThrownExceptionExp
: dmd.expression.Expression;Fake class which holds the thrown exception. Used for implementing exception handling.
-
Declaration
class
CTFEExp
: dmd.expression.Expression;This type is only used by the interpreter.
-
Declaration
bool
needToCopyLiteral
(const Expressionexpr
);Aggregate literals (AA/string/array/struct)
-
Declaration
Expression
resolveSlice
(Expressione
, UnionExp*pue
= null);If
e
is a SliceExp, constant fold it.Parameters
Expression
e
expression to resolve
UnionExp*
pue
if not
null
, store resulting expression hereReturn Value
resulting expression
-
Declaration
ArrayLiteralExp
createBlockDuplicatedArrayLiteral
(UnionExp*pue
, const ref Locloc
, Typetype
, Expressionelem
, size_tdim
);Helper for NewExp Create an array literal consisting of '
elem
' duplicated 'dim
' times.Parameters
UnionExp*
pue
where to store result
Loc
loc
source location where the interpretation occurs
Type
type
target
type
of the resultExpression
elem
the source of array element, it will be owned by the result
size_t
dim
element number of the result
Return Value
Constructed ArrayLiteralExp
-
Declaration
StringExp
createBlockDuplicatedStringLiteral
(UnionExp*pue
, const ref Locloc
, Typetype
, dcharvalue
, size_tdim
, ubytesz
);Helper for NewExp Create a string literal consisting of '
value
' duplicated 'dim
' times. -
Declaration
bool
isTypeInfo_Class
(const Typetype
);TypeInfo operations
-
Declaration
bool
isPointer
(Typet
);Pointer operations
-
Declaration
bool
pointToSameMemoryBlock
(Expressionagg1
, Expressionagg2
);Return
true
ifagg1
andagg2
are pointers to the same memory block -
Declaration
bool
isCtfeComparable
(Expressione
);Constant folding, with support for CTFE Return
true
if non-pointer expressione
can be compared with >,is, ==, etc, using ctfeCmp, ctfeEqual, ctfeIdentity -
Declaration
bool
specificCmp
(EXPop
, intrawCmp
);Returns cmp OP 0; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
bool
intUnsignedCmp
(EXPop
, dinteger_tn1
, dinteger_tn2
);Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
bool
intSignedCmp
(EXPop
, sinteger_tn1
, sinteger_tn2
);Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
bool
realCmp
(EXPop
, real_tr1
, real_tr2
);Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
bool
ctfeEqual
(const ref Locloc
, EXPop
, Expressione1
, Expressione2
);Evaluate ==, !=. Resolves slices before comparing. Returns 0 or 1
-
Declaration
bool
ctfeIdentity
(const ref Locloc
, EXPop
, Expressione1
, Expressione2
);Evaluate is, !is. Resolves slices before comparing. Returns 0 or 1
-
Declaration
bool
ctfeCmp
(const ref Locloc
, EXPop
, Expressione1
, Expressione2
);Evaluate >,<=, etc. Resolves slices before comparing. Returns 0 or 1
-
Declaration
void
assignInPlace
(Expressiondest
, Expressionsrc
);Assignment helper functions
-
Declaration
UnionExp
changeArrayLiteralLength
(const ref Locloc
, TypeArrayarrayType
, Expressionoldval
, size_toldlen
, size_tnewlen
);Given array literal
oldval
of type ArrayLiteralExp or StringExp, of lengtholdlen
, change its length tonewlen
. If thenewlen
is longer thanoldlen
, all new elements will be set to the default initializer for the element type. -
Declaration
bool
isCtfeValueValid
(Expressionnewval
);CTFE Sanity Checks
-
Declaration
UnionExp
voidInitLiteral
(Typet
, VarDeclarationvar
);Void initialization