khepri-compile
Advanced tools
Comparing version 0.3.6 to 0.3.7
/* | ||
* THIS FILE IS AUTO GENERATED from 'lib/ast.kep' | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/ast.kep' | ||
* DO NOT EDIT | ||
*/"use strict"; | ||
*/ | ||
"use strict"; | ||
var isLiteral, isNumberish, isPrimitive, isSimple, isPod, isTruthy, isBlockFunction, isLambda, getUid; | ||
@@ -6,0 +7,0 @@ (isLiteral = (function(node) { |
/* | ||
* THIS FILE IS AUTO GENERATED from 'lib/builtin.kep' | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/builtin.kep' | ||
* DO NOT EDIT | ||
*/"use strict"; | ||
*/ | ||
"use strict"; | ||
var ast_node = require("khepri-ast")["node"], | ||
@@ -41,5 +42,9 @@ setData = ast_node["setData"], | ||
unaryOp = (function(op) { | ||
return unary((function(x) { | ||
var op0 = (function(x) { | ||
return ast_expression.UnaryExpression.create(null, op, x); | ||
})); | ||
}), | ||
xArg = identifier(null, "x", unique()); | ||
return ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern.create(null, null, [ | ||
ast_pattern.IdentifierPattern.create(null, xArg) | ||
]), op0(xArg)); | ||
}); | ||
@@ -54,11 +59,17 @@ [ | ||
].forEach((function(__o) { | ||
var op = __o[0], | ||
var op0, op1, xArg, op = __o[0], | ||
name = __o[1]; | ||
registerAliasedSymbol(op, name, unaryOp(op)); | ||
registerAliasedSymbol(op, name, ((op0 = op), (op1 = (function(x) { | ||
return ast_expression.UnaryExpression.create(null, op0, x); | ||
})), (xArg = identifier(null, "x", unique())), ast_expression.FunctionExpression.create(null, null, | ||
ast_pattern.ArgumentsPattern.create(null, null, [ast_pattern.IdentifierPattern.create(null, | ||
xArg)]), op1(xArg)))); | ||
})); | ||
var xArg, yArg, zArg, ternaryOperator = ((xArg = identifier(null, "x", unique())), (yArg = identifier(null, "y", unique())), ( | ||
zArg = identifier(null, "z", unique())), ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern | ||
.create(null, null, [ast_pattern.IdentifierPattern.create(null, xArg), ast_pattern.IdentifierPattern.create( | ||
null, yArg), ast_pattern.IdentifierPattern.create(null, zArg)]), ast_expression.ConditionalExpression.create( | ||
null, xArg, yArg, zArg))); | ||
var xArg = identifier(null, "x", unique()), | ||
yArg = identifier(null, "y", unique()), | ||
zArg = identifier(null, "z", unique()), | ||
ternaryOperator = ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern.create(null, | ||
null, [ast_pattern.IdentifierPattern.create(null, xArg), ast_pattern.IdentifierPattern.create(null, yArg), | ||
ast_pattern.IdentifierPattern.create(null, zArg) | ||
]), ast_expression.ConditionalExpression.create(null, xArg, yArg, zArg)); | ||
registerAliasedSymbol("?", "__cond", ternaryOperator); | ||
@@ -65,0 +76,0 @@ var binary = (function(flipped, op) { |
/* | ||
* THIS FILE IS AUTO GENERATED from 'lib/compile.kep' | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/compile.kep' | ||
* DO NOT EDIT | ||
*/"use strict"; | ||
*/ | ||
"use strict"; | ||
var pre_normalize = require("./stages/pre_normalize"), | ||
@@ -6,0 +7,0 @@ lexical = require("./stages/lexical"), |
@@ -10,9 +10,11 @@ /* | ||
khepriZipper = __o["khepriZipper"], | ||
__o0 = require("neith")["walk"], | ||
neithWalk = __o0["walk"], | ||
__o0 = require("neith")["zipper"], | ||
detach = __o0["detach"], | ||
__o1 = require("neith")["walk"], | ||
neithWalk = __o1["walk"], | ||
tree = require("neith")["tree"], | ||
__o1 = require("khepri-ast")["node"], | ||
Node = __o1["Node"], | ||
setUserData = __o1["setUserData"], | ||
setData = __o1["setData"], | ||
__o2 = require("khepri-ast")["node"], | ||
Node = __o2["Node"], | ||
setUserData = __o2["setUserData"], | ||
setData = __o2["setData"], | ||
ast_declaration = require("khepri-ast")["declaration"], | ||
@@ -23,6 +25,6 @@ ast_statement = require("khepri-ast")["statement"], | ||
ast_value = require("khepri-ast")["value"], | ||
__o2 = require("akh")["base"], | ||
next = __o2["next"], | ||
seq = __o2["sequence"], | ||
seqa = __o2["sequencea"], | ||
__o3 = require("akh")["base"], | ||
next = __o3["next"], | ||
seq = __o3["sequence"], | ||
seqa = __o3["sequencea"], | ||
Unique = require("akh")["unique"], | ||
@@ -32,9 +34,10 @@ StateT = require("akh")["trans"]["state"], | ||
walk = require("zipper-m")["walk"], | ||
__o3 = require("./builtin"), | ||
builtins = __o3["builtins"], | ||
definitions = __o3["definitions"], | ||
__o4 = require("./ast"), | ||
getUid = __o4["getUid"], | ||
isLambda = __o4["isLambda"], | ||
__o5 = require("./builtin"), | ||
builtins = __o5["builtins"], | ||
definitions = __o5["definitions"], | ||
fun = require("./fun"), | ||
optimize, State = record.declare(null, ["bindings", "globals"]), | ||
optimize, visit, State = record.declare(null, ["bindings", "globals"]), | ||
M = ZipperT(StateT(Unique)), | ||
@@ -82,7 +85,7 @@ run = (function(c, ctx, state, seed) { | ||
return tree.node(neithWalk((function(ctx) { | ||
var node = tree.node(ctx); | ||
return ((((node && node.ud) && node.ud.uid) && (list.indexOf(node.ud.uid) !== -1)) ? tree.modifyNode( | ||
(function(node) { | ||
return setData(node, "uid", ((base + "-") + node.ud.uid)); | ||
}), ctx) : ctx); | ||
var node = tree.node(ctx), | ||
uid = getUid(node); | ||
return ((list.indexOf(uid) >= 0) ? tree.modifyNode((function(node) { | ||
return setData(node, "uid", ((base + "-") + uid)); | ||
}), ctx) : ctx); | ||
}), (function(x) { | ||
@@ -92,2 +95,4 @@ return x; | ||
}), | ||
UP = true, | ||
DOWN = false, | ||
peepholes = ({}), | ||
@@ -107,7 +112,7 @@ addPeephole = (function(types, up, test, f) { | ||
}); | ||
addPeephole(["UnaryOperatorExpression"], false, always, node.chain((function(__o) { | ||
addPeephole(["UnaryOperatorExpression"], DOWN, always, node.chain((function(__o) { | ||
var op = __o["op"]; | ||
return seq(addGlobal(op), set(builtins[op])); | ||
}))); | ||
addPeephole(["BinaryOperatorExpression"], false, always, node.chain((function(__o) { | ||
addPeephole(["BinaryOperatorExpression"], DOWN, always, node.chain((function(__o) { | ||
var op = __o["op"], | ||
@@ -118,17 +123,17 @@ flipped = __o["flipped"], | ||
}))); | ||
addPeephole(["TernaryOperatorExpression"], false, always, seq(addGlobal("?"), set(builtins["?"]))); | ||
addPeephole(["VariableDeclarator"], true, (function(node) { | ||
addPeephole(["TernaryOperatorExpression"], DOWN, always, seq(addGlobal("?"), set(builtins["?"]))); | ||
addPeephole(["VariableDeclarator"], UP, (function(node) { | ||
return (((node.immutable && node.init) && isLambda(node.init)) && false); | ||
}), node.chain((function(node) { | ||
return addBinding(node.id.ud.uid, node.init); | ||
return addBinding(getUid(node.id), node.init); | ||
}))); | ||
addPeephole(["Binding"], true, (function(node) { | ||
addPeephole(["Binding"], UP, (function(node) { | ||
return (((node.pattern.id && node.pattern.id.ud) && (!node.recursive)) && isLambda(node.value)); | ||
}), node.chain((function(node) { | ||
return addBinding(node.pattern.id.ud.uid, node.value); | ||
return addBinding(getUid(node.pattern.id), node.value); | ||
}))); | ||
addPeephole(["CallExpression"], true, (function(node) { | ||
return ((node.callee.type === "Identifier") && node.callee.ud.uid); | ||
addPeephole(["CallExpression"], UP, (function(node) { | ||
return ((node.callee.type === "Identifier") && getUid(node.callee)); | ||
}), node.chain((function(node) { | ||
return getBinding(node.callee.ud.uid) | ||
return getBinding(getUid(node.callee)) | ||
.chain((function(binding) { | ||
@@ -140,6 +145,6 @@ return (binding ? modify((function(node) { | ||
}))); | ||
addPeephole(["CurryExpression"], true, (function(node) { | ||
return ((node.base.type === "Identifier") && node.base.ud.uid); | ||
addPeephole(["CurryExpression"], UP, (function(node) { | ||
return ((node.base.type === "Identifier") && getUid(node.base)); | ||
}), node.chain((function(node) { | ||
return getBinding(node.base.ud.uid) | ||
return getBinding(getUid(node.base)) | ||
.chain((function(binding) { | ||
@@ -151,34 +156,38 @@ return (binding ? modify((function(node) { | ||
}))); | ||
addPeephole(["CallExpression"], true, (function(node) { | ||
return isLambda(node.callee); | ||
}), unique.chain((function(uid) { | ||
return modify((function(node) { | ||
var map = node.callee.params.elements.map((function(x) { | ||
return x.id.ud.uid; | ||
})), | ||
bindings = node.callee.params.elements.map((function(x, i) { | ||
return ast_declaration.Binding.create(null, rewrite(uid, map, x), (node.args[ | ||
i] ? node.args[i] : ast_value.Identifier.create(null, | ||
"undefined"))); | ||
})); | ||
return ast_expression.LetExpression.create(null, bindings, rewrite(uid, map, node.callee.body)); | ||
})); | ||
}))); | ||
addPeephole(["CallExpression"], true, (function(node) { | ||
return ((node.callee.type === "LetExpression") && (node.callee.body.type === "FunctionExpression")); | ||
}), unique.chain((function(uid) { | ||
return modify((function(node) { | ||
var map = node.callee.body.params.elements.map((function(x) { | ||
return x.id.ud.uid; | ||
})), | ||
bindings = node.callee.body.params.elements.map((function(x, i) { | ||
return ast_declaration.Binding.create(null, rewrite(uid, map, x), (node.args[ | ||
i] ? node.args[i] : ast_value.Identifier.create(null, | ||
"undefined"))); | ||
})); | ||
return ast_expression.LetExpression.create(null, fun.concat(node.callee.bindings, bindings), | ||
rewrite(uid, map, node.callee.body.body)); | ||
})); | ||
}))); | ||
addPeephole(["CallExpression"], true, (function(__o) { | ||
addPeephole(["CallExpression"], UP, (function(node) { | ||
return isLambda(node.callee); | ||
}), unique.chain((function(uid) { | ||
return modify((function(node) { | ||
var map = node.callee.params.elements.map((function(x) { | ||
return getUid(x.id); | ||
})), | ||
bindings = node.callee.params.elements.map((function(x, i) { | ||
return ast_declaration.Binding.create(null, x, (node.args[i] ? node.args[i] : | ||
ast_value.Identifier.create(null, "undefined"))); | ||
})); | ||
return rewrite(uid, map, ast_expression.LetExpression.create(null, bindings, node.callee.body)); | ||
})); | ||
})) | ||
.chain((function() { | ||
return visit; | ||
}))); | ||
addPeephole(["CallExpression"], UP, (function(node) { | ||
return ((node.callee.type === "LetExpression") && isLambda(node.callee.body)); | ||
}), unique.chain((function(uid) { | ||
return modify((function(node) { | ||
var map = node.callee.body.params.elements.map((function(x) { | ||
return getUid(x.id); | ||
})), | ||
bindings = node.callee.body.params.elements.map((function(x, i) { | ||
return ast_declaration.Binding.create(null, x, (node.args[i] ? node.args[i] : | ||
ast_value.Identifier.create(null, "undefined"))); | ||
})); | ||
return rewrite(uid, map, ast_expression.LetExpression.create(null, fun.concat(node.callee.bindings, | ||
bindings), node.callee.body.body)); | ||
})); | ||
})) | ||
.chain((function() { | ||
return visit; | ||
}))); | ||
addPeephole(["CallExpression"], UP, (function(__o) { | ||
var callee = __o["callee"]; | ||
@@ -190,3 +199,3 @@ return (callee.type === "CurryExpression"); | ||
}))); | ||
addPeephole(["CallExpression"], true, (function(node) { | ||
addPeephole(["CallExpression"], UP, (function(node) { | ||
return ((node.callee.type === "LetExpression") && (node.callee.body.type === "CurryExpression")); | ||
@@ -203,3 +212,3 @@ }), modify((function(node) { | ||
}))); | ||
addPeephole(["CurryExpression"], true, (function(node) { | ||
addPeephole(["CurryExpression"], UP, (function(node) { | ||
return isLambda(node.base); | ||
@@ -210,3 +219,3 @@ }), unique.chain((function(uid) { | ||
return ((!node.base.params.elements.length) ? node.base : ((first = node.base.params.elements[ | ||
0]), (rest = node.base.params.elements.slice(1)), (map = [first.id.ud.uid]), ( | ||
0]), (rest = node.base.params.elements.slice(1)), (map = [getUid(first.id)]), ( | ||
body = ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern | ||
@@ -220,3 +229,3 @@ .create(null, null, rest, node.base.params.self), rewrite(uid, map, node.base | ||
}))); | ||
addPeephole(["CurryExpression"], true, (function(node) { | ||
addPeephole(["CurryExpression"], UP, (function(node) { | ||
return ((node.base.type === "LetExpression") && isLambda(node.base.body)); | ||
@@ -227,12 +236,11 @@ }), unique.chain((function(uid) { | ||
return ((!node.base.body.params.elements.length) ? node.base : ((first = node.base.body.params | ||
.elements[0]), (rest = node.base.body.params.elements.slice(1)), (map = [first.id | ||
.ud.uid | ||
]), (body = ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern | ||
.create(null, null, rest, node.base.body.params.self), rewrite(uid, map, | ||
node.base.body.body))), ((first && (((first.type === "IdentifierPattern") || | ||
(first.type === "AsPattern")) || (first.type === "ObjectPattern"))) ? | ||
ast_expression.LetExpression.create(null, fun.concat(node.base.bindings, | ||
rewrite(uid, map, ast_declaration.Binding.create(null, first, node.args[ | ||
0]))), body) : ast_expression.LetExpression.create(null, node.base.bindings, | ||
body)))); | ||
.elements[0]), (rest = node.base.body.params.elements.slice(1)), (map = [getUid( | ||
first.id)]), (body = ast_expression.FunctionExpression.create(null, null, | ||
ast_pattern.ArgumentsPattern.create(null, null, rest, node.base.body.params | ||
.self), rewrite(uid, map, node.base.body.body))), ((first && (((first.type === | ||
"IdentifierPattern") || (first.type === "AsPattern")) || (first.type === | ||
"ObjectPattern"))) ? ast_expression.LetExpression.create(null, fun.concat( | ||
node.base.bindings, rewrite(uid, map, ast_declaration.Binding.create( | ||
null, first, node.args[0]))), body) : ast_expression.LetExpression.create( | ||
null, node.base.bindings, body)))); | ||
})); | ||
@@ -272,5 +280,10 @@ }))); | ||
return s.setBindings(hashtrie.set(id.ud.uid, def, s.bindings)); | ||
}), new(State)(hashtrie.empty, hashtrie.empty)); | ||
}), new(State)(hashtrie.empty, hashtrie.empty)), | ||
merge = (function(ctx, o) { | ||
return (o ? ctx.setLoc(ctx.loc.setFocus((o && o.loc.focus)) | ||
.setDirty(o.loc.dirty)) : o); | ||
}); | ||
(visit = walk(M, _transform, _transformPost)); | ||
(optimize = (function(ast, data) { | ||
return run(next(walk(M, _transform, _transformPost), node.chain((function(node) { | ||
return run(next(visit, node.chain((function(node) { | ||
return globals.chain((function(g) { | ||
@@ -277,0 +290,0 @@ return unique.chain((function(unique) { |
@@ -77,3 +77,5 @@ /* | ||
}), | ||
"%": "%", | ||
"%": (function(x, y) { | ||
return (x % y); | ||
}), | ||
"<<": (function(x, y) { | ||
@@ -173,8 +175,9 @@ return (x << y); | ||
addPeephole(["Binding"], true, (function(node) { | ||
return ((node.pattern.type === "IdentifierPattern") && getUid(node.pattern)); | ||
return ((node.pattern.type === "IdentifierPattern") && getUid(node.pattern.id)); | ||
}), node.chain((function(node) { | ||
return seq(addBinding(getUid(node.pattern.id), node.value), (isPrimitive(node.value) ? set([]) : pass), ( | ||
(node.value.type === "Identifier") ? getBinding(getUid(node.value)) | ||
var uid = getUid(node.pattern.id); | ||
return (isPrimitive(node.value) ? seq(addBinding(uid, node.value), set([])) : ((node.value.type === | ||
"Identifier") ? getBinding(getUid(node.value)) | ||
.chain((function(binding) { | ||
return (binding ? set([]) : pass); | ||
return (binding ? seq(addBinding(uid, node.value), set([])) : pass); | ||
})) : pass)); | ||
@@ -181,0 +184,0 @@ }))); |
/* | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/scope.kep' | ||
* THIS FILE IS AUTO GENERATED from 'lib/scope.kep' | ||
* DO NOT EDIT | ||
*/ | ||
"use strict"; | ||
*/"use strict"; | ||
var record = require("bes")["record"], | ||
@@ -42,3 +41,3 @@ hashtrie = require("hashtrie"), | ||
var self = this; | ||
if ((!self.hasOwnBinding(id))) return id; | ||
if ((!self.hasBinding(id))) return id; | ||
for (var i = 0;; | ||
@@ -45,0 +44,0 @@ (i = (i + 1))) |
/* | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/stages/inline.kep' | ||
* THIS FILE IS AUTO GENERATED from 'lib/stages/inline.kep' | ||
* DO NOT EDIT | ||
*/ | ||
"use strict"; | ||
*/"use strict"; | ||
var inline = require("../inline"), | ||
@@ -14,4 +13,4 @@ __o = require("bes")["object"], | ||
out = inline.optimize(ast, data); | ||
return setProperty(setProperty(input, "ast", out.tree), "data", out.data); | ||
return setProperty(setProperty(input, "tree", out.tree), "data", out.data); | ||
})); | ||
(module.exports = optimize); |
/* | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/stages/khepri_peep.kep' | ||
* THIS FILE IS AUTO GENERATED from 'lib/stages/khepri_peep.kep' | ||
* DO NOT EDIT | ||
*/ | ||
"use strict"; | ||
*/"use strict"; | ||
var khepri_peep = require("../khepri_peep"), | ||
@@ -11,6 +10,6 @@ __o = require("bes")["object"], | ||
(optimize = (function(input) { | ||
var ast = input["ast"], | ||
var tree = input["tree"], | ||
data = input["data"]; | ||
return setProperty(input, "ast", khepri_peep.optimize(ast, data)); | ||
return setProperty(input, "ast", khepri_peep.optimize(tree, data)); | ||
})); | ||
(module.exports = optimize); |
@@ -32,11 +32,13 @@ /* | ||
walk = require("zipper-m")["walk"], | ||
__o1 = require("../ast"), | ||
getUid = __o1["getUid"], | ||
scope = require("../scope"), | ||
fun = require("../fun"), | ||
flip = fun["flip"], | ||
__o1 = require("../builtin"), | ||
builtins = __o1["builtins"], | ||
definitions = __o1["definitions"], | ||
__o2 = require("../unpack"), | ||
innerPattern = __o2["innerPattern"], | ||
unpackParameters = __o2["unpackParameters"], | ||
__o2 = require("../builtin"), | ||
builtins = __o2["builtins"], | ||
definitions = __o2["definitions"], | ||
__o3 = require("../unpack"), | ||
innerPattern = __o3["innerPattern"], | ||
unpackParameters = __o3["unpackParameters"], | ||
transform, M = ZipperT(StateT(Unique)), | ||
@@ -47,3 +49,2 @@ run = (function(m, s, ctx, seed) { | ||
ok = M.of, | ||
bind = M.chain, | ||
pass = ok(null), | ||
@@ -78,8 +79,8 @@ cons = (function(a, b) { | ||
inspectScopeWith = (function(f) { | ||
return bind(extract, (function(s) { | ||
return extract.chain((function(s) { | ||
return f(s.scope); | ||
})); | ||
}), | ||
packageManager = inspectStateWith((function(s) { | ||
return ok(s.packageManager); | ||
packageManager = extract.map((function(s) { | ||
return s.packageManager; | ||
})), | ||
@@ -117,2 +118,3 @@ modifyScope = (function(f) { | ||
set = M.setNode, | ||
withNode = node.chain.bind(node), | ||
enterBlock = inspectScopeWith((function(s) { | ||
@@ -140,13 +142,11 @@ return setScope(scope.Scope.empty.setOuter(s)); | ||
}), | ||
getBindings = (function(f) { | ||
return bind(inspectStateWith((function(s) { | ||
return enumeration(fun.map((function(__o) { | ||
var name = __o[0], | ||
uid = __o[1]; | ||
return getName(name, uid); | ||
}), s.bindings[0])); | ||
})), f); | ||
}), | ||
_trans, _transform = bind(node, (function(x) { | ||
return _trans(x); | ||
getBindings = M.chain.bind(null, inspectStateWith((function(s) { | ||
return enumeration(fun.map((function(__o) { | ||
var name = __o[0], | ||
uid = __o[1]; | ||
return getName(name, uid); | ||
}), s.bindings[0])); | ||
}))), | ||
_trans, _transform = withNode((function(node) { | ||
return _trans(node); | ||
})), | ||
@@ -270,3 +270,3 @@ identifier = (function(loc, name) { | ||
}))); | ||
addTransform("WithStatement", next(bind(packageManager, (function(packageManager) { | ||
addTransform("WithStatement", next(packageManager.chain((function(packageManager) { | ||
return modify((function(node) { | ||
@@ -336,3 +336,3 @@ return withStatement(packageManager, node.loc, node.bindings, node.body); | ||
}))); | ||
addTransform("LetExpression", seq(bind(node, (function(node) { | ||
addTransform("LetExpression", seq(withNode((function(node) { | ||
var bindings = fun.flatten(fun.map((function(x) { | ||
@@ -342,3 +342,3 @@ return (x ? innerPattern(null, x.pattern) : []); | ||
identifiers = fun.map((function(x) { | ||
return [x.pattern.id.name, x.pattern.id.ud.uid]; | ||
return [x.pattern.id.name, getUid(x.pattern.id)]; | ||
}), bindings); | ||
@@ -369,6 +369,4 @@ return addBindings(identifiers); | ||
}))); | ||
addTransform("IdentifierPattern", bind(node, (function(node) { | ||
return ((node.id.ud && (node.id.ud.uid !== undefined)) ? addVar(node.id.name, node.id.ud.uid) : pass); | ||
})), modify((function(node) { | ||
return node.id; | ||
addTransform("IdentifierPattern", withNode((function(node) { | ||
return seq((getUid(node.id) ? addVar(node.id.name, getUid(node.id)) : pass), set(node.id)); | ||
}))); | ||
@@ -403,3 +401,3 @@ addTransform("AsPattern", null, modify((function(node) { | ||
}))); | ||
addTransform("Package", bind(packageManager, (function(packageManager) { | ||
addTransform("Package", packageManager.chain((function(packageManager) { | ||
return globals.chain((function(globals) { | ||
@@ -411,7 +409,6 @@ return modify((function(node) { | ||
}))); | ||
addTransform("Identifier", null, bind(node, (function(node) { | ||
return ((node.ud && node.ud.uid) ? next(addVar(node.name, node.ud.uid), getMapping(node.ud.uid, ( | ||
function(name) { | ||
return set(identifier(node.loc, name)); | ||
}))) : set(identifier(node.loc, node.name))); | ||
addTransform("Identifier", null, withNode((function(node) { | ||
return (getUid(node) ? next(addVar(node.name, getUid(node)), getMapping(getUid(node), (function(name) { | ||
return set(identifier(node.loc, name)); | ||
}))) : set(identifier(node.loc, node.name))); | ||
}))); | ||
@@ -432,3 +429,3 @@ (_trans = (function(node) { | ||
}), | ||
_transformPost = bind(node, _transp); | ||
_transformPost = withNode(_transp); | ||
(transform = (function(ast, manager, data) { | ||
@@ -447,5 +444,5 @@ var amd_manager = require("./package_manager/amd"), | ||
}))) : [])); | ||
return run(seq(addVar("require", builtins.require.ud.uid), addVar("exports", builtins.exports.ud.uid), walk( | ||
M, _transform, _transformPost), node), s, khepriZipper(ast)); | ||
return run(seq(addVar("require", getUid(builtins.require)), addVar("exports", getUid(builtins.exports)), | ||
walk(M, _transform, _transformPost), node), s, khepriZipper(ast)); | ||
})); | ||
(exports["transform"] = transform); |
{ | ||
"name": "khepri-compile", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Compiler for the Khepri programming language", | ||
@@ -5,0 +5,0 @@ "author": "Matt Bierner", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
213586
2954