ddmd.expression
Source: expression.d
- Expression
getRightThis(Locloc, Scope*sc, AggregateDeclarationad, Expressione1, Declarationvar, intflag= 0); - Given
var, get the right this pointer ifvaris in an outer class, but our existing this pointer is in an inner class.Parameters:Expression e1existing this AggregateDeclaration adstruct or class we need the correct this for Declaration varthe specific member of adwe're accessingReturns:Expression representing the this for thevar - Expression
resolve(Locloc, Scope*sc, Dsymbols, boolhasOverloads); - Resolve a symbol
sand wraps it in an expression object.Parameters:bool hasOverloadsworks if the aliased symbol is a function. true: it'
soverloaded and will be resolved later.false: it'
sexact function symbol. - FuncDeclaration
hasThis(Scope*sc); - Determine if this is available by walking up the enclosing scopes until a function is found.Parameters:
Scope* sccontext Returns:Found function if it satisfies isThis(), otherwise null - bool
isNeedThisScope(Scope*sc, Declarationd); - Expression
resolvePropertiesX(Scope*sc, Expressione1, Expressione2= null); - Pull out any properties.
- bool
checkPropertyCall(Expressione, Expressionemsg); - Check the tail CallExp is really property function call.Bugs:This doesn't appear to do anything.
- Expression
resolvePropertiesOnly(Scope*sc, Expressione1); - If
e1is a property function (template), resolve it. - Expression
searchUFCS(Scope*sc, UnaExpue, Identifierident); - Find symbol in accordance with the UFCS name look up rule
- bool
isDotOpDispatch(Expressione); - check
eis exp.opDispatch!(tiargs) or not It's used to switch to UFCS the semantic analysis path - Expression
resolveUFCS(Scope*sc, CallExpce); - Pull out callable entity with UFCS.
- Expression
resolveUFCSProperties(Scope*sc, Expressione1, Expressione2= null); - Pull out property with UFCS.
- bool
arrayExpressionSemantic(Expressions*exps, Scope*sc, boolpreserveErrors= false); - Perform semantic() on an array of Expressions.
- void
expandTuples(Expressions*exps); - Expand tuples.
Input:
expsaray of ExpressionsOutput:
expsrewritten in place - TupleDeclaration
isAliasThisTuple(Expressione); - Expand alias this tuples.
- bool
arrayExpressionToCommonType(Scope*sc, Expressions*exps, Type*pt); - The common type is determined by applying ?: to each pair.
Output:
exps[] properties resolved, implicitly cast to common type, rewritten in place *ptifptis not NULL, set to the common typeReturns:truea semantic error was detected - TemplateDeclaration
getFuncTemplateDecl(Dsymbols); - Get TemplateDeclaration enclosing FuncDeclaration.
- bool
preFunctionParameters(Locloc, Scope*sc, Expressions*exps); - Preprocess arguments to function.
Output:
exps[] tuples expanded, properties resolved, rewritten in placeReturns:truea semantic error occurred - Expression
valueNoDtor(Expressione); - If we want the value of this expression, but do not want to call the destructor on it.
- bool
checkDefCtor(Locloc, Typet); - Issue an error if default construction is disabled for type
t. Default construction is required for arrays and 'out' parameters.Returns:truean error was issued - Expression
callCpCtor(Scope*sc, Expressione); - If
eis an instance of a struct, and that struct has a copy constructor, rewriteeas: (tmp =e),tmpInput:
scjust used to specify the scope of created temporary variable - Expression
doCopyOrMove(Scope*sc, Expressione); - Handle the postblit call on lvalue, or the move of rvalue.
- bool
functionParameters(Locloc, Scope*sc, TypeFunctiontf, Typetthis, Expressions*arguments, FuncDeclarationfd, Type*prettype, Expression*peprefix); - Now that we know the exact type of the function we're calling, the
arguments[] need to be adjusted: 1. implicitly convert argument to the corresponding parameter type 2. add defaultargumentsfor any missingarguments3. do default promotions onargumentscorresponding to ... 4. add hidden arguments[] argument 5. call copy constructor for struct valueargumentsInput:
tftype of the functionfdthe function being called, NULL if called indirectlyOutput: *
prettypereturn type of function *peprefixexpression to execute beforearguments[] are evaluated, NULL if noneReturns:trueerrors happened - struct
UnionExp; - int
RealEquals(real_tx1, real_tx2); - Test to see if two reals are the same. Regard NaN's as equivalent. Regard +0 and -0 as different.
- DotIdExp
typeDotIdExp(Locloc, Typetype, Identifierident); - TypeDotIdExp
- int
modifyFieldVar(Locloc, Scope*sc, VarDeclarationvar, Expressione1); - Mark variable v as modified if it is inside a constructor that
varis a field in. - Expression
extractOpDollarSideEffect(Scope*sc, UnaExpue); - Expression
resolveOpDollar(Scope*sc, ArrayExpae, Expression*pe0); - Runs semantic on
ae.arguments. Declares temporary variables if '$' was used. - Expression
resolveOpDollar(Scope*sc, ArrayExpae, IntervalExpie, Expression*pe0); - Runs semantic on se.lwr and se.upr. Declares a temporary variable if '$' was used.
- StringExp
semanticString(Scope*sc, Expressionexp, const char*s); - Resolve
expas a compile-time known string.Parameters:Scope* scscope Expression expExpression which expected as a string char* sWhat the string is expected for, will be used in error diagnostic. Returns:String literal, or null if error happens. - abstract class
Expression: ddmd.root.rootobject.RootObject; http: //dlang.org/spec/expression.html#expression
- final Expression
copy(); - Does *not* do a deep
copy. - static Expression
combine(Expressione1, Expressione2); - Combine
e1ande2by CommaExp if both are not NULL. - static Expression
extractLast(Expressione, Expression*pe0); - If '
e' is a tree of commas, returns the leftmost expression by stripping off it from the tree. The remained part of the tree is returned via *pe0. Otherwise 'e' is directly returned and *pe0is set to NULL. - bool
isLvalue(); - Return !=0 if expression is an lvalue.
- Expression
toLvalue(Scope*sc, Expressione); - Give error if we're not an lvalue. If we can, convert expression to be an lvalue.
- Expression
resolveLoc(Locloc, Scope*sc); - Resolve __FILE__, __LINE__, __MODULE__, __FUNCTION__, __PRETTY_FUNCTION__ to
loc. - bool
checkType(); - Check that the expression has a valid type. If not, generates an error "... has no type".Returns:
trueif the expression is not valid.Note: When this function returns
true, checkValue() should also returntrue. - bool
checkValue(); - Check that the expression has a valid value. If not, generates an error "... has no value".Returns:
trueif the expression is not valid or has void type. - final bool
checkPurity(Scope*sc, FuncDeclarationf); - Calling function
f. Check the purity, i.e. if we're in a pure function we can only call other pure functions. Returnstrueif error occurs. - final bool
checkPurity(Scope*sc, VarDeclarationv); - Accessing variable
v. Check for purity and safety violations. Returnstrueif error occurs. - final bool
checkSafety(Scope*sc, FuncDeclarationf); - Calling function
f. Check the safety, i.e. if we're in a @safe function we can only call @safe or @trusted functions. Returnstrueif error occurs. - final bool
checkNogc(Scope*sc, FuncDeclarationf); - Calling function
f. Check the @nogc-ness, i.e. if we're in a @nogc function we can only call other @nogc functions. Returnstrueif error occurs. - final bool
checkPostblit(Scope*sc, Typet); - Check that the postblit is callable if
tis an array of structs. Returnstrueif error happens. - final bool
checkReadModifyWrite(TOKrmwOp, Expressionex= null); - Check whether the expression allows RMW operations, error with rmw operator diagnostic if not.
exis the RHS expression, or NULL if ++/-- is used (for diagnostics) Returnstrueif error occurs. - int
checkModifiable(Scope*sc, intflag= 0); Parameters:
sc: scope
flag: 1: do not issue error message for invalid modification
Returns:0: is not modifiable 1: is modifiable in default == being related to type.isMutable() 2: is modifiable, because this is a part of initializing.- Expression
toBoolean(Scope*sc); - If expression can be tested for
trueorfalse, returns the modified expression. Otherwise returns ErrorExp. - Expression
addDtorHook(Scope*sc); - Destructors are attached to VarDeclarations. Hence, if expression returns a temp that needs a destructor, make sure and create a VarDeclaration for that temp.
- final Expression
addressOf(); - Take address of expression.
- final Expression
deref(); - If this is a reference, dereference it.
- bool
isBool(boolresult); - Does this expression statically evaluate to a boolean '
result' (trueorfalse)?
- class
IntegerExp: ddmd.expression.Expression; - class
ErrorExp: ddmd.expression.Expression; - Use this expression for error recovery. It should behave as a 'sink' to prevent further cascaded error messages.
- class
RealExp: ddmd.expression.Expression; - class
ComplexExp: ddmd.expression.Expression; - class
IdentifierExp: ddmd.expression.Expression; - class
DollarExp: ddmd.expression.IdentifierExp; - class
DsymbolExp: ddmd.expression.Expression; - Won't be generated by parser.
- class
ThisExp: ddmd.expression.Expression; http: //dlang.org/spec/expression.html#this
- class
SuperExp: ddmd.expression.ThisExp; http: //dlang.org/spec/expression.html#super
- class
NullExp: ddmd.expression.Expression; http: //dlang.org/spec/expression.html#
null- class
StringExp: ddmd.expression.Expression; http: //dlang.org/spec/expression.html#string_literals
- final const size_t
numberOfCodeUnits(inttynto= 0); - Return the number of code units the string would be if it were re-encoded as
tynto.Parameters:int tyntocode unit type of the target encoding Returns:number of code units - const void
writeTo(void*dest, boolzero, inttyto= 0); - Write the contents of the string to
dest. Use numberOfCodeUnits() to determine size of result.Parameters:void* destdestination int tytoencoding type of the result bool zeroadd terminating 0 - final const pure dchar
getCodeUnit(size_ti); - Get the code unit at index
iParameters:size_t iindex Returns:code unit at indexi - final void
setCodeUnit(size_ti, dcharc); - Set the code unit at index
itocParameters:size_t iindex dchar ccode unit to set it to - char*
toPtr(); - If the string data is UTF-8 and can be accessed directly, return a pointer to it. Do not assume a terminating 0.Returns:pointer to string data if possible,
nullif not - StringExp
toUTF8(Scope*sc); - Convert string to char[].
- final const const(char)[]
toStringz(); - Convert string contents to a 0 terminated string, allocated by mem.xmalloc().
- class
TupleExp: ddmd.expression.Expression; - class
ArrayLiteralExp: ddmd.expression.Expression; - [ e1, e2, e3, ... ]
http: //dlang.org/spec/expression.html#array_literals
- Expression
basis; - If !is
null, elements[] can be sparse andbasisis used for the "default" element value. In other words, non-nullelements[i] overrides this 'basis' value. - static Expressions*
copyElements(Expressione1, Expressione2= null); - Copy element Expressions in the parameters when they're ArrayLiteralExps.Parameters:
Expression e1If it's ArrayLiteralExp, its elements will be copied. Otherwise, e1itself will be pushed into the new Expressions.Expression e2If it's not null, it will be pushed/appended to the new Expressions by the same way with e1.Returns:Newly allocated Expressions. Note that it points to the original Expression values ine1ande2.
- class
AssocArrayLiteralExp: ddmd.expression.Expression; - [ key0 : value0, key1 : value1, ... ]
http: //dlang.org/spec/expression.html#associative_array_literals
- enum int
stageScrub; - scrubReturnValue is running
- enum int
stageSearchPointers; - hasNonConstPointers is running
- enum int
stageOptimize; - optimize is running
- enum int
stageApply; - apply is running
- enum int
stageInlineScan; - inlineScan is running
- enum int
stageToCBuffer; - toCBuffer is running
- class
StructLiteralExp: ddmd.expression.Expression; - sd( e1, e2, e3, ... )
- StructDeclaration
sd; - which aggregate this is for
- Expressions*
elements; - parallels sd.fields[] with
nullentries for fields to skip - Type
stype; - final type of result (can be different from sd's type)
- bool
useStaticInit; - if this is
true, use the StructDeclaration's init symbol - Symbol*
sym; - back end symbol to initialize with literal
- StructLiteralExp
origin; - pointer to the
origininstance of the expression. once a new expression is created,originis set to 'this'. anytime when an expression copy is created, 'origin' pointer is set to 'origin' pointer value of the original expression. - StructLiteralExp
inlinecopy; - those fields need to prevent a infinite recursion when one field of struct initialized with 'this' pointer.
- int
stageflags; - anytime when recursive function is calling, '
stageflags' marks with bit flag of current stage and unmarks before return from this function. 'inlinecopy' uses similar 'stageflags' and from multiple evaluation 'doInline' (with infinite recursion) of this expression. - Expression
getField(Typetype, uintoffset); - Gets expression at
offsetoftype. Returns NULL if not found. - int
getFieldIndex(Typetype, uintoffset); - Get index of field. Returns -1 if not found.
- class
TypeExp: ddmd.expression.Expression; - Mainly just a placeholder
- class
ScopeExp: ddmd.expression.Expression; - Mainly just a placeholder of Package, Module, Nspace, and TemplateInstance (including TemplateMixin)A template instance that requires IFTI: foo!tiargs(fargs) // foo!tiargs is left until CallExp::semantic() or resolveProperties()
- class
TemplateExp: ddmd.expression.Expression; - Mainly just a placeholder
- class
NewExp: ddmd.expression.Expression; - thisexp.new(newargs) newtype(arguments)
- class
NewAnonClassExp: ddmd.expression.Expression; - thisexp.new(newargs) class baseclasses { } (arguments)
- class
SymbolExp: ddmd.expression.Expression; - class
SymOffExp: ddmd.expression.SymbolExp; - Offset from symbol
- class
VarExp: ddmd.expression.SymbolExp; - Variable
- class
OverExp: ddmd.expression.Expression; - Overload Set
- class
FuncExp: ddmd.expression.Expression; - Function/Delegate literal
- class
DeclarationExp: ddmd.expression.Expression; - Declaration of a symbolD grammar allows declarations only as statements. However in AST representation it can be part of any expression. This is used, for example, during internal syntax re-writes to inject hidden symbols.
- class
TypeidExp: ddmd.expression.Expression; - typeid(int)
- class
TraitsExp: ddmd.expression.Expression; - _traits(identifier, args...)
- class
HaltExp: ddmd.expression.Expression; - class
IsExp: ddmd.expression.Expression; - is(targ id tok tspec) is(targ id == tok2)
- class
UnaExp: ddmd.expression.Expression; -
- final Expression
incompatibleTypes(); - The type for a unary expression is incompatible. Print error message.Returns:ErrorExp
- final void
setNoderefOperand(); - Mark the operand as will never be dereferenced, which is useful info for @safe checks. Do before semantic() on operands rewrites them.
- abstract class
BinExp: ddmd.expression.Expression; -
- final Expression
incompatibleTypes(); - The types for a binary expression are incompatible. Print error message.Returns:ErrorExp
- final void
setNoderefOperands(); - Mark the operands as will never be dereferenced, which is useful info for @safe checks. Do before semantic() on operands rewrites them.
- class
BinAssignExp: ddmd.expression.BinExp; - class
CompileExp: ddmd.expression.UnaExp; - class
ImportExp: ddmd.expression.UnaExp; - class
AssertExp: ddmd.expression.UnaExp; - class
DotIdExp: ddmd.expression.UnaExp; - class
DotTemplateExp: ddmd.expression.UnaExp; - Mainly just a placeholder
- class
DotVarExp: ddmd.expression.UnaExp; - class
DotTemplateInstanceExp: ddmd.expression.UnaExp; - foo.bar!(args)
- class
DelegateExp: ddmd.expression.UnaExp; - class
DotTypeExp: ddmd.expression.UnaExp; - class
CallExp: ddmd.expression.UnaExp; - class
AddrExp: ddmd.expression.UnaExp; - class
PtrExp: ddmd.expression.UnaExp; - class
NegExp: ddmd.expression.UnaExp; - class
UAddExp: ddmd.expression.UnaExp; - class
ComExp: ddmd.expression.UnaExp; - class
NotExp: ddmd.expression.UnaExp; - class
DeleteExp: ddmd.expression.UnaExp; - class
CastExp: ddmd.expression.UnaExp; - Possible to cast to one type while painting to another type
- class
VectorExp: ddmd.expression.UnaExp; - class
SliceExp: ddmd.expression.UnaExp; - e1 [lwr .. upr]
http: //dlang.org/spec/expression.html#slice_expressions
- this(Loc
loc, Expressione1, IntervalExpie);
- class
ArrayLengthExp: ddmd.expression.UnaExp; -
- static Expression
rewriteOpAssign(BinExpexp); Rewrite: array.length op= e2
as: array.length = array.length op e2
or: auto tmp = &array; (*tmp).length = (*tmp).length op e2
- class
ArrayExp: ddmd.expression.UnaExp; - e1 [ a0, a1, a2, a3 ,... ]
http: //dlang.org/spec/expression.html#index_expressions
- class
DotExp: ddmd.expression.BinExp; - class
CommaExp: ddmd.expression.BinExp; -
- const bool
isGenerated; - This is needed because AssignExp rewrites CommaExp, hence it needsto trigger the deprecation.
- bool
allowCommaExp; - Temporary variable to enable / disable deprecation of comma expressiondepending on the context. Since most constructor calls are rewritting, the only place where
falsewill be passed will be from the parser. - static void
allow(Expressionexp); - If the argument is a CommaExp, set a flag to prevent deprecation messagesIt's impossible to know from CommaExp.semantic if the result will be used, hence when there is a result (type != void), a deprecation message is always emitted. However, some construct can produce a result but won't use it (ExpStatement and for loop increment). Those should call this function to prevent unwanted deprecations to be emitted.Parameters:
Expression expAn expression that discards its result. If the argument is nullor not a CommaExp, nothing happens.
- class
IntervalExp: ddmd.expression.Expression; - Mainly just a placeholder
- class
DelegateFuncptrExp: ddmd.expression.UnaExp; - class
IndexExp: ddmd.expression.BinExp; - e1 [ e2 ]
- class
PostExp: ddmd.expression.BinExp; - For both i++ and i--
- class
PreExp: ddmd.expression.UnaExp; - For both ++i and --i
- class
AssignExp: ddmd.expression.BinExp; -
- final this(Loc
loc, Expressione1, Expressione2);
- class
ConstructExp: ddmd.expression.AssignExp; - class
BlitExp: ddmd.expression.AssignExp; - class
AddAssignExp: ddmd.expression.BinAssignExp; - class
MinAssignExp: ddmd.expression.BinAssignExp; - class
MulAssignExp: ddmd.expression.BinAssignExp; - class
DivAssignExp: ddmd.expression.BinAssignExp; - class
ModAssignExp: ddmd.expression.BinAssignExp; - class
AndAssignExp: ddmd.expression.BinAssignExp; - class
OrAssignExp: ddmd.expression.BinAssignExp; - class
XorAssignExp: ddmd.expression.BinAssignExp; - class
PowAssignExp: ddmd.expression.BinAssignExp; - class
ShlAssignExp: ddmd.expression.BinAssignExp; - class
ShrAssignExp: ddmd.expression.BinAssignExp; - class
UshrAssignExp: ddmd.expression.BinAssignExp; - class
CatAssignExp: ddmd.expression.BinAssignExp; - class
AddExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#add_expressions
- class
MinExp: ddmd.expression.BinExp; - class
CatExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#cat_expressions
- class
MulExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#mul_expressions
- class
DivExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#mul_expressions
- class
ModExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#mul_expressions
- class
PowExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#pow_expressions
- class
ShlExp: ddmd.expression.BinExp; - class
ShrExp: ddmd.expression.BinExp; - class
UshrExp: ddmd.expression.BinExp; - class
AndExp: ddmd.expression.BinExp; - class
OrExp: ddmd.expression.BinExp; - class
XorExp: ddmd.expression.BinExp; - class
OrOrExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#oror_expressions
- class
AndAndExp: ddmd.expression.BinExp; http: //dlang.org/spec/expression.html#andand_expressions
- class
CmpExp: ddmd.expression.BinExp; - op is one of: TOKlt, TOKle, TOKgt, TOKge, TOKunord, TOKlg, TOKleg, TOKule, TOKul, TOKuge, TOKug, TOKue
http: //dlang.org/spec/expression.html#relation_expressions
- class
InExp: ddmd.expression.BinExp; - class
RemoveExp: ddmd.expression.BinExp; - This deletes the key e1 from the associative array e2
- class
EqualExp: ddmd.expression.BinExp; - == and !=TOKequal and TOKnotequal
http: //dlang.org/spec/expression.html#equality_expressions
- class
IdentityExp: ddmd.expression.BinExp; - is and !isTOKidentity and TOKnotidentity
http: //dlang.org/spec/expression.html#identity_expressions
- class
CondExp: ddmd.expression.BinExp; - econd ? e1 : e2
http: //dlang.org/spec/expression.html#conditional_expressions
- class
DefaultInitExp: ddmd.expression.Expression; - class
FileInitExp: ddmd.expression.DefaultInitExp; - class
LineInitExp: ddmd.expression.DefaultInitExp; - class
ModuleInitExp: ddmd.expression.DefaultInitExp; - class
FuncInitExp: ddmd.expression.DefaultInitExp; - class
PrettyFuncInitExp: ddmd.expression.DefaultInitExp;