public class ILOCFunction extends Object
Modifier and Type | Class and Description |
---|---|
class |
ILOCFunction.Variable
Helper wrapper class for debug variable information (useful for data flow analysis)
|
Modifier and Type | Field and Description |
---|---|
List<ILOCBasicBlock> |
allBlocks
It is useful to maintain a list of all blocks for liveness analysis
|
ILOCBasicBlock |
entryBlock
Entry block (start of CFG)
|
Symbol |
functionSymbol
Function
Symbol from the AST symbol tables |
List<ILOCInstruction> |
instructions
List of ILOC instructions
|
int |
localSize
Size (in bytes) to allocate on stack for local variables
|
Constructor and Description |
---|
ILOCFunction(Symbol symbol)
Create a new (empty) ILOC function
|
Modifier and Type | Method and Description |
---|---|
void |
addInstruction(ILOCInstruction insn)
Append a new instruction to the function.
|
void |
buildCFG()
Builds the control flow graph for this function.
|
void |
findBlockVars(Set<Integer> seen,
ILOCBasicBlock current,
Set<Integer> candidates,
Map<Integer,String> varMap)
This is a recursive helper function which finds the uninitialized
variables in a given basic block and all successors
Original code written by Steven Young, CS 480 honors student.
|
void |
findUnitializedVars(boolean strictFlag)
Finds and reports possible uninitialized variables in this ILOCFunction
Original code written by Steven Young, CS 480 honors student.
|
void |
flattenCFG()
Flattens the control-flow graph into linear form (presumably after
modifications have been made to the CFG).
|
ILOCBasicBlock |
getEntryBlock()
Get the entry point to the function's control flow graph.
|
List<ILOCInstruction> |
getInstructions()
Get the current instruction sequence.
|
void |
setInstructions(List<ILOCInstruction> instructions)
Replace all instructions with a new sequence.
|
void |
temp(List<ILOCBasicBlock> allBlocks) |
String |
toString()
Builds a standard string-based representation of an ILOC function
|
public int localSize
public List<ILOCInstruction> instructions
public ILOCBasicBlock entryBlock
public List<ILOCBasicBlock> allBlocks
public List<ILOCInstruction> getInstructions()
ILOCInstruction
objectspublic void setInstructions(List<ILOCInstruction> instructions)
instructions
- Replacement instructionspublic void addInstruction(ILOCInstruction insn)
insn
- New instructionpublic ILOCBasicBlock getEntryBlock()
public void buildCFG()
public void temp(List<ILOCBasicBlock> allBlocks)
public void findUnitializedVars(boolean strictFlag)
strictFlag
- - if true will report on variables that can be defined
as: "being read with no prior definition in at least one of
the predecessor blocks" if passed false, will report all
variables that can be described as: "being read with no prior
definition in all of the previous blocks"public void findBlockVars(Set<Integer> seen, ILOCBasicBlock current, Set<Integer> candidates, Map<Integer,String> varMap)
seen
- - the set of currently live variablescurrent
- - the current basic blockcandidates
- - the set of possibly uninitialized variablesvarMap
- - mapping from variable offsets to variable namespublic void flattenCFG()
Copyright © 2019. All rights reserved.