Revision: 4147 http://vexi.svn.sourceforge.net/vexi/?rev=4147&view=rev Author: mkpg2 Date: 2011-05-20 03:00:36 +0000 (Fri, 20 May 2011)
Log Message: ----------- Fix. Safe navigation use null check not falsiness. Works for e.g. ""?.length Modified Paths: -------------- trunk/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java trunk/org.vexi-library.js/src/test/java/test/js/exec/general/truthiness.js Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java 2011-05-20 01:56:20 UTC (rev 4146) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java 2011-05-20 03:00:36 UTC (rev 4147) @@ -673,9 +673,18 @@ // safe navigation case HOOK_LB: case HOOK_DOT: { - b.add(parserLine, DUP); - b.add(parserLine, JF, integer(0)); // jump to the end - int jump = b.size; + b.add(parserLine, DUP); + b.add(parserLine, LITERAL, null); + b.add(parserLine, SHNE); + b.add(parserLine, JT, integer(0)); // jump to the end + int jump1 = b.size; + b.add(parserLine, POP); + b.add(parserLine, LITERAL, null); // + b.add(parserLine, JMP, integer(0)); // jump to the end + b.set(jump1 - 1, integer(b.size - jump1 + 1)); // now we know where the target of the jump is + int jump2 = b.size; + + if(tok==HOOK_DOT){ consume(NAME); b.add(parserLine, LITERAL, string(string)); @@ -684,7 +693,7 @@ consume(RB); } continueExprAfterAssignable(b,minPrecedence,null); - b.set(jump - 1, integer(b.size - jump + 1)); // now we know where the target of the jump is + b.set(jump2 - 1, integer(b.size - jump2 + 1)); // now we know where the target of the jump is // the top item of the stack is either the object before the ? or break; } Modified: trunk/org.vexi-library.js/src/test/java/test/js/exec/general/truthiness.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/general/truthiness.js 2011-05-20 01:56:20 UTC (rev 4146) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/general/truthiness.js 2011-05-20 03:00:36 UTC (rev 4147) @@ -30,11 +30,15 @@ //////// == assert(1==true); assert(0==false); -assert(""==false); assert(null!=false); assert("true"!=true); assert(-1e-6!=null); +// STUPID js standard +//assert(""==false); +assert(""!=false); +assert(!!""==false); + //////// === assert(1!==true); assert(0!==false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ What Every C/C++ and Fortran developer Should Know! Read this article and learn how Intel has extended the reach of its next-generation tools to help Windows* and Linux* C/C++ and Fortran developers boost performance applications - including clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn