+22
-6
@@ -56,3 +56,2 @@ var assert = require('assert') | ||
| function isRecursive (fn) { | ||
@@ -90,2 +89,3 @@ var {name, body} = parseFun(fn) | ||
| var H = 0 | ||
| function loopify(fn, argv, scope) { | ||
@@ -100,9 +100,14 @@ var hygene = 1 | ||
| //if so, unroll the recursion. | ||
| scope = createScope(fn, (k, i) => argv[i], scope) | ||
| var _inline = a => inline_expr(a, scope, fn, hygene) | ||
| var _inline = a => { | ||
| return inline_expr(a, scope, fn, hygene) | ||
| } | ||
| var r = inline_expr(test, scope, fn, hygene) | ||
| if(isBasic(r)) return _inline(r ? result : recurse) | ||
| var _scope = createScope(fn, (k, i) => argv[i], scope) | ||
| var r = inline_expr(test, _scope, fn, hygene) | ||
| if(isBasic(r)) { | ||
| return inline_expr(r ? result : recurse, _scope, fn, hygene) | ||
| } | ||
| //else, make sure we don't override the parameters! | ||
| //(doesn't work without this...) | ||
| scope = createScope(fn, (k, i) => args[i], scope) | ||
@@ -117,2 +122,5 @@ | ||
| // loopify a function that is exported. | ||
| // I havn't actually needed this, because usually | ||
| // the looping function is an internal closure. | ||
| function loopify_fun(fn, scope) { | ||
@@ -181,3 +189,2 @@ var hygene = 1 | ||
| var v = R(body[2]) //didn't forget to recurse into value this time! | ||
| //console.log("INLINE_def", k, v, remap) | ||
@@ -215,2 +222,11 @@ //okay problem is we are inlining a function that can see | ||
| //note, we already attempted to inline the args just above ---` | ||
| /* | ||
| // HMM what was this fixing? | ||
| // I added this, but now removing it makes the tests pass... | ||
| if(isFunction (value) && | ||
| //XXX VERY UGLY HACK TO NOT INLINE SIDE EFFECTS | ||
| /^(?:get_|set_|i32_store|i32_load)/.test(body[0].description)) { | ||
| return [body[0]].concat(args) | ||
| } | ||
| */ | ||
| if(isFunction (value) && args.every(isBasic)) | ||
@@ -217,0 +233,0 @@ return value.apply(null, args) |
+1
-1
| { | ||
| "name": "acidlisp", | ||
| "description": "a lisp for webassembly", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "homepage": "https://github.com/dymynyc/acidlisp", | ||
@@ -6,0 +6,0 @@ "repository": { |
+2
-0
@@ -117,2 +117,4 @@ var syms = require('./symbols') | ||
| //let the inliner handle them. | ||
| if(!_value) | ||
| throw new Error('undefined variable:'+ast[i].description) | ||
| if(_value.hasValue !== false) ast[i] = _value.value | ||
@@ -119,0 +121,0 @@ } |
426185
0.13%3016
0.63%