fix compilation format.
This commit is contained in:
parent
64a01d4abf
commit
abdea0828f
|
@ -98,16 +98,24 @@ function evaluate (env, expr, locals = []) {
|
|||
const args = [ ...expr.args ].reverse();
|
||||
const body = evaluate(env, expr.body, args);
|
||||
|
||||
return body;
|
||||
return compile_function(args, body);
|
||||
}
|
||||
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
function compile_function (args, body) {
|
||||
if (args.length > 1) {
|
||||
return [0, compile_function(args.slice(1), body)];
|
||||
} else {
|
||||
return [0, body];
|
||||
}
|
||||
}
|
||||
|
||||
function has_local (locals, name) {
|
||||
return locals.includes(name);
|
||||
}
|
||||
|
||||
function get_local (locals, name) {
|
||||
return locals.indexOf(name);
|
||||
return locals.indexOf(name) + 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue