mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
perf
This commit is contained in:
20
src/eval.js
20
src/eval.js
@@ -651,15 +651,17 @@ const symbol_for_identifier = (node, context) => {
|
||||
|
||||
const do_eval_frame_expr = (node, scope, callsleft, context) => {
|
||||
if(node.type == 'identifier') {
|
||||
let value
|
||||
if(node.definition == 'global') {
|
||||
return {...eval_codestring(node.value, scope), calls: callsleft, scope}
|
||||
value = globalThis.app_window[node.value]
|
||||
} else {
|
||||
return {
|
||||
ok: true,
|
||||
value: scope[symbol_for_identifier(node, context)],
|
||||
calls: callsleft,
|
||||
scope
|
||||
}
|
||||
value = scope[symbol_for_identifier(node, context)]
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
value,
|
||||
calls: callsleft,
|
||||
scope,
|
||||
}
|
||||
} else if([
|
||||
'builtin_identifier',
|
||||
@@ -668,7 +670,7 @@ const do_eval_frame_expr = (node, scope, callsleft, context) => {
|
||||
'backtick_string',
|
||||
].includes(node.type)){
|
||||
// TODO exprs inside backtick string
|
||||
// Pass scope for backtick string
|
||||
// TODO for string literal and number, do not use eval
|
||||
return {...eval_codestring(node.value, scope), calls: callsleft, scope}
|
||||
} else if(node.type == 'array_spread') {
|
||||
const result = eval_children(node, scope, callsleft, context)
|
||||
@@ -1025,6 +1027,8 @@ const eval_decl_pair = (s, scope, calls, context) => {
|
||||
const names = name_nodes.map(n => n.value)
|
||||
const destructuring = codegen(s.name_node, {literal_identifiers: true})
|
||||
|
||||
// TODO if destructuring is just one id, then do not use eval_codestring
|
||||
|
||||
// TODO unique name for __value (gensym)
|
||||
const codestring = `
|
||||
const ${destructuring} = __value;
|
||||
|
||||
Reference in New Issue
Block a user