Commit graph

213 commits

Author SHA1 Message Date
Yogthos
a8c453183f Phase 4: Macro expansion in compiler
- resolve-macro: resolve symbols to macro vars via ctx
- Macro expansion in analyze-form: detects macro heads, expands, re-analyzes
- compile-ast: emits Janet data structures with resolved core fn values
- compile-and-eval uses compile-ast (no source parse roundtrip)
- eval-string routes macros through compiler (expanded at analyze time)
- Fix - mapping: core-sub (core-- doesn't exist)
- All 317 tests pass + 6 new Phase 4 macro tests
2026-06-02 15:43:08 -04:00
Yogthos
ab7ff85816 Phase 3: Compile-aware loader, :compile? flag, compile-and-eval
- loader.janet: load-ns with compile? dispatch, compiled-cache, compiled?, clear-compiled-cache
- compiler.janet: compile-ast (Janet data structures for direct eval), compile-and-eval
- api.janet: compile-string, compile-file, eval-string dispatches to compile-and-eval when :compile? is true
- types.janet: :compile? flag and :compiled-cache table in context env
- Stateful forms (def, defmacro, ns, deftype, defmulti, defmethod) fall back to interpreter
- All 317 tests pass + 16 new Phase 3 tests
2026-06-02 15:24:28 -04:00
Yogthos
dfa98746ee Phase 1+2: Clojure→Janet source compiler with symbol classification
- analyze-form: Clojure forms → annotated AST nodes (:op keys)
- emit-ast: AST dispatch → Janet source via StringBuffer
- compile-form: analyze → emit → Janet source string
- Symbol classification: locals, core refs, qualified refs
- Ops: const, do, if, def, fn, let, invoke, quote, vector, map
- Local binding awareness in fn* and let* (shadowing works)
- All 317 existing tests pass, 24 new compiler tests
2026-06-02 14:59:13 -04:00
Yogthos
5052e391da perf: clean HAMT persistent hash map, 18-form .clj source
Rewrite persistent_hash_map.clj with correct paren balancing.
BitmapIndexedNode constructor + bit-or verified working in isolation.
Core HAMT operations (bmn-assoc, bmn-find, phm-assoc, phm-get,
phm-contains?, hash-map) structurally correct.

Calling phm-assoc at runtime fails with 64-bit hash overflow
in Janet bit ops — hash values exceed 32-bit signed range.
Fix: wrap (hash key) with (bit-and (int h) 0x7FFFFFFF) in phm-assoc.
2026-06-02 12:44:16 -04:00
Yogthos
677d059c0b fix: prototype-aware binding lookup for nested let
Add binding-get helper that walks Janet table prototype chain.
resolve-sym now uses two-stage lookup: direct get first,
then prototype walk as fallback. This fixes access to outer
let bindings from inner let forms without breaking fn parameter
resolution (which uses direct table keys).

All 9 test suites pass including macro-test.
2026-06-02 12:02:57 -04:00
Yogthos
794f60dff2 fix: vendor/sci submodule, defrecord fix, all tests pass
- Add SCI as git submodule at vendor/sci (replaces absolute path)
- Fix defrecord macro: emit array-map at expansion time, no interleave dep
- Remove stale test files (test-ctor, test-parser, edamame_shim)
- All 317 SCI forms load with 0 failures, 9 test suites green
2026-06-02 09:48:52 -04:00
Yogthos
7112632f2f chore: update memory/skills 2026-06-02 08:43:27 -04:00
Yogthos
7ecd781fe6 feat: SCI submodule, gensym, doto, defrecord, multi-arity defn
Phase 2: load internal SCI namespaces
- Add SCI as git submodule at vendor/sci
- gensym: symbol generation with prefix+counter
- doto macro: (doto obj (method args)...)
- defrecord macro: emits positional constructor ->TypeName
- name: Clojure core function for keyword/symbol name
- Fix multi-arity defn: indexed? check for vector patterns (tuples)
- Edamame stubs for parser.cljc deps

Internal namespace loading results:
  interop: 14 bindings (all OK)
  opts: 16 bindings (all OK — defrecord fixed)
  parser: 2 bindings (6 failures: utils/new-var, edamame/normalize-opts)
  analyzer/interpreter: pending (15+ deps each)
2026-06-02 01:41:44 -04:00
Yogthos
6e0b95aaae feat: SCI eval-string via Jolt-native reader/evaluator
Replace SCI's internal interpreter/parser/analyzer pipeline with
Jolt-native eval-string that delegates to Jolt's reader and evaluator.
All 317 SCI source forms load, 9 namespaces populated, 46 total ns.

eval-string result: (+ 1 2 3) → 6, (def x 42) x → 42

Removed edamame/core shim — no longer needed since we bypass
the SCI internal eval pipeline entirely.
2026-06-02 01:22:19 -04:00
Yogthos
5ba938abeb feat: edamame shim for SCI eval-string pipeline
Add edamame.core + clojure.tools.reader.reader-types shim to core.janet.
init-edamame-shim! takes parse-string and read-form as args to avoid
circular module dependencies. Creates shim namespaces after SCI loads.

SCI eval-string is found and callable — next step is loading the 4
internal namespaces (interpreter, parser, analyzer, opts) whose source
files aren't loaded by the ns :require handler.
2026-06-02 01:18:12 -04:00
Yogthos
b948c4fdbb fix: all 317 SCI forms load, zero failures
- Reorder load sequence: types→unrestrict→vars→lang→utils→namespaces→core
- Add if-let/when-let/if-some/when-some/let macros and register in core-macro-names
- Add stubs: resolve, update, copy-core-var, copy-var, macrofy, new-var, avoid-method-too-large
- Add dynamic vars: *1, *2, *3, *e, *assert with nil-sentinel
- Fix core-update: use put instead of Janet's update (struct-incompatible)
- Change *clojure-version* from struct to table (mutable for update)
- Fix core-avoid-method-too-large: return @{} not nil
- Fix init-core! nil-sentinel unwrapping
- Fix let* destructuring for {:keys [...]} and sequential patterns
- Fix fn*/defmacro: capture defining ns for symbol resolution in closures
2026-06-02 00:07:40 -04:00
Yogthos
b20536d1e3 bootstrap: SCI core deps loading with 284/304 forms passing
reader: #?@ empty splice fix (nil→@[]), #? nil→:jolt/skip, map reader handles #_/#?@ in K/V
evaluator: unwrap-meta-name helper, deftype interns ->Name too, dot-suffix fix
core: comment/prefer-method stubs, *unchecked-math*/*clojure-version* dynamic vars
2026-06-01 23:24:13 -04:00
Yogthos
cdcf569506 Initial commit: Jolt — Clojure interpreter on Janet
- PEG-based Clojure reader (symbols, keywords, numbers, strings, lists,
  vectors, maps, sets, quote forms, reader macros, metadata)
- Tree-walking evaluator (quote, do, if, def, fn*, let*, loop*/recur,
  syntax-quote/unquote/unquote-splicing, macro system, ns/require/in-ns)
- 95+ clojure.core functions (predicates, math, collections, seq ops,
  higher-order, atoms, I/O)
- Public API (init, eval-string, eval-string*)
- REPL (jolt/main.janet)
- 7 test suites, all green
- MIT license
2026-06-01 16:48:56 -04:00