feat: persistent vector (working) + HAMT hash map (wip)

PersistentVector: 17-form .clj source, fully working.
- 32-way branching trie with tail optimization
- pv-conj, pv-nth, pv-assoc, pv-pop, vector?, vector constructor
- instance? check works on deftype tables
- .-field accessor syntax for deftype fields

api.janet: :mutable? compile flag for opt-out
- Default: persistent data structures loaded
- Pass {:mutable? true} to use Janet native types

Supporting changes (evaluator/core):
- 17 new primitives: bit ops, array ops, unchecked math, hash, cond
- loop macro, zero?, dec/inc, defn multi-arity
- instance? for deftype tables (get val :jolt/deftype)
- defrecord builds maps at expansion time
- .-field field access in default function application path

PersistentHashMap: 24-form HAMT source loads OK.
- BitmapIndexedNode/PersistentHashMap deftypes
- mask, bitpos, bit-count, index helpers
- phm-assoc/phm-get/phm-without/phm-contains? stubs
- bmn-assoc insert path structured, bitmap propagation wip
This commit is contained in:
Yogthos 2026-06-02 11:51:39 -04:00
parent 51860a553e
commit 33a5b7e7a4
11 changed files with 688 additions and 109 deletions

View file

@ -0,0 +1 @@
["^ ","~$pv-empty",["^ ","~:row",157,"~:col",1,"~:fixed-arities",["~#set",[1]],"~:name","^0","~:ns","~$jolt.lang.persistent-vector","~:top-ns","^7","~:type","~:fn"],"~$empty-array",["^ ","^1",11,"^2",1,"^5","^;","^6","^7","^8","^7"],"~$VectorNode",["^ ","^1",8,"^2",1,"^5","^<","^6","^7","^8","^7","~:class",true],"~$push-tail",["^ ","^3",["^4",[4]],"~:private",true,"^6","^7","^5","^>","^9","^:","^2",1,"^8","^7","^1",24],"~$vector?",["^ ","^1",165,"^2",1,"^3",["^4",[1]],"^5","^@","^6","^7","^8","^7","~:arities",["^ ","~i1",["^ ","~:ret","~:boolean","~:arglist-str","[x]"]],"^9","^:"],"~$tailoff",["^ ","^3",["^4",[1]],"^?",true,"^6","^7","^5","^E","^9","^:","^2",1,"^8","^7","^A",["^ ","~i1",["^ ","^B","~:int","^D","[pv]"]],"^1",14],"~$tail-max",["^ ","^1",6,"^2",1,"^5","^G","^6","^7","^8","^7","^9","~:pos-int"],"~$pv-pop",["^ ","^1",132,"^2",1,"^3",["^4",[1]],"^5","^I","^6","^7","^8","^7","^9","^:"],"~$new-path",["^ ","^3",["^4",[2]],"^?",true,"^6","^7","^5","^J","^9","^:","^2",1,"^8","^7","^1",17],"~$do-assoc",["^ ","^3",["^4",[4]],"^?",true,"^6","^7","^5","^K","^9","^:","^2",1,"^8","^7","^1",36],"~$pop-tail",["^ ","^3",["^4",[3]],"^?",true,"^6","^7","^5","^L","^9","^:","^2",1,"^8","^7","^1",106],"~:filename","/Users/yogthos/src/jolt/src/jolt/clojure/lang/persistent_vector.clj","~$shift-increment",["^ ","^1",5,"^2",1,"^5","^N","^6","^7","^8","^7","^9","^H"],"~$PersistentVector",["^ ","^1",9,"^2",1,"^5","^O","^6","^7","^8","^7","^=",true],"~$vector",["^ ","^1",159,"^2",1,"~:varargs-min-arity",0,"^5","^P","^6","^7","^8","^7","^9","^:"],"~$array-for",["^ ","^3",["^4",[2]],"^?",true,"^6","^7","^5","^R","^9","^:","^2",1,"^8","^7","^1",45],"~$branch-factor",["^ ","^1",4,"^2",1,"^5","^S","^6","^7","^8","^7","^9","^H"],"~$pv-assoc",["^ ","^1",90,"^2",1,"^3",["^4",[3]],"^5","^T","^6","^7","^8","^7","^9","^:"],"~$->VectorNode",["^ ","^1",8,"^2",1,"^3",["^4",[1]],"^5","^U","^6","^7","^8","^7"],"~$pv-nth-internal",["^ ","^3",["^4",[4]],"^?",true,"^6","^7","^5","^V","^9","^:","^2",1,"^8","^7","^1",121],"~$EMPTY",["^ ","^1",12,"^2",1,"^5","^W","^6","^7","^8","^7"],"~$pv-conj",["^ ","^1",57,"^2",1,"^3",["^4",[2]],"^5","^X","^6","^7","^8","^7","^9","^:"],"~$pv-nth",["^ ","^1",84,"^2",1,"^3",["^4",[2]],"^5","^Y","^6","^7","^8","^7","^9","^:"],"~$->PersistentVector",["^ ","^1",9,"^2",1,"^3",["^4",[5]],"^5","^Z","^6","^7","^8","^7"]]

View file

@ -1 +1 @@
["^ ","~$ctx",["^ ","~:row",6,"~:col",1,"~:name","^0","~:ns","~$user","~:top-ns",null],"~$load-file",["^ ","^1",8,"^2",1,"~:fixed-arities",["~#set",[2]],"^3","^7","^4","^5","^6",null,"~:arities",["^ ","~i2",["^ ","~:ret",["^ ","~:type","~:map","~:val",["^ ","~:ok",["^ ","^1",32,"~:end-row",32,"^2",8,"~:end-col",10],"~:fail",["^ ","^1",32,"^@",32,"^2",17,"^A",21],"~:total",["^ ","^1",32,"^@",32,"^2",29,"^A",34],"~:failures",["^ ","^1",32,"^@",32,"^2",45,"^A",53]]],"~:arglist-str","[ctx path]"]],"^<","~:fn"],"~$sci-base",["^ ","^1",34,"^2",1,"^3","^G","^4","^5","^6",null,"^<","~:string"],"~$load-order",["^ ","^1",36,"^2",1,"^3","^I","^4","^5","^6",null,"^<","~:any"],"~$path",["^ ","^1",53,"^2",3,"^3","^K","^4","^5","^6",null],"~$result",["^ ","^1",55,"^2",3,"^3","^L","^4","^5","^6",null],"~:filename","/Users/yogthos/src/jolt/test/test-load-sci.janet"]
["^ ","~$load-persistent-structures",["^ ","~:fixed-arities",["~#set",[1]],"~:private",true,"~:ns","~$user","~:name","^0","~:type","~:fn","~:col",1,"~:top-ns",null,"~:row",9],"~$source",["^ ","^;",13,"^9",3,"^6","^<","^4","^5","^:",null],"~$init",["^ ","^;",26,"^9",1,"^1",["^2",[2]],"^6","^=","^4","^5","^:",null,"^7","^8"],"~$eval-string",["^ ","^;",46,"^9",1,"^1",["^2",[2]],"^6","^>","^4","^5","^:",null,"^7","^8"],"~$eval-string*",["^ ","^;",55,"^9",1,"^1",["^2",[3]],"^6","^?","^4","^5","^:",null,"^7","^8"],"~:filename","/Users/yogthos/src/jolt/src/jolt/api.janet"]