Revision: 4145 http://vexi.svn.sourceforge.net/vexi/?rev=4145&view=rev Author: mkpg2 Date: 2011-05-20 01:21:09 +0000 (Fri, 20 May 2011)
Log Message: ----------- Feature. Support properties on functions. Modified Paths: -------------- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java Added Paths: ----------- trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java 2011-05-18 17:14:47 UTC (rev 4144) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java 2011-05-20 01:21:09 UTC (rev 4145) @@ -12,7 +12,7 @@ public class JSFunction extends JS.Immutable implements ByteCodes, Tokens{ final Function f; - + JS.Obj object; Scope parentScope; ///< the default scope to use as a parent scope when executing this @@ -28,9 +28,17 @@ if("apply".equals(JSU.toString(key))) //return METHOD; return new Apply(this); - return super.get(key); + if(object==null) return null; + return object.get(key); } + public void put(JS key, JS val) throws JSExn { + if(object==null) { + object = new JS.Obj(); + } + object.put(key, val); + } + public JS apply(JS this_, JS[] args) throws JSExn{ // UNIDEAL .. we are prevented from yielding after apply is called // (until it returns). Added: trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js =================================================================== --- trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js (rev 0) +++ trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js 2011-05-20 01:21:09 UTC (rev 4145) @@ -0,0 +1,9 @@ +// simple + +var f = function(){ + return callee.prop; +}; +f.prop = 1; + +assert(f.prop==1); +assert(f()==1); \ No newline at end of file Property changes on: trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js ___________________________________________________________________ Added: svn:mime-type + text/plain 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