Package org.jmol.script
Class ScriptMathProcessor
java.lang.Object
org.jmol.script.ScriptMathProcessor
Reverse Polish Notation Engine for IF, SET, and @{...}
Just a (not so simple?) RPN processor that can handle boolean, int, float,
String, Point3f, BitSet, Array, Hashtable, Matrix3f, Matrix4f
-- Bob Hanson 2/16/2007
- Author:
- hansonr
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
boolean
private boolean
private boolean
private int
private boolean
private boolean
private boolean
private int
private ScriptExpr
private boolean
private int
private char[]
private boolean
private boolean
private boolean
private SV
int
private T[]
private int
private int
private int
private int
private static final String
private boolean
private int
private Viewer
private boolean
boolean
private int
private SV[]
-
Constructor Summary
ConstructorsConstructorDescriptionScriptMathProcessor
(ScriptExpr eval, boolean isSpecialAssignment, boolean isArrayItem, boolean asVector, boolean asBitSet, boolean allowUnderflow, String key) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addOp The primary driver of the Reverse Polish Notation evaluation engine.(package private) boolean
addOpAllowMath
(T op, boolean allowMathFunc, int tokNext) boolean
boolean
addXAD
(double[] x) boolean
addXAF
(float[] x) boolean
addXAFF
(float[][] x) boolean
addXAI
(int[] x) boolean
addXAII
(int[][] x) boolean
boolean
boolean
addXBool
(boolean x) boolean
addXBs
(javajs.util.BS bs) boolean
boolean
addXFloat
(float x) boolean
addXInt
(int x) boolean
addXList
(javajs.util.Lst<?> x) boolean
addXM3
(javajs.util.M3 x) boolean
addXM4
(javajs.util.M4 x) boolean
boolean
boolean
boolean
addXPt
(javajs.util.P3 pt) boolean
addXPt4
(javajs.util.P4 pt) boolean
boolean
private boolean
private boolean
(package private) void
dumpStacks
(String message) boolean
private boolean
evaluateFunction
(int tok) private boolean
getAllProperties
(SV x2, String abbr) private boolean
getBoundBox
(SV x2) static javajs.util.M4
getMatrix4f
(javajs.util.M3 matRotate, javajs.util.T3 vTranslate) private boolean
getPointOrBitsetOperation
(T op, SV x2) (package private) SV
getX()
int
getXTok()
private boolean
private static boolean
private boolean
operate()
javajs.util.P3
private void
putIf
(char c) private void
private void
private static String
-
Field Details
-
wasX
public boolean wasX -
asBitSet
public boolean asBitSet -
oPt
public int oPt -
chk
private boolean chk -
wasSyntaxCheck
private boolean wasSyntaxCheck -
debugHigh
private boolean debugHigh -
eval
-
vwr
-
oStack
-
xStack
-
ifStack
private char[] ifStack -
ifPt
private int ifPt -
xPt
private int xPt -
parenCount
private int parenCount -
squareCount
private int squareCount -
braceCount
private int braceCount -
isArrayItem
private boolean isArrayItem -
asVector
private boolean asVector -
haveSpaceBeforeSquare
private boolean haveSpaceBeforeSquare -
equalCount
private int equalCount -
ptid
private int ptid -
ptx
private int ptx -
pto
private int pto -
isSpecialAssignment
private boolean isSpecialAssignment -
doSelections
private boolean doSelections -
assignLeft
private boolean assignLeft -
allowUnderflow
private boolean allowUnderflow -
isAssignment
private boolean isAssignment -
skipping
private boolean skipping -
lastAssignedString
-
qMods
- See Also:
-
-
Constructor Details
-
ScriptMathProcessor
ScriptMathProcessor(ScriptExpr eval, boolean isSpecialAssignment, boolean isArrayItem, boolean asVector, boolean asBitSet, boolean allowUnderflow, String key) - Parameters:
eval
-isSpecialAssignment
- x[n] = ...isArrayItem
-asVector
- return a Lst(SV) from getResult()asBitSet
- return a (SV)bitsetallowUnderflow
- expression can terminate prior to end of statementkey
-
-
-
Method Details
-
endAssignment
public boolean endAssignment() -
getResult
- Throws:
ScriptException
-
putX
-
putOp
-
putIf
private void putIf(char c) -
addXCopy
-
addX
-
addXObj
-
addXStr
-
addXBool
public boolean addXBool(boolean x) -
addXInt
public boolean addXInt(int x) -
addXList
public boolean addXList(javajs.util.Lst<?> x) -
addXMap
-
addXM3
public boolean addXM3(javajs.util.M3 x) -
addXM4
public boolean addXM4(javajs.util.M4 x) -
addXFloat
public boolean addXFloat(float x) -
addXBs
public boolean addXBs(javajs.util.BS bs) -
addXPt
public boolean addXPt(javajs.util.P3 pt) -
addXPt4
public boolean addXPt4(javajs.util.P4 pt) -
addXNum
- Throws:
ScriptException
-
addXAV
-
addXAD
public boolean addXAD(double[] x) -
addXAS
-
addXAI
public boolean addXAI(int[] x) -
addXAII
public boolean addXAII(int[][] x) -
addXAF
public boolean addXAF(float[] x) -
addXAFF
public boolean addXAFF(float[][] x) -
isOpFunc
-
addOp
addOp The primary driver of the Reverse Polish Notation evaluation engine. This method loads operators onto the oStack[] and processes them based on a precedence system. Operands are added by addX() onto the xStack[]. We check here for syntax issues that were not caught in the compiler. I suppose that should be done at compilation stage, but this is how it is for now. The processing of functional arguments and (___?___:___) constructs is carried out by pushing markers onto the stacks that later can be used to fill argument lists or turn "skipping" on or off. Note that in the case of skipped sections of ( ? : ) no attempt is made to do syntax checking. [That's not entirely true -- when syntaxChecking is true, that is, when the user is typing at the Jmol application console, then this code is being traversed with dummy variables. That could be improved, for sure. Actually, there's plenty of room for improvement here. I did this based on what I learned in High School in 1974 -- 35 years ago! -- when I managed to build a mini FORTRAN compiler from scratch in machine code. That was fun. (This was fun, too.) -- Bob Hanson, hansonr@stolaf.edu 6/9/2009- Parameters:
op
-- Returns:
- false if an error condition arises
- Throws:
ScriptException
-
addOpAllowMath
- Throws:
ScriptException
-
checkSkip
-
doSelection
private boolean doSelection() -
dumpStacks
-
getX
- Throws:
ScriptException
-
getXTok
public int getXTok() -
evaluateFunction
- Throws:
ScriptException
-
operate
- Throws:
ScriptException
-
binaryOp
- Throws:
ScriptException
-
isDecimal
-
ptValue
- Throws:
ScriptException
-
typeOf
-
getAllProperties
- Throws:
ScriptException
-
getMatrix4f
public static javajs.util.M4 getMatrix4f(javajs.util.M3 matRotate, javajs.util.T3 vTranslate) -
getBoundBox
-
getPointOrBitsetOperation
- Throws:
ScriptException
-