dmd.ob

Flow analysis for Ownership/Borrowing

Members

Aliases

ObNodes
alias ObNodes = Array!(ObNode*)
Undocumented in source.
StmtState
alias StmtState = dmd.stmtstate.StmtState!ObNode
Undocumented in source.

Enums

ObType
enum ObType
Undocumented in source.
PtrState
enum PtrState

Pointer variable states:

Functions

allocDeps
void allocDeps(PtrVarState[] pvss)

Allocate BitArrays in PtrVarState. Can be allocated much more efficiently by subdividing a single large array of bits

allocStates
void allocStates(ObState obstate)

Allocate state variables foreach node.

checkObErrors
void checkObErrors(ObState obstate)

Check for Ownership/Borrowing errors.

collectVars
void collectVars(FuncDeclaration funcdecl, VarDeclarations vars)

Find the pointer variable declarations in this function, and fill vars with them.

computePreds
void computePreds(ObNodes obnodes)

Compute predecessors.

doDataFlowAnalysis
void doDataFlowAnalysis(ObState obstate)

Do the data flow analysis (i.e. compute the input[] and output[] vectors for each ObNode).

genKill
void genKill(ObState obstate, ObNode* ob)

Compute the gen vector for ob.

hasMutableFields
bool hasMutableFields(Type t)

Does type t have any mutable fields?

hasPointersToMutableFields
bool hasPointersToMutableFields(Type t)

Does type t contain any pointers to mutable?

insertFinallyBlockCalls
void insertFinallyBlockCalls(ObNodes 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
void insertFinallyBlockGotos(ObNodes obnodes)

Remove try-finally scaffolding.

isBorrowedPtr
bool isBorrowedPtr(VarDeclaration v)

Does v meet the definiton of a Borrowed pointer?

isMutableRef
bool isMutableRef(Type t)

Is type t a reference to a const or a reference to a mutable?

isReadonlyPtr
bool isReadonlyPtr(VarDeclaration v)

Does v meet the definiton of a Readonly pointer?

isTrackableVar
bool isTrackableVar(VarDeclaration v)

Are we interested in tracking variable v?

isTrackableVarExp
VarDeclaration isTrackableVarExp(Expression e)

Are we interested in tracking this expression?

makeChildrenUndefined
void makeChildrenUndefined(size_t vi, PtrVarState[] gen)

Recursively make Undefined all who list vi as a dependency

makeUndefined
void makeUndefined(size_t vi, PtrVarState[] gen)

Recursively make Undefined vi undefined and all who list vi as a dependency

numberNodes
void numberNodes(ObNodes obnodes)

Set the index field of each ObNode to its index in the obnodes[] array.

oblive
void oblive(FuncDeclaration funcdecl)

Perform ownership/borrowing checks for funcdecl. Does not modify the AST, just checks for errors.

readVar
void readVar(ObNode* ob, size_t vi, bool mutable, PtrVarState[] 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
void removeUnreachable(ObNodes obnodes)

Remove unreachable nodes and compress them out of obnodes[].

setLabelStatementExtraFields
void setLabelStatementExtraFields(DsymbolTable labtab)

Set the .extra field for LabelStatements in labtab[].

toChars
const(char)* toChars(PtrState state)
toObNodes
void toObNodes(ObNodes obnodes, Statement s)

Convert statement into ObNodes.

toPtrState
PtrState toPtrState(VarDeclaration v)

Determine the state of a variable based on its type and storage class.

toString
string toString(ObType obtype)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString(PtrState state)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

ObNode
struct ObNode

A node in the function's expression graph, and its edges to predecessors and successors.

ObState
struct ObState

Collect the state information.

PtrVarState
struct PtrVarState

Carries the state of a pointer variable.

Meta