khepri-compile
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -136,2 +136,6 @@ /* | ||
})); | ||
registerBinary(".?", "__cdot", (function(x, y) { | ||
return ast_expression.BinaryExpression.create(null, "&&", x, setUd("id", identifier("__x", unique()), | ||
ast_expression.MemberExpression.create(null, x, y, true))); | ||
})); | ||
registerBinary("@", "__curry", (function(x, y) { | ||
@@ -138,0 +142,0 @@ return ast_expression.CurryExpression.create(null, x, [y]); |
@@ -33,3 +33,2 @@ /* | ||
.chain(inline) | ||
.chain(reachable) | ||
.chain(khepri_peep) | ||
@@ -36,0 +35,0 @@ .chain(transform) |
@@ -30,2 +30,4 @@ /* | ||
getUid = __o1["getUid"], | ||
setUd = __o1["setUd"], | ||
getUd = __o1["getUd"], | ||
isLambda = __o1["isLambda"], | ||
@@ -58,8 +60,9 @@ isLambdaWithoutArgs = __o1["isLambdaWithoutArgs"], | ||
ops34, __args35, ops35, __args36, ops36, consequent8, alternate0, __args37, ops37, __args38, ops38, consequent9, | ||
consequent10, consequent11, consequent12, __args39, ops39, __args40, ops40, __args41, ops41, __args42, ops42, | ||
exp, consequent13, consequent14, __args43, ops43, __args44, ops44, exp0, consequent15, consequent16, __args45, | ||
ops45, __args46, ops46, consequent17, consequent18, __args47, ops47, __args48, ops48, __args49, ops49, __args50, | ||
ops50, __args51, ops51, __args52, ops52, __args53, ops53, consequent19, __and = (function(x, y) { | ||
return (x && y); | ||
}), | ||
consequent10, consequent11, consequent12, consequent13, __args39, ops39, __args40, ops40, __args41, ops41, | ||
__args42, ops42, exp, consequent14, consequent15, __args43, ops43, __args44, ops44, exp0, consequent16, | ||
consequent17, __args45, ops45, __args46, ops46, consequent18, consequent19, __args47, ops47, __args48, ops48, | ||
__args49, ops49, __args50, ops50, __args51, ops51, __args52, ops52, __args53, ops53, consequent20, __and = ( | ||
function(x, y) { | ||
return (x && y); | ||
}), | ||
__plus = (function(x) { | ||
@@ -89,2 +92,5 @@ return (+x); | ||
}), | ||
__band = (function(x, y) { | ||
return (x & y); | ||
}), | ||
__mul = (function(x, y) { | ||
@@ -108,5 +114,11 @@ return (x * y); | ||
}), | ||
__bor = (function(x, y) { | ||
return (x | y); | ||
}), | ||
__gt = (function(x, y) { | ||
return (x > y); | ||
}), | ||
__bxor = (function(x, y) { | ||
return (x ^ y); | ||
}), | ||
__bnot = (function(x) { | ||
@@ -145,2 +157,5 @@ return (~x); | ||
}), | ||
invalidateWorking = (function(uid) { | ||
return modifyState(state.invalidateWorking.bind(null, uid)); | ||
}), | ||
getBinding = (function(uid) { | ||
@@ -201,3 +216,3 @@ return (uid ? getState.map(state.getBinding.bind(null, uid)) : pass); | ||
false)); | ||
})) : addWorking(uid, value, false)))); | ||
})) : invalidateWorking(uid)))); | ||
}), | ||
@@ -207,3 +222,4 @@ setWorkingForNode = (function(id, value) { | ||
.chain((function(binding) { | ||
return (((!binding) || binding.value) ? addWorkingForNode(id, value) : pass); | ||
return ((binding && binding.value) ? addWorkingForNode(id, value) : invalidateWorking( | ||
getUid(id))); | ||
})); | ||
@@ -273,6 +289,8 @@ }), | ||
addRewrite("VariableDeclarator", seq(((__args7 = ["init", checkTop]), (ops7 = [].slice.call(__args7, 1)), seq(moveChild( | ||
"init"), seqa(ops7), up)), ((consequent1 = extract((function(node) { | ||
return (node.immutable ? seq(addBindingForNode(node.id, node.init), tryPrune(node.id)) : | ||
addWorking(getUid(node.id), node.init, ((isPrimitive(node.init) || isIdentifier(node.init)) || | ||
isLambda(node.init)))); | ||
"init"), seqa(ops7), up)), ((consequent1 = extract((function(__o6) { | ||
var immutable = __o6["immutable"], | ||
id = __o6["id"], | ||
init = __o6["init"]; | ||
return (immutable ? seq(addBindingForNode(id, init), tryPrune(id)) : addWorking(getUid(id), | ||
init, ((isPrimitive(init) || isIdentifier(init)) || isLambda(init)))); | ||
}))), extract((function(node) { | ||
@@ -363,4 +381,7 @@ return (node.init ? consequent1 : (undefined || pass)); | ||
">=": __gte, | ||
"||": __or, | ||
"&&": __and | ||
"|": __bor, | ||
"&": __band, | ||
"^": __bxor, | ||
"&&": __and, | ||
"||": __or | ||
})), seq(((__args31 = ["left", checkTop]), (ops31 = [].slice.call(__args31, 1)), seq(moveChild("left"), seqa( | ||
@@ -392,7 +413,6 @@ ops31), up)), ((__args32 = ["right", checkTop]), (ops32 = [].slice.call(__args32, 1)), seq(moveChild( | ||
moveChild("right"), seqa(ops33), up)), ((consequent7 = extract((function(__o6) { | ||
var operator = __o6["operator"], | ||
var immutable = __o6["immutable"], | ||
left = __o6["left"], | ||
right0 = __o6["right"]; | ||
return ((operator === "=") ? setWorkingForNode(left, right0) : addBindingForNode(left, | ||
right0)); | ||
return (immutable ? addBindingForNode(left, right0) : setWorkingForNode(left, right0)); | ||
}))), extract((function(node) { | ||
@@ -418,3 +438,12 @@ var z, y0; | ||
return (node.computed ? consequent9 : (undefined || pass)); | ||
}))), ((consequent10 = modify((function(__o6) { | ||
}))), ((consequent10 = extract((function(node) { | ||
var id = getUd("id", node); | ||
return getBinding(getUid(id)) | ||
.chain((function(binding) { | ||
return (((binding && binding.value) && binding.simple) ? set(setUd("id", | ||
binding.value, node)) : pass); | ||
})); | ||
}))), extract((function(node) { | ||
return (node.checked ? consequent10 : (undefined || pass)); | ||
}))), ((consequent11 = modify((function(__o6) { | ||
var object = __o6["object"], | ||
@@ -425,4 +454,4 @@ property = __o6["property"]; | ||
return (((node.computed && (node.object.type === "ArrayExpression")) && isNumberish(node.property)) ? | ||
consequent10 : (undefined || pass)); | ||
}))), ((consequent11 = modify((function(__o6) { | ||
consequent11 : (undefined || pass)); | ||
}))), ((consequent12 = modify((function(__o6) { | ||
var object = __o6["object"]; | ||
@@ -434,4 +463,4 @@ return ast_value.Literal.create(null, "number", object.elements.length); | ||
node.property.type === "Literal")) && (node.property.value === "length")))) ? | ||
consequent11 : (undefined || pass)); | ||
}))), ((consequent12 = modify((function(node) { | ||
consequent12 : (undefined || pass)); | ||
}))), ((consequent13 = modify((function(node) { | ||
var str = node.object.value, | ||
@@ -442,3 +471,3 @@ idx = node.property.value; | ||
return (((node.computed && ((node.object.type === "Literal") && (node.object.kind === "string"))) && | ||
isNumberish(node.property)) ? consequent12 : (undefined || pass)); | ||
isNumberish(node.property)) ? consequent13 : (undefined || pass)); | ||
}))))); | ||
@@ -452,3 +481,3 @@ addRewrite("NewExpression", seq(((__args39 = ["callee", checkTop]), (ops39 = [].slice.call(__args39, 1)), seq(moveChild( | ||
return x0.callee; | ||
}))), (consequent13 = exp.chain((function(z) { | ||
}))), (consequent14 = exp.chain((function(z) { | ||
var callee = expandNode(z); | ||
@@ -462,4 +491,4 @@ return modify((function(node) { | ||
}))), extract((function(node) { | ||
return (isExpansion(node.callee) ? consequent13 : (undefined || pass)); | ||
}))), ((consequent14 = seq(unique((function(uid) { | ||
return (isExpansion(node.callee) ? consequent14 : (undefined || pass)); | ||
}))), ((consequent15 = seq(unique((function(uid) { | ||
return extract((function(node) { | ||
@@ -473,3 +502,3 @@ var __o6 = expandCallee(uid, node.callee, node.args), | ||
return ((isLambda(node.callee) || ((node.callee.type === "LetExpression") && isLambda(node.callee | ||
.body))) ? consequent14 : (undefined || pass)); | ||
.body))) ? consequent15 : (undefined || pass)); | ||
}))))); | ||
@@ -480,3 +509,3 @@ addRewrite("CurryExpression", seq(((__args43 = ["base", checkTop]), (ops43 = [].slice.call(__args43, 1)), seq(moveChild( | ||
return x0.base; | ||
}))), (consequent15 = exp0.chain((function(z) { | ||
}))), (consequent16 = exp0.chain((function(z) { | ||
var base = expandNode(z); | ||
@@ -488,4 +517,4 @@ return modify((function(node) { | ||
}))), extract((function(node) { | ||
return (isExpansion(node.base) ? consequent15 : (undefined || pass)); | ||
}))), ((consequent16 = seq(unique((function(uid) { | ||
return (isExpansion(node.base) ? consequent16 : (undefined || pass)); | ||
}))), ((consequent17 = seq(unique((function(uid) { | ||
return modify((function(node) { | ||
@@ -495,8 +524,9 @@ return expandCurry(uid, node.base, node.args); | ||
})), checkTop)), extract((function(node) { | ||
return ((isLambdaWithoutArgs(node.base) || ((node.base.type === "LetExpression") && | ||
isLambdaWithoutArgs(node.base.body))) ? consequent16 : (undefined || pass)); | ||
var base; | ||
return (((base = node["base"]), (isLambdaWithoutArgs(base) || ((type(base) === "LetExpression") && | ||
isLambdaWithoutArgs(base.body)))) ? consequent17 : (undefined || pass)); | ||
}))))); | ||
addRewrite("LetExpression", seq(((__args45 = ["bindings", checkTop]), (ops45 = [].slice.call(__args45, 1)), seq( | ||
moveChild("bindings"), seqa(ops45), up)), ((__args46 = ["body", checkTop]), (ops46 = [].slice.call(__args46, | ||
1)), seq(moveChild("body"), seqa(ops46), up)), ((consequent17 = modify((function(__o6) { | ||
1)), seq(moveChild("body"), seqa(ops46), up)), ((consequent18 = modify((function(__o6) { | ||
var loc = __o6["loc"], | ||
@@ -508,3 +538,3 @@ bindings = __o6["bindings"], | ||
var z, y0; | ||
return (((z = node.body), (y0 = type(z)), ("LetExpression" === y0)) ? consequent17 : (undefined || | ||
return (((z = node.body), (y0 = type(z)), ("LetExpression" === y0)) ? consequent18 : (undefined || | ||
pass)); | ||
@@ -516,7 +546,7 @@ }))), modify((function(__o6) { | ||
return ast_expression.LetExpression.create(loc, flattenr(bindings), body3); | ||
})), ((consequent18 = modify((function(x0) { | ||
})), ((consequent19 = modify((function(x0) { | ||
return x0.body; | ||
}))), extract((function(node) { | ||
var bindings; | ||
return (((bindings = node["bindings"]), (!bindings.length)) ? consequent18 : (undefined || pass)); | ||
return (((bindings = node["bindings"]), (!bindings.length)) ? consequent19 : (undefined || pass)); | ||
}))))); | ||
@@ -538,3 +568,3 @@ addRewrite(["SliceUnpack", "RelativeUnpack"], ((__args47 = ["target", checkTop]), (ops47 = [].slice.call(__args47, 1)), | ||
"value"), seqa(ops53), up))); | ||
addRewrite("Identifier", ((consequent19 = extract((function(node) { | ||
addRewrite("Identifier", ((consequent20 = extract((function(node) { | ||
return getBinding(getUid(node)) | ||
@@ -546,3 +576,3 @@ .chain((function(binding) { | ||
}))), extract((function(node) { | ||
return ((getUid(node) && (!isExpansion(node))) ? consequent19 : (undefined || pass)); | ||
return ((getUid(node) && (!isExpansion(node))) ? consequent20 : (undefined || pass)); | ||
})))); | ||
@@ -549,0 +579,0 @@ (_check = (function(node) { |
@@ -19,2 +19,4 @@ /* | ||
tryGetUd = __o3["tryGetUd"], | ||
getUd = __o3["getUd"], | ||
setUd = __o3["setUd"], | ||
getUid = __o3["getUid"], | ||
@@ -42,3 +44,5 @@ setUid = __o3["setUid"], | ||
type(node) === "FunctionExpression") ? tree.setNode(updateClosure(node, prefix, | ||
list), ctx) : ctx)); | ||
list), ctx) : (((type(node) === "MemberExpression") && node.checked) ? tree.setNode( | ||
setUd("id", rename(prefix, list, tree.node(khepriZipper(getUd("id", node)))), | ||
node), ctx) : ctx))); | ||
}), khepriZipper(root))); | ||
@@ -45,0 +49,0 @@ })); |
@@ -10,4 +10,4 @@ /* | ||
__o0 = require("./binding"), | ||
State, getBinding, addBinding, addWorking, push, pop, getGlobals, addGlobal, addLocals, getLocals, pushLocals, | ||
popLocals, concat = __o["concat"], | ||
State, getBinding, addBinding, addWorking, invalidateWorking, push, pop, getGlobals, addGlobal, addLocals, | ||
getLocals, pushLocals, popLocals, concat = __o["concat"], | ||
Binding = __o0["Binding"], | ||
@@ -44,2 +44,5 @@ MUTABLE = __o0["MUTABLE"], | ||
})); | ||
(invalidateWorking = (function(uid, s) { | ||
return s.setWorking(hamt.set(uid, null, s.working)); | ||
})); | ||
var y = hamt.keys; | ||
@@ -70,2 +73,3 @@ (getGlobals = (function(z) { | ||
(exports["addWorking"] = addWorking); | ||
(exports["invalidateWorking"] = invalidateWorking); | ||
(exports["push"] = push); | ||
@@ -72,0 +76,0 @@ (exports["pop"] = pop); |
@@ -43,7 +43,7 @@ /* | ||
__args51, actions51, __args52, actions52, __args53, actions53, __args54, actions54, __args55, actions55, | ||
__args56, actions56, __args57, actions57, consequent3, __args58, actions58, __args59, actions59, __args60, | ||
actions60, __args61, actions61, body14, __args62, actions62, __args63, actions63, __args64, actions64, __args65, | ||
actions65, __args66, actions66, __args67, actions67, __args68, actions68, __args69, actions69, __args70, | ||
actions70, __args71, actions71, __args72, actions72, __args73, actions73, __args74, actions74, __args75, | ||
actions75, consequent4, alternate2, x3, _check, reserved = getUd.bind(null, "reserved"), | ||
__args56, actions56, __args57, actions57, consequent3, consequent4, __args58, actions58, __args59, actions59, | ||
__args60, actions60, __args61, actions61, body14, __args62, actions62, __args63, actions63, __args64, actions64, | ||
__args65, actions65, __args66, actions66, __args67, actions67, __args68, actions68, __args69, actions69, | ||
__args70, actions70, __args71, actions71, __args72, actions72, __args73, actions73, __args74, actions74, | ||
__args75, actions75, consequent5, alternate2, x3, _check, reserved = getUd.bind(null, "reserved"), | ||
M = ErrorT(TreeZipperT(ScopeT(Unique))), | ||
@@ -335,2 +335,7 @@ run = (function(p, s, ctx, ok, err) { | ||
return (node.computed ? consequent3 : (undefined || pass)); | ||
}))), ((consequent4 = unique((function(uid) { | ||
return modifyNode(setUd.bind(null, "id", setUid(uid, ast_value.Identifier.create(null, | ||
"__x")))); | ||
}))), inspect((function(node) { | ||
return (node.checked ? consequent4 : (undefined || pass)); | ||
}))))); | ||
@@ -386,3 +391,3 @@ addCheck("ArrayExpression", ((__args58 = ["elements", checkTop]), (actions58 = [].slice.call(__args58, 1)), seq( | ||
}))); | ||
addCheck(["UnaryOperator"], ((consequent4 = pass), (alternate2 = inspect((function(node) { | ||
addCheck(["UnaryOperator"], ((consequent5 = pass), (alternate2 = inspect((function(node) { | ||
var loc = node["loc"], | ||
@@ -396,3 +401,3 @@ name = node["name"]; | ||
var z, y3; | ||
return (((z = node.name), (y3 = z[0]), ("." === y3)) ? consequent4 : (alternate2 || pass)); | ||
return (((z = node.name), (y3 = z[0]), ("." === y3)) ? consequent5 : (alternate2 || pass)); | ||
})))); | ||
@@ -406,3 +411,3 @@ (_check = (function(node) { | ||
"!==", "&", "^", "|", "||", "&&", "|>", "\\>", "\\>>", "<|", "<\\", "<<\\", "!", "++", "--", "~", ".", | ||
"@", "void", "instanceof", "typeof", "new" | ||
".?", "@", "void", "instanceof", "typeof", "new" | ||
])), foldl((function(p, c) { | ||
@@ -409,0 +414,0 @@ return scope.addOperator(c, null, p); |
@@ -16,7 +16,8 @@ /* | ||
normalize, modify = __o["modify"], | ||
setData = __o["setData"], | ||
getData = __o["getData"], | ||
SliceUnpack = __o0["SliceUnpack"], | ||
RelativeUnpack = __o0["RelativeUnpack"], | ||
type = __o1["type"], | ||
getUd = __o1["getUd"], | ||
setUd = __o1["setUd"], | ||
constant = __o2["constant"], | ||
concat = __o2["concat"], | ||
@@ -30,4 +31,5 @@ map = __o2["map"], | ||
rewrite = __o3["rewrite"], | ||
string = ast_value.Literal.create.bind(null, null, "string"), | ||
y, y0, id, string = ast_value.Literal.create.bind(null, null, "string"), | ||
number = ast_value.Literal.create.bind(null, null, "number"), | ||
markReserved = setUd.bind(null, "reserved", true), | ||
always = (function(_) { | ||
@@ -68,2 +70,3 @@ return true; | ||
elements = __o4["elements"], | ||
checked = __o4["checked"], | ||
indx = elements.map(type) | ||
@@ -82,3 +85,3 @@ .indexOf("EllipsisPattern"), | ||
return RelativeUnpack.create(null, x, null, (post.length - i), (post.length + pre0.length)); | ||
}), post)))); | ||
}), post))), checked); | ||
})); | ||
@@ -89,3 +92,3 @@ rewrites.add("ArgumentsPattern", UP, (function(node) { | ||
}), (function(node) { | ||
var node0, elements = node.elements, | ||
var elements = node.elements, | ||
indx = elements.map(type) | ||
@@ -98,4 +101,4 @@ .indexOf("EllipsisPattern"), | ||
post = __o4[2], | ||
id = (node.id || ((node0 = ast_pattern.IdentifierPattern.create(null, ast_value.Identifier.create(null, | ||
"__args"))), setData(node0, "reserved", true))); | ||
id = (node.id || markReserved(ast_pattern.IdentifierPattern.create(null, ast_value.Identifier.create( | ||
null, "__args")))); | ||
return modify(node, ({ | ||
@@ -124,20 +127,18 @@ id: id, | ||
})); | ||
rewrites.add("AsPattern", DOWN, (function(node) { | ||
return (!getData(node.target, "id")); | ||
}), (function(node) { | ||
return ast_pattern.AsPattern.create(node.loc, node.id, setData(node.target, "id", node.id)); | ||
rewrites.add("AsPattern", DOWN, ((y = getUd.bind(null, "id")), (function(z) { | ||
var x = y(z.target); | ||
return (!x); | ||
})), (function(node) { | ||
return ast_pattern.AsPattern.create(null, node.id, setUd("id", node.id, node.target)); | ||
})); | ||
rewrites.add("ObjectPattern", UP, (function(node) { | ||
return (!getData(node, "id")); | ||
}), (function(node) { | ||
var node0 = ast_pattern.IdentifierPattern.create(null, ast_value.Identifier.create(null, "__o")), | ||
id = setData(node0, "reserved", true); | ||
return ast_pattern.AsPattern.create(null, id, setData(node, "id", id)); | ||
})); | ||
rewrites.add("SinkPattern", DOWN, always, (function(node) { | ||
var loc = node["loc"], | ||
node0 = ast_pattern.IdentifierPattern.create(loc, ast_value.Identifier.create(null, "_")); | ||
return setData(node0, "reserved", true); | ||
})); | ||
rewrites.add("ObjectPattern", UP, ((y0 = getUd.bind(null, "id")), (function(z) { | ||
var x = y0(z); | ||
return (!x); | ||
})), ((id = markReserved(ast_pattern.IdentifierPattern.create(null, ast_value.Identifier.create(null, "__o")))), ( | ||
function(node) { | ||
return ast_pattern.AsPattern.create(null, id, setUd("id", id, node)); | ||
}))); | ||
rewrites.add("SinkPattern", DOWN, always, constant(markReserved(ast_pattern.IdentifierPattern.create(null, ast_value.Identifier | ||
.create(null, "_"))))); | ||
(normalize = rewrite.bind(null, rewrites)); | ||
(exports["normalize"] = normalize); |
@@ -16,2 +16,3 @@ /* | ||
type = __o0["type"], | ||
setUd = __o0["setUd"], | ||
concat = __o1["concat"], | ||
@@ -21,4 +22,5 @@ flatten = __o1["flatten"], | ||
map = __o1["map"], | ||
expandObjectElement = (function(base, pattern, key) { | ||
var innerBase = ast_expression.MemberExpression.create(null, base, key, true); | ||
expandObjectElement = (function(base, pattern, key, checked) { | ||
var member = ast_expression.MemberExpression.create(null, base, key, true, checked), | ||
innerBase = (checked ? setUd("hasBinding", true, setUd("id", base, member)) : member); | ||
return (pattern ? flatten(innerPattern(innerBase, pattern)) : ast_declaration.Binding.create(null, | ||
@@ -28,3 +30,3 @@ ast_pattern.IdentifierPattern.create(null, ast_value.Identifier.create(null, key.value)), innerBase | ||
}), | ||
expandObject = (function(base, pattern) { | ||
expandObject = (function(base, pattern, checked) { | ||
return flattenr(map((function(node) { | ||
@@ -38,3 +40,3 @@ var target, pattern0, from, to, target0, start, indx, pattern1; | ||
target0, indx, start), pattern1)) : expandObjectElement(pattern.ud.id.id, node.target, | ||
node.key))); | ||
node.key, pattern.checked))); | ||
}), pattern.elements)); | ||
@@ -52,3 +54,3 @@ }), | ||
case "ObjectPattern": | ||
return expandObject(base, pattern); | ||
return expandObject(base, pattern, pattern.checked); | ||
default: | ||
@@ -55,0 +57,0 @@ return []; |
@@ -6,4 +6,3 @@ /* | ||
"use strict"; | ||
var Unique = require("akh")["unique"], | ||
StateT = require("akh")["trans"]["statei"], | ||
var StateM = require("akh")["state"], | ||
__o = require("akh")["base"], | ||
@@ -50,5 +49,5 @@ TreeZipperT = require("zipper-m")["trans"]["tree"], | ||
__args59, actions60, __args60, actions61, __args61, actions62, __args62, actions63, move, uid, f1, uid0, f2, | ||
_trans, M = TreeZipperT(StateT(Unique)), | ||
run = (function(m, s, ctx, seed) { | ||
return Unique.runUnique(StateT.evalStateT(TreeZipperT.runTreeZipperT(m, ctx), s), seed); | ||
_trans, M = TreeZipperT(StateM), | ||
run = (function(m, s, ctx) { | ||
return StateM.evalState(TreeZipperT.runTreeZipperT(m, ctx), s); | ||
}), | ||
@@ -205,3 +204,6 @@ pass = M.of(null), | ||
moveChild("object"), sequencea(actions44), up)), ((__args45 = ["property", checkTop]), (actions45 = [].slice | ||
.call(__args45, 1)), seq(moveChild("property"), sequencea(actions45), up)), modify(translate.memberExpression))); | ||
.call(__args45, 1)), seq(moveChild("property"), sequencea(actions45), up)), withNode((function(node0) { | ||
return (node0.checked ? seq(modify(translate.checkedMemberExpression.bind(null, getUd("id", node0))), | ||
checkTop) : modify(translate.memberExpression)); | ||
})))); | ||
addTransform("LetExpression", seq(((__args46 = ["bindings", checkTop]), (actions46 = [].slice.call(__args46, 1)), seq( | ||
@@ -208,0 +210,0 @@ moveChild("bindings"), sequencea(actions46), up)), withNode((function(z) { |
@@ -13,3 +13,5 @@ /* | ||
ecma_value = require("ecma-ast")["value"], | ||
khepri_declaration = require("khepri-ast")["declaration"], | ||
khepri_expression = require("khepri-ast")["expression"], | ||
khepri_pattern = require("khepri-ast")["pattern"], | ||
khepri_statement = require("khepri-ast")["statement"], | ||
@@ -22,7 +24,9 @@ khepri_value = require("khepri-ast")["value"], | ||
binaryExpression, logicalExpression, conditionalExpression, newExpression, callExpression, memberExpression, | ||
arrayExpression, objectExpression, objectValue, functionExpression, functionExpressionPost, letExpression, | ||
curryExpression, catchClause, switchCase, emptyStatement, blockStatement, withStatement, expressionStatement, | ||
returnStatement, throwStatement, breakStatement, continueStatement, ifStatement, switchStatement, forStatement, | ||
doWhileStatement, whileStatement, tryStatement, packageBlock, type = __o["type"], | ||
checkedMemberExpression, arrayExpression, objectExpression, objectValue, functionExpression, | ||
functionExpressionPost, letExpression, curryExpression, catchClause, switchCase, emptyStatement, blockStatement, | ||
withStatement, expressionStatement, returnStatement, throwStatement, breakStatement, continueStatement, | ||
ifStatement, switchStatement, forStatement, doWhileStatement, whileStatement, tryStatement, packageBlock, type = | ||
__o["type"], | ||
tryGetUd = __o["tryGetUd"], | ||
getUd = __o["getUd"], | ||
setUid = __o["setUid"], | ||
@@ -103,2 +107,10 @@ concat = fun["concat"], | ||
})); | ||
(checkedMemberExpression = (function(id, node) { | ||
var body = khepri_expression.BinaryExpression.create(null, "&&", id, khepri_expression.MemberExpression.create( | ||
null, id, node.property, node.computed, false)); | ||
return (getUd("hasBinding", node) ? body : khepri_expression.LetExpression.create(node.loc, [ | ||
khepri_declaration.Binding.create(null, khepri_pattern.IdentifierPattern.create(null, id), node | ||
.object) | ||
], body)); | ||
})); | ||
(letExpression = (function(node) { | ||
@@ -220,2 +232,3 @@ return ecma_expression.SequenceExpression.create(node.loc, flatten(concat(map(unpackAssign, node.bindings), | ||
(exports["memberExpression"] = memberExpression); | ||
(exports["checkedMemberExpression"] = checkedMemberExpression); | ||
(exports["arrayExpression"] = arrayExpression); | ||
@@ -222,0 +235,0 @@ (exports["objectExpression"] = objectExpression); |
{ | ||
"name": "khepri-compile", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "Compiler for the Khepri programming language", | ||
@@ -43,3 +43,3 @@ "author": "Matt Bierner", | ||
"khepri-ast": "4.4.x", | ||
"khepri-ast": "4.5.x", | ||
"khepri-ast-zipper": "1.2.x", | ||
@@ -57,3 +57,3 @@ | ||
"khepri-parse": "2.2.x", | ||
"khepri-parse": "2.3.x", | ||
"ecma-unparse": "3.3.x" | ||
@@ -60,0 +60,0 @@ }, |
@@ -54,3 +54,3 @@ var parser = require('khepri-parse').parse.parser; | ||
exports.computed_member_evaled_once = function(test) { | ||
exports.computed_member_arg_evaled_once = function(test) { | ||
test.equal( | ||
@@ -62,1 +62,41 @@ testParser("var g = 0; var f = \\x -> { g = g + 1; return x; }; var a = [1, [4], 3]; a.(f(1)).(0); g;"), | ||
}; | ||
exports.checked_member = function(test) { | ||
test.equal( | ||
testParser("var o = {'x':3}; o.?x;"), | ||
3); | ||
test.equal( | ||
testParser("var o = {'x':3}; o.?u;"), | ||
undefined); | ||
test.equal( | ||
testParser("var o; o.?x;"), | ||
undefined); | ||
test.equal( | ||
testParser("var o = null; o.?x;"), | ||
null); | ||
test.done(); | ||
}; | ||
exports.checked_member_evals_base_once = function(test) { | ||
test.equal( | ||
testParser("var g = 0; var o = {'x':{'y': 3}}; var f = \\-> { g = g + 1; return o; }; (f()).?x.y; g;"), | ||
1); | ||
test.done(); | ||
}; | ||
exports.checked_member_evals_arg_at_most_once = function(test) { | ||
test.equal( | ||
testParser("var g = 0; var o = {'x':{'y': 3}}; var f = \\-> { g = g + 1; return 'x'; }; o.?(f()).y; g;"), | ||
1); | ||
test.equal( | ||
testParser("var g = 0; var o = null; var f = \\-> { g = g + 1; return 'x'; }; o.?(f()).?y; g;"), | ||
0); | ||
test.done(); | ||
}; |
@@ -17,3 +17,3 @@ var parser = require('khepri-parse').parse.parser; | ||
test.equal( | ||
testParser("var f = \\{'x': val} -> val; f {'x': 1, 'y': 2};"), | ||
testParser("var f = \\{'x'#val} -> val; f {'x': 1, 'y': 2};"), | ||
1); | ||
@@ -26,3 +26,3 @@ | ||
test.equal( | ||
testParser("var f = \\{'x': x, 'y': y} -> x + y; f {'x': 1, 'y': 2};"), | ||
testParser("var f = \\{'x'# x, 'y'# y} -> x + y; f {'x': 1, 'y': 2};"), | ||
3); | ||
@@ -35,3 +35,3 @@ | ||
test.equal( | ||
testParser("var f = \\{'undefined': x} -> x; f {'x': 1, 'y': 2};"), | ||
testParser("var f = \\{'undefined'#x} -> x; f {'x': 1, 'y': 2};"), | ||
undefined); | ||
@@ -60,3 +60,3 @@ | ||
test.equal( | ||
testParser("var f = \\{'1': x} -> x; f [0, 1, 2, 3];"), | ||
testParser("var f = \\{'1'# x} -> x; f [0, 1, 2, 3];"), | ||
1); | ||
@@ -74,1 +74,13 @@ | ||
}; | ||
exports.checked = function(test) { | ||
test.equal( | ||
testParser("var f = \\?{x} -> x; f {'x': 1, 'y': 2};"), | ||
1); | ||
test.equal( | ||
testParser("var f = \\?{x} -> x; f null;"), | ||
null); | ||
test.done(); | ||
}; |
@@ -42,3 +42,3 @@ var parser = require('khepri-parse').parse.parser; | ||
testParser("var f = (.); f ([1, 2, 3], 2);"), | ||
3); | ||
testParser("[1, 2, 3].('2');")); | ||
@@ -48,2 +48,14 @@ test.done(); | ||
exports.checked_member = function(test) { | ||
test.equal( | ||
testParser("var f = (.?); f ([1, 2, 3], 2);"), | ||
testParser("[1, 2, 3].?(2);")); | ||
test.equal( | ||
testParser("var f = (.?); var a; f (a, 2);"), | ||
undefined); | ||
test.done(); | ||
}; | ||
exports.non_computed_member = function(test) { | ||
@@ -50,0 +62,0 @@ test.equal( |
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
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
346946
4525
+ Addedkhepri-ast@4.5.1(transitive)
- Removedkhepri-ast@4.4.0(transitive)
Updatedkhepri-ast@4.5.x