Revision: 20420 http://sourceforge.net/p/jmol/code/20420 Author: hansonr Date: 2015-03-31 12:24:18 +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: -------------- branches/v14_2/Jmol/src/org/jmol/script/ScriptExpr.java branches/v14_2/Jmol/src/org/jmol/script/ScriptMathProcessor.java Modified: branches/v14_2/Jmol/src/org/jmol/script/ScriptExpr.java =================================================================== --- branches/v14_2/Jmol/src/org/jmol/script/ScriptExpr.java 2015-03-31 12:24:14 UTC (rev 20419) +++ branches/v14_2/Jmol/src/org/jmol/script/ScriptExpr.java 2015-03-31 12:24:18 UTC (rev 20420) @@ -188,7 +188,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) { @@ -355,7 +355,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; } @@ -436,7 +436,7 @@ i = iToken; if (nParen == 0 && isOneExpressionOnly) { iToken++; - return listBS((BS)v); + return listBS((BS) v); } break; case T.spacebeforesquare: @@ -501,11 +501,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); } @@ -562,12 +564,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: branches/v14_2/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- branches/v14_2/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2015-03-31 12:24:14 UTC (rev 20419) +++ branches/v14_2/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2015-03-31 12:24:18 UTC (rev 20420) @@ -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