Most of the logic to implement scoped pointers and scoped references is here.
Compiler implementation of the D programming language.
Array literal is going to be allocated on the GC heap. Check its elements to see if any would escape by going on the heap.
Scope* sc
| used to determine current function and module |
ArrayLiteralExp ae
| array literal expression |
bool gag
| do not print error messages |
true
if any elements escapedAssociative array literal is going to be allocated on the GC heap. Check its elements to see if any would escape by going on the heap.
Scope* sc
| used to determine current function and module |
AssocArrayLiteralExp ae
| associative array literal expression |
bool gag
| do not print error messages |
true
if any elements escapedFunction parameter par
is being initialized to arg
, and par
may escape. Detect if scoped values can escape this way. Print error messages when these are detected.
Scope* sc
| used to determine current function and module |
FuncDeclaration fdc
| function being called, null if called indirectly |
Parameter par
| function parameter (this if null) |
Expression arg
| initializer for param |
bool gag
| do not print error messages |
true
if pointers to the stack can escape via assignmentFunction argument initializes a return
parameter, and that parameter gets assigned to firstArg
. Essentially, treat as firstArg = arg;
Scope* sc
| used to determine current function and module |
Expression firstArg
|
ref argument through which arg may be assigned |
Expression arg
| initializer for parameter |
bool gag
| do not print error messages |
true
if assignment to firstArg
would cause an errorCheck struct constructor of the form s.this(args)
, by checking each return
parameter to see if it gets assigned to s
.
Scope* sc
| used to determine current function and module |
CallExp ce
| constructor call of the form s.this(args)
|
bool gag
| do not print error messages |
true
if construction would cause an escaping reference errorGiven an AssignExp
, determine if the lvalue will cause the contents of the rvalue to escape. Print error messages when these are detected. Infer scope
attribute for the lvalue where possible, in order to eliminate the error.
Scope* sc
| used to determine current function and module |
Expression e
|
AssignExp or CatAssignExp to check for any pointers to the stack |
bool gag
| do not print error messages |
true
if pointers to the stack can escape via assignmentDetect cases where pointers to the stack can escape the lifetime of the stack frame when throwing e
. Print error messages when these are detected.
Scope* sc
| used to determine current function and module |
Expression e
| expression to check for any pointers to the stack |
bool gag
| do not print error messages |
true
if pointers to the stack can escapeDetect cases where pointers to the stack can escape the lifetime of the stack frame by being placed into a GC allocated object. Print error messages when these are detected.
Scope* sc
| used to determine current function and module |
Expression e
| expression to check for any pointers to the stack |
bool gag
| do not print error messages |
true
if pointers to the stack can escapeDetect cases where pointers to the stack can escape the lifetime of the stack frame by returning e
by value. Print error messages when these are detected.
Scope* sc
| used to determine current function and module |
Expression e
| expression to check for any pointers to the stack |
bool gag
| do not print error messages |
true
if pointers to the stack can escapeDetect cases where returning e
by ref
can result in a reference to the stack being returned. Print error messages when these are detected.
Scope* sc
| used to determine current function and module |
Expression e
| expression to check |
bool gag
| do not print error messages |
true
if references to the stack can escapeFind all variables accessed by this delegate that are in functions enclosing it.
FuncDeclaration fd
| function |
VarDeclarations* vars
| array to append found variables to |
Turn off STC.maybescope
for variable v
.
This exists in order to find where STC.maybescope
is getting turned off.
VarDeclaration v
| variable |
Have some variables that are maybescopes that were assigned values from other maybescope variables. Now that semantic analysis of the function is complete, we can finalize this by turning off maybescope for array elements that cannot be scope.
va |
v |
=> | va |
v |
---|---|---|---|---|
maybe | maybe | => | scope | scope |
scope | scope | => | scope | scope |
scope | maybe | => | scope | scope |
maybe | scope | => | scope | scope |
- | - | => | - | - |
- | maybe | => | - | - |
- | scope | => | error | error |
maybe | - | => | scope | - |
scope | - | => | scope | - |
VarDeclaration[] array
| array of variables that were assigned to from maybescope variables |
© 1999–2019 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/dmd_escape.html