khepri-compile
Advanced tools
Comparing version
@@ -7,3 +7,3 @@ /* | ||
var __o = require("khepri-ast")["node"], | ||
type, isIdentifier, isOperator, isSymbol, isLiteral, isNumberish, isPrimitive, isSimple, isPod, isTruthy, | ||
type, isIdentifier, isOperator, isSymbol, isLiteral, isString, isNumberish, isPrimitive, isSimple, isPod, isTruthy, | ||
isBlockFunction, isLambda, isLambdaWithoutArgs, tryGetUd, getUd, setUd, modify, getUid, setUid, getLocals, | ||
@@ -31,2 +31,5 @@ setLocals, getClosure, setClosure, setData = __o["setData"], | ||
})); | ||
(isString = (function(node) { | ||
return (isLiteral(node) && (node.kind === "string")); | ||
})); | ||
(isNumberish = (function(node) { | ||
@@ -100,2 +103,3 @@ return (isPrimitive(node) && (!isNaN(node.value))); | ||
(exports["isLiteral"] = isLiteral); | ||
(exports["isString"] = isString); | ||
(exports["isNumberish"] = isNumberish); | ||
@@ -102,0 +106,0 @@ (exports["isPrimitive"] = isPrimitive); |
@@ -7,41 +7,56 @@ /* | ||
var record = require("bes")["record"], | ||
__o = require("khepri-ast")["node"], | ||
__o0 = require("../ast"), | ||
markExpansion, incrementCount, getExpansion, isExpansion, mergeExpansions, expandNode, setData = __o["setData"], | ||
getUd = __o0["getUd"], | ||
__o = require("../ast"), | ||
getExpansion, isExpansion, getExpansionDepth, getExpansionValue, setExpansion, deleteExpansion, canExpand, | ||
markExpansion, incrementCount, mergeExpansions, expandNode, getUd = __o["getUd"], | ||
setUd = __o["setUd"], | ||
Expansion = record.declare(null, ["count", "value"]); | ||
(getExpansion = getUd.bind(null, "expand")); | ||
(isExpansion = getExpansion); | ||
(getExpansionDepth = (function(node) { | ||
var exp = getExpansion(node); | ||
return (exp ? exp.count : 0); | ||
})); | ||
(getExpansionValue = (function(z) { | ||
var y = getExpansion(z); | ||
return (y && y.value); | ||
})); | ||
(setExpansion = setUd.bind(null, "expand")); | ||
(deleteExpansion = setExpansion.bind(null, null)); | ||
(canExpand = (function(node) { | ||
var exp; | ||
return (getExpansion(node) && (((exp = getExpansion(node)), (exp ? exp.count : 0)) < 1)); | ||
})); | ||
(markExpansion = (function(node, count, value) { | ||
var expansion, expansion0; | ||
return (getExpansion(value) ? ((expansion = getExpansion(value)), setData(node, "expand", expansion)) : (( | ||
expansion0 = Expansion.create(Math.max(count, (getExpansion(node) ? getExpansion(node) | ||
.count : 0)), value)), setData(node, "expand", expansion0))); | ||
var exp; | ||
return (getExpansion(value) ? setExpansion(getExpansion(value), node) : setExpansion(Expansion.create(Math.max( | ||
count, ((exp = getExpansion(node)), (exp ? exp.count : 0))), value), node)); | ||
})); | ||
(mergeExpansions = (function(val, other) { | ||
var expansion; | ||
return ((getExpansion(other) && getExpansion(val)) ? ((expansion = Expansion.create(Math.max(getExpansion( | ||
val) | ||
.count, getExpansion(other) | ||
.count), getExpansion(val) | ||
.value)), setData(val, "expand", expansion)) : val); | ||
var exp, exp0; | ||
return ((getExpansion(other) && getExpansion(val)) ? setExpansion(Expansion.create(Math.max(((exp = | ||
getExpansion(val)), (exp ? exp.count : 0)), ((exp0 = getExpansion(other)), (exp0 ? exp0 | ||
.count : 0))), getExpansion(val) | ||
.value), val) : val); | ||
})); | ||
(incrementCount = (function(node, count, value) { | ||
var exp = getExpansion(node), | ||
count0 = (((exp && exp.count) || count) + 1), | ||
expansion, expansion0; | ||
return (getExpansion(value) ? ((expansion = getExpansion(value)), setData(node, "expand", expansion)) : (( | ||
expansion0 = Expansion.create(Math.max(count0, (getExpansion(node) ? getExpansion(node) | ||
.count : 0)), value)), setData(node, "expand", expansion0))); | ||
var exp, count0 = ((((exp = getExpansion(node)), (exp ? exp.count : 0)) || count) + 1), | ||
exp0; | ||
return (getExpansion(value) ? setExpansion(getExpansion(value), node) : setExpansion(Expansion.create(Math.max( | ||
count0, ((exp0 = getExpansion(node)), (exp0 ? exp0.count : 0))), value), node)); | ||
})); | ||
(expandNode = (function(node) { | ||
var exp; | ||
return (getExpansion(node) ? ((exp = getExpansion(node)), ((exp.count < 1) ? exp.value : setData(node, | ||
"expand", null))) : node); | ||
return (getExpansion(node) ? ((getExpansion(node) && (((exp = getExpansion(node)), (exp ? exp.count : 0)) < | ||
1)) ? getExpansionValue(node) : deleteExpansion(node)) : node); | ||
})); | ||
(exports["getExpansion"] = getExpansion); | ||
(exports["isExpansion"] = isExpansion); | ||
(exports["getExpansionDepth"] = getExpansionDepth); | ||
(exports["getExpansionValue"] = getExpansionValue); | ||
(exports["setExpansion"] = setExpansion); | ||
(exports["deleteExpansion"] = deleteExpansion); | ||
(exports["canExpand"] = canExpand); | ||
(exports["markExpansion"] = markExpansion); | ||
(exports["incrementCount"] = incrementCount); | ||
(exports["getExpansion"] = getExpansion); | ||
(exports["isExpansion"] = isExpansion); | ||
(exports["mergeExpansions"] = mergeExpansions); | ||
(exports["expandNode"] = expandNode); |
@@ -15,39 +15,41 @@ /* | ||
TreeZipperT = require("zipper-m")["trans"]["tree"], | ||
__o1 = require("../ast"), | ||
ast = require("../ast"), | ||
builtin = require("../builtin"), | ||
__o2 = require("../fun"), | ||
__o1 = require("../fun"), | ||
state = require("./state"), | ||
__o3 = require("./expand"), | ||
__o4 = require("./expansion"), | ||
__o5 = require("./rename"), | ||
__o2 = require("./expand"), | ||
__o3 = require("./expansion"), | ||
__o4 = require("./rename"), | ||
optimize, modifyNode = __o["modify"], | ||
setData = __o["setData"], | ||
next = __o0["next"], | ||
seq = __o0["sequence"], | ||
seqa = __o0["sequencea"], | ||
type = __o1["type"], | ||
isIdentifier = __o1["isIdentifier"], | ||
getUid = __o1["getUid"], | ||
isLambda = __o1["isLambda"], | ||
isLambdaWithoutArgs = __o1["isLambdaWithoutArgs"], | ||
isPrimitive = __o1["isPrimitive"], | ||
isNumberish = __o1["isNumberish"], | ||
isTruthy = __o1["isTruthy"], | ||
type = ast["type"], | ||
isIdentifier = ast["isIdentifier"], | ||
getUid = ast["getUid"], | ||
isLambda = ast["isLambda"], | ||
isLambdaWithoutArgs = ast["isLambdaWithoutArgs"], | ||
isPrimitive = ast["isPrimitive"], | ||
isString = ast["isString"], | ||
isNumberish = ast["isNumberish"], | ||
isTruthy = ast["isTruthy"], | ||
builtins = builtin["builtins"], | ||
definitions = builtin["definitions"], | ||
flattenr = __o2["flattenr"], | ||
flatten = __o2["flatten"], | ||
foldl = __o2["foldl"], | ||
concat = __o2["concat"], | ||
map = __o2["map"], | ||
range = __o2["range"], | ||
flattenr = __o1["flattenr"], | ||
flatten = __o1["flatten"], | ||
foldl = __o1["foldl"], | ||
concat = __o1["concat"], | ||
map = __o1["map"], | ||
range = __o1["range"], | ||
State = state["State"], | ||
expandCallee = __o3["expandCallee"], | ||
expandCurry = __o3["expandCurry"], | ||
markExpansion = __o4["markExpansion"], | ||
mergeExpansions = __o4["mergeExpansions"], | ||
getExpansion = __o4["getExpansion"], | ||
isExpansion = __o4["isExpansion"], | ||
expandNode = __o4["expandNode"], | ||
incCount = __o5["incCount"], | ||
expandCallee = __o2["expandCallee"], | ||
expandCurry = __o2["expandCurry"], | ||
markExpansion = __o3["markExpansion"], | ||
mergeExpansions = __o3["mergeExpansions"], | ||
getExpansion = __o3["getExpansion"], | ||
getExpansionDepth = __o3["getExpansionDepth"], | ||
getExpansionValue = __o3["getExpansionValue"], | ||
isExpansion = __o3["isExpansion"], | ||
expandNode = __o3["expandNode"], | ||
incCount = __o4["incCount"], | ||
x, y, x3, y3, __args, ops, consequent0, alternate0, consequent, alternate, __args0, ops0, consequent1, __args1, | ||
@@ -59,8 +61,8 @@ ops1, __args2, ops2, __args3, ops3, __args4, ops4, __args5, ops5, __args7, ops7, consequent2, __args8, ops8, | ||
ops29, __args30, ops30, consequent5, __args31, ops31, __args32, ops32, consequent6, consequent7, __args33, | ||
ops33, consequent8, __args34, ops34, __args35, ops35, __args36, ops36, consequent9, alternate1, __args37, ops37, | ||
__args38, ops38, consequent10, __args39, ops39, __args40, ops40, consequent11, consequent12, consequent13, | ||
consequent14, __args41, ops41, __args42, ops42, __args43, ops43, __args44, ops44, exp, consequent15, | ||
consequent16, __args45, ops45, __args46, ops46, exp0, consequent17, consequent18, __args47, ops47, __args48, | ||
ops48, consequent19, consequent20, __args49, ops49, consequent21, __args51, ops51, __args52, ops52, __args53, | ||
ops53, x40, y40, __and = (function(x, y) { | ||
ops33, consequent8, __args35, ops35, __args36, ops36, __args37, ops37, consequent9, alternate1, __args38, ops38, | ||
__args39, ops39, consequent10, __args40, ops40, __args41, ops41, consequent11, consequent12, consequent13, | ||
consequent14, __args42, ops42, __args43, ops43, __args44, ops44, __args45, ops45, exp, consequent15, | ||
consequent16, __args46, ops46, __args47, ops47, exp0, consequent17, consequent18, __args48, ops48, __args49, | ||
ops49, consequent19, consequent20, __args50, ops50, consequent21, __args52, ops52, __args53, ops53, __args54, | ||
ops54, x41, y41, __and = (function(x, y) { | ||
return (x && y); | ||
@@ -131,2 +133,4 @@ }), | ||
}), | ||
SIMPLE = true, | ||
COMPLEX = false, | ||
_check, M = TreeZipperT(StateT(Unique)), | ||
@@ -196,26 +200,31 @@ run = (function(c, ctx, state0, seed) { | ||
}), | ||
addBindingForNode = (function(id, value) { | ||
var uid = getUid(id); | ||
return (isPrimitive(value) ? addBinding(uid, value, true) : (isLambda(value) ? addBinding(uid, | ||
markExpansion(id, 0, value), true) : (isIdentifier(value) ? getBinding(getUid(value)) | ||
getBindingType = (function(id, value) { | ||
return (isPrimitive(value) ? M.of([SIMPLE, value]) : (isLambda(value) ? M.of([SIMPLE, markExpansion(id, 0, | ||
value)]) : (isIdentifier(value) ? getBinding(getUid(value)) | ||
.chain((function(binding) { | ||
return ((binding && binding.immutable) ? addBinding(uid, ((binding.simple && | ||
binding.value) ? mergeExpansions(binding.value, value) : value), true) : | ||
addBinding(uid, value, false)); | ||
})) : addBinding(uid, value, false)))); | ||
return ((binding && binding.immutable) ? M.of([SIMPLE, ((binding.simple && binding.value) ? | ||
mergeExpansions(binding.value, value) : value)]) : M.of([COMPLEX, value])); | ||
})) : M.of([COMPLEX, value])))); | ||
}), | ||
addBindingForNode = (function(id, value) { | ||
return getBindingType(id, value) | ||
.chain((function(__o5) { | ||
var kind = __o5[0], | ||
value0 = __o5[1]; | ||
return addBinding(getUid(id), value0, kind); | ||
})); | ||
}), | ||
addWorkingForNode = (function(id, value) { | ||
var uid = getUid(id); | ||
return (isPrimitive(value) ? addWorking(uid, value, true) : (isLambda(value) ? addWorking(uid, | ||
markExpansion(id, 0, value), true) : (isIdentifier(value) ? getBinding(getUid(value)) | ||
.chain((function(binding) { | ||
return ((binding && binding.immutable) ? addWorking(uid, ((binding.simple && | ||
binding.value) ? binding.value : value), true) : addWorking(uid, value, | ||
false)); | ||
})) : invalidateWorking(uid)))); | ||
return getBindingType(id, value) | ||
.chain((function(__o5) { | ||
var kind = __o5[0], | ||
value0 = __o5[1]; | ||
return addWorking(getUid(id), value0, kind); | ||
})); | ||
}), | ||
setWorkingForNode = (function(id, value) { | ||
return getBinding(getUid(id)) | ||
var uid = getUid(id); | ||
return getBinding(uid) | ||
.chain((function(binding) { | ||
return (binding ? addWorkingForNode(id, value) : invalidateWorking(getUid(id))); | ||
return (binding ? addWorkingForNode(id, value) : invalidateWorking(uid)); | ||
})); | ||
@@ -233,4 +242,4 @@ }), | ||
x0 = addRewrite.bind(null, "UnaryOperator"), | ||
y0 = seq(extract((function(__o6) { | ||
var name = __o6["name"], | ||
y0 = seq(extract((function(__o5) { | ||
var name = __o5["name"], | ||
x1, y1; | ||
@@ -241,4 +250,4 @@ return seq(addGlobal(name), ((x1 = set), (y1 = builtins[name]), x1(y1))); | ||
var x1 = addRewrite.bind(null, "BinaryOperator"), | ||
y1 = seq(extract((function(__o6) { | ||
var name = __o6["name"], | ||
y1 = seq(extract((function(__o5) { | ||
var name = __o5["name"], | ||
x2, y2; | ||
@@ -252,10 +261,10 @@ return seq(addGlobal(name), ((x2 = set), (y2 = builtins[name]), x2(y2))); | ||
var x4 = addRewrite.bind(null, "OperatorExpression"), | ||
y4 = seq(((consequent = seq(unique((function(uid) { | ||
return modify((function(__o6) { | ||
var operator = __o6["operator"]; | ||
y4 = seq(((consequent = unique((function(uid) { | ||
return modify((function(__o5) { | ||
var operator = __o5["operator"]; | ||
return builtin.member(operator, uid); | ||
})); | ||
})), checkTop)), (alternate = seq(((__args = ["operator", checkTop]), (ops = [__args[1]]), seq(moveChild( | ||
"operator"), seqa(ops), up)), ((consequent0 = modify((function(__o6) { | ||
var operator = __o6["operator"]; | ||
}))), (alternate = seq(((__args = ["operator", checkTop]), (ops = [__args[1]]), seq(moveChild("operator"), | ||
seqa(ops), up)), ((consequent0 = modify((function(__o5) { | ||
var operator = __o5["operator"]; | ||
return ast_expression.CallExpression.create(null, builtins["_"], [operator]); | ||
@@ -266,7 +275,7 @@ }))), (alternate0 = modify((function(x5) { | ||
return (node.flipped ? consequent0 : (alternate0 || pass)); | ||
}))), checkTop)), extract((function(node) { | ||
}))))), extract((function(node) { | ||
var operator; | ||
return (((operator = node["operator"]), ((type(operator) === "MemberExpression") || (type( | ||
operator) === "CallExpression"))) ? consequent : (alternate || pass)); | ||
})))); | ||
}))), checkTop); | ||
x4(y4); | ||
@@ -278,3 +287,3 @@ var x5 = addRewrite.bind(null, "Program"), | ||
return modifyNode(node, ({ | ||
body: concat(createGlobalDeclarations(globals0), node.body) | ||
"body": concat(createGlobalDeclarations(globals0), node.body) | ||
})); | ||
@@ -292,9 +301,9 @@ })); | ||
return modify((function(node) { | ||
var body = node["body"]; | ||
return modifyNode(node, ({ | ||
"body": ((type(node.body) === "WithStatement") ? ast_statement.WithStatement | ||
.create(node.body.loc, node.body.bindings, ast_statement.BlockStatement | ||
.create(null, concat(createGlobalDeclarations(globals0), node.body.body | ||
.body))) : concat(createGlobalDeclarations(globals0), node.body) | ||
) | ||
}), ({})); | ||
"body": ((type(body) === "WithStatement") ? modifyNode(body, ({ | ||
"body": ast_statement.BlockStatement.create(null, concat( | ||
createGlobalDeclarations(globals0), body.body.body)) | ||
})) : concat(createGlobalDeclarations(globals0), body)) | ||
})); | ||
})); | ||
@@ -319,6 +328,6 @@ }))); | ||
y10 = seq(((__args7 = ["init", checkTop]), (ops7 = [__args7[1]]), seq(moveChild("init"), seqa(ops7), up)), (( | ||
consequent2 = extract((function(__o6) { | ||
var immutable = __o6["immutable"], | ||
id = __o6["id"], | ||
init = __o6["init"]; | ||
consequent2 = extract((function(__o5) { | ||
var immutable = __o5["immutable"], | ||
id = __o5["id"], | ||
init = __o5["init"]; | ||
return (immutable ? seq(addBindingForNode(id, init), tryPrune(id)) : addWorking(getUid(id), | ||
@@ -331,22 +340,20 @@ init, ((isPrimitive(init) || isIdentifier(init)) || isLambda(init)))); | ||
var x11 = addRewrite.bind(null, "Binding"), | ||
y11 = seq(((__args8 = ["value", checkTop]), (ops8 = [__args8[1]]), seq(moveChild("value"), seqa(ops8), up)), | ||
extract((function() { | ||
return pass; | ||
})), ((consequent3 = extract((function(__o6) { | ||
var pattern = __o6["pattern"], | ||
value = __o6["value"]; | ||
y11 = seq(((__args8 = ["value", checkTop]), (ops8 = [__args8[1]]), seq(moveChild("value"), seqa(ops8), up)), (( | ||
consequent3 = extract((function(__o5) { | ||
var pattern = __o5["pattern"], | ||
value = __o5["value"]; | ||
return seq(addBindingForNode(pattern.id, value), tryPrune(pattern.id)); | ||
}))), extract((function(node) { | ||
var pattern; | ||
return (((pattern = node["pattern"]), ((type(pattern) === "IdentifierPattern") && getUid( | ||
pattern.id))) ? consequent3 : (undefined || pass)); | ||
}))), ((consequent4 = extract((function(node) { | ||
var y12 = concat(node.value.bindings, ast_declaration.Binding.create(null, node.pattern, | ||
node.value.body)), | ||
bindings = flatten(y12); | ||
return seq(set(bindings), visitChild((bindings.length - 1))); | ||
}))), extract((function(node) { | ||
return (((type(node) === "Binding") && (type(node.value) === "LetExpression")) ? consequent4 : | ||
(undefined || pass)); | ||
})))); | ||
var pattern; | ||
return (((pattern = node["pattern"]), ((type(pattern) === "IdentifierPattern") && getUid( | ||
pattern.id))) ? consequent3 : (undefined || pass)); | ||
}))), ((consequent4 = extract((function(node) { | ||
var y12 = concat(node.value.bindings, ast_declaration.Binding.create(null, node.pattern, | ||
node.value.body)), | ||
bindings = flatten(y12); | ||
return seq(set(bindings), visitChild((bindings.length - 1))); | ||
}))), extract((function(node) { | ||
return (((type(node) === "Binding") && (type(node.value) === "LetExpression")) ? consequent4 : | ||
(undefined || pass)); | ||
})))); | ||
x11(y11); | ||
@@ -406,3 +413,3 @@ var x12 = addRewrite.bind(null, "BlockStatement"), | ||
return modify((function(node) { | ||
return setData(node, "locals", concat(node.ud.locals, locals)); | ||
return ast.setLocals(concat(ast.getLocals(node), locals), node); | ||
})); | ||
@@ -422,6 +429,6 @@ })), popLocals | ||
y22 = seq(((__args30 = ["argument", checkTop]), (ops30 = [__args30[1]]), seq(moveChild("argument"), seqa(ops30), up)), ( | ||
(consequent5 = modify((function(__o6) { | ||
var loc = __o6["loc"], | ||
operator = __o6["operator"], | ||
argument = __o6["argument"], | ||
(consequent5 = modify((function(__o5) { | ||
var loc = __o5["loc"], | ||
operator = __o5["operator"], | ||
argument = __o5["argument"], | ||
value = arithmetic[operator](argument.value); | ||
@@ -457,6 +464,6 @@ return ast_value.Literal.create(loc, (typeof value), value); | ||
__args32 = ["right", checkTop]), (ops32 = [__args32[1]]), seq(moveChild("right"), seqa(ops32), up)), (( | ||
consequent6 = modify((function(__o6) { | ||
var operator = __o6["operator"], | ||
left = __o6["left"], | ||
right0 = __o6["right"], | ||
consequent6 = modify((function(__o5) { | ||
var operator = __o5["operator"], | ||
left = __o5["left"], | ||
right0 = __o5["right"], | ||
value = arithmetic0[operator](left.value, right0.value); | ||
@@ -469,6 +476,6 @@ return ast_value.Literal.create(null, (typeof value), value); | ||
undefined || pass)); | ||
}))), ((consequent7 = extract((function(__o6) { | ||
var operator = __o6["operator"], | ||
left = __o6["left"], | ||
right0 = __o6["right"], | ||
}))), ((consequent7 = extract((function(__o5) { | ||
var operator = __o5["operator"], | ||
left = __o5["left"], | ||
right0 = __o5["right"], | ||
x24, y24; | ||
@@ -487,6 +494,6 @@ return seq(addGlobal(operator), ((x24 = set), (y24 = ast_expression.CallExpression.create( | ||
y24 = seq(((__args33 = ["right", checkTop]), (ops33 = [__args33[1]]), seq(moveChild("right"), seqa(ops33), up)), (( | ||
consequent8 = extract((function(__o6) { | ||
var immutable = __o6["immutable"], | ||
left = __o6["left"], | ||
right0 = __o6["right"]; | ||
consequent8 = extract((function(__o5) { | ||
var immutable = __o5["immutable"], | ||
left = __o5["left"], | ||
right0 = __o5["right"]; | ||
return (immutable ? addBindingForNode(left, right0) : setWorkingForNode(left, right0)); | ||
@@ -499,19 +506,24 @@ }))), extract((function(node) { | ||
x24(y24); | ||
var x25 = addRewrite.bind(null, ["ConditionalExpression", "IfStatement"]), | ||
y25 = seq(((__args34 = ["test", checkTop]), (ops34 = [__args34[1]]), seq(moveChild("test"), seqa(ops34), up)), (( | ||
consequent9 = extract((function(__o6) { | ||
var test = __o6["test"], | ||
consequent10 = __o6["consequent"], | ||
alternate1 = __o6["alternate"]; | ||
var x25 = addRewrite.bind(null, "DeleteExpression"), | ||
__args34 = ["argument", checkTop], | ||
ops34 = [__args34[1]], | ||
y25 = seq(moveChild("argument"), seqa(ops34), up); | ||
x25(y25); | ||
var x26 = addRewrite.bind(null, ["ConditionalExpression", "IfStatement"]), | ||
y26 = seq(((__args35 = ["test", checkTop]), (ops35 = [__args35[1]]), seq(moveChild("test"), seqa(ops35), up)), (( | ||
consequent9 = extract((function(__o5) { | ||
var test = __o5["test"], | ||
consequent10 = __o5["consequent"], | ||
alternate1 = __o5["alternate"]; | ||
return seq(set((isTruthy(test) ? consequent10 : alternate1)), checkTop); | ||
}))), (alternate1 = seq(((__args35 = ["consequent", checkTop]), (ops35 = [__args35[1]]), seq(moveChild( | ||
"consequent"), seqa(ops35), up)), ((__args36 = ["alternate", checkTop]), (ops36 = [__args36[1]]), | ||
seq(moveChild("alternate"), seqa(ops36), up)))), extract((function(node) { | ||
}))), (alternate1 = seq(((__args36 = ["consequent", checkTop]), (ops36 = [__args36[1]]), seq(moveChild( | ||
"consequent"), seqa(ops36), up)), ((__args37 = ["alternate", checkTop]), (ops37 = [__args37[1]]), | ||
seq(moveChild("alternate"), seqa(ops37), up)))), extract((function(node) { | ||
return (isPrimitive(node.test) ? consequent9 : (alternate1 || pass)); | ||
})))); | ||
x25(y25); | ||
var x26 = addRewrite.bind(null, "CheckedMemberExpression"), | ||
y26 = seq(((__args37 = ["object", checkTop]), (ops37 = [__args37[1]]), seq(moveChild("object"), seqa(ops37), up)), ( | ||
(__args38 = ["property", checkTop]), (ops38 = [__args38[1]]), (consequent10 = seq(moveChild("property"), | ||
seqa(ops38), up)), extract((function(node) { | ||
x26(y26); | ||
var x27 = addRewrite.bind(null, "CheckedMemberExpression"), | ||
y27 = seq(((__args38 = ["object", checkTop]), (ops38 = [__args38[1]]), seq(moveChild("object"), seqa(ops38), up)), ( | ||
(__args39 = ["property", checkTop]), (ops39 = [__args39[1]]), (consequent10 = seq(moveChild("property"), | ||
seqa(ops39), up)), extract((function(node) { | ||
return (node.computed ? consequent10 : (undefined || pass)); | ||
@@ -521,18 +533,18 @@ }))), extract((function(node) { | ||
.chain((function(binding) { | ||
var x27, y27; | ||
return (((binding && binding.value) && binding.simple) ? ((x27 = set), (y27 = | ||
var x28, y28; | ||
return (((binding && binding.value) && binding.simple) ? ((x28 = set), (y28 = | ||
modifyNode(node, ({ | ||
"id": binding.value | ||
}))), x27(y27)) : pass); | ||
}))), x28(y28)) : pass); | ||
})); | ||
}))); | ||
x26(y26); | ||
var x27 = addRewrite.bind(null, "MemberExpression"), | ||
y27 = seq(((__args39 = ["object", checkTop]), (ops39 = [__args39[1]]), seq(moveChild("object"), seqa(ops39), up)), ( | ||
(__args40 = ["property", checkTop]), (ops40 = [__args40[1]]), (consequent11 = seq(moveChild("property"), | ||
seqa(ops40), up)), extract((function(node) { | ||
x27(y27); | ||
var x28 = addRewrite.bind(null, "MemberExpression"), | ||
y28 = seq(((__args40 = ["object", checkTop]), (ops40 = [__args40[1]]), seq(moveChild("object"), seqa(ops40), up)), ( | ||
(__args41 = ["property", checkTop]), (ops41 = [__args41[1]]), (consequent11 = seq(moveChild("property"), | ||
seqa(ops41), up)), extract((function(node) { | ||
return (node.computed ? consequent11 : (undefined || pass)); | ||
}))), ((consequent12 = modify((function(__o6) { | ||
var object = __o6["object"], | ||
property = __o6["property"]; | ||
}))), ((consequent12 = modify((function(__o5) { | ||
var object = __o5["object"], | ||
property = __o5["property"]; | ||
return (object.elements[property.value] || builtins.undefined); | ||
@@ -542,4 +554,4 @@ }))), extract((function(node) { | ||
consequent12 : (undefined || pass)); | ||
}))), ((consequent13 = modify((function(__o6) { | ||
var object = __o6["object"]; | ||
}))), ((consequent13 = modify((function(__o5) { | ||
var object = __o5["object"]; | ||
return ast_value.Literal.create(null, "number", object.elements.length); | ||
@@ -556,21 +568,23 @@ }))), extract((function(node) { | ||
}))), extract((function(node) { | ||
return (((node.computed && ((type(node.object) === "Literal") && (node.object.kind === "string"))) && | ||
isNumberish(node.property)) ? consequent14 : (undefined || pass)); | ||
return (((node.computed && isString(node.object)) && isNumberish(node.property)) ? consequent14 : | ||
(undefined || pass)); | ||
})))); | ||
x27(y27); | ||
var x28 = addRewrite.bind(null, ["NewExpression", "ApplyExpression"]), | ||
y28 = seq(((__args41 = ["callee", checkTop]), (ops41 = [__args41[1]]), seq(moveChild("callee"), seqa(ops41), up)), ( | ||
(__args42 = ["args", checkTop]), (ops42 = [__args42[1]]), seq(moveChild("args"), seqa(ops42), up))); | ||
x28(y28); | ||
var x29 = addRewrite.bind(null, "CallExpression"), | ||
y29 = seq(((__args43 = ["callee", checkTop]), (ops43 = [__args43[1]]), seq(moveChild("callee"), seqa(ops43), up)), ( | ||
(__args44 = ["args", checkTop]), (ops44 = [__args44[1]]), seq(moveChild("args"), seqa(ops44), up)), ((exp = | ||
M.node.map((function(x30) { | ||
return x30.callee; | ||
var x29 = addRewrite.bind(null, ["NewExpression", "ApplyExpression"]), | ||
y29 = seq(((__args42 = ["callee", checkTop]), (ops42 = [__args42[1]]), seq(moveChild("callee"), seqa(ops42), up)), ( | ||
(__args43 = ["args", checkTop]), (ops43 = [__args43[1]]), seq(moveChild("args"), seqa(ops43), up))); | ||
x29(y29); | ||
var x30 = addRewrite.bind(null, "CallExpression"), | ||
y30 = seq(((__args44 = ["callee", checkTop]), (ops44 = [__args44[1]]), seq(moveChild("callee"), seqa(ops44), up)), ( | ||
(__args45 = ["args", checkTop]), (ops45 = [__args45[1]]), seq(moveChild("args"), seqa(ops45), up)), ((exp = | ||
M.node.map((function(x31) { | ||
return x31.callee; | ||
}))), (consequent15 = exp.chain((function(z) { | ||
var callee = expandNode(z); | ||
var newCallee = expandNode(z); | ||
return modify((function(node) { | ||
return incCount(getUid(node.callee), (getExpansion(node.callee) | ||
.count || 1), getExpansion(node.callee) | ||
.value, ast_expression.CallExpression.create(node.loc, callee, node.args)); | ||
var callee = node["callee"]; | ||
return incCount(getUid(callee), (getExpansionDepth(callee) || 1), | ||
getExpansionValue(callee), modifyNode(node, ({ | ||
"callee": newCallee | ||
}))); | ||
})); | ||
@@ -581,5 +595,5 @@ }))), extract((function(node) { | ||
return extract((function(node) { | ||
var __o6 = expandCallee(uid, node.callee, node.args), | ||
locals = __o6[0], | ||
node0 = __o6[1]; | ||
var __o5 = expandCallee(uid, node.callee, node.args), | ||
locals = __o5[0], | ||
node0 = __o5[1]; | ||
return seq(modifyState(state.addLocals.bind(null, locals)), set(node0)); | ||
@@ -592,13 +606,16 @@ })); | ||
})))); | ||
x29(y29); | ||
var x30 = addRewrite.bind(null, "CurryExpression"), | ||
y30 = seq(((__args45 = ["base", checkTop]), (ops45 = [__args45[1]]), seq(moveChild("base"), seqa(ops45), up)), (( | ||
__args46 = ["args", checkTop]), (ops46 = [__args46[1]]), seq(moveChild("args"), seqa(ops46), up)), ((exp0 = | ||
M.node.map((function(x31) { | ||
return x31.base; | ||
x30(y30); | ||
var x31 = addRewrite.bind(null, "CurryExpression"), | ||
y31 = seq(((__args46 = ["base", checkTop]), (ops46 = [__args46[1]]), seq(moveChild("base"), seqa(ops46), up)), (( | ||
__args47 = ["args", checkTop]), (ops47 = [__args47[1]]), seq(moveChild("args"), seqa(ops47), up)), ((exp0 = | ||
M.node.map((function(x32) { | ||
return x32.base; | ||
}))), (consequent17 = exp0.chain((function(z) { | ||
var base = expandNode(z); | ||
var expandedBase = expandNode(z); | ||
return modify((function(node) { | ||
return incCount(getUid(node.base), getExpansion(node.base), getExpansion(node.base) | ||
.value, ast_expression.CurryExpression.create(node.loc, base, node.args)); | ||
var base = node["base"]; | ||
return incCount(getUid(base), getExpansion(base), getExpansionValue(base), | ||
modifyNode(node, ({ | ||
"base": expandedBase | ||
}))); | ||
})); | ||
@@ -616,29 +633,28 @@ }))), extract((function(node) { | ||
})))); | ||
x30(y30); | ||
var x31 = addRewrite.bind(null, "LetExpression"), | ||
y31 = seq(((__args47 = ["bindings", checkTop]), (ops47 = [__args47[1]]), seq(moveChild("bindings"), seqa(ops47), up)), ( | ||
(__args48 = ["body", checkTop]), (ops48 = [__args48[1]]), seq(moveChild("body"), seqa(ops48), up)), (( | ||
consequent19 = modify((function(__o6) { | ||
var loc = __o6["loc"], | ||
bindings = __o6["bindings"], | ||
body3 = __o6["body"]; | ||
x31(y31); | ||
var x32 = addRewrite.bind(null, "LetExpression"), | ||
y32 = seq(((__args48 = ["bindings", checkTop]), (ops48 = [__args48[1]]), seq(moveChild("bindings"), seqa(ops48), up)), ( | ||
(__args49 = ["body", checkTop]), (ops49 = [__args49[1]]), seq(moveChild("body"), seqa(ops49), up)), (( | ||
consequent19 = modify((function(__o5) { | ||
var loc = __o5["loc"], | ||
bindings = __o5["bindings"], | ||
body3 = __o5["body"]; | ||
return ast_expression.LetExpression.create(loc, concat(bindings, body3.bindings), body3.body); | ||
}))), extract((function(node) { | ||
var z, y32; | ||
return (((z = node.body), (y32 = type(z)), ("LetExpression" === y32)) ? consequent19 : ( | ||
var z, y33; | ||
return (((z = node.body), (y33 = type(z)), ("LetExpression" === y33)) ? consequent19 : ( | ||
undefined || pass)); | ||
}))), modify((function(__o6) { | ||
var loc = __o6["loc"], | ||
bindings = __o6["bindings"], | ||
body3 = __o6["body"]; | ||
return ast_expression.LetExpression.create(loc, flattenr(bindings), body3); | ||
})), ((consequent20 = modify((function(x32) { | ||
return x32.body; | ||
}))), modify((function(node) { | ||
return modifyNode(node, ({ | ||
"bindings": flattenr(node.bindings) | ||
})); | ||
})), ((consequent20 = modify((function(x33) { | ||
return x33.body; | ||
}))), extract((function(node) { | ||
var bindings; | ||
return (((bindings = node["bindings"]), (!bindings.length)) ? consequent20 : (undefined || pass)); | ||
var x33; | ||
return (((x33 = node.bindings.length), (!x33)) ? consequent20 : (undefined || pass)); | ||
})))); | ||
x31(y31); | ||
var x32 = addRewrite.bind(null, "SliceUnpack"), | ||
y32 = seq(((__args49 = ["target", checkTop]), (ops49 = [__args49[1]]), seq(moveChild("target"), seqa(ops49), up)), ( | ||
x32(y32); | ||
var x33 = addRewrite.bind(null, "SliceUnpack"), | ||
y33 = seq(((__args50 = ["target", checkTop]), (ops50 = [__args50[1]]), seq(moveChild("target"), seqa(ops50), up)), ( | ||
(consequent21 = extract((function(node) { | ||
@@ -648,6 +664,6 @@ return getBinding(getUid(node.target)) | ||
return (((binding && binding.value) && (type(binding.value) === | ||
"ArrayExpression")) ? modify((function(__o6) { | ||
var target = __o6["target"], | ||
from = __o6["from"], | ||
to = __o6["to"]; | ||
"ArrayExpression")) ? modify((function(__o5) { | ||
var target = __o5["target"], | ||
from = __o5["from"], | ||
to = __o5["to"]; | ||
return ast_expression.ArrayExpression.create(null, map(( | ||
@@ -665,34 +681,35 @@ function(i) { | ||
})))); | ||
x32(y32); | ||
var x33 = addRewrite.bind(null, ["RelativeUnpack"]), | ||
__args50 = ["target", checkTop], | ||
ops50 = [__args50[1]], | ||
y33 = seq(moveChild("target"), seqa(ops50), up); | ||
x33(y33); | ||
var x34 = addRewrite.bind(null, "ArgumentsPattern"), | ||
y34 = seq(((__args51 = ["id", checkTop]), (ops51 = [__args51[1]]), seq(moveChild("id"), seqa(ops51), up)), (( | ||
__args52 = ["elements", checkTop]), (ops52 = [__args52[1]]), seq(moveChild("elements"), seqa(ops52), up)), ( | ||
(__args53 = ["self", checkTop]), (ops53 = [__args53[1]]), seq(moveChild("self"), seqa(ops53), up))); | ||
var x34 = addRewrite.bind(null, ["RelativeUnpack"]), | ||
__args51 = ["target", checkTop], | ||
ops51 = [__args51[1]], | ||
y34 = seq(moveChild("target"), seqa(ops51), up); | ||
x34(y34); | ||
var x35 = addRewrite.bind(null, "IdentifierPattern"), | ||
y35 = extract((function(node) { | ||
return addBinding(getUid(node.id), null, true); | ||
var x35 = addRewrite.bind(null, "ArgumentsPattern"), | ||
y35 = seq(((__args52 = ["id", checkTop]), (ops52 = [__args52[1]]), seq(moveChild("id"), seqa(ops52), up)), (( | ||
__args53 = ["elements", checkTop]), (ops53 = [__args53[1]]), seq(moveChild("elements"), seqa(ops53), up)), ( | ||
(__args54 = ["self", checkTop]), (ops54 = [__args54[1]]), seq(moveChild("self"), seqa(ops54), up))); | ||
x35(y35); | ||
var x36 = addRewrite.bind(null, "IdentifierPattern"), | ||
y36 = extract((function(__o5) { | ||
var id = __o5["id"]; | ||
return addBinding(getUid(id), null, SIMPLE); | ||
})); | ||
x35(y35); | ||
var x36 = addRewrite.bind(null, "ArrayExpression"), | ||
__args54 = ["elements", checkTop], | ||
ops54 = [__args54[1]], | ||
y36 = seq(moveChild("elements"), seqa(ops54), up); | ||
x36(y36); | ||
var x37 = addRewrite.bind(null, "ObjectExpression"), | ||
__args55 = ["properties", checkTop], | ||
var x37 = addRewrite.bind(null, "ArrayExpression"), | ||
__args55 = ["elements", checkTop], | ||
ops55 = [__args55[1]], | ||
y37 = seq(moveChild("properties"), seqa(ops55), up); | ||
y37 = seq(moveChild("elements"), seqa(ops55), up); | ||
x37(y37); | ||
var x38 = addRewrite.bind(null, "ObjectValue"), | ||
__args56 = ["value", checkTop], | ||
var x38 = addRewrite.bind(null, "ObjectExpression"), | ||
__args56 = ["properties", checkTop], | ||
ops56 = [__args56[1]], | ||
y38 = seq(moveChild("value"), seqa(ops56), up); | ||
y38 = seq(moveChild("properties"), seqa(ops56), up); | ||
x38(y38); | ||
var x39 = addRewrite.bind(null, "Identifier"), | ||
var x39 = addRewrite.bind(null, "ObjectValue"), | ||
__args57 = ["value", checkTop], | ||
ops57 = [__args57[1]], | ||
y39 = seq(moveChild("value"), seqa(ops57), up); | ||
x39(y39); | ||
var x40 = addRewrite.bind(null, "Identifier"), | ||
consequent22 = extract((function(node) { | ||
@@ -704,6 +721,6 @@ return getBinding(getUid(node)) | ||
})), | ||
y39 = extract((function(node) { | ||
y40 = extract((function(node) { | ||
return ((getUid(node) && (!isExpansion(node))) ? consequent22 : (undefined || pass)); | ||
})); | ||
x39(y39); | ||
x40(y40); | ||
(_check = (function(node) { | ||
@@ -728,10 +745,10 @@ if (Array.isArray(node)) { | ||
}))), | ||
initialState = ((x40 = foldl((function(s, name) { | ||
initialState = ((x41 = foldl((function(s, name) { | ||
var id = builtins[name], | ||
def = definitions[name]; | ||
return state.addBinding(getUid(id), markExpansion(id, 0, def), true, s); | ||
}), State.empty, Object.keys(builtins))), (y40 = state.addGlobal.bind(null, "_")), y40(x40)); | ||
(optimize = (function(ast, data) { | ||
return run(inline, ast, initialState, data.unique); | ||
return state.addBinding(getUid(id), markExpansion(id, 0, def), SIMPLE, s); | ||
}), State.empty, Object.keys(builtins))), (y41 = state.addGlobal.bind(null, "_")), y41(x41)); | ||
(optimize = (function(ast0, data) { | ||
return run(inline, ast0, initialState, data.unique); | ||
})); | ||
(exports["optimize"] = optimize); |
@@ -44,7 +44,7 @@ /* | ||
__args40, actions40, __args41, actions41, __args42, actions42, __args43, actions43, __args44, actions44, body12, | ||
__args45, actions45, __args46, actions46, consequent1, __args47, actions47, __args48, actions48, __args49, | ||
actions49, __args50, actions50, __args51, actions51, __args52, actions52, __args53, actions53, __args54, | ||
actions54, __args55, actions55, __args56, actions56, __args57, actions57, consequent2, __args60, actions60, | ||
__args61, actions61, __args62, actions62, __args63, actions63, __args67, actions67, __args68, actions68, | ||
__args70, actions70, __args71, actions71, __args72, actions72, __args73, actions73, __args74, actions74, _check, | ||
__args45, actions45, __args46, actions46, consequent1, __args47, actions47, __args49, actions49, __args50, | ||
actions50, __args51, actions51, __args52, actions52, __args53, actions53, __args54, actions54, __args55, | ||
actions55, __args56, actions56, __args57, actions57, __args58, actions58, consequent2, __args61, actions61, | ||
__args62, actions62, __args63, actions63, __args64, actions64, __args68, actions68, __args69, actions69, | ||
__args71, actions71, __args72, actions72, __args73, actions73, __args74, actions74, __args75, actions75, _check, | ||
reserved = getUd.bind(null, "reserved"), | ||
@@ -396,63 +396,68 @@ getStart = (function(y) { | ||
x25(y25); | ||
var x26 = addCheck.bind(null, "BinaryExpression"), | ||
y26 = seq(((__args48 = ["operator", checkTop]), (actions48 = [__args48[1]]), seq(moveChild("operator"), seqa( | ||
actions48), up)), ((__args49 = ["left", checkTop]), (actions49 = [__args49[1]]), seq(moveChild("left"), | ||
seqa(actions49), up)), ((__args50 = ["right", checkTop]), (actions50 = [__args50[1]]), seq(moveChild( | ||
"right"), seqa(actions50), up))); | ||
var x26 = addCheck.bind(null, "DeleteExpression"), | ||
__args48 = ["argument", checkTop], | ||
actions48 = [__args48[1]], | ||
y26 = seq(moveChild("argument"), seqa(actions48), up); | ||
x26(y26); | ||
var x27 = addCheck.bind(null, "ConditionalExpression"), | ||
y27 = seq(((__args51 = ["test", checkTop]), (actions51 = [__args51[1]]), seq(moveChild("test"), seqa(actions51), up)), ( | ||
(__args52 = ["consequent", checkTop]), (actions52 = [__args52[1]]), seq(moveChild("consequent"), seqa( | ||
actions52), up)), ((__args53 = ["alternate", checkTop]), (actions53 = [__args53[1]]), seq(moveChild( | ||
"alternate"), seqa(actions53), up))); | ||
var x27 = addCheck.bind(null, "BinaryExpression"), | ||
y27 = seq(((__args49 = ["operator", checkTop]), (actions49 = [__args49[1]]), seq(moveChild("operator"), seqa( | ||
actions49), up)), ((__args50 = ["left", checkTop]), (actions50 = [__args50[1]]), seq(moveChild("left"), | ||
seqa(actions50), up)), ((__args51 = ["right", checkTop]), (actions51 = [__args51[1]]), seq(moveChild( | ||
"right"), seqa(actions51), up))); | ||
x27(y27); | ||
var x28 = addCheck.bind(null, ["CallExpression", "NewExpression"]), | ||
y28 = seq(((__args54 = ["callee", checkTop]), (actions54 = [__args54[1]]), seq(moveChild("callee"), seqa(actions54), | ||
up)), ((__args55 = ["args", checkTop]), (actions55 = [__args55[1]]), seq(moveChild("args"), seqa(actions55), | ||
var x28 = addCheck.bind(null, "ConditionalExpression"), | ||
y28 = seq(((__args52 = ["test", checkTop]), (actions52 = [__args52[1]]), seq(moveChild("test"), seqa(actions52), up)), ( | ||
(__args53 = ["consequent", checkTop]), (actions53 = [__args53[1]]), seq(moveChild("consequent"), seqa( | ||
actions53), up)), ((__args54 = ["alternate", checkTop]), (actions54 = [__args54[1]]), seq(moveChild( | ||
"alternate"), seqa(actions54), up))); | ||
x28(y28); | ||
var x29 = addCheck.bind(null, ["CallExpression", "NewExpression"]), | ||
y29 = seq(((__args55 = ["callee", checkTop]), (actions55 = [__args55[1]]), seq(moveChild("callee"), seqa(actions55), | ||
up)), ((__args56 = ["args", checkTop]), (actions56 = [__args56[1]]), seq(moveChild("args"), seqa(actions56), | ||
up))); | ||
x28(y28); | ||
var x29 = addCheck.bind(null, ["MemberExpression", "CheckedMemberExpression"]), | ||
y29 = seq(((__args56 = ["object", checkTop]), (actions56 = [__args56[1]]), seq(moveChild("object"), seqa(actions56), | ||
up)), ((__args57 = ["property", checkTop]), (actions57 = [__args57[1]]), (consequent2 = seq(moveChild( | ||
"property"), seqa(actions57), up)), inspect((function(node) { | ||
x29(y29); | ||
var x30 = addCheck.bind(null, ["MemberExpression", "CheckedMemberExpression"]), | ||
y30 = seq(((__args57 = ["object", checkTop]), (actions57 = [__args57[1]]), seq(moveChild("object"), seqa(actions57), | ||
up)), ((__args58 = ["property", checkTop]), (actions58 = [__args58[1]]), (consequent2 = seq(moveChild( | ||
"property"), seqa(actions58), up)), inspect((function(node) { | ||
return (node.computed ? consequent2 : (undefined || pass)); | ||
})))); | ||
x29(y29); | ||
var x30 = addCheck.bind(null, "ArrayExpression"), | ||
__args58 = ["elements", checkTop], | ||
actions58 = [__args58[1]], | ||
y30 = seq(moveChild("elements"), seqa(actions58), up); | ||
x30(y30); | ||
var x31 = addCheck.bind(null, "ObjectExpression"), | ||
__args59 = ["properties", checkTop], | ||
var x31 = addCheck.bind(null, "ArrayExpression"), | ||
__args59 = ["elements", checkTop], | ||
actions59 = [__args59[1]], | ||
y31 = seq(moveChild("properties"), seqa(actions59), up); | ||
y31 = seq(moveChild("elements"), seqa(actions59), up); | ||
x31(y31); | ||
var x32 = addCheck.bind(null, "LetExpression"), | ||
body13 = [((__args60 = ["bindings", checkTop]), (actions60 = [__args60[1]]), seq(moveChild("bindings"), seqa( | ||
actions60), up)), ((__args61 = ["body", checkTop]), (actions61 = [__args61[1]]), seq(moveChild("body"), | ||
seqa(actions61), up))], | ||
y32 = seq(push, seqa(body13), pop); | ||
var x32 = addCheck.bind(null, "ObjectExpression"), | ||
__args60 = ["properties", checkTop], | ||
actions60 = [__args60[1]], | ||
y32 = seq(moveChild("properties"), seqa(actions60), up); | ||
x32(y32); | ||
var x33 = addCheck.bind(null, "CurryExpression"), | ||
y33 = seq(((__args62 = ["base", checkTop]), (actions62 = [__args62[1]]), seq(moveChild("base"), seqa(actions62), up)), ( | ||
(__args63 = ["args", checkTop]), (actions63 = [__args63[1]]), seq(moveChild("args"), seqa(actions63), up))); | ||
var x33 = addCheck.bind(null, "LetExpression"), | ||
body13 = [((__args61 = ["bindings", checkTop]), (actions61 = [__args61[1]]), seq(moveChild("bindings"), seqa( | ||
actions61), up)), ((__args62 = ["body", checkTop]), (actions62 = [__args62[1]]), seq(moveChild("body"), | ||
seqa(actions62), up))], | ||
y33 = seq(push, seqa(body13), pop); | ||
x33(y33); | ||
var x34 = addCheck.bind(null, "OperatorExpression"), | ||
__args64 = ["operator", checkTop], | ||
actions64 = [__args64[1]], | ||
y34 = seq(moveChild("operator"), seqa(actions64), up); | ||
var x34 = addCheck.bind(null, "CurryExpression"), | ||
y34 = seq(((__args63 = ["base", checkTop]), (actions63 = [__args63[1]]), seq(moveChild("base"), seqa(actions63), up)), ( | ||
(__args64 = ["args", checkTop]), (actions64 = [__args64[1]]), seq(moveChild("args"), seqa(actions64), up))); | ||
x34(y34); | ||
var x35 = addCheck.bind(null, "EllipsisPattern"), | ||
__args65 = ["id", checkTop], | ||
var x35 = addCheck.bind(null, "OperatorExpression"), | ||
__args65 = ["operator", checkTop], | ||
actions65 = [__args65[1]], | ||
y35 = seq(moveChild("id"), seqa(actions65), up); | ||
y35 = seq(moveChild("operator"), seqa(actions65), up); | ||
x35(y35); | ||
var x36 = addCheck.bind(null, ["SliceUnpack", "RelativeUnpack", "ImportPattern"]), | ||
__args66 = ["pattern", checkTop], | ||
var x36 = addCheck.bind(null, "EllipsisPattern"), | ||
__args66 = ["id", checkTop], | ||
actions66 = [__args66[1]], | ||
y36 = seq(moveChild("pattern"), seqa(actions66), up); | ||
y36 = seq(moveChild("id"), seqa(actions66), up); | ||
x36(y36); | ||
var x37 = addCheck.bind(null, "IdentifierPattern"), | ||
y37 = seq(inspect((function(node) { | ||
var x37 = addCheck.bind(null, ["SliceUnpack", "RelativeUnpack", "ImportPattern"]), | ||
__args67 = ["pattern", checkTop], | ||
actions67 = [__args67[1]], | ||
y37 = seq(moveChild("pattern"), seqa(actions67), up); | ||
x37(y37); | ||
var x38 = addCheck.bind(null, "IdentifierPattern"), | ||
y38 = seq(inspect((function(node) { | ||
var loc = node["loc"], | ||
@@ -462,37 +467,37 @@ id = node["id"]; | ||
loc)); | ||
})), ((__args67 = ["id", checkTop]), (actions67 = [__args67[1]]), seq(moveChild("id"), seqa(actions67), up))); | ||
x37(y37); | ||
var x38 = addCheck.bind(null, "AsPattern"), | ||
y38 = seq(((__args68 = ["id", checkTop]), (actions68 = [__args68[1]]), seq(moveChild("id"), seqa(actions68), up)), | ||
})), ((__args68 = ["id", checkTop]), (actions68 = [__args68[1]]), seq(moveChild("id"), seqa(actions68), up))); | ||
x38(y38); | ||
var x39 = addCheck.bind(null, "AsPattern"), | ||
y39 = seq(((__args69 = ["id", checkTop]), (actions69 = [__args69[1]]), seq(moveChild("id"), seqa(actions69), up)), | ||
inspect((function(node) { | ||
var __args69 = ["target", modifyNode((function(target) { | ||
var __args70 = ["target", modifyNode((function(target) { | ||
return setUd("id", node.id, target); | ||
})), checkTop], | ||
actions69 = [__args69[1], __args69[2]]; | ||
return seq(moveChild("target"), seqa(actions69), up); | ||
actions70 = [__args70[1], __args70[2]]; | ||
return seq(moveChild("target"), seqa(actions70), up); | ||
}))); | ||
x38(y38); | ||
var x39 = addCheck.bind(null, "ObjectPattern"), | ||
__args69 = ["elements", checkTop], | ||
actions69 = [__args69[1]], | ||
y39 = seq(moveChild("elements"), seqa(actions69), up); | ||
x39(y39); | ||
var x40 = addCheck.bind(null, "ObjectPatternElement"), | ||
y40 = seq(((__args70 = ["target", checkTop]), (actions70 = [__args70[1]]), seq(moveChild("target"), seqa(actions70), | ||
up)), ((__args71 = ["key", checkTop]), (actions71 = [__args71[1]]), seq(moveChild("key"), seqa(actions71), | ||
var x40 = addCheck.bind(null, "ObjectPattern"), | ||
__args70 = ["elements", checkTop], | ||
actions70 = [__args70[1]], | ||
y40 = seq(moveChild("elements"), seqa(actions70), up); | ||
x40(y40); | ||
var x41 = addCheck.bind(null, "ObjectPatternElement"), | ||
y41 = seq(((__args71 = ["target", checkTop]), (actions71 = [__args71[1]]), seq(moveChild("target"), seqa(actions71), | ||
up)), ((__args72 = ["key", checkTop]), (actions72 = [__args72[1]]), seq(moveChild("key"), seqa(actions72), | ||
up))); | ||
x40(y40); | ||
var x41 = addCheck.bind(null, "ArgumentsPattern"), | ||
y41 = seq(((__args72 = ["id", checkTop]), (actions72 = [__args72[1]]), seq(moveChild("id"), seqa(actions72), up)), ( | ||
(__args73 = ["elements", checkTop]), (actions73 = [__args73[1]]), seq(moveChild("elements"), seqa(actions73), | ||
up)), ((__args74 = ["self", checkTop]), (actions74 = [__args74[1]]), seq(moveChild("self"), seqa( | ||
actions74), up))); | ||
x41(y41); | ||
var x42 = addCheck.bind(null, "ObjectValue"), | ||
__args75 = ["value", checkTop], | ||
actions75 = [__args75[1]], | ||
y42 = seq(moveChild("value"), seqa(actions75), up); | ||
var x42 = addCheck.bind(null, "ArgumentsPattern"), | ||
y42 = seq(((__args73 = ["id", checkTop]), (actions73 = [__args73[1]]), seq(moveChild("id"), seqa(actions73), up)), ( | ||
(__args74 = ["elements", checkTop]), (actions74 = [__args74[1]]), seq(moveChild("elements"), seqa(actions74), | ||
up)), ((__args75 = ["self", checkTop]), (actions75 = [__args75[1]]), seq(moveChild("self"), seqa( | ||
actions75), up))); | ||
x42(y42); | ||
var x43 = addCheck.bind(null, ["Identifier", "BinaryOperator"]), | ||
y43 = inspect((function(node) { | ||
var x43 = addCheck.bind(null, "ObjectValue"), | ||
__args76 = ["value", checkTop], | ||
actions76 = [__args76[1]], | ||
y43 = seq(moveChild("value"), seqa(actions76), up); | ||
x43(y43); | ||
var x44 = addCheck.bind(null, ["Identifier", "BinaryOperator"]), | ||
y44 = inspect((function(node) { | ||
var loc = node["loc"], | ||
@@ -502,9 +507,9 @@ name = node["name"]; | ||
var uid = scope.getUid(name, s), | ||
y44; | ||
return seq(addRef(uid), ((y44 = setUid(uid, node)), setNode(y44))); | ||
y45; | ||
return seq(addRef(uid), ((y45 = setUid(uid, node)), setNode(y45))); | ||
}))); | ||
})); | ||
x43(y43); | ||
var x44 = addCheck.bind(null, ["UnaryOperator"]), | ||
y44 = inspect((function(node) { | ||
x44(y44); | ||
var x45 = addCheck.bind(null, ["UnaryOperator"]), | ||
y45 = inspect((function(node) { | ||
var loc = node["loc"], | ||
@@ -514,7 +519,7 @@ name = node["name"]; | ||
var uid = scope.getUid(name, s), | ||
y45; | ||
return seq(((y45 = setUid(uid, node)), setNode(y45)), addOperator(name, uid)); | ||
y46; | ||
return seq(((y46 = setUid(uid, node)), setNode(y46)), addOperator(name, uid)); | ||
}))); | ||
})); | ||
x44(y44); | ||
x45(y45); | ||
(_check = (function(node) { | ||
@@ -527,9 +532,9 @@ return (Array.isArray(node) ? checkArray(node) : (checks[type(node)] || pass)); | ||
addUnaryOps = flip(foldl.bind(null, (function(s, c) { | ||
return scope.addOperator(c, "global", s); | ||
return scope.addOperator(c, "global", scope.addImmutableBinding(c, "global", s)); | ||
}))), | ||
rewrite = seq(checkTop, root, extractCtx.chain((function(x45) { | ||
rewrite = seq(checkTop, root, extractCtx.chain((function(x46) { | ||
return unique((function(unique0) { | ||
return extractScope.map((function(s) { | ||
return ({ | ||
tree: x45, | ||
tree: x46, | ||
data: ({ | ||
@@ -543,7 +548,7 @@ unique: unique0 | ||
(check = (function(ast, globals, builtinBinary, builtinUnary) { | ||
var x45, y45, x46, y46, x47, y47; | ||
return run(rewrite, ((x45 = Scope.empty), (y45 = addGlobals.bind(null, (globals || []))), (x46 = y45(x45)), ( | ||
y46 = addGlobals.bind(null, (builtinBinary || []))), (x47 = y46(x46)), (y47 = addUnaryOps.bind( | ||
null, (builtinUnary || []))), y47(x47)), ast, Error.of, Error.fail); | ||
var x46, y46, x47, y47, x48, y48; | ||
return run(rewrite, ((x46 = Scope.empty), (y46 = addGlobals.bind(null, (globals || []))), (x47 = y46(x46)), ( | ||
y47 = addGlobals.bind(null, (builtinBinary || []))), (x48 = y47(x47)), (y48 = addUnaryOps.bind( | ||
null, (builtinUnary || []))), y48(x48)), ast, Error.of, Error.fail); | ||
})); | ||
(exports["check"] = check); |
@@ -120,3 +120,19 @@ /* | ||
}))); | ||
peepholes.add("BinaryExpression", UP, (function(z) { | ||
var y0 = z.operator; | ||
return ("|>" === y0); | ||
}), (function(__o6) { | ||
var left = __o6["left"], | ||
right = __o6["right"]; | ||
return ast_expression.CallExpression.create(null, right, [left]); | ||
})); | ||
peepholes.add("BinaryExpression", UP, (function(z) { | ||
var y0 = z.operator; | ||
return ("<|" === y0); | ||
}), (function(__o6) { | ||
var left = __o6["left"], | ||
right = __o6["right"]; | ||
return ast_expression.CallExpression.create(null, left, [right]); | ||
})); | ||
(normalize = rewrite.bind(null, peepholes)); | ||
(exports["normalize"] = normalize); |
@@ -189,3 +189,3 @@ /* | ||
x18(y18); | ||
var x19 = addRewrite.bind(null, "UnaryExpression"), | ||
var x19 = addRewrite.bind(null, ["UnaryExpression", "DeleteExpression"]), | ||
__args34 = ["argument", checkTop], | ||
@@ -192,0 +192,0 @@ actions34 = [__args34[1]], |
@@ -15,6 +15,6 @@ /* | ||
builtinBinaryOps = ["*", "/", "+", "-", "%", "<<", ">>", ">>>", "<", ">", "<=", ">=", "==", "!=", "===", "!==", "&", | ||
"^", "|", "||", "&&", "|>", "||>", "\\>", "\\>>", "<|", "<<|", "<\\", "<<\\", "!", "++", "--", "~", ".", "??", | ||
"@", "void", "instanceof", "typeof", "new" | ||
"^", "|", "||", "&&", "|>", "||>", "\\>", "\\>>", "<|", "<<|", "<\\", "<<\\", ".", "??", "@", "instanceof", | ||
"new" | ||
], | ||
builtinUnaryOps = ["!", "++", "--", "~"]; | ||
builtinUnaryOps = ["!", "++", "--", "~", "typeof", "void"]; | ||
(check = (function(input) { | ||
@@ -21,0 +21,0 @@ var options = input["options"], |
@@ -48,6 +48,6 @@ /* | ||
actions48, __args49, actions49, __args50, actions50, __args51, actions51, __args52, actions52, __args53, | ||
actions53, __args54, actions55, __args55, actions56, __args56, actions57, __args57, actions58, __args58, | ||
actions59, __args59, actions60, __args60, actions61, __args61, actions62, __args63, actions64, __args64, | ||
actions65, __args65, actions66, __args66, actions67, move, uid, f1, uid0, f2, _trans, M = TreeZipperT(StateT( | ||
Unique)), | ||
actions53, __args54, actions54, __args55, actions56, __args56, actions57, __args57, actions58, __args58, | ||
actions59, __args59, actions60, __args60, actions61, __args61, actions62, __args62, actions63, __args64, | ||
actions65, __args65, actions66, __args66, actions67, __args67, actions68, move, uid, f1, uid0, f2, _trans, M = | ||
TreeZipperT(StateT(Unique)), | ||
run = (function(m, s, ctx) { | ||
@@ -239,55 +239,59 @@ return Unique.runUnique(StateT.evalStateT(TreeZipperT.runTreeZipperT(m, ctx), s)); | ||
x21(y22); | ||
var x22 = addTransform.bind(null, "UnaryExpression"), | ||
var x22 = addTransform.bind(null, "DeleteExpression"), | ||
y23 = seq(((__args33 = ["argument", checkTop]), (actions33 = [__args33[1]]), seq(moveChild("argument"), sequencea( | ||
actions33), up)), modify(translate.unaryExpression)); | ||
actions33), up)), modify(translate.deleteExpression)); | ||
x22(y23); | ||
var x23 = addTransform.bind(null, "BinaryExpression"), | ||
y24 = seq(((__args34 = ["operator", checkTop]), (actions34 = [__args34[1]]), seq(moveChild("operator"), sequencea( | ||
actions34), up)), ((__args35 = ["left", checkTop]), (actions35 = [__args35[1]]), seq(moveChild("left"), | ||
sequencea(actions35), up)), ((__args36 = ["right", checkTop]), (actions36 = [__args36[1]]), seq(moveChild( | ||
"right"), sequencea(actions36), up)), modify(translate.binaryExpression)); | ||
var x23 = addTransform.bind(null, "UnaryExpression"), | ||
y24 = seq(((__args34 = ["argument", checkTop]), (actions34 = [__args34[1]]), seq(moveChild("argument"), sequencea( | ||
actions34), up)), modify(translate.unaryExpression)); | ||
x23(y24); | ||
var x24 = addTransform.bind(null, "ConditionalExpression"), | ||
y25 = seq(((__args37 = ["test", checkTop]), (actions37 = [__args37[1]]), seq(moveChild("test"), sequencea(actions37), | ||
up)), ((__args38 = ["consequent", checkTop]), (actions38 = [__args38[1]]), seq(moveChild("consequent"), | ||
sequencea(actions38), up)), ((__args39 = ["alternate", checkTop]), (actions39 = [__args39[1]]), seq( | ||
moveChild("alternate"), sequencea(actions39), up)), modify(translate.conditionalExpression)); | ||
var x24 = addTransform.bind(null, "BinaryExpression"), | ||
y25 = seq(((__args35 = ["operator", checkTop]), (actions35 = [__args35[1]]), seq(moveChild("operator"), sequencea( | ||
actions35), up)), ((__args36 = ["left", checkTop]), (actions36 = [__args36[1]]), seq(moveChild("left"), | ||
sequencea(actions36), up)), ((__args37 = ["right", checkTop]), (actions37 = [__args37[1]]), seq(moveChild( | ||
"right"), sequencea(actions37), up)), modify(translate.binaryExpression)); | ||
x24(y25); | ||
var x25 = addTransform.bind(null, "NewExpression"), | ||
y26 = seq(((__args40 = ["callee", checkTop]), (actions40 = [__args40[1]]), seq(moveChild("callee"), sequencea( | ||
actions40), up)), ((__args41 = ["args", checkTop]), (actions41 = [__args41[1]]), seq(moveChild("args"), | ||
sequencea(actions41), up)), modify(translate.newExpression)); | ||
var x25 = addTransform.bind(null, "ConditionalExpression"), | ||
y26 = seq(((__args38 = ["test", checkTop]), (actions38 = [__args38[1]]), seq(moveChild("test"), sequencea(actions38), | ||
up)), ((__args39 = ["consequent", checkTop]), (actions39 = [__args39[1]]), seq(moveChild("consequent"), | ||
sequencea(actions39), up)), ((__args40 = ["alternate", checkTop]), (actions40 = [__args40[1]]), seq( | ||
moveChild("alternate"), sequencea(actions40), up)), modify(translate.conditionalExpression)); | ||
x25(y26); | ||
var x26 = addTransform.bind(null, "CallExpression"), | ||
y27 = seq(((__args42 = ["callee", checkTop]), (actions42 = [__args42[1]]), seq(moveChild("callee"), sequencea( | ||
actions42), up)), ((__args43 = ["args", checkTop]), (actions43 = [__args43[1]]), seq(moveChild("args"), | ||
sequencea(actions43), up)), modify(translate.callExpression)); | ||
var x26 = addTransform.bind(null, "NewExpression"), | ||
y27 = seq(((__args41 = ["callee", checkTop]), (actions41 = [__args41[1]]), seq(moveChild("callee"), sequencea( | ||
actions41), up)), ((__args42 = ["args", checkTop]), (actions42 = [__args42[1]]), seq(moveChild("args"), | ||
sequencea(actions42), up)), modify(translate.newExpression)); | ||
x26(y27); | ||
var x27 = addTransform.bind(null, "ApplyExpression"), | ||
y28 = seq(((__args44 = ["callee", checkTop]), (actions44 = [__args44[1]]), seq(moveChild("callee"), sequencea( | ||
actions44), up)), ((__args45 = ["args", checkTop]), (actions45 = [__args45[1]]), seq(moveChild("args"), | ||
sequencea(actions45), up)), modify(translate.applyExpression)); | ||
var x27 = addTransform.bind(null, "CallExpression"), | ||
y28 = seq(((__args43 = ["callee", checkTop]), (actions43 = [__args43[1]]), seq(moveChild("callee"), sequencea( | ||
actions43), up)), ((__args44 = ["args", checkTop]), (actions44 = [__args44[1]]), seq(moveChild("args"), | ||
sequencea(actions44), up)), modify(translate.callExpression)); | ||
x27(y28); | ||
var x28 = addTransform.bind(null, "MemberExpression"), | ||
y29 = seq(((__args46 = ["object", checkTop]), (actions46 = [__args46[1]]), seq(moveChild("object"), sequencea( | ||
actions46), up)), ((__args47 = ["property", checkTop]), (actions47 = [__args47[1]]), seq(moveChild( | ||
"property"), sequencea(actions47), up)), modify(translate.memberExpression)); | ||
var x28 = addTransform.bind(null, "ApplyExpression"), | ||
y29 = seq(((__args45 = ["callee", checkTop]), (actions45 = [__args45[1]]), seq(moveChild("callee"), sequencea( | ||
actions45), up)), ((__args46 = ["args", checkTop]), (actions46 = [__args46[1]]), seq(moveChild("args"), | ||
sequencea(actions46), up)), modify(translate.applyExpression)); | ||
x28(y29); | ||
var x29 = addTransform.bind(null, "CheckedMemberExpression"), | ||
y30 = seq(((__args48 = ["object", checkTop]), (actions48 = [__args48[1]]), seq(moveChild("object"), sequencea( | ||
actions48), up)), ((__args49 = ["property", checkTop]), (actions49 = [__args49[1]]), seq(moveChild( | ||
"property"), sequencea(actions49), up)), modify(translate.checkedMemberExpression), checkTop); | ||
var x29 = addTransform.bind(null, "MemberExpression"), | ||
y30 = seq(((__args47 = ["object", checkTop]), (actions47 = [__args47[1]]), seq(moveChild("object"), sequencea( | ||
actions47), up)), ((__args48 = ["property", checkTop]), (actions48 = [__args48[1]]), seq(moveChild( | ||
"property"), sequencea(actions48), up)), modify(translate.memberExpression)); | ||
x29(y30); | ||
var x30 = addTransform.bind(null, "LetExpression"), | ||
y31 = seq(((__args50 = ["bindings", checkTop]), (actions50 = [__args50[1]]), seq(moveChild("bindings"), sequencea( | ||
actions50), up)), withNode((function(z) { | ||
var x30 = addTransform.bind(null, "CheckedMemberExpression"), | ||
y31 = seq(((__args49 = ["object", checkTop]), (actions49 = [__args49[1]]), seq(moveChild("object"), sequencea( | ||
actions49), up)), ((__args50 = ["property", checkTop]), (actions50 = [__args50[1]]), seq(moveChild( | ||
"property"), sequencea(actions50), up)), modify(translate.checkedMemberExpression), checkTop); | ||
x30(y31); | ||
var x31 = addTransform.bind(null, "LetExpression"), | ||
y32 = seq(((__args51 = ["bindings", checkTop]), (actions51 = [__args51[1]]), seq(moveChild("bindings"), sequencea( | ||
actions51), up)), withNode((function(z) { | ||
return addBindingsForBindingsList(z.bindings); | ||
})), ((__args51 = ["body", checkTop]), (actions51 = [__args51[1]]), seq(moveChild("body"), sequencea(actions51), | ||
})), ((__args52 = ["body", checkTop]), (actions52 = [__args52[1]]), seq(moveChild("body"), sequencea(actions52), | ||
up)), modify(translate.letExpression)); | ||
x30(y31); | ||
var x31 = addTransform.bind(null, "CurryExpression"), | ||
y32 = seq(((__args52 = ["base", checkTop]), (actions52 = [__args52[1]]), seq(moveChild("base"), sequencea(actions52), | ||
up)), ((__args53 = ["args", checkTop]), (actions53 = [__args53[1]]), seq(moveChild("args"), sequencea( | ||
actions53), up)), modify(translate.curryExpression)); | ||
x31(y32); | ||
var x32 = addTransform.bind(null, "CurryExpression"), | ||
y33 = seq(((__args53 = ["base", checkTop]), (actions53 = [__args53[1]]), seq(moveChild("base"), sequencea(actions53), | ||
up)), ((__args54 = ["args", checkTop]), (actions54 = [__args54[1]]), seq(moveChild("args"), sequencea( | ||
actions54), up)), modify(translate.curryExpression)); | ||
x32(y33); | ||
var createExplicitClosure = (function(locals) { | ||
@@ -306,13 +310,13 @@ return enumeration(map((function(uid) { | ||
}), | ||
x32 = addTransform.bind(null, "FunctionExpression"), | ||
actions54 = [((__args54 = ["id", checkTop]), (actions55 = [__args54[1]]), seq(moveChild("id"), sequencea(actions55), | ||
x33 = addTransform.bind(null, "FunctionExpression"), | ||
actions55 = [((__args55 = ["id", checkTop]), (actions56 = [__args55[1]]), seq(moveChild("id"), sequencea(actions56), | ||
up)), modify((function(node0) { | ||
return translate.functionExpression(node0.loc, node0.id, node0.params, node0.body, getUd("prefix", | ||
node0)); | ||
})), ((__args55 = ["params", checkTop]), (actions56 = [__args55[1]]), seq(moveChild("params"), sequencea( | ||
actions56), up)), ((__args56 = ["body", checkTop]), (actions57 = [__args56[1]]), seq(moveChild("body"), | ||
sequencea(actions57), up)), modify(translate.functionExpressionPost)], | ||
y33 = seq(enterBlock, sequencea(actions54), exitBlock), | ||
evaluate = funcBlock(y33), | ||
y34 = getContext.chain((function(ctx) { | ||
})), ((__args56 = ["params", checkTop]), (actions57 = [__args56[1]]), seq(moveChild("params"), sequencea( | ||
actions57), up)), ((__args57 = ["body", checkTop]), (actions58 = [__args57[1]]), seq(moveChild("body"), | ||
sequencea(actions58), up)), modify(translate.functionExpressionPost)], | ||
y34 = seq(enterBlock, sequencea(actions55), exitBlock), | ||
evaluate = funcBlock(y34), | ||
y35 = getContext.chain((function(ctx) { | ||
return ((ctx === state.LOOP_CTX) ? withNode((function(node0) { | ||
@@ -322,67 +326,67 @@ return seq(evaluate, createExplicitClosure(getClosure(node0))); | ||
})); | ||
x32(y34); | ||
var x33 = addTransform.bind(null, "ArrayExpression"), | ||
y35 = seq(((__args57 = ["elements", checkTop]), (actions58 = [__args57[1]]), seq(moveChild("elements"), sequencea( | ||
actions58), up)), modify(translate.arrayExpression)); | ||
x33(y35); | ||
var x34 = addTransform.bind(null, "ObjectExpression"), | ||
y36 = seq(((__args58 = ["properties", checkTop]), (actions59 = [__args58[1]]), seq(moveChild("properties"), | ||
sequencea(actions59), up)), modify(translate.objectExpression)); | ||
var x34 = addTransform.bind(null, "ArrayExpression"), | ||
y36 = seq(((__args58 = ["elements", checkTop]), (actions59 = [__args58[1]]), seq(moveChild("elements"), sequencea( | ||
actions59), up)), modify(translate.arrayExpression)); | ||
x34(y36); | ||
var x35 = addTransform.bind(null, "ObjectValue"), | ||
y37 = seq(((__args59 = ["key", checkTop]), (actions60 = [__args59[1]]), seq(moveChild("key"), sequencea(actions60), | ||
up)), ((__args60 = ["value", checkTop]), (actions61 = [__args60[1]]), seq(moveChild("value"), sequencea( | ||
actions61), up)), modify(translate.objectValue)); | ||
var x35 = addTransform.bind(null, "ObjectExpression"), | ||
y37 = seq(((__args59 = ["properties", checkTop]), (actions60 = [__args59[1]]), seq(moveChild("properties"), | ||
sequencea(actions60), up)), modify(translate.objectExpression)); | ||
x35(y37); | ||
var x36 = addTransform.bind(null, "IdentifierPattern"), | ||
y38 = seq(((__args61 = ["id", checkTop]), (actions62 = [__args61[1]]), seq(moveChild("id"), sequencea(actions62), | ||
up)), modify((function(x37) { | ||
return x37.id; | ||
var x36 = addTransform.bind(null, "ObjectValue"), | ||
y38 = seq(((__args60 = ["key", checkTop]), (actions61 = [__args60[1]]), seq(moveChild("key"), sequencea(actions61), | ||
up)), ((__args61 = ["value", checkTop]), (actions62 = [__args61[1]]), seq(moveChild("value"), sequencea( | ||
actions62), up)), modify(translate.objectValue)); | ||
x36(y38); | ||
var x37 = addTransform.bind(null, "IdentifierPattern"), | ||
y39 = seq(((__args62 = ["id", checkTop]), (actions63 = [__args62[1]]), seq(moveChild("id"), sequencea(actions63), | ||
up)), modify((function(x38) { | ||
return x38.id; | ||
}))); | ||
x36(y38); | ||
var x37 = addTransform.bind(null, ["RelativeUnpack", "SliceUnpack"]), | ||
__args62 = ["target", checkTop], | ||
actions63 = [__args62[1]], | ||
y39 = seq(moveChild("target"), sequencea(actions63), up); | ||
x37(y39); | ||
var x38 = addTransform.bind(null, "ArgumentsPattern"), | ||
y40 = seq(((__args63 = ["id", checkTop]), (actions64 = [__args63[1]]), seq(moveChild("id"), sequencea(actions64), | ||
up)), ((__args64 = ["elements", checkTop]), (actions65 = [__args64[1]]), seq(moveChild("elements"), | ||
sequencea(actions65), up)), ((__args65 = ["self", checkTop]), (actions66 = [__args65[1]]), seq(moveChild( | ||
"self"), sequencea(actions66), up))); | ||
var x38 = addTransform.bind(null, ["RelativeUnpack", "SliceUnpack"]), | ||
__args63 = ["target", checkTop], | ||
actions64 = [__args63[1]], | ||
y40 = seq(moveChild("target"), sequencea(actions64), up); | ||
x38(y40); | ||
var x39 = addTransform.bind(null, "Program"), | ||
y41 = seq(pushBindings, modify((function(node0) { | ||
var x39 = addTransform.bind(null, "ArgumentsPattern"), | ||
y41 = seq(((__args64 = ["id", checkTop]), (actions65 = [__args64[1]]), seq(moveChild("id"), sequencea(actions65), | ||
up)), ((__args65 = ["elements", checkTop]), (actions66 = [__args65[1]]), seq(moveChild("elements"), | ||
sequencea(actions66), up)), ((__args66 = ["self", checkTop]), (actions67 = [__args66[1]]), seq(moveChild( | ||
"self"), sequencea(actions67), up))); | ||
x39(y41); | ||
var x40 = addTransform.bind(null, "Program"), | ||
y42 = seq(pushBindings, modify((function(node0) { | ||
return ((type(node0.body) === "Package") ? node0 : setUd("prefix", translate.useStrict, node0)); | ||
})), ((__args66 = ["body", checkTop]), (actions67 = [__args66[1]]), seq(moveChild("body"), sequencea(actions67), | ||
})), ((__args67 = ["body", checkTop]), (actions68 = [__args67[1]]), seq(moveChild("body"), sequencea(actions68), | ||
up)), getBindings((function(bindings) { | ||
return modify(translate.program.bind(null, bindings)); | ||
}))); | ||
x39(y41); | ||
var x40 = addTransform.bind(null, "Package"), | ||
y42 = seq(packageManager.chain((function(packageManager0) { | ||
x40(y42); | ||
var x41 = addTransform.bind(null, "Package"), | ||
y43 = seq(packageManager.chain((function(packageManager0) { | ||
return modify(translate.packageBlock.bind(null, packageManager0)); | ||
})), checkTop); | ||
x40(y42); | ||
var x41 = addTransform.bind(null, "Import"), | ||
y43 = packageManager.chain((function(packageManager0) { | ||
var y44; | ||
return modify(((y44 = packageManager0.importPackage), (function(z) { | ||
return y44(z.from); | ||
x41(y43); | ||
var x42 = addTransform.bind(null, "Import"), | ||
y44 = packageManager.chain((function(packageManager0) { | ||
var y45; | ||
return modify(((y45 = packageManager0.importPackage), (function(z) { | ||
return y45(z.from); | ||
}))); | ||
})); | ||
x41(y43); | ||
var x42 = addTransform.bind(null, "Identifier"), | ||
y44 = withNode((function(node0) { | ||
var id, uid, uid0, x43, y45; | ||
x42(y44); | ||
var x43 = addTransform.bind(null, "Identifier"), | ||
y45 = withNode((function(node0) { | ||
var id, uid, uid0, x44, y46; | ||
return (getUid(node0) ? seq(((id = node0.name), (uid = getUid(node0)), modifyScope(scope.addVar.bind( | ||
null, id, uid))), ((uid0 = getUid(node0)), inspectScope(scope.getMapping.bind(null, uid0))) | ||
.chain((function(name) { | ||
var x43 = set, | ||
y45 = translate.identifier(node0.loc, name, getUid(node0)); | ||
return x43(y45); | ||
}))) : ((x43 = set), (y45 = translate.identifier(node0.loc, node0.name)), x43(y45))); | ||
var x44 = set, | ||
y46 = translate.identifier(node0.loc, name, getUid(node0)); | ||
return x44(y46); | ||
}))) : ((x44 = set), (y46 = translate.identifier(node0.loc, node0.name)), x44(y46))); | ||
})); | ||
x42(y44); | ||
var visitArray = ((move = (function(x43, i, a) { | ||
x43(y45); | ||
var visitArray = ((move = (function(x44, i, a) { | ||
return ((i === (a.length - 1)) ? checkTop : seq(checkTop, right)); | ||
@@ -389,0 +393,0 @@ })), (function(node0) { |
@@ -21,7 +21,7 @@ /* | ||
__o0 = require("./unpack"), | ||
useStrict, identifier, program, variableDeclaration, variableDeclarator, assignmentExpression, unaryExpression, | ||
binaryExpression, logicalExpression, conditionalExpression, newExpression, callExpression, applyExpression, | ||
memberExpression, checkedMemberExpression, arrayExpression, objectExpression, objectValue, functionExpression, | ||
functionExpressionPost, explicitClosure, letExpression, curryExpression, catchClause, switchCase, | ||
emptyStatement, blockStatement, withStatement, expressionStatement, returnStatement, throwStatement, | ||
useStrict, identifier, program, variableDeclaration, variableDeclarator, assignmentExpression, deleteExpression, | ||
unaryExpression, binaryExpression, logicalExpression, conditionalExpression, newExpression, callExpression, | ||
applyExpression, memberExpression, checkedMemberExpression, arrayExpression, objectExpression, objectValue, | ||
functionExpression, functionExpressionPost, explicitClosure, letExpression, curryExpression, catchClause, | ||
switchCase, emptyStatement, blockStatement, withStatement, expressionStatement, returnStatement, throwStatement, | ||
breakStatement, continueStatement, ifStatement, switchStatement, forStatement, doWhileStatement, whileStatement, | ||
@@ -74,2 +74,5 @@ tryStatement, packageBlock, type = __o["type"], | ||
})); | ||
(deleteExpression = (function(node) { | ||
return ecma_expression.UnaryExpression.create(node.loc, "delete", node.argument); | ||
})); | ||
var mapOp = (function(op) { | ||
@@ -232,2 +235,3 @@ switch (op) { | ||
(exports["assignmentExpression"] = assignmentExpression); | ||
(exports["deleteExpression"] = deleteExpression); | ||
(exports["unaryExpression"] = unaryExpression); | ||
@@ -234,0 +238,0 @@ (exports["binaryExpression"] = binaryExpression); |
{ | ||
"name": "khepri-compile", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Compiler for the Khepri programming language", | ||
@@ -43,3 +43,3 @@ "author": "Matt Bierner", | ||
"khepri-ast": "4.7.x", | ||
"khepri-ast": "4.8.x", | ||
"khepri-ast-zipper": "1.2.x", | ||
@@ -57,3 +57,3 @@ | ||
"khepri-parse": "2.6.x", | ||
"khepri-parse": "2.7.x", | ||
"ecma-unparse": "3.3.x" | ||
@@ -60,0 +60,0 @@ }, |
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
377433
0.9%105
0.96%5296
1.51%19
5.56%+ Added
- Removed
Updated