java.lang.Object
com.voytechs.jnetstream.npl.Node
com.voytechs.jnetstream.npl.NodeList
com.voytechs.jnetstream.npl.ArrayDimensionNode
- All Implemented Interfaces:
- Visitable
- public class ArrayDimensionNode
- extends NodeList
Support class that allows muti-dimensional array manipulation.
Since array references can have dynamic code associated with array lookup,
a number of convenience functions are performed by the class.
1) Bounds checking for MAX and MIN bounds for all dimensions.
2) Node traversal for each dimension
3) Scalar array size computation which also needs to be done at run time
because of dynamic code.
| Fields inherited from class com.voytechs.jnetstream.npl.NodeList |
|
| Fields inherited from class com.voytechs.jnetstream.npl.Node |
token |
| Methods inherited from class com.voytechs.jnetstream.npl.NodeList |
add, add, addFirst, addLast, canOptimize, clear, contains, empty, get, getBoolean, getFirst, getInt, getLast, getString, indexOf, merge, optimize, remove, remove, size, toString, visit |
debug
private static final boolean debug
- See Also:
- Constant Field Values
constantDimension
private boolean constantDimension
scalarSize
private int scalarSize
ArrayDimensionNode
public ArrayDimensionNode()
toScalar
public int toScalar(ArrayDimensionNode dim)
throws NodeException
- Returns the scalar equivelent value of the entire array.
Since the value has to be evaluated dynamically, there some caching of the
value is done to improve performance.
toScalar
public int toScalar()
throws NodeException
calculateScalarSize
public int calculateScalarSize(ArrayDimensionNode dim)
throws NodeException
- Calculates the scalar dimension of the entire array. This is how many
elements the array takes overall.
calculateScalarSize
protected static int calculateScalarSize(ArrayDimensionNode max,
ArrayDimensionNode dim)
throws NodeException
calculateArraySize
public int calculateArraySize()
throws NodeException
calculateArraySize
protected static int calculateArraySize(ArrayDimensionNode max,
int level)
throws NodeException
createLabel
public java.lang.String createLabel(int scalar)
throws NodeException
checkBoundary
public boolean checkBoundary(ArrayDimensionNode dim)
throws NodeException
- Checks that "dim" is within allocated limits of the array dimension.
evaluateToStatic
public ArrayDimensionNode evaluateToStatic()
throws NodeException
- This method evaluates the code to its NodeInt equivelent and
creates a new Dimension object with static values. This is needed
for when arrays are first instantiated, the dynamic code can only be
run once, otherwise array dimensions could suddenly change on us.
Make sure this method is called only when all the reference have been resolved
and context loaded with primitives. Otherwise an NodeException will be thrown if
references can not be properly dereferenced.
main
public static void main(java.lang.String[] args)
- Test function for ArrayDimensionNode