eliscript 0.0.4 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/bootstrap/compiler/emitter.eli +161 -63
- package/bootstrap/host/check-cli.mjs +0 -1
- package/bootstrap/host/check-cli.mjs.map +1 -1
- package/bootstrap/host/compiler-session.eli +2 -1
- package/bootstrap/host/eliscript-cli.mjs +2 -9
- package/bootstrap/host/eliscript-cli.mjs.map +1 -1
- package/bootstrap/host/project-cli.mjs +1 -11
- package/bootstrap/host/project-cli.mjs.map +1 -1
- package/bootstrap/host/project.mjs +2 -8
- package/bootstrap/host/project.mjs.map +1 -1
- package/browser/README.md +1 -1
- package/compiler/README.md +2 -2
- package/compiler/eliscript-emitter.el +229 -85
- package/compiler/eliscript-ir-emitter.el +64 -34
- package/compiler/eliscript-project.el +20 -5
- package/dist/backends/async.mjs +1 -90
- package/dist/backends/async.mjs.map +1 -1
- package/dist/backends/binary.mjs +1 -91
- package/dist/backends/binary.mjs.map +1 -1
- package/dist/backends/capabilities.mjs +1 -90
- package/dist/backends/capabilities.mjs.map +1 -1
- package/dist/backends/elf.mjs +1 -90
- package/dist/backends/elf.mjs.map +1 -1
- package/dist/backends/managed.mjs +1 -94
- package/dist/backends/managed.mjs.map +1 -1
- package/dist/backends/memory.mjs +1 -90
- package/dist/backends/memory.mjs.map +1 -1
- package/dist/backends/native.mjs +1 -91
- package/dist/backends/native.mjs.map +1 -1
- package/dist/backends/numeric.mjs +1 -90
- package/dist/backends/numeric.mjs.map +1 -1
- package/dist/backends/optimize.mjs +1 -90
- package/dist/backends/optimize.mjs.map +1 -1
- package/dist/backends/regexp.mjs +1 -91
- package/dist/backends/regexp.mjs.map +1 -1
- package/dist/backends/sha256.mjs +2 -96
- package/dist/backends/sha256.mjs.map +1 -1
- package/dist/backends/wasm.mjs +1 -90
- package/dist/backends/wasm.mjs.map +1 -1
- package/dist/bootstrap/analyzer.mjs +1 -95
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +1 -105
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +848 -807
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +1 -96
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/formatter.mjs +1 -104
- package/dist/bootstrap/formatter.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +18 -172
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/lower.mjs +1 -92
- package/dist/bootstrap/lower.mjs.map +1 -1
- package/dist/bootstrap/project.mjs +23 -209
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +1 -96
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/source-map.mjs +7 -112
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/symbol.mjs +7 -114
- package/dist/bootstrap/symbol.mjs.map +1 -1
- package/dist/bootstrap/syntax.mjs +10 -176
- package/dist/bootstrap/syntax.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +1 -93
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +105 -104
- package/dist/browser/loader.js +1 -1
- package/dist/browser/loader.mjs +5 -124
- package/dist/compiler-artifact.json +1 -1
- package/dist/host/compiler-session.mjs +205 -297
- package/dist/host/compiler-session.mjs.map +1 -1
- package/dist/host/compiler-tools.mjs +1 -91
- package/dist/host/compiler-tools.mjs.map +1 -1
- package/dist/literal-sources/runtime/core/order.eli +32 -10
- package/dist/literal-sources/runtime/core/sequence.eli +69 -28
- package/dist/literal-sources/runtime/core/vector.eli +2 -4
- package/dist/literal-sources/stdlib/managed-literal-protocols.eli +5 -5
- package/dist/literal-sources/stdlib/managed-literals.eli +1 -1
- package/dist/package.json +1 -0
- package/dist/runtime/math.mjs +62 -252
- package/dist/runtime/math.mjs.map +1 -1
- package/dist/runtime/prelude.mjs +95 -0
- package/dist/runtime/prelude.mjs.macro-origins.json +1 -0
- package/dist/runtime/prelude.mjs.map +1 -0
- package/dist/runtime/unicode-case-data.mjs +1 -95
- package/dist/runtime/unicode-case-data.mjs.map +1 -1
- package/dist/runtime/unicode-case.mjs +3 -97
- package/dist/runtime/unicode-case.mjs.map +1 -1
- package/dist/stage3-release.json +1 -1
- package/editor/README.md +9 -4
- package/editor/eliscript-abi.el +170 -0
- package/editor/eliscript-async.el +375 -0
- package/editor/eliscript-bind.el +822 -0
- package/editor/eliscript-compat.el +346 -0
- package/editor/eliscript-contract.el +334 -0
- package/editor/eliscript-data.el +1544 -0
- package/editor/eliscript-js.el +318 -0
- package/editor/eliscript-mode.el +1 -1
- package/editor/eliscript-module.el +340 -0
- package/editor/eliscript-repl.el +1 -1
- package/package.json +4 -1
- package/runtime/README.md +21 -1
- package/runtime/core/protocol-impl.mjs +1 -115
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/text-impl.mjs +1 -90
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/vector.eli +1 -1
- package/runtime/core/vector.mjs +0 -9
- package/runtime/emacs-compat.eli +5957 -0
- package/runtime/emacs-compat.mjs +13734 -0
- package/runtime/emacs-compat.mjs.map +1 -0
- package/runtime/math.mjs +62 -252
- package/runtime/math.mjs.map +1 -1
- package/runtime/prelude.eli +4 -0
- package/runtime/prelude.mjs +95 -0
- package/runtime/prelude.mjs.map +1 -0
- package/runtime/unicode-case-data.mjs +1 -95
- package/runtime/unicode-case-data.mjs.map +1 -1
- package/runtime/unicode-case.mjs +3 -97
- package/runtime/unicode-case.mjs.map +1 -1
- package/stdlib/managed-literals.eli +1 -1
- package/stdlib/managed-runtime-vector.eli +2 -4
- package/tools/backends/compiler-build.mjs +3 -93
- package/tools/backends/compiler-cli.mjs +2 -15
- package/tools/backends/compiler-corpus-bit.mjs +2 -95
- package/tools/backends/compiler-corpus-cli-adapters.mjs +1 -97
- package/tools/backends/compiler-corpus-debugging.mjs +2 -95
- package/tools/backends/compiler-corpus-emitter.mjs +1 -97
- package/tools/backends/compiler-corpus-execution.mjs +2 -108
- package/tools/backends/compiler-corpus-fuzz.mjs +2 -95
- package/tools/backends/compiler-corpus-host-context.mjs +2 -99
- package/tools/backends/compiler-corpus-identity-host.mjs +18 -123
- package/tools/backends/compiler-corpus-identity-value-adapters.mjs +0 -9
- package/tools/backends/compiler-corpus-literal-provider.mjs +1 -91
- package/tools/backends/compiler-corpus-managed-adapters.mjs +1 -99
- package/tools/backends/compiler-corpus-managed-fixtures.mjs +2 -113
- package/tools/backends/compiler-corpus-matchers.mjs +3 -106
- package/tools/backends/compiler-corpus-original-program.mjs +1 -91
- package/tools/backends/compiler-corpus-process.mjs +1 -92
- package/tools/backends/compiler-corpus-program-driver.mjs +1 -3
- package/tools/backends/compiler-corpus-project-adapters.mjs +1 -95
- package/tools/backends/compiler-corpus-project-entry-host.mjs +2 -92
- package/tools/backends/compiler-corpus-project-transport.mjs +1 -90
- package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1 -91
- package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1 -92
- package/tools/backends/compiler-corpus-raw-math-fixture.mjs +1 -91
- package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +1 -91
- package/tools/backends/compiler-corpus-reference.mjs +1 -90
- package/tools/backends/compiler-corpus-runtime-adapters.mjs +2 -110
- package/tools/backends/compiler-corpus-tools-cli.mjs +1 -95
- package/tools/backends/compiler-corpus-tools-reference.mjs +22 -163
- package/tools/backends/compiler-corpus.mjs +3 -125
- package/tools/backends/compiler-matrix.mjs +1 -92
- package/tools/backends/compiler-package-browser.mjs +1 -90
- package/tools/backends/compiler-package.mjs +3 -95
- package/tools/backends/compiler-unicode-profile-host.mjs +1 -91
- package/tools/backends/dist/bootstrap-js-stages.mjs +1 -91
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -1
- package/tools/backends/dist/managed-ir-inventory.mjs +1 -91
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -1
- package/tools/backends/dist/record-grid.mjs +1 -91
- package/tools/backends/dist/record-grid.mjs.map +1 -1
- package/tools/backends/dist/release-cli.mjs +4 -94
- package/tools/backends/dist/release-cli.mjs.map +1 -1
- package/tools/backends/dist/run-artifact.mjs +1 -91
- package/tools/backends/dist/run-artifact.mjs.map +1 -1
- package/tools/backends/eliscript/compiler-corpus-bit.eli +1 -0
- package/tools/backends/managed-foreign-binding.mjs +1 -95
- package/tools/backends/managed-host-lifecycle.mjs +1 -91
- package/tools/backends/managed-host-object-provider.mjs +18 -59
- package/tools/backends/managed-host-object-realm.mjs +1 -91
- package/tools/backends/managed-host-proxy.mjs +9 -18
- package/tools/backends/managed-host-runtime.mjs +3 -105
- package/tools/backends/managed-host.mjs +1 -104
- package/tools/backends/managed-module-graph.mjs +1 -97
- package/tools/backends/managed-runtime.mjs +1 -96
- package/tools/backends/managed-source-view.mjs +13 -108
- package/tools/backends/native-managed-runtime.mjs +1 -91
- package/tools/backends/native-memory.mjs +1 -91
- package/tools/backends/stage3-targets.mjs +1 -91
- package/tools/bootstrap-runtime.el +3 -2
- package/tools/project/project.eli +1 -1
- package/tools/testing/stdlib-bit-corpus-host.mjs +1 -90
- package/tools/testing/stdlib-bit.mjs +1 -90
- package/dist/bootstrap/package.json +0 -1
- package/dist/bootstrap/runtime/math.mjs +0 -1117
- package/dist/bootstrap/runtime/math.mjs.map +0 -1
- package/dist/bootstrap/runtime/unicode-case-data.mjs +0 -10125
- package/dist/bootstrap/runtime/unicode-case-data.mjs.map +0 -1
- package/dist/bootstrap/runtime/unicode-case.mjs +0 -281
- package/dist/bootstrap/runtime/unicode-case.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.mjs","sources":["../../tools/project/project.eli"],"sourcesContent":["(module tools.project.project\n (import \"node:crypto\" createHash)\n (import \"node:fs\" lstatSync mkdirSync readFileSync realpathSync writeFileSync)\n (import \"node:path\" basename dirname resolve)\n (import \"node:url\" fileURLToPath)\n (import \"node:buffer\" Buffer)\n (import \"node:module\" createRequire)\n (import \"./project-legacy.mjs\" :as legacy)\n\n (defconst checkProject (get legacy :checkProject))\n (defconst source-root (resolve (dirname (fileURLToPath (js* \"import.meta.url\"))) \"../..\"))\n (defconst capsules (js-array \"math\" \"unicode-case\" \"unicode-case-data\"))\n (defun digest (bytes) (js-call (js-call (createHash \"sha256\") :update bytes) :digest \"hex\"))\n (defun project-error (message filename)\n (let ((error (new globalThis.Error message)))\n (put error :eliscriptDiagnostic (js-object :format \"eliscript-diagnostic\" :version 1\n :code \"ELI-B0001\" :severity \"error\" :phase \"project-build\" :message message\n :location (js-object :file filename)))\n (throw error)))\n (defun attributes (path)\n (try (lstatSync path)\n (catch error (if (= (get error :code) \"ENOENT\") undefined (throw error)))))\n (defun plain-directory (out-dir relative-path)\n (let* ((path (resolve out-dir relative-path)) (value (attributes path)))\n (when value\n (when (js-call value :isSymbolicLink)\n (project-error (str \"project runtime support contains a symlink: \" relative-path) path))\n (unless (js-call value :isDirectory)\n (project-error (str \"project runtime support is not a directory: \" relative-path) path)))))\n (defun check-target (base record)\n (let* ((relative-path (get record :path)) (path (resolve base relative-path))\n (value (attributes path)))\n (when value\n (when (js-call value :isSymbolicLink)\n (project-error (str \"project runtime support contains a symlink: \" relative-path) path))\n (unless (and (js-call value :isFile) (js-call (readFileSync path) :equals (get record :content)))\n (project-error (str \"project runtime support conflicts with existing output: \" relative-path) path)))\n (not (undefined? value))))\n (defun reject-source-alias (base record inputs)\n (let* ((path (resolve base (get record :path))) (value (attributes path)))\n (when value\n (js-call inputs :forEach (lambda (input)\n (when (and (= (get value :dev) (get input :dev))\n (= (get value :ino) (get input :ino)))\n (project-error (str \"project runtime output aliases a source: \" (get record :path)) path)))))))\n (defun asset (path content)\n (js-object :path path :bytes (js-length content) :sha256 (digest content)))\n (defun runtime-inputs ()\n (let ((files (js-array)) (identities (js-array)) (inputs (js-array)))\n (js-call capsules :forEach (lambda (name)\n (let* ((source-path (str \"runtime/\" name \".eli\"))\n (module-path (str \"runtime/\" name \".mjs\")) (map-path (str module-path \".map\"))\n (source (readFileSync (resolve source-root source-path)))\n (module (readFileSync (resolve source-root module-path)))\n (mapping (readFileSync (resolve source-root map-path)))\n (map (JSON/parse (js-call mapping :toString \"utf8\"))))\n (js-call (js-array source-path module-path map-path) :forEach (lambda (path)\n (js-call inputs :push (lstatSync (realpathSync (resolve source-root path))))))\n ;; The source module and its map are one real generator pair. Keep\n ;; every original map coordinate and byte; dist/runtime is another\n ;; producer and is never a fallback for either half of this pair.\n (unless (and (= (get map :version) 3) (= (value-type (get map :file)) \"string\")\n (= (basename (get map :file)) (str name \".mjs\"))\n (Array/isArray (get map :sourcesContent)) (= (js-length (get map :sourcesContent)) 1)\n (= (aref (get map :sourcesContent) 0) (js-call source :toString \"utf8\")))\n (project-error (str \"project runtime source and map identity differ: \" module-path)\n (resolve source-root map-path)))\n (js-call files :push (js-object :path module-path :content module)\n (js-object :path map-path :content mapping))\n (js-call identities :push (js-object :source (asset source-path source)\n :module (asset module-path module) :sourceMap (asset map-path mapping))))))\n (let ((exports (js-object)))\n (js-call capsules :forEach (lambda (name)\n (put exports (str \"./runtime/\" name \".mjs\") (str \"./runtime/\" name \".mjs\"))))\n (js-call files :push (js-object :path \"package.json\" :content\n (js-call Buffer :from (str (JSON/stringify (js-object :name \"eliscript\" :type \"module\"\n :private t :exports exports)) \"\\n\") \"utf8\"))))\n (js-call files :push (js-object :path \"eliscript-runtime.json\" :content\n (js-call Buffer :from (str (JSON/stringify (js-object :format \"eliscript-project-runtime\"\n :version 1 :capsules identities)) \"\\n\") \"utf8\")))\n (js-object :files files :inputs inputs)))\n (defun existing-runtime-route (out-dir)\n ;; Preserve an already available complete package and its actual provider\n ;; identities. A second package with equal bytes is not the same runtime.\n (let ((require (createRequire (resolve out-dir \"__eliscript_runtime_scope.mjs\"))))\n (try\n (js-call capsules :every (lambda (name)\n (js-call (js-array \".mjs\" \".mjs.map\") :every (lambda (suffix)\n (= (realpathSync (js-call require :resolve (str \"eliscript/runtime/\" name suffix)))\n (realpathSync (resolve source-root (str \"runtime/\" name suffix))))))))\n (catch error false))))\n (defun complete-runtime (result)\n (let* ((out-dir (get result :outDir)) (base (resolve out-dir \"node_modules/eliscript\"))\n (runtime (runtime-inputs)) (files (get runtime :files))\n (directories (js-array \"node_modules\" \"node_modules/eliscript\" \"node_modules/eliscript/runtime\")))\n ;; All source authentication and all user-output conflicts precede the\n ;; first support write. The original project manifest/result stay exact.\n (js-call directories :forEach (lambda (path) (plain-directory out-dir path)))\n (unless (and (undefined? (attributes base)) (existing-runtime-route out-dir))\n (js-call files :forEach (lambda (record)\n (check-target base record)\n (reject-source-alias base record (get runtime :inputs))))\n (js-call directories :forEach (lambda (path)\n (plain-directory out-dir path)\n (try (mkdirSync (resolve out-dir path))\n (catch error (unless (= (get error :code) \"EEXIST\") (throw error))))\n (plain-directory out-dir path)))\n (js-call files :forEach (lambda (record)\n (js-call directories :forEach (lambda (path) (plain-directory out-dir path)))\n (reject-source-alias base record (get runtime :inputs))\n (unless (check-target base record)\n (try (writeFileSync (resolve base (get record :path)) (get record :content) (js-object :flag \"wx\"))\n (catch error\n (if (= (get error :code) \"EEXIST\") (check-target base record) (throw error))))))))\n result))\n\n (defasync buildProject (options)\n ;; Preserve legacy option reads, validation, root isolation, cache, reports,\n ;; errors and its frozen return identity. Deployment is only post-success.\n (complete-runtime (await (js-call legacy :buildProject options))))\n\n (export checkProject buildProject))\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AACE,QAAsB;AACtB,QAAkB,WAAU,WAAU,cAAa,cAAa;AAChE,QAAoB,UAAS,SAAQ;AACrC,QAAmB;AACnB,QAAsB;AACtB,QAAsB;AACtB,YAAmC;AAEnC,qBAAuB,CAAK,QAAO;;AACnC,oBAAuB,QAAS,QAAS,cAAc,mBAA0B;;AACjF,iBAAmB,CAAU,QAAO,gBAAe;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AC9C,yBAAS,aAAa,MAAK;UACzB,OAAA;;cAAK,OAAC,cAAe,QAAQ,MAAK,CAAK,QAAO,UAAQ,CAAK,QAAO,YAAU,EAAW,QAAM;aAC3F,QAAO;cACL,IAAI,CAAG,CAAK,OAAM,YAAO;gBAAU,OAAC,aAAa,MAAK;;gBAAQ,OAAA,4DAAO;;;;;;;;;IAC/E,OAAA;;;AAEJ,4BAAwB;EAGtB,OAAC,iBAAiB,OAAO,CAAS,QAAO,gBAAc;;AAEzD,QAAQ,cAAa"}
|
|
1
|
+
{"version":3,"file":"project.mjs","sources":["../../tools/project/project.eli"],"sourcesContent":["(module tools.project.project\n (import \"node:crypto\" createHash)\n (import \"node:fs\" lstatSync mkdirSync readFileSync realpathSync writeFileSync)\n (import \"node:path\" basename dirname resolve)\n (import \"node:url\" fileURLToPath)\n (import \"node:buffer\" Buffer)\n (import \"node:module\" createRequire)\n (import \"./project-legacy.mjs\" :as legacy)\n\n (defconst checkProject (get legacy :checkProject))\n (defconst source-root (resolve (dirname (fileURLToPath (js* \"import.meta.url\"))) \"../..\"))\n (defconst capsules (js-array \"math\" \"prelude\" \"unicode-case\" \"unicode-case-data\"))\n (defun digest (bytes) (js-call (js-call (createHash \"sha256\") :update bytes) :digest \"hex\"))\n (defun project-error (message filename)\n (let ((error (new globalThis.Error message)))\n (put error :eliscriptDiagnostic (js-object :format \"eliscript-diagnostic\" :version 1\n :code \"ELI-B0001\" :severity \"error\" :phase \"project-build\" :message message\n :location (js-object :file filename)))\n (throw error)))\n (defun attributes (path)\n (try (lstatSync path)\n (catch error (if (= (get error :code) \"ENOENT\") undefined (throw error)))))\n (defun plain-directory (out-dir relative-path)\n (let* ((path (resolve out-dir relative-path)) (value (attributes path)))\n (when value\n (when (js-call value :isSymbolicLink)\n (project-error (str \"project runtime support contains a symlink: \" relative-path) path))\n (unless (js-call value :isDirectory)\n (project-error (str \"project runtime support is not a directory: \" relative-path) path)))))\n (defun check-target (base record)\n (let* ((relative-path (get record :path)) (path (resolve base relative-path))\n (value (attributes path)))\n (when value\n (when (js-call value :isSymbolicLink)\n (project-error (str \"project runtime support contains a symlink: \" relative-path) path))\n (unless (and (js-call value :isFile) (js-call (readFileSync path) :equals (get record :content)))\n (project-error (str \"project runtime support conflicts with existing output: \" relative-path) path)))\n (not (undefined? value))))\n (defun reject-source-alias (base record inputs)\n (let* ((path (resolve base (get record :path))) (value (attributes path)))\n (when value\n (js-call inputs :forEach (lambda (input)\n (when (and (= (get value :dev) (get input :dev))\n (= (get value :ino) (get input :ino)))\n (project-error (str \"project runtime output aliases a source: \" (get record :path)) path)))))))\n (defun asset (path content)\n (js-object :path path :bytes (js-length content) :sha256 (digest content)))\n (defun runtime-inputs ()\n (let ((files (js-array)) (identities (js-array)) (inputs (js-array)))\n (js-call capsules :forEach (lambda (name)\n (let* ((source-path (str \"runtime/\" name \".eli\"))\n (module-path (str \"runtime/\" name \".mjs\")) (map-path (str module-path \".map\"))\n (source (readFileSync (resolve source-root source-path)))\n (module (readFileSync (resolve source-root module-path)))\n (mapping (readFileSync (resolve source-root map-path)))\n (map (JSON/parse (js-call mapping :toString \"utf8\"))))\n (js-call (js-array source-path module-path map-path) :forEach (lambda (path)\n (js-call inputs :push (lstatSync (realpathSync (resolve source-root path))))))\n ;; The source module and its map are one real generator pair. Keep\n ;; every original map coordinate and byte; dist/runtime is another\n ;; producer and is never a fallback for either half of this pair.\n (unless (and (= (get map :version) 3) (= (value-type (get map :file)) \"string\")\n (= (basename (get map :file)) (str name \".mjs\"))\n (Array/isArray (get map :sourcesContent)) (= (js-length (get map :sourcesContent)) 1)\n (= (aref (get map :sourcesContent) 0) (js-call source :toString \"utf8\")))\n (project-error (str \"project runtime source and map identity differ: \" module-path)\n (resolve source-root map-path)))\n (js-call files :push (js-object :path module-path :content module)\n (js-object :path map-path :content mapping))\n (js-call identities :push (js-object :source (asset source-path source)\n :module (asset module-path module) :sourceMap (asset map-path mapping))))))\n (let ((exports (js-object)))\n (js-call capsules :forEach (lambda (name)\n (put exports (str \"./runtime/\" name \".mjs\") (str \"./runtime/\" name \".mjs\"))))\n (js-call files :push (js-object :path \"package.json\" :content\n (js-call Buffer :from (str (JSON/stringify (js-object :name \"eliscript\" :type \"module\"\n :private t :exports exports)) \"\\n\") \"utf8\"))))\n (js-call files :push (js-object :path \"eliscript-runtime.json\" :content\n (js-call Buffer :from (str (JSON/stringify (js-object :format \"eliscript-project-runtime\"\n :version 1 :capsules identities)) \"\\n\") \"utf8\")))\n (js-object :files files :inputs inputs)))\n (defun existing-runtime-route (out-dir)\n ;; Preserve an already available complete package and its actual provider\n ;; identities. A second package with equal bytes is not the same runtime.\n (let ((require (createRequire (resolve out-dir \"__eliscript_runtime_scope.mjs\"))))\n (try\n (js-call capsules :every (lambda (name)\n (js-call (js-array \".mjs\" \".mjs.map\") :every (lambda (suffix)\n (= (realpathSync (js-call require :resolve (str \"eliscript/runtime/\" name suffix)))\n (realpathSync (resolve source-root (str \"runtime/\" name suffix))))))))\n (catch error false))))\n (defun complete-runtime (result)\n (let* ((out-dir (get result :outDir)) (base (resolve out-dir \"node_modules/eliscript\"))\n (runtime (runtime-inputs)) (files (get runtime :files))\n (directories (js-array \"node_modules\" \"node_modules/eliscript\" \"node_modules/eliscript/runtime\")))\n ;; All source authentication and all user-output conflicts precede the\n ;; first support write. The original project manifest/result stay exact.\n (js-call directories :forEach (lambda (path) (plain-directory out-dir path)))\n (unless (and (undefined? (attributes base)) (existing-runtime-route out-dir))\n (js-call files :forEach (lambda (record)\n (check-target base record)\n (reject-source-alias base record (get runtime :inputs))))\n (js-call directories :forEach (lambda (path)\n (plain-directory out-dir path)\n (try (mkdirSync (resolve out-dir path))\n (catch error (unless (= (get error :code) \"EEXIST\") (throw error))))\n (plain-directory out-dir path)))\n (js-call files :forEach (lambda (record)\n (js-call directories :forEach (lambda (path) (plain-directory out-dir path)))\n (reject-source-alias base record (get runtime :inputs))\n (unless (check-target base record)\n (try (writeFileSync (resolve base (get record :path)) (get record :content) (js-object :flag \"wx\"))\n (catch error\n (if (= (get error :code) \"EEXIST\") (check-target base record) (throw error))))))))\n result))\n\n (defasync buildProject (options)\n ;; Preserve legacy option reads, validation, root isolation, cache, reports,\n ;; errors and its frozen return identity. Deployment is only post-success.\n (complete-runtime (await (js-call legacy :buildProject options))))\n\n (export checkProject buildProject))\n"],"names":[],"mappings":";;;;;;;;;;AACE,QAAsB;AACtB,QAAkB,WAAU,WAAU,cAAa,cAAa;AAChE,QAAoB,UAAS,SAAQ;AACrC,QAAmB;AACnB,QAAsB;AACtB,QAAsB;AACtB,YAAmC;AAEnC,qBAAuB,CAAK,QAAO;AACnC,oBAAuB,QAAS,QAAS,cAAc,mBAA0B;;AACjF,iBAAmB,CAAU,QAAO,WAAU,gBAAe;;AAC7D,gBAAe;EAAO,OAAA,CAAS,CAAU,WAAW,WAAU,UAAQ,QAAO,UAAQ;;AACrF,uBAAsB,SAAQ;EAC5B;gCAAa,KAAK,kBAAiB;;UAA7B;MACJ,EAAK,OAAM,yBAAqB,EAAW,UAAQ,wBAAuB,WAAS,GACjF,QAAM,aAAY,YAAU,SAAQ,SAAO,iBAAgB,WAAS,SACpE,YAAU,EAAW,QAAM;MAC7B,OAAA,0DAAO;;;;AACX,oBAAmB;EACjB,OAAA;;MAAK,OAAC,UAAU;KACd,QAAO;MAAM,IAAI,CAAG,CAAK,OAAM,YAAO;QAAU,OAAA;;QAAU,OAAA,0DAAO;;;;;AACrE,yBAAwB,SAAQ;EAC9B;QAAO,OAAO,QAAQ,SAAQ;QAAgB,QAAQ,WAAW;IAC/D,uBAAM;MACJ,uBAAM,CAAS,OAAM;QAClB,cAAc,QAAK,yDAA+C,iBAAe;;MACpF,yBAAQ,CAAS,OAAM;QACrB,OAAC,cAAc,QAAK,yDAA+C,iBAAe;;;;;;;;;AAC1F,sBAAqB,MAAK;EACxB;QAAO,gBAAe,CAAK,QAAO;QAAQ,OAAO,QAAQ,MAAK;QACvD,QAAQ,WAAW;IACxB,uBAAM;MACJ,uBAAM,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Q,uEAAqC,uBAAuB,kCAAvD,CAAa,WAAW;MACnC,CAAS,OAAM,WAAS,EAAS;QAC9B,aAAa,MAAK;QACnB,OAAC,oBAAoB,MAAK,QAAO,CAAK,SAAQ;;MAChD,CAAS,aAAY,WAAS,EAAS;QACpC,gBAAgB,SAAQ;QACzB;;YAAK,OAAC,UAAW,QAAQ,SAAQ;WAC/B,QAAO;YAAM,MAAQ,CAAG,CAAK,OAAM,YAAO;cAAU,OAAA,4DAAO;;;;;;QAC7D,OAAC,gBAAgB,SAAQ;;MAC3B,CAAS,OAAM,WAAS,EAAS;QAC/B,CAAS,aAAY,WAAS,EAAS;UAAM,OAAC,gBAAgB,SAAQ;;QACrE,oBAAoB,MAAK,QAAO,CAAK,SAAQ;QAC9C,yBAAS,aAAa,MAAK;UACzB,OAAA;;cAAK,OAAC,cAAe,QAAQ,MAAK,CAAK,QAAO,UAAQ,CAAK,QAAO,YAAU,EAAW,QAAM;aAC3F,QAAO;cACL,IAAI,CAAG,CAAK,OAAM,YAAO;gBAAU,OAAC,aAAa,MAAK;;gBAAQ,OAAA,4DAAO;;;;;;;;;IAC/E,OAAA;;;AAEJ,4BAAwB;EAGtB,OAAC,iBAAiB,OAAO,CAAS,QAAO,gBAAc;;AAEzD,QAAQ,cAAa"}
|
package/browser/README.md
CHANGED
|
@@ -15,7 +15,7 @@ hot-reload `<script type="text/eliscript">` tags (inline or `src="..."`) or
|
|
|
15
15
|
`data-eliscript` entry points directly in the browser without a backend server:
|
|
16
16
|
|
|
17
17
|
```html
|
|
18
|
-
<script defer src="https://unpkg.com/eliscript@0.0
|
|
18
|
+
<script defer src="https://unpkg.com/eliscript@0.1.0/dist/browser/loader.js"></script>
|
|
19
19
|
<script type="text/eliscript">
|
|
20
20
|
(module app.live
|
|
21
21
|
(import "eliscript/runtime/core/order" sort)
|
package/compiler/README.md
CHANGED
|
@@ -22,8 +22,8 @@ This directory contains the first Emacs Lisp seed compiler:
|
|
|
22
22
|
backend and supplies shared formatting helpers.
|
|
23
23
|
- `eliscript.el` exposes the public string and file compilation API.
|
|
24
24
|
- `eliscript-cli.el` implements the batch command used by `bin/eliscript`.
|
|
25
|
-
- `eliscript-project.el` discovers expanded local imports
|
|
26
|
-
source-mapped ESM trees.
|
|
25
|
+
- `eliscript-project.el` discovers expanded local imports (supporting both
|
|
26
|
+
`.eli` and `.el` source files) and writes complete source-mapped ESM trees.
|
|
27
27
|
- `eliscript-project-cli.el` implements the batch command used by
|
|
28
28
|
`bin/eliscript-build`.
|
|
29
29
|
|
|
@@ -26,8 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
(defconst eliscript-emitter--number-conversion-intrinsics
|
|
28
28
|
"const __eliscript_number_intrinsic = globalThis.Number;\nconst __eliscript_bigint_intrinsic = globalThis.BigInt;\nconst __eliscript_numeric_apply = globalThis.Reflect.apply;\nconst __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;\nconst __eliscript_numeric_error = globalThis.TypeError;\nconst __eliscript_numeric_trim = globalThis.String.prototype.trim;\nconst __eliscript_numeric_slice = globalThis.String.prototype.slice;\nconst __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;\n")
|
|
29
|
-
(defconst eliscript-emitter--number-conversion-capsule
|
|
30
|
-
"import { __eliscript_number_intrinsic, __eliscript_bigint_intrinsic, __eliscript_numeric_apply, __eliscript_numeric_symbol, __eliscript_numeric_error, __eliscript_numeric_trim, __eliscript_numeric_slice, __eliscript_numeric_exec } from \"data:text/javascript;base64,ZXhwb3J0IGNvbnN0IF9fZWxpc2NyaXB0X251bWJlcl9pbnRyaW5zaWMgPSBnbG9iYWxUaGlzLk51bWJlcjsKZXhwb3J0IGNvbnN0IF9fZWxpc2NyaXB0X2JpZ2ludF9pbnRyaW5zaWMgPSBnbG9iYWxUaGlzLkJpZ0ludDsKZXhwb3J0IGNvbnN0IF9fZWxpc2NyaXB0X251bWVyaWNfYXBwbHkgPSBnbG9iYWxUaGlzLlJlZmxlY3QuYXBwbHk7CmV4cG9ydCBjb25zdCBfX2VsaXNjcmlwdF9udW1lcmljX3N5bWJvbCA9IGdsb2JhbFRoaXMuU3ltYm9sLnRvUHJpbWl0aXZlOwpleHBvcnQgY29uc3QgX19lbGlzY3JpcHRfbnVtZXJpY19lcnJvciA9IGdsb2JhbFRoaXMuVHlwZUVycm9yOwpleHBvcnQgY29uc3QgX19lbGlzY3JpcHRfbnVtZXJpY190cmltID0gZ2xvYmFsVGhpcy5TdHJpbmcucHJvdG90eXBlLnRyaW07CmV4cG9ydCBjb25zdCBfX2VsaXNjcmlwdF9udW1lcmljX3NsaWNlID0gZ2xvYmFsVGhpcy5TdHJpbmcucHJvdG90eXBlLnNsaWNlOwpleHBvcnQgY29uc3QgX19lbGlzY3JpcHRfbnVtZXJpY19leGVjID0gZ2xvYmFsVGhpcy5SZWdFeHAucHJvdG90eXBlLmV4ZWM7Cg==\";\n")
|
|
31
29
|
(defconst eliscript-emitter--number-conversion-body
|
|
32
30
|
"const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;\nconst __eliscript_numeric_object = (value) => value !== null && (typeof value === \"object\" || typeof value === \"function\" || (typeof value === \"undefined\" && value !== void 0));\nconst __eliscript_numeric_primitive = (value) => {\n if (!__eliscript_numeric_object(value)) return value;\n const exotic = value[__eliscript_numeric_symbol];\n if (exotic !== void 0 && exotic !== null) {\n const result = __eliscript_numeric_apply(exotic, value, [\"number\"]);\n if (!__eliscript_numeric_object(result)) return result;\n throw new __eliscript_numeric_error(\"Cannot convert object to primitive value\");\n }\n for (let index = 0; index < 2; index++) {\n const method = value[index === 0 ? \"valueOf\" : \"toString\"];\n if (typeof method === \"function\" || (typeof method === \"undefined\" && method !== void 0)) {\n const result = __eliscript_numeric_apply(method, value, []);\n if (!__eliscript_numeric_object(result)) return result;\n }\n }\n throw new __eliscript_numeric_error(\"Cannot convert object to primitive value\");\n};\nconst __eliscript_to_number = (value) => {\n const primitive = __eliscript_numeric_primitive(value);\n if (typeof primitive === \"string\") {\n const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);\n if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {\n let first = 2;\n while (first < text.length && text[first] === \"0\") first++;\n if (first === text.length) return 0;\n const prefix = text[1];\n const limit = prefix === \"x\" || prefix === \"X\" ? 256 : prefix === \"b\" || prefix === \"B\" ? 1024 : 342;\n if (text.length - first > limit) return 1 / 0;\n const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);\n return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));\n }\n }\n return __eliscript_number_intrinsic(primitive);\n};\n")
|
|
33
31
|
(defconst eliscript-emitter--number-conversion-helper
|
|
@@ -38,10 +36,46 @@
|
|
|
38
36
|
"Generated primitive numeric operators with exact coercion ordering.")
|
|
39
37
|
(defconst eliscript-emitter--imul-intrinsic
|
|
40
38
|
"const __eliscript_numeric_imul_intrinsic = globalThis.Math.imul;\n")
|
|
41
|
-
(defconst eliscript-emitter--imul-capsule
|
|
42
|
-
"import { __eliscript_numeric_imul_intrinsic } from \"data:text/javascript;base64,ZXhwb3J0IGNvbnN0IF9fZWxpc2NyaXB0X251bWVyaWNfaW11bF9pbnRyaW5zaWMgPSBnbG9iYWxUaGlzLk1hdGguaW11bDsK\";\n")
|
|
43
39
|
(defconst eliscript-emitter--imul-operator-helper
|
|
44
40
|
"const __eliscript_numeric_imul = (a, b) => __eliscript_numeric_imul_intrinsic(__eliscript_implicit_number(a), __eliscript_implicit_number(b));\n")
|
|
41
|
+
;; One compiled runtime module owns every shared helper. Its own module scope
|
|
42
|
+
;; never binds globalThis, so captured intrinsics need no separate capsule.
|
|
43
|
+
(defconst eliscript-emitter--prelude-array-text-names
|
|
44
|
+
'("__eliscript_at" "__eliscript_at_direct"))
|
|
45
|
+
(defconst eliscript-emitter--prelude-number-conversion-names
|
|
46
|
+
'("__eliscript_to_number"))
|
|
47
|
+
(defconst eliscript-emitter--prelude-numeric-coercion-names
|
|
48
|
+
'("__eliscript_numeric_decrement" "__eliscript_numeric_relation"
|
|
49
|
+
"__eliscript_numeric_sub" "__eliscript_numeric_mul" "__eliscript_numeric_div"
|
|
50
|
+
"__eliscript_numeric_rem" "__eliscript_numeric_and" "__eliscript_numeric_or"
|
|
51
|
+
"__eliscript_numeric_xor" "__eliscript_numeric_shl" "__eliscript_numeric_shr"
|
|
52
|
+
"__eliscript_numeric_ushr" "__eliscript_numeric_neg" "__eliscript_numeric_int32"
|
|
53
|
+
"__eliscript_numeric_uint32" "__eliscript_numeric_not"))
|
|
54
|
+
(defconst eliscript-emitter--prelude-imul-names
|
|
55
|
+
'("__eliscript_numeric_imul"))
|
|
56
|
+
(defconst eliscript-emitter--prelude-module
|
|
57
|
+
(concat
|
|
58
|
+
"// Generated by Eliscript. Do not edit.\n"
|
|
59
|
+
"export" (substring eliscript-emitter--array-text-import (length "import"))
|
|
60
|
+
eliscript-emitter--number-conversion-helper
|
|
61
|
+
eliscript-emitter--numeric-operator-helper
|
|
62
|
+
eliscript-emitter--imul-intrinsic
|
|
63
|
+
eliscript-emitter--imul-operator-helper
|
|
64
|
+
"export { "
|
|
65
|
+
(string-join (append eliscript-emitter--prelude-number-conversion-names
|
|
66
|
+
eliscript-emitter--prelude-numeric-coercion-names
|
|
67
|
+
eliscript-emitter--prelude-imul-names) ", ")
|
|
68
|
+
" };\n")
|
|
69
|
+
"Complete generated module for runtime/prelude.eli.")
|
|
70
|
+
(defun eliscript-emitter--prelude-import (array-text number-conversion numeric-coercion imul)
|
|
71
|
+
"Import the shared helpers selected by each runtime requirement."
|
|
72
|
+
(let ((names (append (and array-text eliscript-emitter--prelude-array-text-names)
|
|
73
|
+
(and number-conversion eliscript-emitter--prelude-number-conversion-names)
|
|
74
|
+
(and numeric-coercion eliscript-emitter--prelude-numeric-coercion-names)
|
|
75
|
+
(and imul eliscript-emitter--prelude-imul-names))))
|
|
76
|
+
(if names
|
|
77
|
+
(concat "import { " (string-join names ", ") " } from \"eliscript/runtime/prelude.mjs\";\n")
|
|
78
|
+
"")))
|
|
45
79
|
(defconst eliscript-emitter--host-identity-token-helper
|
|
46
80
|
"const __eliscript_host_identity_token = (() => { const objects = new WeakMap(); const symbols = new Map(); let next = 1; return (value) => { const type = typeof value; if ((type !== \"object\" || value === null) && type !== \"function\" && type !== \"symbol\") throw new TypeError(\"host-identity-token expects an object, function, or symbol\"); const identities = type === \"symbol\" ? symbols : objects; const cached = identities.get(value); if (cached !== undefined) return cached; if (next > Number.MAX_SAFE_INTEGER) throw new RangeError(\"host identity token space exhausted\"); const token = next; next += 1; identities.set(value, token); return token; }; })();\n"
|
|
47
81
|
"Generated module helper for process-local opaque host identities.")
|
|
@@ -93,22 +127,97 @@
|
|
|
93
127
|
(defun eliscript-emitter--tdz-write-text (record name value)
|
|
94
128
|
(if record (concat (eliscript-emitter--tdz-writer-name record) "(" value ")")
|
|
95
129
|
(format "(%s = %s)" (eliscript-emitter--binding-name name) value)))
|
|
130
|
+
(defun eliscript-emitter--tdz-state-create ()
|
|
131
|
+
"Return empty module-variable initialization analysis state."
|
|
132
|
+
(list :variables nil :declarations (make-hash-table :test #'eq)
|
|
133
|
+
:reads (make-hash-table :test #'eq) :writes (make-hash-table :test #'eq)
|
|
134
|
+
:functions (make-hash-table :test #'equal) :references (make-hash-table :test #'equal)
|
|
135
|
+
:raw (make-hash-table :test #'equal) :exported nil :imports nil
|
|
136
|
+
:sites nil :decisions nil :cursor 0 :position 0 :owner nil))
|
|
137
|
+
(defun eliscript-emitter--tdz-declare (state name mutable)
|
|
138
|
+
"Record module variable NAME declared at the current top-level position."
|
|
139
|
+
(let ((record (list :index (length (plist-get state :variables)) :name name :mutable mutable
|
|
140
|
+
:statement (plist-get state :position) :read nil :write nil)))
|
|
141
|
+
(setf (plist-get state :variables) (append (plist-get state :variables) (list record)))
|
|
142
|
+
record))
|
|
143
|
+
(defun eliscript-emitter--tdz-function (state key)
|
|
144
|
+
"Record module function KEY and return its scope entry."
|
|
145
|
+
(puthash key t (plist-get state :functions))
|
|
146
|
+
(list :function key))
|
|
147
|
+
(defun eliscript-emitter--tdz-variable-p (record)
|
|
148
|
+
(and record (plist-get record :index) t))
|
|
149
|
+
(defun eliscript-emitter--tdz-guarded-p (record)
|
|
150
|
+
(and record (or (plist-get record :read) (plist-get record :write))))
|
|
151
|
+
(defun eliscript-emitter--tdz-reference (state record)
|
|
152
|
+
"Record that the current owner can call the function scope entry RECORD."
|
|
153
|
+
(push (plist-get record :function) (gethash (plist-get state :owner) (plist-get state :references))))
|
|
154
|
+
(defun eliscript-emitter--tdz-raw (state)
|
|
155
|
+
"Record raw JavaScript, which may call any module function."
|
|
156
|
+
(puthash (plist-get state :owner) t (plist-get state :raw)))
|
|
157
|
+
(defun eliscript-emitter--tdz-site (state kind record &optional object)
|
|
158
|
+
"Record access KIND to RECORD, or replay its finalized guard decision.
|
|
159
|
+
Form rewriting cannot identify interned symbols, so it walks twice in the
|
|
160
|
+
same order; IR walks pass the accessing OBJECT and finalize only once."
|
|
161
|
+
(let ((decisions (plist-get state :decisions)))
|
|
162
|
+
(if decisions
|
|
163
|
+
(let ((cursor (plist-get state :cursor)))
|
|
164
|
+
(setf (plist-get state :cursor) (1+ cursor))
|
|
165
|
+
(aref decisions cursor))
|
|
166
|
+
(push (list kind record (plist-get state :owner) object) (plist-get state :sites))
|
|
167
|
+
t)))
|
|
168
|
+
(defun eliscript-emitter--tdz-finalize (state)
|
|
169
|
+
"Guard only accesses that can run before their declaration completes.
|
|
170
|
+
A top-level statement runs at its own position. A function can first run
|
|
171
|
+
when a statement or earlier function references it; with imports an exported
|
|
172
|
+
function can run through a cycle before this module, and raw JavaScript can
|
|
173
|
+
call any function. Return the decision of each recorded access in order."
|
|
174
|
+
(let ((functions (plist-get state :functions)) (references (plist-get state :references))
|
|
175
|
+
(raw (plist-get state :raw)) (early (make-hash-table :test #'equal))
|
|
176
|
+
(all most-positive-fixnum) pending)
|
|
177
|
+
(cl-flet ((lower (key index)
|
|
178
|
+
(when (and (gethash key functions)
|
|
179
|
+
(< index (gethash key early most-positive-fixnum)))
|
|
180
|
+
(puthash key index early)
|
|
181
|
+
(push key pending))))
|
|
182
|
+
(when (plist-get state :imports)
|
|
183
|
+
(dolist (key (plist-get state :exported)) (lower key -1)))
|
|
184
|
+
(maphash (lambda (owner keys) (when (integerp owner) (dolist (key keys) (lower key owner)))) references)
|
|
185
|
+
(maphash (lambda (owner _) (when (integerp owner) (setq all (min all owner)))) raw)
|
|
186
|
+
(while pending
|
|
187
|
+
(let* ((key (pop pending)) (index (gethash key early)))
|
|
188
|
+
(when (gethash key raw) (setq all (min all index)))
|
|
189
|
+
(dolist (callee (gethash key references)) (lower callee index)))))
|
|
190
|
+
(mapcar
|
|
191
|
+
(lambda (site)
|
|
192
|
+
(let* ((kind (nth 0 site)) (record (nth 1 site)) (owner (nth 2 site)) (object (nth 3 site))
|
|
193
|
+
(time (if (integerp owner) owner (min all (gethash owner early most-positive-fixnum))))
|
|
194
|
+
(guarded (or (and (eq kind :write) (not (plist-get record :mutable)))
|
|
195
|
+
(<= time (plist-get record :statement)))))
|
|
196
|
+
(when guarded
|
|
197
|
+
(plist-put record kind t)
|
|
198
|
+
(when object
|
|
199
|
+
(puthash object record (plist-get state (if (eq kind :read) :reads :writes)))))
|
|
200
|
+
guarded))
|
|
201
|
+
(reverse (plist-get state :sites)))))
|
|
96
202
|
(defun eliscript-emitter--tdz-prologue (state)
|
|
97
|
-
(
|
|
98
|
-
(
|
|
99
|
-
(
|
|
100
|
-
(
|
|
101
|
-
(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
203
|
+
(let ((records (cl-remove-if-not #'eliscript-emitter--tdz-guarded-p (plist-get state :variables))))
|
|
204
|
+
(when records
|
|
205
|
+
(concat eliscript-emitter--tdz-import
|
|
206
|
+
(mapconcat
|
|
207
|
+
(lambda (record)
|
|
208
|
+
(let* ((ready (eliscript-emitter--tdz-ready-name record))
|
|
209
|
+
(name (eliscript-emitter--binding-name (plist-get record :name)))
|
|
210
|
+
(argument (format "__eliscript_tdz_value_%d" (plist-get record :index)))
|
|
211
|
+
(quoted (eliscript-emitter--json-string name)))
|
|
212
|
+
(concat "var " ready ";\n"
|
|
213
|
+
(when (plist-get record :read)
|
|
214
|
+
(concat "function " (eliscript-emitter--tdz-reader-name record) "() { if (" ready
|
|
215
|
+
" !== true) __eliscript_tdz_error(" quoted "); return " name "; }\n"))
|
|
216
|
+
(when (plist-get record :write)
|
|
217
|
+
(concat "function " (eliscript-emitter--tdz-writer-name record) "(" argument ") { if (" ready
|
|
218
|
+
" !== true) __eliscript_tdz_error(" quoted "); "
|
|
219
|
+
(if (plist-get record :mutable) (concat "return (" name " = " argument ");") "return __eliscript_const_error();") " }\n")))))
|
|
220
|
+
records "")))))
|
|
112
221
|
|
|
113
222
|
|
|
114
223
|
|
|
@@ -127,19 +236,26 @@
|
|
|
127
236
|
(dolist (parameter parameters) (eliscript-emitter--tdz-legacy-shadow parameter scope)))
|
|
128
237
|
(defun eliscript-emitter--tdz-legacy-predeclare (forms scope state)
|
|
129
238
|
(dolist (form forms)
|
|
130
|
-
(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
((
|
|
134
|
-
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
239
|
+
(if (and (consp form) (eq (car form) 'module))
|
|
240
|
+
(eliscript-emitter--tdz-legacy-predeclare (cddr form) scope state)
|
|
241
|
+
(when (consp form)
|
|
242
|
+
(pcase (car form)
|
|
243
|
+
((or 'defvar 'defconst)
|
|
244
|
+
(let ((record (eliscript-emitter--tdz-declare state (cadr form) (eq (car form) 'defvar))))
|
|
245
|
+
(puthash form record (plist-get state :declarations))
|
|
246
|
+
(puthash (eliscript-emitter--binding-name (cadr form)) record scope)))
|
|
247
|
+
((or 'defun 'defn 'defasync)
|
|
248
|
+
(let ((key (eliscript-emitter--binding-name (cadr form))))
|
|
249
|
+
(puthash key (eliscript-emitter--tdz-function state key) scope)))
|
|
250
|
+
('export
|
|
251
|
+
(dolist (name (cdr form))
|
|
252
|
+
(push (eliscript-emitter--binding-name name) (plist-get state :exported))))
|
|
253
|
+
((or 'import 'import-portable)
|
|
254
|
+
(setf (plist-get state :imports) t)
|
|
255
|
+
(dolist (name (cddr form))
|
|
256
|
+
(when (and name (symbolp name) (not (keywordp name)))
|
|
257
|
+
(puthash (eliscript-emitter--binding-name name) nil scope))))))
|
|
258
|
+
(setf (plist-get state :position) (1+ (plist-get state :position))))))
|
|
143
259
|
(defun eliscript-emitter--tdz-legacy-sequence (forms scope)
|
|
144
260
|
(mapcar (lambda (form) (eliscript-emitter--tdz-legacy-expression form scope)) forms))
|
|
145
261
|
(defun eliscript-emitter--tdz-legacy-expression (form scope)
|
|
@@ -202,13 +318,20 @@
|
|
|
202
318
|
(defun eliscript-emitter--tdz-legacy-expression-recursive (form scope)
|
|
203
319
|
(cond
|
|
204
320
|
((and form (symbolp form) (not (keywordp form)))
|
|
205
|
-
(let ((record (gethash (eliscript-emitter--tdz-root form) scope))
|
|
206
|
-
|
|
321
|
+
(let ((record (gethash (eliscript-emitter--tdz-root form) scope))
|
|
322
|
+
(state eliscript-emitter--tdz-state))
|
|
323
|
+
(cond
|
|
324
|
+
((and record (not (eliscript-emitter--tdz-variable-p record)))
|
|
325
|
+
(eliscript-emitter--tdz-reference state record) form)
|
|
326
|
+
((and record (eliscript-emitter--tdz-site state :read record))
|
|
327
|
+
(list eliscript-emitter--tdz-read-tag record form))
|
|
328
|
+
(t form))))
|
|
207
329
|
((vectorp form) (vconcat (eliscript-emitter--tdz-legacy-sequence (append form nil) scope)))
|
|
208
330
|
((consp form)
|
|
209
331
|
(let ((operator (car form)) (arguments (cdr form)))
|
|
210
332
|
(pcase operator
|
|
211
|
-
(
|
|
333
|
+
('quote form)
|
|
334
|
+
('js* (eliscript-emitter--tdz-raw eliscript-emitter--tdz-state) form)
|
|
212
335
|
((or 'lambda 'fn 'async)
|
|
213
336
|
(let ((child (copy-hash-table scope)))
|
|
214
337
|
(eliscript-emitter--tdz-legacy-parameters (car arguments) child)
|
|
@@ -232,8 +355,11 @@
|
|
|
232
355
|
(let ((pending arguments) pairs original-pairs guarded)
|
|
233
356
|
(while pending
|
|
234
357
|
(let* ((name (pop pending)) (value (pop pending))
|
|
235
|
-
(
|
|
236
|
-
(
|
|
358
|
+
(rewritten (eliscript-emitter--tdz-legacy-expression value scope))
|
|
359
|
+
(entry (and (symbolp name) (gethash (eliscript-emitter--tdz-root name) scope)))
|
|
360
|
+
(record (and (eliscript-emitter--tdz-variable-p entry)
|
|
361
|
+
(eliscript-emitter--tdz-site eliscript-emitter--tdz-state :write entry)
|
|
362
|
+
entry)))
|
|
237
363
|
(when record (setq guarded t))
|
|
238
364
|
(push (list name rewritten) original-pairs)
|
|
239
365
|
(push (list eliscript-emitter--tdz-write-tag record name rewritten) pairs)))
|
|
@@ -272,19 +398,35 @@
|
|
|
272
398
|
(eliscript-emitter--tdz-legacy-sequence arguments scope))))))
|
|
273
399
|
(t form)))
|
|
274
400
|
(defun eliscript-emitter--tdz-legacy-top (form scope state)
|
|
275
|
-
(if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
((
|
|
279
|
-
((
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
401
|
+
(if (and (consp form) (eq (car form) 'module))
|
|
402
|
+
(cons 'module (cons (cadr form) (mapcar (lambda (child) (eliscript-emitter--tdz-legacy-top child scope state)) (cddr form))))
|
|
403
|
+
(let ((position (plist-get state :position)))
|
|
404
|
+
(setf (plist-get state :position) (1+ position))
|
|
405
|
+
(setf (plist-get state :owner)
|
|
406
|
+
(if (and (consp form) (memq (car form) '(defun defn defasync)))
|
|
407
|
+
(eliscript-emitter--binding-name (cadr form))
|
|
408
|
+
position))
|
|
409
|
+
(if (not (consp form)) (eliscript-emitter--tdz-legacy-expression form scope)
|
|
410
|
+
(pcase (car form)
|
|
411
|
+
((or 'import 'import-portable 'export) form)
|
|
412
|
+
((or 'defvar 'defconst)
|
|
413
|
+
(let ((copy (cons (car form) (cons (cadr form) (eliscript-emitter--tdz-legacy-sequence (cddr form) scope)))))
|
|
414
|
+
(puthash copy (gethash form (plist-get state :declarations)) (plist-get state :declarations)) copy))
|
|
415
|
+
((or 'defun 'defn 'defasync)
|
|
416
|
+
(let ((child (copy-hash-table scope)))
|
|
417
|
+
(eliscript-emitter--tdz-legacy-parameters (nth 2 form) child)
|
|
418
|
+
(append (list (car form) (cadr form) (nth 2 form)) (eliscript-emitter--tdz-legacy-sequence (nthcdr 3 form) child))))
|
|
419
|
+
('export-default (cons 'export-default (eliscript-emitter--tdz-legacy-sequence (cdr form) scope)))
|
|
420
|
+
(_ (eliscript-emitter--tdz-legacy-expression form scope)))))))
|
|
421
|
+
|
|
422
|
+
(defun eliscript-emitter--tdz-legacy-rewrite (forms scope state)
|
|
423
|
+
"Rewrite FORMS with only the TDZ guards their accesses require."
|
|
424
|
+
(let ((rewrite (lambda ()
|
|
425
|
+
(setf (plist-get state :position) 0)
|
|
426
|
+
(mapcar (lambda (form) (eliscript-emitter--tdz-legacy-top form scope state)) forms))))
|
|
427
|
+
(funcall rewrite)
|
|
428
|
+
(setf (plist-get state :decisions) (vconcat (eliscript-emitter--tdz-finalize state)))
|
|
429
|
+
(funcall rewrite)))
|
|
288
430
|
|
|
289
431
|
(defun eliscript-emitter--fail (format-string &rest arguments)
|
|
290
432
|
"Signal a compiler error using FORMAT-STRING and ARGUMENTS."
|
|
@@ -2061,7 +2203,8 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2061
2203
|
(eliscript-emitter-emit-expression (cadr arguments)))
|
|
2062
2204
|
(let ((record (and eliscript-emitter--tdz-state
|
|
2063
2205
|
(gethash form (plist-get eliscript-emitter--tdz-state :declarations)))))
|
|
2064
|
-
(when
|
|
2206
|
+
(when (eliscript-emitter--tdz-guarded-p record)
|
|
2207
|
+
(concat "\n" (eliscript-emitter--tdz-ready-name record) " = true;")))))
|
|
2065
2208
|
((or 'defun 'defn 'defasync)
|
|
2066
2209
|
(eliscript-emitter--require-arity (symbol-name operator) arguments 2)
|
|
2067
2210
|
(let ((name (nth 0 arguments))
|
|
@@ -2157,32 +2300,16 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2157
2300
|
(eliscript-emitter--some-form forms
|
|
2158
2301
|
(lambda (node) (and (consp node) (memq (car node) '(equal)) t)) '(quote)))
|
|
2159
2302
|
|
|
2160
|
-
(defun eliscript-emitter--forms-name-global-root-p (forms)
|
|
2161
|
-
"Find the unquoted global root binding without host recursion."
|
|
2162
|
-
(eliscript-emitter--some-form forms (lambda (node) (eq node 'globalThis)) '(quote)))
|
|
2163
|
-
|
|
2164
|
-
(defun eliscript-emitter--number-conversion-prologue (shadowed)
|
|
2165
|
-
"Capture intrinsics independently of a SHADOWED global root binding."
|
|
2166
|
-
(if shadowed
|
|
2167
|
-
(concat eliscript-emitter--number-conversion-capsule
|
|
2168
|
-
eliscript-emitter--number-conversion-body)
|
|
2169
|
-
eliscript-emitter--number-conversion-helper))
|
|
2170
|
-
|
|
2171
2303
|
(defun eliscript-emitter--uses-imul-p (forms)
|
|
2172
2304
|
"Find the corresponding unquoted runtime operation without host recursion."
|
|
2173
2305
|
(eliscript-emitter--some-form forms
|
|
2174
2306
|
(lambda (node) (and (consp node) (memq (car node) '(imul32)) t)) '(quote)))
|
|
2175
2307
|
|
|
2176
|
-
(defun eliscript-emitter--imul-prologue (shadowed)
|
|
2177
|
-
"Capture Math.imul only when required, outside SHADOWED global bindings."
|
|
2178
|
-
(concat (if shadowed eliscript-emitter--imul-capsule eliscript-emitter--imul-intrinsic)
|
|
2179
|
-
eliscript-emitter--imul-operator-helper))
|
|
2180
|
-
|
|
2181
2308
|
(defconst eliscript-emitter--unicode-runtime-import
|
|
2182
2309
|
"import \"eliscript/runtime/unicode-case.mjs\";\n")
|
|
2183
2310
|
|
|
2184
|
-
(defun eliscript-emitter--
|
|
2185
|
-
"Recognize
|
|
2311
|
+
(defun eliscript-emitter--runtime-capsule-p (filename module-name entries)
|
|
2312
|
+
"Recognize one of ENTRIES by full source and module identity."
|
|
2186
2313
|
(let ((name (if (symbolp module-name) (symbol-name module-name) module-name)))
|
|
2187
2314
|
(and (stringp filename)
|
|
2188
2315
|
(cl-some
|
|
@@ -2191,8 +2318,19 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2191
2318
|
(or (equal filename (car entry))
|
|
2192
2319
|
(and (file-name-absolute-p filename)
|
|
2193
2320
|
(string-suffix-p (concat "/" (car entry)) filename)))))
|
|
2194
|
-
|
|
2195
|
-
|
|
2321
|
+
entries))))
|
|
2322
|
+
|
|
2323
|
+
(defun eliscript-emitter--unicode-capsule-p (filename module-name)
|
|
2324
|
+
"Recognize bootstrap capsules by full source and module identity."
|
|
2325
|
+
(eliscript-emitter--runtime-capsule-p
|
|
2326
|
+
filename module-name
|
|
2327
|
+
'(("runtime/unicode-case.eli" . "eliscript.runtime.unicode-case")
|
|
2328
|
+
("runtime/unicode-case-data.eli" . "eliscript.runtime.unicode-case-data"))))
|
|
2329
|
+
|
|
2330
|
+
(defun eliscript-emitter--prelude-capsule-p (filename module-name)
|
|
2331
|
+
"Recognize the shared helper module by full source and module identity."
|
|
2332
|
+
(eliscript-emitter--runtime-capsule-p
|
|
2333
|
+
filename module-name '(("runtime/prelude.eli" . "eliscript.runtime.prelude"))))
|
|
2196
2334
|
|
|
2197
2335
|
(defun eliscript-emitter--forms-unicode-capsule-p (forms filename)
|
|
2198
2336
|
"Require a single exact module as well as its compilation source context."
|
|
@@ -2200,6 +2338,12 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2200
2338
|
(eq (caar forms) 'module)
|
|
2201
2339
|
(eliscript-emitter--unicode-capsule-p filename (cadar forms))))
|
|
2202
2340
|
|
|
2341
|
+
(defun eliscript-emitter--forms-prelude-p (forms filename)
|
|
2342
|
+
"Require the exact empty prelude module and its compilation source context."
|
|
2343
|
+
(and (equal (length forms) 1) (consp (car forms))
|
|
2344
|
+
(eq (caar forms) 'module) (null (cddar forms))
|
|
2345
|
+
(eliscript-emitter--prelude-capsule-p filename (cadar forms))))
|
|
2346
|
+
|
|
2203
2347
|
(defconst eliscript-emitter--math-runtime-import
|
|
2204
2348
|
"import \"eliscript/runtime/math.mjs\";\n")
|
|
2205
2349
|
|
|
@@ -2233,11 +2377,16 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2233
2377
|
|
|
2234
2378
|
(defun eliscript-emit-module (forms &optional filename)
|
|
2235
2379
|
"Emit FORMS as one ECMAScript module."
|
|
2236
|
-
(let* ((eliscript-emitter--tdz-state (
|
|
2380
|
+
(let* ((eliscript-emitter--tdz-state (eliscript-emitter--tdz-state-create))
|
|
2237
2381
|
(scope (make-hash-table :test #'equal)))
|
|
2238
2382
|
(eliscript-emitter--tdz-legacy-predeclare forms scope eliscript-emitter--tdz-state)
|
|
2239
|
-
(eliscript-emitter--
|
|
2240
|
-
|
|
2383
|
+
(if (eliscript-emitter--forms-prelude-p forms filename)
|
|
2384
|
+
eliscript-emitter--prelude-module
|
|
2385
|
+
(eliscript-emitter--emit-module-ready
|
|
2386
|
+
(if (plist-get eliscript-emitter--tdz-state :variables)
|
|
2387
|
+
(eliscript-emitter--tdz-legacy-rewrite forms scope eliscript-emitter--tdz-state)
|
|
2388
|
+
forms)
|
|
2389
|
+
forms filename))))
|
|
2241
2390
|
|
|
2242
2391
|
(defun eliscript-emitter--emit-module-ready (forms &optional source-forms filename)
|
|
2243
2392
|
(let ((eliscript-emitter--temporary-counter 0)
|
|
@@ -2248,7 +2397,12 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2248
2397
|
(if (eliscript-emitter--forms-unicode-capsule-p prologue-forms filename)
|
|
2249
2398
|
"" eliscript-emitter--unicode-runtime-import)
|
|
2250
2399
|
(if (eliscript-emitter--uses-math-runtime-p prologue-forms) eliscript-emitter--math-runtime-import "")
|
|
2251
|
-
(
|
|
2400
|
+
(let ((numeric-coercion (eliscript-emitter--uses-numeric-coercion-p prologue-forms)))
|
|
2401
|
+
(eliscript-emitter--prelude-import
|
|
2402
|
+
(eliscript-emitter--uses-array-text-p prologue-forms)
|
|
2403
|
+
(or numeric-coercion (eliscript-emitter--uses-number-conversion-p prologue-forms))
|
|
2404
|
+
numeric-coercion
|
|
2405
|
+
(eliscript-emitter--uses-imul-p prologue-forms)))
|
|
2252
2406
|
(if (eliscript-emitter--uses-literal-runtime-p prologue-forms)
|
|
2253
2407
|
eliscript-emitter--literal-runtime-import
|
|
2254
2408
|
"")
|
|
@@ -2262,16 +2416,6 @@ placement and exponent spelling. No rounded decimal arithmetic is involved."
|
|
|
2262
2416
|
eliscript-emitter--value-runtime-import
|
|
2263
2417
|
"")
|
|
2264
2418
|
"const __eliscript_truthy = (value) => value !== false && value != null;\n"
|
|
2265
|
-
(if (or (eliscript-emitter--uses-number-conversion-p prologue-forms)
|
|
2266
|
-
(eliscript-emitter--uses-numeric-coercion-p prologue-forms))
|
|
2267
|
-
(eliscript-emitter--number-conversion-prologue
|
|
2268
|
-
(eliscript-emitter--forms-name-global-root-p prologue-forms))
|
|
2269
|
-
"")
|
|
2270
|
-
(if (eliscript-emitter--uses-numeric-coercion-p prologue-forms)
|
|
2271
|
-
eliscript-emitter--numeric-operator-helper "")
|
|
2272
|
-
(if (eliscript-emitter--uses-imul-p prologue-forms)
|
|
2273
|
-
(eliscript-emitter--imul-prologue
|
|
2274
|
-
(eliscript-emitter--forms-name-global-root-p prologue-forms)) "")
|
|
2275
2419
|
(if (eliscript-emitter--uses-host-identity-token-p prologue-forms)
|
|
2276
2420
|
eliscript-emitter--host-identity-token-helper
|
|
2277
2421
|
"")
|