dmd.ctfeexpr
CTFE for expressions involving pointers, slices, array concatenation etc.
License
Source: ctfeexpr.d
Documentation: https://dlang.org/phobos/dmd_ctfeexpr.html
-
Declaration
classClassReferenceExp: 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 intfindFieldIndexByName(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
classThrownExceptionExp: dmd.expression.Expression;Fake class which holds the thrown exception. Used for implementing exception handling.
-
Declaration
classCTFEExp: dmd.expression.Expression;This type is only used by the interpreter.
-
Declaration
boolneedToCopyLiteral(const Expressionexpr);Aggregate literals (AA/string/array/struct)
-
Declaration
ExpressionresolveSlice(Expressione, UnionExp*pue= null);If
eis a SliceExp, constant fold it.Parameters
Expressioneexpression to resolve
UnionExp*pueif not
null, store resulting expression hereReturn Value
resulting expression
-
Declaration
ArrayLiteralExpcreateBlockDuplicatedArrayLiteral(UnionExp*pue, const ref Locloc, Typetype, Expressionelem, size_tdim);Helper for NewExp Create an array literal consisting of '
elem' duplicated 'dim' times.Parameters
UnionExp*puewhere to store result
Loclocsource location where the interpretation occurs
Typetypetarget
typeof the resultExpressionelemthe source of array element, it will be owned by the result
size_tdimelement number of the result
Return Value
Constructed ArrayLiteralExp
-
Declaration
StringExpcreateBlockDuplicatedStringLiteral(UnionExp*pue, const ref Locloc, Typetype, dcharvalue, size_tdim, ubytesz);Helper for NewExp Create a string literal consisting of '
value' duplicated 'dim' times. -
Declaration
boolisTypeInfo_Class(const Typetype);TypeInfo operations
-
Declaration
boolisPointer(Typet);Pointer operations
-
Declaration
boolpointToSameMemoryBlock(Expressionagg1, Expressionagg2);Return
trueifagg1andagg2are pointers to the same memory block -
Declaration
boolisCtfeComparable(Expressione);Constant folding, with support for CTFE Return
trueif non-pointer expressionecan be compared with >,is, ==, etc, using ctfeCmp, ctfeEqual, ctfeIdentity -
Declaration
boolspecificCmp(EXPop, intrawCmp);Returns cmp OP 0; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
boolintUnsignedCmp(EXPop, dinteger_tn1, dinteger_tn2);Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
boolintSignedCmp(EXPop, sinteger_tn1, sinteger_tn2);Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
boolrealCmp(EXPop, real_tr1, real_tr2);Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-
Declaration
boolctfeEqual(const ref Locloc, EXPop, Expressione1, Expressione2);Evaluate ==, !=. Resolves slices before comparing. Returns 0 or 1
-
Declaration
boolctfeIdentity(const ref Locloc, EXPop, Expressione1, Expressione2);Evaluate is, !is. Resolves slices before comparing. Returns 0 or 1
-
Declaration
boolctfeCmp(const ref Locloc, EXPop, Expressione1, Expressione2);Evaluate >,<=, etc. Resolves slices before comparing. Returns 0 or 1
-
Declaration
voidassignInPlace(Expressiondest, Expressionsrc);Assignment helper functions
-
Declaration
ExpressionchangeArrayLiteralLength(UnionExp*pue, const ref Locloc, TypeArrayarrayType, Expressionoldval, size_toldlen, size_tnewlen);Given array literal
oldvalof type ArrayLiteralExp or StringExp, of lengtholdlen, change its length tonewlen. If thenewlenis longer thanoldlen, all new elements will be set to the default initializer for the element type. -
Declaration
boolisCtfeValueValid(Expressionnewval);CTFE Sanity Checks
-
Declaration
UnionExpvoidInitLiteral(Typet, VarDeclarationvar);Void initialization