Revision: 20419
          http://sourceforge.net/p/jmol/code/20419
Author:   hansonr
Date:     2015-03-31 12:24:14 +0000 (Tue, 31 Mar 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.13_2015.03.30" 

bug fix: {hash}.Key = value will be stored as "key" rather than "Key" if "key" 
is also a user-defined function.
bug fix: {hash}.key will fail if "key" is also a user-defined function. 
bug fix: print a  where a is an associative arrays fails in JavaScript (since 
jmol-14.3.7_2014.08.25) 

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/script/ScriptExpr.java
    trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java

Modified: trunk/Jmol/src/org/jmol/script/ScriptExpr.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptExpr.java      2015-03-31 04:44:02 UTC 
(rev 20418)
+++ trunk/Jmol/src/org/jmol/script/ScriptExpr.java      2015-03-31 12:24:14 UTC 
(rev 20419)
@@ -141,8 +141,8 @@
    *        variables
    * @param localVar
    *        x or y in above for(), select() examples
-   * @param isSpecialAssignment 
-   *        x[n] = .... 
+   * @param isSpecialAssignment
+   *        x[n] = ....
    * @return either a vector or a value, caller's choice.
    * @throws ScriptException
    *         errors are thrown directly to the Eval error system.
@@ -150,7 +150,9 @@
   private Object parameterExpression(int pt, int ptMax, String key,
                                      boolean ignoreComma, boolean asVector,
                                      int ptAtom, boolean isArrayItem,
-                                     Map<String, SV> localVars, String 
localVar, boolean isSpecialAssignment)
+                                     Map<String, SV> localVars,
+                                     String localVar,
+                                     boolean isSpecialAssignment)
       throws ScriptException {
 
     /*
@@ -175,8 +177,8 @@
     if (ptMax < pt)
       ptMax = slen;
     int ptEq = (isSpecialAssignment ? 0 : 1);
-    ScriptMathProcessor rpn = new ScriptMathProcessor(this, 
isSpecialAssignment, isArrayItem, asVector,
-        false, false, key);
+    ScriptMathProcessor rpn = new ScriptMathProcessor(this,
+        isSpecialAssignment, isArrayItem, asVector, false, false, key);
     Object v, res;
     int nSquare = 0;
     int nParen = 0;
@@ -190,7 +192,7 @@
             : getBitsetPropertySelector(i));
         if (token != null) {
           rpn.addX(localVars.get(localVar));
-          if (!rpn.addOpAllowMath(token, (tokAt(i + 1) == T.leftparen)))
+          if (!rpn.addOpAllowMath(token, (tokAt(i + 1) == T.leftparen), 
T.nada))
             invArg();
           if ((token.intValue == T.function || token.intValue == T.parallel)
               && tokAt(iToken + 1) != T.leftparen) {
@@ -357,7 +359,7 @@
       // these next are for the within() command
       case T.plane:
         if (tokAt(iToken + 1) == T.leftparen) {
-          if (!rpn.addOpAllowMath(theToken, true))
+          if (!rpn.addOpAllowMath(theToken, true, T.nada))
             invArg();
           break;
         }
@@ -438,7 +440,7 @@
         i = iToken;
         if (nParen == 0 && isOneExpressionOnly) {
           iToken++;
-          return listBS((BS)v);
+          return listBS((BS) v);
         }
         break;
       case T.spacebeforesquare:
@@ -503,11 +505,13 @@
             getToken(iToken + 2);
           }
         }
-        allowMathFunc &= (tokAt(iToken + 1) == T.leftparen || isUserFunction);
-        if (!rpn.addOpAllowMath(var, allowMathFunc))
+        int tokNext = tokAt(iToken + 1);
+        allowMathFunc &= (tokNext == T.leftparen || isUserFunction);
+        if (!rpn.addOpAllowMath(var, allowMathFunc, isUserFunction ? tokNext
+            : T.nada))
           invArg();
         i = iToken;
-        if (var.intValue == T.function && tokAt(i + 1) != T.leftparen) {
+        if (var.intValue == T.function && tokNext != T.leftparen) {
           rpn.addOp(T.tokenLeftParen);
           rpn.addOp(T.tokenRightParen);
         }
@@ -564,12 +568,14 @@
           // first check to see if the variable has been defined already
           String name = paramAsStr(i).toLowerCase();
           boolean haveParens = (tokAt(i + 1) == T.leftparen);
-          if (chk) {
-            v = name;
-          } else if (!haveParens
-              && (localVars == null || (v = PT.getMapValueNoCase(localVars, 
name)) == null && allContext)) {
-            v = getContextVariableAsVariable(name);
-          }
+          if (!haveParens)
+            if (chk) {
+              v = name;
+            } else if (localVars == null
+                || (v = PT.getMapValueNoCase(localVars, name)) == null
+                && allContext) {
+              v = getContextVariableAsVariable(name);
+            }
           if (v == null) {
             if (T.tokAttr(theTok, T.identifier) && vwr.isFunction(name)) {
               if (!rpn.addOp(SV.newV(T.function, theToken.value)))

Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2015-03-31 
04:44:02 UTC (rev 20418)
+++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2015-03-31 
12:24:14 UTC (rev 20419)
@@ -409,10 +409,10 @@
    * @throws ScriptException
    */
   public boolean addOp(T op) throws ScriptException {
-    return addOpAllowMath(op, true);
+    return addOpAllowMath(op, true, T.nada);
   }
 
-  boolean addOpAllowMath(T op, boolean allowMathFunc) throws ScriptException {
+  boolean addOpAllowMath(T op, boolean allowMathFunc, int tokNext) throws 
ScriptException {
 
     if (debugHigh) {
       dumpStacks("adding " + op + " wasx=" + wasX);
@@ -495,8 +495,16 @@
     default:
       if (isMathFunc) {
         boolean isArgument = (oPt >= 1 && tok0 == T.leftparen);
-        if (!isDotSelector && wasX && !isArgument)
+        if (isDotSelector) {
+          if (tokNext == T.leftparen) {
+          // check for {hash}.x(), which is not allowed
+          // if this is desired, one needs to use {hash}..x()
+            if (xStack[xPt].tok == T.hash)
+              return false;
+          }
+        } else if (wasX && !isArgument) {
           return false;
+        }
         newOp = op;
         isLeftOp = true;
         break;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to