Class ScriptMathProcessor

java.lang.Object
org.jmol.script.ScriptMathProcessor

public class ScriptMathProcessor extends Object
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 Details

    • wasX

      public boolean wasX
    • asBitSet

      public boolean asBitSet
    • oPt

      public int oPt
  • Method Details

    • endAssignment

      public boolean endAssignment()
    • addXCopy

      public boolean addXCopy(SV x)
    • addX

      public boolean addX(SV x)
    • addXObj

      public boolean addXObj(Object x)
    • addXStr

      public boolean addXStr(String x)
    • addXBool

      public boolean addXBool(boolean x)
    • addXInt

      public boolean addXInt(int x)
    • addXList

      public boolean addXList(Lst<?> x)
    • addXMap

      public boolean addXMap(Map<String,?> x)
    • addXM3

      public boolean addXM3(M3 x)
    • addXM4

      public boolean addXM4(M4 x)
    • addXFloat

      public boolean addXFloat(float x)
    • addXBs

      public boolean addXBs(BS bs)
    • addXPt

      public boolean addXPt(P3 pt)
    • addXPt4

      public boolean addXPt4(P4 pt)
    • addXNum

      public boolean addXNum(T x) throws ScriptException
      Throws:
      ScriptException
    • addXAV

      public boolean addXAV(SV[] x)
    • addXAD

      public boolean addXAD(double[] x)
    • addXAS

      public boolean addXAS(String[] x)
    • addXAI

      public boolean addXAI(int[] x)
    • addXAII

      public boolean addXAII(int[][] x)
    • addXAF

      public boolean addXAF(float[] x)
    • addXAFF

      public boolean addXAFF(float[][] x)
    • addOp

      public boolean addOp(T op) throws ScriptException
      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
    • getX

      public SV getX() throws ScriptException
      Throws:
      ScriptException
    • getXTok

      public int getXTok()
    • binaryOp

      public boolean binaryOp(T op, SV x1, SV x2) throws ScriptException
      Throws:
      ScriptException
    • ptValue

      public P3 ptValue(SV x, BS bsRestrict) throws ScriptException
      Throws:
      ScriptException
    • getMatrix4f

      public static M4 getMatrix4f(M3 matRotate, T3 vTranslate)