@shd101wyy/yo 0.0.2
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/LICENSE.md +17 -0
- package/README.md +80 -0
- package/out/cjs/index.cjs +51 -0
- package/out/cjs/yo-cli.cjs +2158 -0
- package/out/esm/index.mjs +51 -0
- package/out/types/src/codegen/async/runtime.d.ts +2 -0
- package/out/types/src/codegen/async/state-code-gen.d.ts +10 -0
- package/out/types/src/codegen/async/state-machine.d.ts +13 -0
- package/out/types/src/codegen/c/collection.d.ts +3 -0
- package/out/types/src/codegen/codegen-c.d.ts +12 -0
- package/out/types/src/codegen/constants.d.ts +3 -0
- package/out/types/src/codegen/expressions/array.d.ts +4 -0
- package/out/types/src/codegen/expressions/generation.d.ts +11 -0
- package/out/types/src/codegen/expressions/index.d.ts +2 -0
- package/out/types/src/codegen/functions/collection.d.ts +5 -0
- package/out/types/src/codegen/functions/context.d.ts +57 -0
- package/out/types/src/codegen/functions/generation.d.ts +25 -0
- package/out/types/src/codegen/functions/index.d.ts +2 -0
- package/out/types/src/codegen/index.d.ts +20 -0
- package/out/types/src/codegen/parallelism/runtime.d.ts +2 -0
- package/out/types/src/codegen/types/collection.d.ts +8 -0
- package/out/types/src/codegen/types/generation.d.ts +13 -0
- package/out/types/src/codegen/types/index.d.ts +2 -0
- package/out/types/src/codegen/utils/fixup.d.ts +2 -0
- package/out/types/src/codegen/utils/index.d.ts +77 -0
- package/out/types/src/codegen/values/index.d.ts +1 -0
- package/out/types/src/emitter.d.ts +11 -0
- package/out/types/src/env.d.ts +85 -0
- package/out/types/src/error.d.ts +45 -0
- package/out/types/src/evaluator/async/await-analysis-types.d.ts +23 -0
- package/out/types/src/evaluator/async/await-analysis.d.ts +5 -0
- package/out/types/src/evaluator/builtins/alignof.d.ts +8 -0
- package/out/types/src/evaluator/builtins/and_or.d.ts +8 -0
- package/out/types/src/evaluator/builtins/arc_fns.d.ts +58 -0
- package/out/types/src/evaluator/builtins/array_fns.d.ts +0 -0
- package/out/types/src/evaluator/builtins/as.d.ts +8 -0
- package/out/types/src/evaluator/builtins/async_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_assert.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_boolean_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_expect_error.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_list_fns.d.ts +33 -0
- package/out/types/src/evaluator/builtins/compt_print.d.ts +8 -0
- package/out/types/src/evaluator/builtins/compt_string_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/consume.d.ts +8 -0
- package/out/types/src/evaluator/builtins/drop.d.ts +8 -0
- package/out/types/src/evaluator/builtins/dup.d.ts +8 -0
- package/out/types/src/evaluator/builtins/expr_fns.d.ts +33 -0
- package/out/types/src/evaluator/builtins/future_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/gc.d.ts +8 -0
- package/out/types/src/evaluator/builtins/gensym.d.ts +8 -0
- package/out/types/src/evaluator/builtins/impl_constraint.d.ts +8 -0
- package/out/types/src/evaluator/builtins/macro_expand.d.ts +8 -0
- package/out/types/src/evaluator/builtins/numeric_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/panic.d.ts +8 -0
- package/out/types/src/evaluator/builtins/ptr_fns.d.ts +8 -0
- package/out/types/src/evaluator/builtins/quote.d.ts +13 -0
- package/out/types/src/evaluator/builtins/rc.d.ts +8 -0
- package/out/types/src/evaluator/builtins/sizeof.d.ts +8 -0
- package/out/types/src/evaluator/builtins/the.d.ts +8 -0
- package/out/types/src/evaluator/builtins/type_fns.d.ts +28 -0
- package/out/types/src/evaluator/builtins/va_start.d.ts +8 -0
- package/out/types/src/evaluator/builtins/var_fns.d.ts +18 -0
- package/out/types/src/evaluator/calls/array.d.ts +13 -0
- package/out/types/src/evaluator/calls/array_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/closure_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/compt_function.d.ts +19 -0
- package/out/types/src/evaluator/calls/compt_list_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/function.d.ts +16 -0
- package/out/types/src/evaluator/calls/function_type.d.ts +15 -0
- package/out/types/src/evaluator/calls/helper.d.ts +42 -0
- package/out/types/src/evaluator/calls/iso.d.ts +15 -0
- package/out/types/src/evaluator/calls/module_type.d.ts +11 -0
- package/out/types/src/evaluator/calls/numeric_type.d.ts +15 -0
- package/out/types/src/evaluator/calls/pointer.d.ts +8 -0
- package/out/types/src/evaluator/calls/pointer_type.d.ts +14 -0
- package/out/types/src/evaluator/calls/type.d.ts +12 -0
- package/out/types/src/evaluator/context.d.ts +169 -0
- package/out/types/src/evaluator/exprs/_expr.d.ts +8 -0
- package/out/types/src/evaluator/exprs/assignment.d.ts +9 -0
- package/out/types/src/evaluator/exprs/begin.d.ts +10 -0
- package/out/types/src/evaluator/exprs/binding.d.ts +12 -0
- package/out/types/src/evaluator/exprs/c_include.d.ts +8 -0
- package/out/types/src/evaluator/exprs/cond.d.ts +8 -0
- package/out/types/src/evaluator/exprs/destructuring_assignment.d.ts +33 -0
- package/out/types/src/evaluator/exprs/exists.d.ts +0 -0
- package/out/types/src/evaluator/exprs/expr.d.ts +9 -0
- package/out/types/src/evaluator/exprs/extern.d.ts +8 -0
- package/out/types/src/evaluator/exprs/identifer_and_operator.d.ts +9 -0
- package/out/types/src/evaluator/exprs/import.d.ts +9 -0
- package/out/types/src/evaluator/exprs/initialization_assignment.d.ts +8 -0
- package/out/types/src/evaluator/exprs/match.d.ts +8 -0
- package/out/types/src/evaluator/exprs/open.d.ts +8 -0
- package/out/types/src/evaluator/exprs/property_access.d.ts +8 -0
- package/out/types/src/evaluator/exprs/recur.d.ts +8 -0
- package/out/types/src/evaluator/exprs/subtype_of.d.ts +21 -0
- package/out/types/src/evaluator/exprs/test.d.ts +8 -0
- package/out/types/src/evaluator/exprs/typeof.d.ts +8 -0
- package/out/types/src/evaluator/exprs/while.d.ts +8 -0
- package/out/types/src/evaluator/index.d.ts +26 -0
- package/out/types/src/evaluator/types/array.d.ts +8 -0
- package/out/types/src/evaluator/types/closure.d.ts +8 -0
- package/out/types/src/evaluator/types/compt_list.d.ts +8 -0
- package/out/types/src/evaluator/types/concrete_module.d.ts +8 -0
- package/out/types/src/evaluator/types/dyn.d.ts +8 -0
- package/out/types/src/evaluator/types/enum.d.ts +8 -0
- package/out/types/src/evaluator/types/expr_synthesizer.d.ts +14 -0
- package/out/types/src/evaluator/types/field.d.ts +14 -0
- package/out/types/src/evaluator/types/fn_module.d.ts +8 -0
- package/out/types/src/evaluator/types/function.d.ts +58 -0
- package/out/types/src/evaluator/types/future_module.d.ts +8 -0
- package/out/types/src/evaluator/types/module.d.ts +19 -0
- package/out/types/src/evaluator/types/newtype.d.ts +8 -0
- package/out/types/src/evaluator/types/object.d.ts +8 -0
- package/out/types/src/evaluator/types/proofs.d.ts +0 -0
- package/out/types/src/evaluator/types/slice.d.ts +8 -0
- package/out/types/src/evaluator/types/struct.d.ts +8 -0
- package/out/types/src/evaluator/types/synthesizer.d.ts +16 -0
- package/out/types/src/evaluator/types/tuple.d.ts +18 -0
- package/out/types/src/evaluator/types/union.d.ts +8 -0
- package/out/types/src/evaluator/types/utils.d.ts +71 -0
- package/out/types/src/evaluator/types/validation.d.ts +3 -0
- package/out/types/src/evaluator/utils/array-utils.d.ts +15 -0
- package/out/types/src/evaluator/utils/closure.d.ts +35 -0
- package/out/types/src/evaluator/utils.d.ts +4 -0
- package/out/types/src/evaluator/values/anonymous_function.d.ts +8 -0
- package/out/types/src/evaluator/values/anonymous_module.d.ts +17 -0
- package/out/types/src/evaluator/values/anonymous_struct.d.ts +8 -0
- package/out/types/src/evaluator/values/array.d.ts +8 -0
- package/out/types/src/evaluator/values/boolean.d.ts +3 -0
- package/out/types/src/evaluator/values/char.d.ts +3 -0
- package/out/types/src/evaluator/values/compt_list.d.ts +8 -0
- package/out/types/src/evaluator/values/dyn.d.ts +8 -0
- package/out/types/src/evaluator/values/float.d.ts +4 -0
- package/out/types/src/evaluator/values/integer.d.ts +4 -0
- package/out/types/src/evaluator/values/module.d.ts +58 -0
- package/out/types/src/evaluator/values/string.d.ts +3 -0
- package/out/types/src/evaluator/values/tuple.d.ts +32 -0
- package/out/types/src/expr.d.ts +456 -0
- package/out/types/src/function-value.d.ts +42 -0
- package/out/types/src/index.d.ts +4 -0
- package/out/types/src/lexer.d.ts +2 -0
- package/out/types/src/logger.d.ts +1 -0
- package/out/types/src/module-manager.d.ts +30 -0
- package/out/types/src/naming-checker.d.ts +4 -0
- package/out/types/src/parser.d.ts +33 -0
- package/out/types/src/test-runner.d.ts +30 -0
- package/out/types/src/tests/codegen.test.d.ts +1 -0
- package/out/types/src/tests/fixme.test.d.ts +1 -0
- package/out/types/src/tests/module-manager.test.d.ts +1 -0
- package/out/types/src/tests/parser.test.d.ts +1 -0
- package/out/types/src/tests/sample.test.d.ts +0 -0
- package/out/types/src/tests/std.test.d.ts +1 -0
- package/out/types/src/token.d.ts +40 -0
- package/out/types/src/type-value.d.ts +7 -0
- package/out/types/src/types/compatibility.d.ts +16 -0
- package/out/types/src/types/creators.d.ts +73 -0
- package/out/types/src/types/definitions.d.ts +218 -0
- package/out/types/src/types/guards.d.ts +70 -0
- package/out/types/src/types/hierarchy.d.ts +4 -0
- package/out/types/src/types/index.d.ts +7 -0
- package/out/types/src/types/module_field.d.ts +2 -0
- package/out/types/src/types/tags.d.ts +45 -0
- package/out/types/src/types/utils.d.ts +50 -0
- package/out/types/src/unit-value.d.ts +7 -0
- package/out/types/src/utils.d.ts +6 -0
- package/out/types/src/value-tag.d.ts +29 -0
- package/out/types/src/value.d.ts +110 -0
- package/out/types/src/yo-cli.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +57 -0
- package/scripts/check-liburing.js +76 -0
- package/std/alg/hash.yo +50 -0
- package/std/allocator.yo +113 -0
- package/std/allocators/c_allocator.yo +118 -0
- package/std/async.yo +13 -0
- package/std/collections/array_list.yo +415 -0
- package/std/collections/hash_map.yo +482 -0
- package/std/collections/hash_set.yo +706 -0
- package/std/collections/index.yo +11 -0
- package/std/collections/linked_list.yo +439 -0
- package/std/error.yo +0 -0
- package/std/gc.yo +10 -0
- package/std/index.yo +12 -0
- package/std/io/file.yo +191 -0
- package/std/io/index.yo +5 -0
- package/std/libc/assert.yo +39 -0
- package/std/libc/ctype.yo +57 -0
- package/std/libc/errno.yo +182 -0
- package/std/libc/float.yo +87 -0
- package/std/libc/index.yo +29 -0
- package/std/libc/limits.yo +65 -0
- package/std/libc/math.yo +679 -0
- package/std/libc/signal.yo +101 -0
- package/std/libc/stdatomic.yo +213 -0
- package/std/libc/stdint.yo +214 -0
- package/std/libc/stdio.yo +225 -0
- package/std/libc/stdlib.yo +204 -0
- package/std/libc/string.yo +151 -0
- package/std/libc/time.yo +92 -0
- package/std/libc/unistd.yo +130 -0
- package/std/monad.yo +152 -0
- package/std/prelude.yo +3094 -0
- package/std/string/index.yo +8 -0
- package/std/string/rune.yo +82 -0
- package/std/string/string.yo +288 -0
- package/std/sync.yo +95 -0
- package/std/thread.yo +36 -0
- package/std/time.yo +13 -0
- package/std/worker.yo +36 -0
- package/vendor/mimalloc/.gitattributes +12 -0
- package/vendor/mimalloc/CMakeLists.txt +763 -0
- package/vendor/mimalloc/LICENSE +21 -0
- package/vendor/mimalloc/SECURITY.md +41 -0
- package/vendor/mimalloc/azure-pipelines.yml +251 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64.lib +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect-arm64ec.lib +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect.lib +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect32.dll +0 -0
- package/vendor/mimalloc/bin/mimalloc-redirect32.lib +0 -0
- package/vendor/mimalloc/bin/minject-arm64.exe +0 -0
- package/vendor/mimalloc/bin/minject.exe +0 -0
- package/vendor/mimalloc/bin/minject32.exe +0 -0
- package/vendor/mimalloc/bin/readme.md +118 -0
- package/vendor/mimalloc/cmake/JoinPaths.cmake +23 -0
- package/vendor/mimalloc/cmake/mimalloc-config-version.cmake +19 -0
- package/vendor/mimalloc/cmake/mimalloc-config.cmake +14 -0
- package/vendor/mimalloc/contrib/docker/alpine/Dockerfile +23 -0
- package/vendor/mimalloc/contrib/docker/alpine-arm32v7/Dockerfile +28 -0
- package/vendor/mimalloc/contrib/docker/alpine-x86/Dockerfile +28 -0
- package/vendor/mimalloc/contrib/docker/manylinux-x64/Dockerfile +23 -0
- package/vendor/mimalloc/contrib/docker/readme.md +10 -0
- package/vendor/mimalloc/contrib/vcpkg/portfile.cmake +64 -0
- package/vendor/mimalloc/contrib/vcpkg/readme.md +40 -0
- package/vendor/mimalloc/contrib/vcpkg/usage +20 -0
- package/vendor/mimalloc/contrib/vcpkg/vcpkg-cmake-wrapper.cmake +20 -0
- package/vendor/mimalloc/contrib/vcpkg/vcpkg.json +48 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-a.svg +887 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-b.svg +1185 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-a.svg +757 -0
- package/vendor/mimalloc/doc/bench-2020/bench-c5-18xlarge-2020-01-20-rss-b.svg +1028 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-1.svg +769 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-a.svg +868 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-12xlarge-2020-01-16-b.svg +1157 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-2.svg +983 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-1.svg +683 -0
- package/vendor/mimalloc/doc/bench-2020/bench-r5a-rss-2.svg +854 -0
- package/vendor/mimalloc/doc/bench-2020/bench-spec-rss.svg +713 -0
- package/vendor/mimalloc/doc/bench-2020/bench-spec.svg +713 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-1.svg +890 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-2.svg +1146 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-1.svg +796 -0
- package/vendor/mimalloc/doc/bench-2020/bench-z4-rss-2.svg +974 -0
- package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-a.svg +952 -0
- package/vendor/mimalloc/doc/bench-2021/bench-amd5950x-2021-01-30-b.svg +1255 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-a.svg +955 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-b.svg +1269 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-a.svg +836 -0
- package/vendor/mimalloc/doc/bench-2021/bench-c5-18xlarge-2021-01-30-rss-b.svg +1131 -0
- package/vendor/mimalloc/doc/bench-2021/bench-macmini-2021-01-30.svg +766 -0
- package/vendor/mimalloc/doc/doxyfile +2895 -0
- package/vendor/mimalloc/doc/ds-logo.jpg +0 -0
- package/vendor/mimalloc/doc/ds-logo.png +0 -0
- package/vendor/mimalloc/doc/mimalloc-doc.h +1452 -0
- package/vendor/mimalloc/doc/mimalloc-doxygen.css +60 -0
- package/vendor/mimalloc/doc/mimalloc-logo-100.png +0 -0
- package/vendor/mimalloc/doc/mimalloc-logo.png +0 -0
- package/vendor/mimalloc/doc/mimalloc-logo.svg +161 -0
- package/vendor/mimalloc/doc/spades-logo.png +0 -0
- package/vendor/mimalloc/doc/unreal-logo.svg +43 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj +500 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj.filters +108 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj +508 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-dll.vcxproj.filters +111 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-test-dep.vcxproj +355 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-override-test.vcxproj +360 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-test-api.vcxproj +295 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-test-stress.vcxproj +292 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc-test.vcxproj +289 -0
- package/vendor/mimalloc/ide/vs2022/mimalloc.sln +151 -0
- package/vendor/mimalloc/include/mimalloc/atomic.h +557 -0
- package/vendor/mimalloc/include/mimalloc/internal.h +1153 -0
- package/vendor/mimalloc/include/mimalloc/prim.h +421 -0
- package/vendor/mimalloc/include/mimalloc/track.h +145 -0
- package/vendor/mimalloc/include/mimalloc/types.h +685 -0
- package/vendor/mimalloc/include/mimalloc-new-delete.h +66 -0
- package/vendor/mimalloc/include/mimalloc-override.h +68 -0
- package/vendor/mimalloc/include/mimalloc-stats.h +103 -0
- package/vendor/mimalloc/include/mimalloc.h +612 -0
- package/vendor/mimalloc/mimalloc.pc.in +11 -0
- package/vendor/mimalloc/readme.md +946 -0
- package/vendor/mimalloc/src/alloc-aligned.c +360 -0
- package/vendor/mimalloc/src/alloc-override.c +316 -0
- package/vendor/mimalloc/src/alloc-posix.c +185 -0
- package/vendor/mimalloc/src/alloc.c +692 -0
- package/vendor/mimalloc/src/arena-abandon.c +346 -0
- package/vendor/mimalloc/src/arena.c +1043 -0
- package/vendor/mimalloc/src/bitmap.c +441 -0
- package/vendor/mimalloc/src/bitmap.h +119 -0
- package/vendor/mimalloc/src/free.c +572 -0
- package/vendor/mimalloc/src/heap.c +733 -0
- package/vendor/mimalloc/src/init.c +714 -0
- package/vendor/mimalloc/src/libc.c +334 -0
- package/vendor/mimalloc/src/options.c +663 -0
- package/vendor/mimalloc/src/os.c +770 -0
- package/vendor/mimalloc/src/page-queue.c +390 -0
- package/vendor/mimalloc/src/page.c +1049 -0
- package/vendor/mimalloc/src/prim/emscripten/prim.c +249 -0
- package/vendor/mimalloc/src/prim/osx/alloc-override-zone.c +461 -0
- package/vendor/mimalloc/src/prim/osx/prim.c +9 -0
- package/vendor/mimalloc/src/prim/prim.c +76 -0
- package/vendor/mimalloc/src/prim/readme.md +9 -0
- package/vendor/mimalloc/src/prim/unix/prim.c +934 -0
- package/vendor/mimalloc/src/prim/wasi/prim.c +284 -0
- package/vendor/mimalloc/src/prim/windows/etw-mimalloc.wprp +61 -0
- package/vendor/mimalloc/src/prim/windows/etw.h +905 -0
- package/vendor/mimalloc/src/prim/windows/etw.man +0 -0
- package/vendor/mimalloc/src/prim/windows/prim.c +878 -0
- package/vendor/mimalloc/src/prim/windows/readme.md +17 -0
- package/vendor/mimalloc/src/random.c +258 -0
- package/vendor/mimalloc/src/segment-map.c +142 -0
- package/vendor/mimalloc/src/segment.c +1702 -0
- package/vendor/mimalloc/src/static.c +41 -0
- package/vendor/mimalloc/src/stats.c +635 -0
- package/vendor/mimalloc/test/CMakeLists.txt +56 -0
- package/vendor/mimalloc/test/main-override-dep.cpp +51 -0
- package/vendor/mimalloc/test/main-override-dep.h +11 -0
- package/vendor/mimalloc/test/main-override-static.c +539 -0
- package/vendor/mimalloc/test/main-override.c +36 -0
- package/vendor/mimalloc/test/main-override.cpp +497 -0
- package/vendor/mimalloc/test/main.c +46 -0
- package/vendor/mimalloc/test/readme.md +16 -0
- package/vendor/mimalloc/test/test-api-fill.c +343 -0
- package/vendor/mimalloc/test/test-api.c +466 -0
- package/vendor/mimalloc/test/test-stress.c +428 -0
- package/vendor/mimalloc/test/test-wrong.c +92 -0
- package/vendor/mimalloc/test/testhelper.h +49 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import{readFileSync as da}from"node:fs";import Ta from"path";var v=class{constructor({characterIndex:n,message:t}){this.characterIndex=n,this.message=t}},q=class{constructor(n,t){this.tokenAndErrorList=[];this.tokenAndErrorList=n,this.isAssertionError=t||!1}toString(){return this.tokenAndErrorList.map(({token:t,errorMessage:o})=>`Error: ${o}
|
|
2
|
+
${be({token:t})}`).join(`
|
|
3
|
+
|
|
4
|
+
`)}};function be({token:e}){let{position:n,modulePath:t,inputString:o}=e,{row:i,column:r}=n,l=o.split(`
|
|
5
|
+
`)[i];return`${t}:${i+1}:${r+1}:
|
|
6
|
+
${l}
|
|
7
|
+
${" ".repeat(r+Math.floor(e.value.length/2))}^`}function y({token:e,errorMessage:n,cause:t,isAssertionError:o}){let i=`${n.trim()}
|
|
8
|
+
|
|
9
|
+
${be({token:e})}`;return new q([{token:e,errorMessage:i+(t?.message?`
|
|
10
|
+
`+t.message:"")}],o)}var z=(m=>(m.Operator="operator",m.Dot=".",m.LParen="(",m.RParen=")",m.LBracket="[",m.RBracket="]",m.LCurlyBracket="{",m.RCurlyBracket="}",m.Char="char",m.String="string",m.Identifier="identifier",m.Integer="integer",m.Float="float",m.Bool="bool",m.Semicolon=";",m.Comma=",",m.SingleLineComment="single_line_comment",m.MultiLineComment="multi_line_comment",m.Whitespace="whitespace",m.BacktickIdentifier="backtick_identifier",m))(z||{}),G={modulePath:"_",inputString:"_",type:"identifier",value:"_",position:{row:0,column:0,character:0}},ht={modulePath:"drop",inputString:"drop",type:"identifier",value:"drop",position:{row:0,column:0,character:0}},oe=["=","+","-","*","/","<",">","@","$","~","&","%","|","!","?","^",".",":","\\","#"];function P(e){return oe.includes(e)}function Ce(e){let n=!0;for(let t=0;t<e.length;t++){let o=e[t];if(!P(o)){n=!1;break}}return n}var j=/^[_a-zA-Z\xA0-\uFFFF][_a-zA-Z0-9\xA0-\uFFFF]*[!?]?$/;function Ve(e,n){let t=")";if(!e[n])return-1;let o=e[n].type;if(o==="{")t="}";else if(o==="(")t=")";else if(o==="[")t="]";else throw this.formatErrorMessage(e[n],"Expected '{', '(' or '['");n=n+1;let i=1,r=-1;for(;;){let p=e[n];if(!p)return-1;if(p.type===t){if(i=i-1,i===0){r=n;break}}else p.type===o&&(i=i+1);n=n+1}return r}function Fe(e,n){let t=[],o=0,i=0;for(let r=0;r<e.length;r++){let p=e[r],l=r-i,f=r,c="",u=r;if(e[u]===".")for(;e[u]===".";)c+=e[u],u=u+1;else for(;P(e[u])&&e[u]!==".";)c+=e[u],u=u+1;if(c&&!c.startsWith("//")&&!c.startsWith("/*")){t.push({type:c==="."?".":"operator",value:c,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=u-1;continue}switch(p){case" ":case" ":case`
|
|
11
|
+
`:case"\r":{let s="",a=r,d=o;for(;e[a]===" "||e[a]===" "||e[a]===`
|
|
12
|
+
`||e[a]==="\r";)s+=e[a],e[a]===`
|
|
13
|
+
`&&(o++,i=a+1),a=a+1;t.push({type:"whitespace",value:s,position:{row:d,column:l,character:f},modulePath:n,inputString:e}),r=a-1;break}case"/":if(e[r+1]==="/"){let s="",a=r;for(;e[a]!==`
|
|
14
|
+
`&&a<e.length;)s+=e[a],a=a+1;t.push({type:"single_line_comment",value:s,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=a-1}else if(e[r+1]==="*"){let s=r,a="",d=o,V=1;for(a+=e[s],s++,a+=e[s],s++;V>0&&s<e.length;){if(e[s]===`
|
|
15
|
+
`&&(i=s+1,o++),e[s]==="/"&&e[s+1]==="*"){V++,a+="/*",s+=2;continue}if(e[s]==="*"&&e[s+1]==="/"){V--,a+="*/",s+=2;continue}a+=e[s],s++}if(V>0)throw new v({message:"Unterminated multi-line comment",characterIndex:e.length-1});t.push({type:"multi_line_comment",value:a,position:{row:d,column:l,character:f},modulePath:n,inputString:e}),r=s-1}else throw new v({message:`Unexpected character ${p}`,characterIndex:r+1});break;case"(":t.push({type:"(",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case")":t.push({type:")",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"[":t.push({type:"[",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"]":t.push({type:"]",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"{":t.push({type:"{",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"}":t.push({type:"}",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"'":{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==="'"){r=a;break}s+=e[a]}if(s.length===1||s.length===2&&s[0]==="\\")t.push({type:"char",value:`'${s}'`,position:{row:o,column:l,character:f},modulePath:n,inputString:e});else throw new v({message:`Invalid char '${s}', expected char to have length 1.`,characterIndex:r});break}case'"':{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==='"'){r=a;break}s+=e[a]}t.push({type:"string",value:`"${s}"`,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break}case"`":{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==="`"){r=a;break}s+=e[a]}if(!j.test(s))throw new v({message:`Invalid backtick identifier \`${s}\``,characterIndex:r});t.push({type:"backtick_identifier",value:`\`${s}\``,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break}case",":t.push({type:",",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case";":t.push({type:";",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;default:if(/[0-9]/.test(p)){let s=r,a=p;r=r+1;let d=/[0-9_]/;for(e[r-1]==="0"&&typeof e[r]=="string"&&(e[r]==="x"||e[r]==="X"?(a+=e[r],r=r+1,d=/[0-9A-Fa-f]/):e[r]==="b"||e[r]==="B"?(a+=e[r],r=r+1,d=/[01]/):(e[r]==="o"||e[r]==="O")&&(a+=e[r],r=r+1,d=/[0-7]/));typeof e[r]=="string"&&d.test(e[r]);)a+=e[r],r=r+1;if(e[r]==="."&&e[s-1]!=="."&&(e[r+1]??"").match(/[0-9]/)){for(a+=e[r],r=r+1;typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"float",value:a,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=r-1}else{if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"integer",value:a,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=r-1}}else if(/[_a-zA-Z\xA0-\uFFFF]/.test(p)){let s=p,a=r;for(r=r+1;typeof e[r]=="string"&&/[_a-zA-Z0-9\xA0-\uFFFF]/.test(e[r]);)s+=e[r],r=r+1;if(r=r-1,(e[r+1]==="!"||e[r+1]==="?")&&j.test(s+e[r+1])&&(r=r+1,s+=e[r]),j.test(s))switch(s){case"true":case"false":t.push({type:"bool",value:s,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;default:t.push({type:"identifier",value:s,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break}else throw new v({message:`Invalid identifier ${s}`,characterIndex:a})}else throw new v({message:`Unexpected character ${p}`,characterIndex:r});break}}return t}var L=class{constructor({modulePath:n,inputString:t}){this.modulePath=n,this.inputString=t,this.tokens=Fe(t,n),this.program=[],this.parse(this.tokens)}skipWhitespace(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t+1;return t}skipWhitespaceBackward(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t-1;return t}isParenthesizedExpression(n,t,o){return t=this.skipWhitespace(n,t),o=this.skipWhitespaceBackward(n,o),!!n[t]&&n[t].type==="("&&!!n[o]&&n[o].type===")"&&Ve(n,t)===o}parseParenExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="(")throw y({token:n[t],errorMessage:"Expected left paren"});if(n[t+1]?.type===")")return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.tuple,position:n[t].position,modulePath:this.modulePath,inputString:this.inputString}},args:[],token:n[t]},index:t+2};let i=this.parseExpression({tokens:n,index:t+1}),r=i.expr;if(t=i.index,n[t].type===")")return{expr:r,index:t+1};{let p,l=[r];for(;;){if(!n[t])throw y({token:n[t-1],errorMessage:"Expected ) or , for tuple"});if(n[t].type===","){if(!p||p===",")p=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in (...)'});t=t+1}else if(n[t].type===";"){if(!p||p===";")p=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in (...)'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type===")")break;let{expr:c,index:u}=this.parseExpression({tokens:n,index:t});l.push(c),t=u}let f=p===";"||!p;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:f?_.Tuple[0]:_.tuple,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:l,token:n[o]},index:t+1}}}parseArrayExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="[")throw y({token:n[t],errorMessage:"Expected left bracket"});t=t+1;let i,r=[];for(;;){if(!n[t])throw y({token:n[t-1],errorMessage:"Expected ] or , for array"});if(n[t].type===","){if(!i||i===",")i=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in [...]'});t=t+1}else if(n[t].type===";"){if(!i||i===";")i=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in [...]'});t=t+1}if(n[t].type==="]")break;let{expr:c,index:u}=this.parseExpression({tokens:n,index:t});r.push(c),t=u}let p=i===";"||!i;if(p&&r.length>2)throw y({token:n[o],errorMessage:`Expected at 2 arguments for Array type, or 1 argument for Slice type, got ${r.length}`});let l=p&&r.length===2,f=p&&r.length===1;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:l?_.Array[0]:f?_.Slice[0]:_.array,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:r,token:n[o]},index:t+1}}parseCurlyBracketExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="{")throw y({token:n[t],errorMessage:"Expected left curly bracket"});let i=[],r;for(t=t+1;;){if(t=this.skipWhitespace(n,t),!n[t])throw y({token:n[t-1],errorMessage:'Unexpected end of curly bracket. Expected "}" or "," or ";"'});if(n[t].type===","){if(!r||r===",")r=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in {...}'});t=t+1}else if(n[t].type===";"){if(!r||r===";")r=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in {...}'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type==="}"){let f=n[this.skipWhitespaceBackward(n,t-1)];if(r===";"&&f&&(f.type===";"||f.type==="{")){let c={type:"identifier",value:_.tuple,position:f.position,modulePath:this.modulePath,inputString:this.inputString};i.push({tag:"FuncCall",func:{tag:"Atom",token:c},args:[],token:c})}break}let{expr:p,index:l}=this.parseExpression({tokens:n,index:t});i.push(p),t=l}if(r===","||!r){for(let l=0;l<i.length;l++){let f=i[l];if(F(f)){let c={type:"operator",value:":",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString},u={tag:"FuncCall",func:{tag:"Atom",token:c},isInfix:!0,args:[f,f],token:c};i[l]=u}}return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:"_",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}else return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.begin[0],position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}parsePrimary({tokens:n,index:t}){t=this.skipWhitespace(n,t);let o=n[t];if(!o)throw y({token:G,errorMessage:"Unexpected end of input"});let i=null;switch(o.type){case"identifier":case"operator":case"bool":case"integer":case"float":case"string":case"char":{i={expr:{tag:"Atom",token:o},index:t+1};break}case"(":{i=this.parseParenExpr({tokens:n,index:t});break}case"[":{i=this.parseArrayExpr({tokens:n,index:t});break}case"{":{i=this.parseCurlyBracketExpr({tokens:n,index:t});break}case".":{i={expr:{tag:"Atom",token:o},index:t+1};break}default:throw y({token:o,errorMessage:`Unexpected token "${o.type}"`})}return i}isOperatorAtLineStart(n,t){for(let o=n.length-1;o>=0;o--){let i=n[o];if(i.type==="whitespace"&&i.value.includes(`
|
|
16
|
+
`))return n.slice(o+1).every(l=>l.type==="whitespace");if(i.type!=="whitespace")return!1}return n.every(o=>o.type==="whitespace")}parseLeftAssociativeOperator({primaryExpr:n,operatorToken:t,rhs:o,tokens:i,index:r}){if(o.tag==="FuncCall"&&o.isInfix&&o.func.tag==="Atom"&&o.func.token.type!=="."){let p=o.args[0],l=o.args[1],f=o.func,c={tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,p],isInfix:!0,token:t};return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:f,args:[c,l],isInfix:!0,token:f.token},tokens:i,index:r})}else return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,o],isInfix:!0,token:t},tokens:i,index:r})}getExprMinimumColumnNumber(n){return F(n)?n.token.position.column:Math.min(this.getExprMinimumColumnNumber(n.func),...n.args.map(t=>this.getExprMinimumColumnNumber(t)))}parsePrimaryEnd({primaryExpr:n,tokens:t,index:o}){let i=this.skipWhitespace(t,o),r=i!==o,p=t[o-1]?.type==="whitespace";o=i;let l=t[i];if(!l||l.type===";"||l.type===","||l.type===")"||l.type==="]"||l.type==="}")return{expr:n,index:o};let f=n.tag==="Atom"&&n.token.type===".";if(f||l.type==="."&&!r&&!p&&t[i+1]?.type!=="whitespace"){let{expr:c,index:u}=this.parsePrimary({tokens:t,index:f?o:o+1});o=u;let s={expr:{tag:"FuncCall",func:{tag:"Atom",token:f?n.token:l},args:f?[c]:[n,c],isInfix:!f,token:f?n.token:l},index:o};for(;t[o]&&t[o].type===".";){let{expr:a,index:d}=this.parsePrimary({tokens:t,index:o+1});s={expr:{tag:"FuncCall",func:{tag:"Atom",token:l},args:[s.expr,a],isInfix:!0,token:l},index:d},o=d}return this.parsePrimaryEnd({primaryExpr:s.expr,tokens:t,index:s.index})}else if((l.type==="operator"||l.type==="."&&!r||l.type==="backtick_identifier")&&t[o+1]?.type!=="("){let c=this.skipWhitespace(t,o+1),{expr:u,index:s}=this.parseExpression({tokens:t,index:c});if(u.tag==="FuncCall"&&u.isInfix&&u.func.tag==="Atom"&&u.func.token.type!=="."&&!this.isParenthesizedExpression(t,c,s-1)){let a=`Ambiguous operator precedence.
|
|
17
|
+
Please use parentheses to clarify:
|
|
18
|
+
|
|
19
|
+
${g(n)} ${l.value} (${g(u)})
|
|
20
|
+
// or
|
|
21
|
+
(${g(n)} ${l.value} ${g(u.args[0])}) ${g(u.func)} ${g(u.args[1])}
|
|
22
|
+
|
|
23
|
+
Or use newline after "${l.value}" to confirm the right-associativity.
|
|
24
|
+
`,V=t.slice(o+1,c).some(Ee=>Ee.type==="whitespace"&&Ee.value.includes(`
|
|
25
|
+
`)),re=t.slice(0,o),x=this.isOperatorAtLineStart(re,o),U=t.slice(o+1,c),De=x&&U.length>0&&U[0]?.type==="whitespace"&&U[0]?.value.includes(`
|
|
26
|
+
`);if(!(V&&!x)){if(!De){if(x)return this.parseLeftAssociativeOperator({primaryExpr:n,operatorToken:l,rhs:u,tokens:t,index:s});throw y({token:l,errorMessage:a})}}}return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:l},args:[n,u],isInfix:!0,token:l},tokens:t,index:s})}else if(!r&&l.type==="("){let c=this.parseFunctionCall({func:n,tokens:t,index:o+1,hasWhitespace:!1});return this.parsePrimaryEnd({primaryExpr:c.expr,tokens:t,index:c.index})}else{let c=this.parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:!0});return this.parsePrimaryEnd({primaryExpr:c.expr,tokens:t,index:c.index})}}parseFunctionArguments({tokens:n,index:t,hasWhitespace:o}){let i=[];if(t=this.skipWhitespace(n,t),!o&&n[t]?.type===")")return{args:i,index:t+1};for(;;){let{expr:r,index:p}=this.parseExpression({tokens:n,index:t});i.push(r),t=p;let l=n[t];if(l?.type===",")t=t+1;else{if(!l||l.type===";"||l.type==="]"||l.type==="}")return{args:i,index:t};if(l.type===")")return{args:i,index:o?t:t+1};throw y({token:l,errorMessage:o?"Expected ; to end the function call":`Expected , to separate arguments
|
|
27
|
+
or ) to end the function call`})}}}parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:i}){let{args:r,index:p}=this.parseFunctionArguments({tokens:t,index:o,hasWhitespace:i});return o=p,{expr:{tag:"FuncCall",func:n,args:r,token:n.token},index:o}}parseExpression({tokens:n,index:t}){t=this.skipWhitespace(n,t);let{expr:o,index:i}=this.parsePrimary({tokens:n,index:t});return this.parsePrimaryEnd({primaryExpr:o,tokens:n,index:i})}programToString(){return this.program.map(t=>g(t)).join(`;
|
|
28
|
+
`)}parse(n){let t=0,o=[];for(;t<n.length;){switch(n[t].type){case"whitespace":case";":case"single_line_comment":case"multi_line_comment":{t=t+1;continue}}if(t>=n.length)break;try{let{expr:p,index:l}=this.parseExpression({tokens:n,index:t});o.push(p),t=l}catch(p){this.parserError=p;break}}let i=n[this.skipWhitespaceBackward(n,n.length-1)];if(i&&i.type===";"){let r={type:"identifier",value:_.tuple,position:i.position,modulePath:this.modulePath,inputString:this.inputString};o.push({tag:"FuncCall",func:{tag:"Atom",token:r},args:[],token:r})}this.program=o}getProgram(){return this.program}getParserError(){return this.parserError}getTokens(){return this.tokens}};function ie(e){let n=new L({modulePath:`auto-generated://
|
|
29
|
+
// === START auto-generated code ===
|
|
30
|
+
${e}
|
|
31
|
+
// === END auto-generated code ===
|
|
32
|
+
`,inputString:e});if(n.getParserError())throw n.getParserError();let t=n.getProgram();if(t.length!==1)throw new Error(`Expected exactly one expression from parsed code, got ${t.length}: "${e}"
|
|
33
|
+
${t.map(o=>g(o)).join(`
|
|
34
|
+
`)}
|
|
35
|
+
`);return t[0]}import{createHash as Ye}from"crypto";var Qe=0;function Ae(){return`id${Qe++}`}function Je(e){return"yo"+Ye("sha1").update(e).digest("hex").slice(0,8)}var Ie=new Map;function ce(e,n){let t="";for(let r=0;r<n.length;r++)if(P(n[r])){let p=oe.indexOf(n[r]);t+=`${p}`}else t+=n[r];let o=Je(e)+"_"+t,i=Ie.get(o);return i===void 0?i=0:i++,Ie.set(o,i),o+(i==0?"":`_${i}`)}var fe=null;function Ue(){if(fe)return fe;let e=Pe(),n=ze(e),t={id:"unit",tag:"unit",module:n};return n.receiverType=t,fe=t,t}function ze(e){return{id:`module_${Ae()}`,tag:"Module",fields:[],env:e,module:void 0}}function k(e){return e?.tag==="FuncCall"}function F(e){return e?.tag==="Atom"}function w(e){return e.tag==="Atom"&&e.token.type==="operator"}function A(e,n,t){if(e.tag!=="FuncCall"||e.func.tag!=="Atom")return!1;let o=e.func.token.value;return e.func.token.type==="backtick_identifier"&&(o=o.slice(1,-1)),e.tag==="FuncCall"&&e.func.tag==="Atom"&&(typeof n=="string"?o===n:n.includes(o))&&(t===void 0||e.args.length===t)}var _={compt:["compt"],ref:["ref"],forall:["forall","\u2200"],where:["where"],quote:["quote",":"],unquote:["unquote","#"],unquote_splicing:["unquote_splicing","...#"],return:["return"],recur:["recur"],fn:["fn"],unsafe_fn:["unsafe_fn"],extern:["extern"],cond:["cond"],type:["type"],match:["match"],test:["test"],struct:["struct"],object:["object"],newtype:["newtype"],enum:["enum"],union:["union"],module:["module"],impl:["impl"],Impl:["Impl"],begin:["begin"],module_begin:["module_begin"],import:["import"],export:["export"],open:["open"],clone:["clone","%"],break:["break"],continue:["continue"],while:["while"],if:["if"],op_and:["&&"],op_or:["||"],not:["not"],gensym:["gensym"],dyn:["dyn"],Dyn:["Dyn"],Fn:["Fn"],c_include:["c_include"],undefined:["undefined"],null:["null"],true:["true"],false:["false"],unique:["unique","^"],Ptr:["*"],Iso:["Iso"],Tuple:["Tuple"],Array:["Array"],Slice:["Slice"],Future:["Future"],Concrete:["Concrete"],Type:["Type"],Module:["Module"],ComptList:["ComptList"],tuple:"tuple",array:"array",compt_list:"compt_list"};function I(e){return!!(e.tag==="FuncCall"&&e.isInfix&&e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="backtick_identifier")&&e.args.length===2)}function g(e,n){let o={...{prettyPrint:!1,indentSize:2,maxLineLength:80,indentLevel:0},...n};return o.prettyPrint?T(e,o):h(e)}function h(e){let n="";switch(e.tag){case"Atom":{n=e.token.value;break}case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){e.func.token.value==="."?n=`${e.func.token.value}${h(e.args[0])}`:n=`${e.func.token.value}(${h(e.args[0])})`;break}else if(e.args.length===2&&e.isInfix){let i=h(e.args[0]),r=h(e.args[1]);i=I(e.args[0])||w(e.args[0])?`(${i})`:i,r=I(e.args[1])||w(e.args[1])?`(${r})`:r,e.func.token.value==="."?n=`(${i}.${r})`:n=`${i} ${e.func.token.value} ${r}`;break}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){e.args.length===1?n=`(${h(e.args[0])},)`:n=`(${e.args.map(i=>h(i)).join(", ").trim()})`;break}let t=h(e.func);t=I(e.func)||w(e.func)?`(${t})`:t;let o=e.args.map(i=>h(i)).join(", ").trim();n=`${t}(${o})`;break}}return n}function T(e,n){let t=" ".repeat(n.indentLevel*n.indentSize),o={...n,indentLevel:n.indentLevel+1},i=" ".repeat(o.indentLevel*n.indentSize);switch(e.tag){case"Atom":return e.token.value;case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){if(e.func.token.value===".")return`${e.func.token.value}${T(e.args[0],n)}`;{let c=T(e.args[0],n);return`${e.func.token.value}(${c})`}}else if(e.args.length===2&&e.isInfix){let c=T(e.args[0],n),u=T(e.args[1],n);return c=I(e.args[0])||w(e.args[0])?`(${c})`:c,u=I(e.args[1])||w(e.args[1])?`(${u})`:u,e.func.token.value==="."?`(${c}.${u})`:`${c} ${e.func.token.value} ${u}`}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){if(e.args.length===0)return"()";if(e.args.length===1)return`(${T(e.args[0],n)},)`;{let c=e.args.map(s=>T(s,n)),u=`(${c.join(", ")})`;return u.length<=n.maxLineLength?u:`(
|
|
36
|
+
${i}${c.join(`,
|
|
37
|
+
${i}`)}
|
|
38
|
+
${t})`}}let r=e.func.tag==="Atom"?e.func.token.value:null,p=r&&[..._.begin,..._.cond,..._.match,..._.fn,..._.if,..._.while].includes(r),l=T(e.func,n);if(l=I(e.func)||w(e.func)?`(${l})`:l,e.args.length===0)return`${l}()`;if(!p){let c=e.args.map(s=>T(s,n)),u=`${l}(${c.join(", ")})`;if(u.length<=n.maxLineLength)return u}if(p){if(r===_.begin[0]){if(e.args.length===1){let u=T(e.args[0],n);if(u.length<=n.maxLineLength&&!u.includes(`
|
|
39
|
+
`))return`${l}(${u})`}let c=e.args.map(u=>T(u,o));return`${l}(
|
|
40
|
+
${i}${c.join(`,
|
|
41
|
+
${i}`)}
|
|
42
|
+
${t})`}else if(r===_.cond[0]){let c=e.args.map(u=>{if(k(u)&&u.isInfix&&A(u,"=>")){let s=u.args[0],a=T(u.args[1],o),d=T(s,n);if(k(s)&&s.isInfix&&!A(s,"=>")&&(d=`(${d})`),a.includes(`
|
|
43
|
+
`)){let re=a.split(`
|
|
44
|
+
`).map((x,U)=>U===0?x:`${i}${x}`).join(`
|
|
45
|
+
`);return`${d} => ${re}`}else return`${d} => ${a}`}return T(u,o)});return`${l}(
|
|
46
|
+
${i}${c.join(`,
|
|
47
|
+
${i}`)}
|
|
48
|
+
${t})`}}let f=e.args.map(c=>T(c,o));return`${l}(
|
|
49
|
+
${i}${f.join(`,
|
|
50
|
+
${i}`)}
|
|
51
|
+
${t})`}}return h(e)}var lt={tag:"Unit",type:Ue()};var ve=new Map,ne=new Map,yt=new Map;function _t(e){for(let[n,t]of ne.entries()){let o=t.filter(i=>i.sourceModulePath!==e);o.length===0?ne.delete(n):ne.set(n,o)}}function mt(){ve.clear(),ne.clear(),yt.clear()}function dt(e){let n=ve.get(e);if(n){for(let t of n)t.fields=t.fields.filter(o=>o.sourceModulePath!==e);ve.delete(e)}}function Ne({modulePath:e,inputString:n}){return{functionDeclarationFrameLevel:-1,frames:[],freeVariables:[],modulePath:e,inputString:n}}function Pe(){let e=Ne({modulePath:"",inputString:""});return R(e)}function R(e,n={id:ce(e.modulePath,"frame"),variables:[],isBeginBlockFrame:!1},t){let o=t?{...n,isBeginBlockFrame:!0}:n;return{functionDeclarationFrameLevel:e.functionDeclarationFrameLevel,freeVariables:e.freeVariables,frames:[...e.frames,o],modulePath:e.modulePath,inputString:e.inputString}}var Fa=process.env.YO_SKIP_PRELUDE==="1"||process.env.YO_SKIP_PRELUDE==="true";export{j as IdentifierRegex,oe as Operators,G as PlaceholderToken,ht as RAIIToken,z as TokenType,P as charIsOperator,mt as clearAllGlobalImplState,_t as clearGenericImplsFromModule,dt as clearImplsFromModule,Ve as findMatchingBracketTokenIndex,ie as generateExprFromCode,Ce as stringIsOperator,Fe as tokenize};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AwaitPoint } from "../../evaluator/async/await-analysis";
|
|
2
|
+
import { Expr } from "../../expr";
|
|
3
|
+
import { FunctionGenerationContext } from "../functions/context";
|
|
4
|
+
export interface StateSegment {
|
|
5
|
+
stateNumber: number;
|
|
6
|
+
expressions: Expr[];
|
|
7
|
+
awaitPoint: AwaitPoint | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function splitIntoStateSegments(body: Expr, awaitPoints: AwaitPoint[]): StateSegment[];
|
|
10
|
+
export declare function generateStateSegmentCode(segment: StateSegment, indent: string, context: FunctionGenerationContext, captureLastExprResult?: boolean): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AwaitAnalysisResult, AwaitPoint } from "../../evaluator/async/await-analysis";
|
|
2
|
+
import { Expr } from "../../expr";
|
|
3
|
+
import { DynType, SomeType, StructType } from "../../types";
|
|
4
|
+
import { FunctionGenerationContext } from "../functions/context";
|
|
5
|
+
export declare function getFutureFieldName(awaitPoint: AwaitPoint, analysis: AwaitAnalysisResult): string;
|
|
6
|
+
export interface StateMachineInfo {
|
|
7
|
+
structName: string;
|
|
8
|
+
resumeFunctionName: string;
|
|
9
|
+
analysis: AwaitAnalysisResult;
|
|
10
|
+
}
|
|
11
|
+
export declare function generateResumeFunctionDeclaration(info: StateMachineInfo, context: FunctionGenerationContext): void;
|
|
12
|
+
export declare function getStateMachineFieldName(variableId: string, kind?: "outer" | "local"): string;
|
|
13
|
+
export declare function generateAsyncBlockResumeFunction(bodyExpr: Expr, asyncBlockId: string, structName: string, resumeFunctionName: string, analysis: AwaitAnalysisResult, futureType: SomeType | DynType, captureType: StructType | undefined, context: FunctionGenerationContext): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleValue } from "../value";
|
|
2
|
+
export declare class CodeGeneratorC {
|
|
3
|
+
private emitter;
|
|
4
|
+
constructor();
|
|
5
|
+
compileModule(modulePath: string, moduleValue: ModuleValue, options?: {
|
|
6
|
+
debugGc?: boolean;
|
|
7
|
+
debugParallelism?: boolean;
|
|
8
|
+
debugAsyncAwait?: boolean;
|
|
9
|
+
allocator?: "mimalloc" | "libc";
|
|
10
|
+
}): void;
|
|
11
|
+
print(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FuncCallExpr } from "../../expr";
|
|
2
|
+
import { CodeGenContext } from "../utils";
|
|
3
|
+
export declare function isArrayFillMethodCall(expr: FuncCallExpr): boolean;
|
|
4
|
+
export declare function generateArrayFillCall(expr: FuncCallExpr, indent: string, context: CodeGenContext): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Expr } from "../../expr";
|
|
2
|
+
import { Type } from "../../types";
|
|
3
|
+
import { FunctionGenerationContext } from "../functions/context";
|
|
4
|
+
import { CodeGenContext } from "../utils";
|
|
5
|
+
export declare function generateExpr(expr: Expr, indent: string, context: CodeGenContext): string;
|
|
6
|
+
export declare function getDupFunctionForType(type: Type, context: CodeGenContext): string | undefined;
|
|
7
|
+
export declare function generateReturnStatement(expr: Expr, indent: string, context: CodeGenContext): void;
|
|
8
|
+
export declare function generateDeferredDropExpressions(expr: Expr, indent: string, context: FunctionGenerationContext): void;
|
|
9
|
+
export declare function generateDeferredDupExpressions(expr: Expr, indent: string, context: FunctionGenerationContext): void;
|
|
10
|
+
export declare function preRegisterAsyncBlockTypes(context: FunctionGenerationContext): void;
|
|
11
|
+
export declare function generateDeferredAsyncBlocks(context: FunctionGenerationContext): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Expr } from "../../expr";
|
|
2
|
+
import { ModuleValue } from "../../value";
|
|
3
|
+
import { CodeGenContext } from "../utils";
|
|
4
|
+
export declare function collectRequiredFunctions(moduleValue: ModuleValue, context: CodeGenContext): void;
|
|
5
|
+
export declare function findFunctionCallsInExpr(expr: Expr, context: CodeGenContext): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AwaitAnalysisResult, CapturedVariable } from "../../evaluator/async/await-analysis";
|
|
2
|
+
import { Expr } from "../../expr";
|
|
3
|
+
import { FunctionValue, FuncValueId } from "../../function-value";
|
|
4
|
+
import { DynType, FunctionType, SomeType, StructType, Type, TypeId } from "../../types";
|
|
5
|
+
import { CodeGenContext } from "../utils";
|
|
6
|
+
export interface FunctionGenerationContext extends CodeGenContext {
|
|
7
|
+
functions: Record<FuncValueId, {
|
|
8
|
+
value: FunctionValue;
|
|
9
|
+
cName: string;
|
|
10
|
+
}>;
|
|
11
|
+
externFunctions: Record<TypeId, {
|
|
12
|
+
type: FunctionType;
|
|
13
|
+
cName: string;
|
|
14
|
+
cInclude?: string;
|
|
15
|
+
}>;
|
|
16
|
+
currentFunctionName: string;
|
|
17
|
+
currentFunctionType?: FunctionType;
|
|
18
|
+
currentClosureCaptures?: string[];
|
|
19
|
+
currentClosureCaptureFrameLevel?: number;
|
|
20
|
+
currentClosureType?: FunctionType;
|
|
21
|
+
currentClosureCaptureTypeCName?: string;
|
|
22
|
+
inStateMachine?: {
|
|
23
|
+
futureType: SomeType | DynType;
|
|
24
|
+
};
|
|
25
|
+
stateMachineVariables?: Map<string, CapturedVariable>;
|
|
26
|
+
pendingDeferredDrops?: Expr[];
|
|
27
|
+
deferredAsyncBlocks?: Array<{
|
|
28
|
+
bodyExpr: Expr;
|
|
29
|
+
asyncBlockId: string;
|
|
30
|
+
structName: string;
|
|
31
|
+
resumeFunctionName: string;
|
|
32
|
+
constructorName: string;
|
|
33
|
+
disposeFunctionName: string;
|
|
34
|
+
futureType: SomeType | DynType;
|
|
35
|
+
futureModuleType: import("../../types").FutureModuleType;
|
|
36
|
+
resultType: Type;
|
|
37
|
+
resultTypeCName: string;
|
|
38
|
+
captureType: StructType | undefined;
|
|
39
|
+
analysis: AwaitAnalysisResult;
|
|
40
|
+
}>;
|
|
41
|
+
condBranchInfo?: Map<number, {
|
|
42
|
+
branches: Array<{
|
|
43
|
+
index: number;
|
|
44
|
+
value: Expr;
|
|
45
|
+
hasAwait: boolean;
|
|
46
|
+
remainingExprs?: Expr[];
|
|
47
|
+
deferredDropExpressions?: Expr[];
|
|
48
|
+
}>;
|
|
49
|
+
targetVariableId?: string;
|
|
50
|
+
}>;
|
|
51
|
+
whileLoopInfo?: Map<number, {
|
|
52
|
+
conditionExpr: Expr;
|
|
53
|
+
bodyExpr: Expr;
|
|
54
|
+
bodyExprsAfterAwait?: Expr[];
|
|
55
|
+
}>;
|
|
56
|
+
localShadowedVariables?: Set<string>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Expr } from "../../expr";
|
|
2
|
+
import { FunctionValue } from "../../function-value";
|
|
3
|
+
import { FunctionType } from "../../types";
|
|
4
|
+
import { CodeGenContext } from "../utils";
|
|
5
|
+
import { FunctionGenerationContext } from "./context";
|
|
6
|
+
export declare function generateFunctionDeclarations(context: FunctionGenerationContext): void;
|
|
7
|
+
export declare function generateFunctionPrototype(functionType: FunctionType, cFunctionName: string, context: CodeGenContext, overrideReturnType?: string): string;
|
|
8
|
+
export declare function generateFunctionDeclaration(functionType: FunctionType, cFunctionName: string, isExtern: boolean, context: CodeGenContext, functionBody?: Expr): void;
|
|
9
|
+
export declare function generateAllFunctions(context: FunctionGenerationContext): void;
|
|
10
|
+
export declare function generateDynDupDrop(context: FunctionGenerationContext): void;
|
|
11
|
+
export declare function generateMainWrapper(context: FunctionGenerationContext): void;
|
|
12
|
+
export declare function generateFunction(functionValue: FunctionValue, cFunctionName: string, context: FunctionGenerationContext): void;
|
|
13
|
+
export declare function generateFunctionBody(expr: Expr, functionType: FunctionType, indent: string, context: FunctionGenerationContext): void;
|
|
14
|
+
export declare function generateSpecializedFunctionDeclarations(context: CodeGenContext): void;
|
|
15
|
+
export declare function generateSpecializedFunctions(context: CodeGenContext): void;
|
|
16
|
+
export declare function generateObjectConstructorDeclarations(context: FunctionGenerationContext): void;
|
|
17
|
+
export declare function generateClosureConstructorDeclarations(context: FunctionGenerationContext): void;
|
|
18
|
+
export declare function generateCaptureDisposeFunctionDeclarations(context: FunctionGenerationContext): void;
|
|
19
|
+
export declare function generateClosureVtableDeclarations(_context: FunctionGenerationContext): void;
|
|
20
|
+
export declare function generateRefStructConstructorFunctions(context: FunctionGenerationContext): void;
|
|
21
|
+
export declare function generateClosureConstructorFunctions(context: FunctionGenerationContext): void;
|
|
22
|
+
export declare function generateClosureDisposeFunctions(context: FunctionGenerationContext): void;
|
|
23
|
+
export declare function generateDynBoxFunctions(context: FunctionGenerationContext): void;
|
|
24
|
+
export declare function generateDynWrapperFunctions(context: FunctionGenerationContext): void;
|
|
25
|
+
export declare function generateDynVtables(context: FunctionGenerationContext): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class CodeGenerator {
|
|
2
|
+
private moduleManager;
|
|
3
|
+
constructor();
|
|
4
|
+
compileModule(modulePath: string, options: {
|
|
5
|
+
output: string;
|
|
6
|
+
cCompiler: string;
|
|
7
|
+
target: "c";
|
|
8
|
+
extern: string[];
|
|
9
|
+
emitC?: boolean;
|
|
10
|
+
skipCodegen?: boolean;
|
|
11
|
+
skipCCompiler?: boolean;
|
|
12
|
+
debugGc?: boolean;
|
|
13
|
+
debugParallelism?: boolean;
|
|
14
|
+
debugAsyncAwait?: boolean;
|
|
15
|
+
release?: boolean;
|
|
16
|
+
optimize?: "0" | "1" | "2" | "3";
|
|
17
|
+
allocator?: "mimalloc" | "libc";
|
|
18
|
+
sanitize?: "address" | "leak";
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Expr } from "../../expr";
|
|
2
|
+
import { FunctionType, Type } from "../../types";
|
|
3
|
+
import { ModuleValue } from "../../value";
|
|
4
|
+
import { CodeGenContext } from "../utils";
|
|
5
|
+
export declare function collectRequiredTypes(moduleValue: ModuleValue, context: CodeGenContext): void;
|
|
6
|
+
export declare function collectTypesFromFunctionType(functionType: FunctionType, context: CodeGenContext): void;
|
|
7
|
+
export declare function collectTypesFromExpr(expr: Expr, context: CodeGenContext): void;
|
|
8
|
+
export declare function collectType(type: Type, context: CodeGenContext): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DynType, EnumType, FunctionType, StructType, TupleType, UnionType } from "../../types";
|
|
2
|
+
import { CodeGenContext } from "../utils";
|
|
3
|
+
export declare function generateTypeDeclarations(context: CodeGenContext): void;
|
|
4
|
+
export declare function generateArrayStructDeclarations(context: CodeGenContext): void;
|
|
5
|
+
export declare function generateSliceStructDeclarations(context: CodeGenContext): void;
|
|
6
|
+
export declare function generateIsoTypeDeclarations(context: CodeGenContext): void;
|
|
7
|
+
export declare function generateClosureDeclaration(functionType: FunctionType, cName: string, captureType: StructType | undefined, context: CodeGenContext): void;
|
|
8
|
+
export declare function generateStructDeclaration(structType: StructType, cName: string, context: CodeGenContext): void;
|
|
9
|
+
export declare function generateTupleDeclaration(tupleType: TupleType, cName: string, context: CodeGenContext): void;
|
|
10
|
+
export declare function generateUnionDeclaration(unionType: UnionType, cName: string, context: CodeGenContext): void;
|
|
11
|
+
export declare function generateEnumDeclaration(enumType: EnumType, cName: string, context: CodeGenContext): void;
|
|
12
|
+
export declare function generateDynDeclaration(dynType: DynType, cName: string, context: CodeGenContext): void;
|
|
13
|
+
export declare function generateDynBoxTypes(context: CodeGenContext): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Emitter } from "../../emitter";
|
|
2
|
+
import { FunctionValue, FuncValueId } from "../../function-value";
|
|
3
|
+
import { DynType, EnumType, FunctionType, IsoType, StructType, Type, TypeId } from "../../types";
|
|
4
|
+
import { ModuleValue } from "../../value";
|
|
5
|
+
export interface CodeGenContext {
|
|
6
|
+
types: Record<TypeId, {
|
|
7
|
+
type: Type;
|
|
8
|
+
cName: string;
|
|
9
|
+
}>;
|
|
10
|
+
functions: Record<FuncValueId, {
|
|
11
|
+
value: FunctionValue;
|
|
12
|
+
cName: string;
|
|
13
|
+
}>;
|
|
14
|
+
externFunctions: Record<TypeId, {
|
|
15
|
+
type: FunctionType;
|
|
16
|
+
cName: string;
|
|
17
|
+
cInclude?: string;
|
|
18
|
+
}>;
|
|
19
|
+
arrayStructTypes: Map<string, {
|
|
20
|
+
childType: string;
|
|
21
|
+
length: number;
|
|
22
|
+
}>;
|
|
23
|
+
sliceStructTypes: Map<string, {
|
|
24
|
+
childType: string;
|
|
25
|
+
}>;
|
|
26
|
+
isoTypes?: Map<string, {
|
|
27
|
+
childTypeCName: string;
|
|
28
|
+
isoType: IsoType;
|
|
29
|
+
optionTypeCName?: string;
|
|
30
|
+
structGenerated?: boolean;
|
|
31
|
+
createGenerated?: boolean;
|
|
32
|
+
extractGenerated?: boolean;
|
|
33
|
+
disposeGenerated?: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
spawnedFunctionSignatures: Map<string, {
|
|
36
|
+
parameterTypes: Type[];
|
|
37
|
+
returnType: Type;
|
|
38
|
+
}>;
|
|
39
|
+
spawnedClosureSignatures: Map<string, {
|
|
40
|
+
closureType: Type;
|
|
41
|
+
}>;
|
|
42
|
+
tempVarAsyncStructNames?: Map<string, string>;
|
|
43
|
+
closureCaptureMap: Map<string, {
|
|
44
|
+
closureType: FunctionType;
|
|
45
|
+
closureCName: string;
|
|
46
|
+
captureType: StructType;
|
|
47
|
+
captureCName: string;
|
|
48
|
+
}>;
|
|
49
|
+
implClosureCallMap: Map<TypeId, {
|
|
50
|
+
functionCName: string;
|
|
51
|
+
callTypeId: TypeId;
|
|
52
|
+
}>;
|
|
53
|
+
currentFunctionName: string;
|
|
54
|
+
cIncludes: Set<string>;
|
|
55
|
+
emitter: Emitter;
|
|
56
|
+
debugGc: boolean;
|
|
57
|
+
debugParallelism: boolean;
|
|
58
|
+
debugAsyncAwait: boolean;
|
|
59
|
+
allocator: "mimalloc" | "libc";
|
|
60
|
+
dynImpls: Map<string, {
|
|
61
|
+
dynType: DynType;
|
|
62
|
+
concreteType: Type;
|
|
63
|
+
dataType: Type;
|
|
64
|
+
moduleValue: ModuleValue;
|
|
65
|
+
}>;
|
|
66
|
+
currentLoopLabel?: string;
|
|
67
|
+
}
|
|
68
|
+
export declare function sanitizeForCIdentifier(str: string): string;
|
|
69
|
+
export declare function shouldAvoidConst(type: Type): boolean;
|
|
70
|
+
export declare function getTypeString(type: Type | undefined, context: CodeGenContext): string;
|
|
71
|
+
export declare function getVariableTypeString(type: Type, varName: string, context: CodeGenContext): string;
|
|
72
|
+
export declare function getEnumVariantCName(enumType: EnumType, variantName: string, context: CodeGenContext): string;
|
|
73
|
+
export declare function isGenericFunction(functionValue: FunctionValue): boolean;
|
|
74
|
+
export declare function isComptFunction(functionValue: FunctionValue): boolean;
|
|
75
|
+
export declare function isFunctionValueWithOnlyBuiltinYoInlineFunctionCall(functionValue: FunctionValue): string | null;
|
|
76
|
+
export declare function canOptimizeAsNullablePointer(enumType: EnumType): Type | null;
|
|
77
|
+
export declare function canOptimizeAsSimpleEnum(enumType: EnumType): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Emitter {
|
|
2
|
+
private headers;
|
|
3
|
+
private declarations;
|
|
4
|
+
private code;
|
|
5
|
+
constructor();
|
|
6
|
+
emit(code: string, indentation?: string): string;
|
|
7
|
+
emitLine(code: string, indentation?: string): string;
|
|
8
|
+
emitHeaderLine(code: string, indentation?: string): string;
|
|
9
|
+
emitDeclarationLine(code: string, indentation?: string): string;
|
|
10
|
+
print(): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Token } from "./token";
|
|
2
|
+
import { FunctionType, Type } from "./types";
|
|
3
|
+
import { Value } from "./value";
|
|
4
|
+
export interface Variable {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type: Type;
|
|
8
|
+
value?: Value;
|
|
9
|
+
isCompileTimeOnly: boolean;
|
|
10
|
+
isOwningTheGcValue: boolean;
|
|
11
|
+
isOwningTheSameGcValueAs?: Variable;
|
|
12
|
+
isReassignable?: boolean;
|
|
13
|
+
initializedAtToken: Token | undefined;
|
|
14
|
+
consumedAtToken: Token | undefined;
|
|
15
|
+
frameLevel: number;
|
|
16
|
+
token: Token;
|
|
17
|
+
isCreatedFromDestructuringAtomVariable?: boolean;
|
|
18
|
+
parameterAlias?: string;
|
|
19
|
+
}
|
|
20
|
+
export type Frame = {
|
|
21
|
+
variables: Variable[];
|
|
22
|
+
id: string;
|
|
23
|
+
isBeginBlockFrame: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type Environment = {
|
|
26
|
+
functionDeclarationFrameLevel: number;
|
|
27
|
+
freeVariables: Variable[];
|
|
28
|
+
frames: Frame[];
|
|
29
|
+
modulePath: string;
|
|
30
|
+
inputString: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function createNewEnv({ modulePath, inputString, }: {
|
|
33
|
+
modulePath: string;
|
|
34
|
+
inputString: string;
|
|
35
|
+
}): Environment;
|
|
36
|
+
export declare function createEmptyEnv(): Environment;
|
|
37
|
+
export declare function setEnvContainingPrelude(env: Environment): void;
|
|
38
|
+
export declare function clearEnvContainingPrelude(): void;
|
|
39
|
+
export declare function createEnvContainingPrelude(): Environment;
|
|
40
|
+
export declare function isEvaluatingPreludeModule(): boolean;
|
|
41
|
+
export declare function addVariableToEnv({ env, variable, deltaFrame, variableId, skipCheckingFunctionOverloading, addToBeginBlockFrame, }: {
|
|
42
|
+
env: Environment;
|
|
43
|
+
variable: Omit<Variable, "id" | "frameLevel">;
|
|
44
|
+
deltaFrame?: number;
|
|
45
|
+
variableId?: string;
|
|
46
|
+
skipCheckingFunctionOverloading?: boolean;
|
|
47
|
+
addToBeginBlockFrame?: boolean;
|
|
48
|
+
}): {
|
|
49
|
+
env: Environment;
|
|
50
|
+
variable: Variable;
|
|
51
|
+
};
|
|
52
|
+
export declare function addVariableToFrame({ frame, variable, }: {
|
|
53
|
+
frame: Frame;
|
|
54
|
+
variable: Variable;
|
|
55
|
+
}): Frame;
|
|
56
|
+
export declare function getVariablesFromFrame(frame: Frame, variableName: string, variableFilter?: (variable: Variable) => boolean): Variable[];
|
|
57
|
+
export declare function getVariablesFromEnv(env: Environment, variableName: string, variableFilter?: (variable: Variable) => boolean): Variable[];
|
|
58
|
+
export declare function getVariablesFromEnvByFilter(env: Environment, variableFilter: (variable: Variable) => boolean): Variable[];
|
|
59
|
+
export declare function pushEnvFrame(env: Environment, frame?: Frame, isBeginBlockFrame?: boolean): Environment;
|
|
60
|
+
export declare function popEnvFrame(env: Environment, ignoreCheck?: boolean): Environment;
|
|
61
|
+
export declare function updateExistingVariable(env: Environment, oldVariable: Variable, newVariable: Variable): Environment;
|
|
62
|
+
export declare function printEnvVarNames(env: Environment): void;
|
|
63
|
+
export declare function printEnvFrame(frame: Frame): void;
|
|
64
|
+
export declare function getVariableInfo(variable: Variable): {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
type: string;
|
|
68
|
+
typeId: string;
|
|
69
|
+
value: string;
|
|
70
|
+
isCompileTimeOnly: boolean;
|
|
71
|
+
isUndefined: boolean;
|
|
72
|
+
isOwningTheGcValue: boolean;
|
|
73
|
+
isOwningTheSameGcValueAs: string | undefined;
|
|
74
|
+
isReassignable: boolean;
|
|
75
|
+
isConsumed: boolean;
|
|
76
|
+
};
|
|
77
|
+
export declare function getMethodsByNameFromEnv(env: Environment, methodName: string, receiverType: Type, isInfixOperatorCall?: boolean, currentFunctionType?: FunctionType): {
|
|
78
|
+
type: Type;
|
|
79
|
+
value: Value | undefined;
|
|
80
|
+
needsPointerConversion?: boolean;
|
|
81
|
+
}[];
|
|
82
|
+
export declare function keepTopLevelFrameAndComptimeVariablesFromEnv(env: Environment): Environment;
|
|
83
|
+
export declare function getVariablesNeedingDrop(env: Environment): Variable[];
|
|
84
|
+
export declare function findNearestBeginBlockFrameLevel(env: Environment): number;
|
|
85
|
+
export declare function variableExistsInEnvTopFrame(env: Environment, variableName: string): boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Token } from "./token";
|
|
2
|
+
export interface TokenAndError {
|
|
3
|
+
token: Token;
|
|
4
|
+
errorMessage: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class YoLexerError {
|
|
7
|
+
characterIndex: number;
|
|
8
|
+
message: string;
|
|
9
|
+
constructor({ characterIndex, message, }: {
|
|
10
|
+
characterIndex: number;
|
|
11
|
+
message: string;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export declare class YoError {
|
|
15
|
+
tokenAndErrorList: TokenAndError[];
|
|
16
|
+
isAssertionError: boolean;
|
|
17
|
+
constructor(tokenAndErrorList: TokenAndError[], isAssertionError?: boolean);
|
|
18
|
+
toString(): string;
|
|
19
|
+
}
|
|
20
|
+
export declare function getLineAtToken({ token }: {
|
|
21
|
+
token: Token;
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function getLineAtPosition({ modulePath, inputString, position, }: {
|
|
24
|
+
modulePath: string;
|
|
25
|
+
inputString: string;
|
|
26
|
+
position: {
|
|
27
|
+
row: number;
|
|
28
|
+
column: number;
|
|
29
|
+
};
|
|
30
|
+
}): string;
|
|
31
|
+
export declare function formatErrorMessage({ token, errorMessage, cause, isAssertionError, }: {
|
|
32
|
+
token: Token;
|
|
33
|
+
errorMessage: string;
|
|
34
|
+
cause?: Error;
|
|
35
|
+
isAssertionError?: boolean;
|
|
36
|
+
}): YoError;
|
|
37
|
+
export declare function formatErrorMessages(tokenAndErrorList: TokenAndError[], isAssertionError?: boolean): YoError;
|
|
38
|
+
export declare function formatWarningMessages({ warningMessage, tokenAndWarningList, }: {
|
|
39
|
+
warningMessage?: string;
|
|
40
|
+
tokenAndWarningList: {
|
|
41
|
+
token: Token;
|
|
42
|
+
warningMessage: string;
|
|
43
|
+
}[];
|
|
44
|
+
}): string;
|
|
45
|
+
export declare function printYoError(error: YoError | Error): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Type } from "../../types";
|
|
2
|
+
export interface AwaitPoint {
|
|
3
|
+
index: number;
|
|
4
|
+
expr: unknown;
|
|
5
|
+
resultType: Type;
|
|
6
|
+
futureType?: Type;
|
|
7
|
+
targetVariableId?: string;
|
|
8
|
+
futureVariableId?: string;
|
|
9
|
+
isInsideCond?: boolean;
|
|
10
|
+
isInsideWhile?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CapturedVariable {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: Type;
|
|
16
|
+
kind: "local" | "outer";
|
|
17
|
+
isOwningTheSameGcValueAs: CapturedVariable | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface AwaitAnalysisResult {
|
|
20
|
+
awaitPoints: AwaitPoint[];
|
|
21
|
+
capturedVariables: CapturedVariable[];
|
|
22
|
+
hasAwaits: boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Expr } from "../../expr";
|
|
2
|
+
export type { AwaitAnalysisResult, AwaitPoint, CapturedVariable, } from "./await-analysis-types";
|
|
3
|
+
import type { AwaitAnalysisResult, CapturedVariable } from "./await-analysis-types";
|
|
4
|
+
export declare function analyzeAwaitPoints(body: Expr): AwaitAnalysisResult;
|
|
5
|
+
export declare function getLocalVariablesFromBody(body: Expr): CapturedVariable[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Environment } from "../../env";
|
|
2
|
+
import { FuncCallExpr } from "../../expr";
|
|
3
|
+
import { EvaluatorContext } from "../context";
|
|
4
|
+
export declare function evaluateAlignOf({ expr, env, context, }: {
|
|
5
|
+
expr: FuncCallExpr;
|
|
6
|
+
env: Environment;
|
|
7
|
+
context: EvaluatorContext;
|
|
8
|
+
}): FuncCallExpr;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Environment } from "../../env";
|
|
2
|
+
import { FuncCallExpr } from "../../expr";
|
|
3
|
+
import { EvaluatorContext } from "../context";
|
|
4
|
+
export declare function evaluateAndOr({ expr, env, context, }: {
|
|
5
|
+
expr: FuncCallExpr;
|
|
6
|
+
env: Environment;
|
|
7
|
+
context: EvaluatorContext;
|
|
8
|
+
}): FuncCallExpr;
|