FGArrow

public final class FGArrow

An arrow in the Flow Graph.

Fields

carry

public Object carry

cases

public TapIntList cases

destination

public Block destination

inACycle

public boolean inACycle

Boolean which is true for arrows that go to the header of a SYNTACTIC loop, i.e. a Do loop, back from syntactically INSIDE the loop, without going through the outside of the loop.

isAJumpIntoNextCase

public boolean isAJumpIntoNextCase

Boolean which is true when this arrow is a jump from a switch case to the next switch case.

iter

public TapList<TapPair<Integer, LoopBlock>> iter

The “iter” field represents the effect of this FGArrow with respect to loops, i.e. the list of loops that this arrow POPs from, followed by the loop it CYCLE’s in or by the list of loops it PUSH’es into. It contains a list of TapPair’s, whose first element is the action in {POP, PUSH, CYCLE}, and the second the loop.

origin

public Block origin

rank

public int rank

reachable

public boolean reachable

Mark if the arrow is reachable during runtime. Can be set to false when we can infer that a conditional will be always true or false for example.

test

public int test

Constructors

FGArrow

public FGArrow(Block origin, int test, int cas, Block destination)

Creates a new FGArrow, and sets it from Block “origin” to Block “destination”, with “test” and “cas”. Adds this arrow to the corresponding flow and backFlow.

FGArrow

public FGArrow(Block origin, int test, TapIntList cases, Block destination)

FGArrow

public FGArrow(Block origin, int test, int cas, Block destination, boolean inCycle)

FGArrow

public FGArrow(Block origin, int test, TapIntList cases, Block destination, boolean inCycle)

FGArrow

public FGArrow()

Methods

coherence

public void coherence()

Fills the field iter that summarizes the movement across nested loops structure. Also sets all the references to this FGArrow into the entryBlocks, exitBlocks, entryArrows, exitArrows, and cycleArrows of LoopBlocks.

commonSymbolTable

public SymbolTable commonSymbolTable()

containsCase

public boolean containsCase(int oneCase)

delete

public void delete()

Deletes this FGArrow. Removes it from the flow from its origin and from the backFlow to its destination.

dump

public void dump()

Prints in detail the contents of this FGArrow, onto TapEnv.curOutputStream().

dumpTestCaseCarry

protected void dumpTestCaseCarry()

exitsFromLoopAndLoopSymbolTable

public boolean exitsFromLoopAndLoopSymbolTable()
Returns

True when this FGArrow exits from a loop and this loop has a loop local SymbolTable

finalCycle

public LoopBlock finalCycle()
Returns

the LoopBlock of the loop level in which “this” FGArrow finally cycles.

goesInsideControl

public boolean goesInsideControl()

insertBlockAtDest

public FGArrow insertBlockAtDest(Block block, int test, int cas)

Inserts “block” between the current origin and current destination of this FGArrow, so that this FGArrow now designates the arrow that flows INTO the given “block”.

Returns

the newly created arrow that flows FROM the given “block”.

insertBlockAtOrig

public void insertBlockAtOrig(Block block, int test, int cas)

Inserts “block” between the current origin and current destination of this FGArrow, so that this FGArrow now designates the arrow that flows FROM the given “block”.

isCyclingArrow

public boolean isCyclingArrow()
Returns

true if this arrow goes back to the header of a loop, comes from inside this loop, and is not considered going “out-then-back-in” this loop.

mayBeNatural

public boolean mayBeNatural()

used in treeGen.

mergeCases

public void mergeCases(FGArrow newArrow)

Assume that this FGArrow and “newArrow” have same origin and destination. This function tries to merge the two FGArrows’ test/cases into the test/case of this FGArrow.

redirectDestination

public void redirectDestination(Block block)

Redirects the destination of this FGArrow to “block”. If block==null, this disconnects this FGArrow from its destination.

redirectDestination

public void redirectDestination(Block block, boolean cycle)

Redirects the destination of this FGArrow to “block” and may declare this FGArrow a cycle in the loop headed by “block”.

redirectOrigin

public void redirectOrigin(Block block)

Redirects the origin of this FGArrow to “block”. If block==null, this disconnects this FGArrow from its origin.

setRank

public void setRank(int rank)

testAndCasesToString

public static String testAndCasesToString(int test, TapIntList cases)

toString

public String toString()

topmostPop

public Block topmostPop()
Returns

the LoopBlock of the topmost loop level that “this” FGArrow pops from. If this arrow does not POP, returns the plain origin Block of this arrow.

turnNomatchIntoDefault

public void turnNomatchIntoDefault()

Turns the unique final NOMATCH case after a switch into a DEFAULT (which will also be unique and final).