Refactor MCP tree server: dispatch table, caching, validation, subprocess cleanup
Break up the 1735-line handle_tool match into 45 individual handler functions with hashtable-based dispatch. Add mtime-based file parse caching (AST + CST), consolidated run_command helper replacing 9 bare open_process_in patterns, require_file/require_dir input validation, and pagination (limit/offset) for sx_find_across, sx_comp_list, sx_comp_usage. Also includes pending VM changes: rest-arity support, hyperscript parser, compiler/transpiler updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
21
lib/vm.sx
21
lib/vm.sx
@@ -137,18 +137,21 @@
|
||||
code-from-value
|
||||
(fn
|
||||
(v)
|
||||
"Convert a compiler output dict to a vm-code object."
|
||||
"Convert a compiler output dict to a vm-code dict. Idempotent — if v\n already has vm-code keys (vc-bytecode), returns as-is."
|
||||
(if
|
||||
(not (dict? v))
|
||||
(make-vm-code 0 16 (list) (list))
|
||||
(let
|
||||
((bc-raw (get v "bytecode"))
|
||||
(bc (if (nil? bc-raw) (list) bc-raw))
|
||||
(consts-raw (get v "constants"))
|
||||
(consts (if (nil? consts-raw) (list) consts-raw))
|
||||
(arity-raw (get v "arity"))
|
||||
(arity (if (nil? arity-raw) 0 arity-raw)))
|
||||
(make-vm-code arity (+ arity 16) bc consts)))))
|
||||
(if
|
||||
(has-key? v "vc-bytecode")
|
||||
v
|
||||
(let
|
||||
((bc-raw (get v "bytecode"))
|
||||
(bc (if (nil? bc-raw) (list) bc-raw))
|
||||
(consts-raw (get v "constants"))
|
||||
(consts (if (nil? consts-raw) (list) consts-raw))
|
||||
(arity-raw (get v "arity"))
|
||||
(arity (if (nil? arity-raw) 0 arity-raw)))
|
||||
(make-vm-code arity (+ arity 16) bc consts))))))
|
||||
(define vm-closure? (fn (v) (and (dict? v) (has-key? v "vm-code"))))
|
||||
(define *active-vm* nil)
|
||||
(define *jit-compile-fn* nil)
|
||||
|
||||
Reference in New Issue
Block a user