View source code
Display the source code in dmd/ob.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module dmd.ob

Flow analysis for Ownership/Borrowing




allocDeps(pvss) Allocate BitArrays in PtrVarState. Can be allocated much more efficiently by subdividing a single large array of bits
allocStates(obstate) Allocate state variables foreach node.
checkObErrors(obstate) Check for Ownership/Borrowing errors.
collectVars(funcdecl, vars) Find the pointer variable declarations in this function, and fill vars with them.
computePreds(obnodes) Compute predecessors.
doDataFlowAnalysis(obstate) Do the data flow analysis (i.e. compute the input[] and output[] vectors for each ObNode).
genKill(obstate, ob) Compute the gen vector for ob.
hasMutableFields(t) Does type t have any mutable fields?
hasPointersToMutableFields(t) Does type t contain any pointers to mutable?
insertFinallyBlockCalls(obnodes) Insert finally block calls when doing a goto from inside a try block to outside. Done after blocks are generated because then we know all the edges of the graph, but before the pred's are computed.
insertFinallyBlockGotos(obnodes) Remove try-finally scaffolding.
isBorrowedPtr(v) Does v meet the definiton of a Borrowed pointer?
isMutableRef(t) Is type t a reference to a const or a reference to a mutable?
isReadonlyPtr(v) Does v meet the definiton of a Readonly pointer?
isTrackableVar(v) Are we interested in tracking variable v?
isTrackableVarExp(e) Are we interested in tracking this expression?
makeChildrenUndefined(vi, gen) Recursively make Undefined all who list vi as a dependency
makeUndefined(vi, gen) Recursively make Undefined vi undefined and all who list vi as a dependency
numberNodes(obnodes) Set the index field of each ObNode to its index in the obnodes[] array.
oblive(funcdecl) Perform ownership/borrowing checks for funcdecl. Does not modify the AST, just checks for errors.
readVar(ob, vi, mutable, gen) Read from variable vi. The beginning of the 'scope' of a variable is when it is first read. Hence, when a read is done, instead of when assignment to the variable is done, the O/B rules are enforced. (Also called "non-lexical scoping".)
removeUnreachable(obnodes) Remove unreachable nodes and compress them out of obnodes[].
setLabelStatementExtraFields(labtab) Set the .extra field for LabelStatements in labtab[].
toObNodes(obnodes, s) Convert statement into ObNodes.
toPtrState(v) Determine the state of a variable based on its type and storage class.


ObNode A node in the function's expression graph, and its edges to predecessors and successors.
ObState Collect the state information.
PtrVarState Carries the state of a pointer variable.


PtrState Pointer variable states:


Walter Bright


Boost License 1.0