xbintsc 0.5.23 → 0.5.32
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/AGENTS.md +11 -2
- package/README.md +47 -16
- package/README.zh-CN.md +21 -2
- package/dist/scripts/support-matrix.d.ts +18 -0
- package/dist/scripts/support-matrix.js +141 -0
- package/dist/scripts/support-matrix.js.map +1 -0
- package/dist/src/ast/common.d.ts +2 -2
- package/dist/src/ast/declarations.d.ts +7 -1
- package/dist/src/ast/expressions.d.ts +5 -0
- package/dist/src/ast/kinds.d.ts +2 -0
- package/dist/src/ast/kinds.js +2 -0
- package/dist/src/ast/kinds.js.map +1 -1
- package/dist/src/binder/binder.d.ts +2 -1
- package/dist/src/binder/binder.js +2 -0
- package/dist/src/binder/binder.js.map +1 -1
- package/dist/src/binder/declarations.d.ts +9 -0
- package/dist/src/binder/declarations.js +64 -0
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/binder/references.js +99 -4
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/binder/types.d.ts +32 -0
- package/dist/src/binder/types.js.map +1 -1
- package/dist/src/canonical.d.ts +29 -0
- package/dist/src/canonical.js +35 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/checker/assignability.d.ts +13 -0
- package/dist/src/checker/assignability.js +146 -0
- package/dist/src/checker/assignability.js.map +1 -0
- package/dist/src/checker/calls.d.ts +13 -0
- package/dist/src/checker/calls.js +127 -0
- package/dist/src/checker/calls.js.map +1 -0
- package/dist/src/checker/checker.d.ts +26 -0
- package/dist/src/checker/checker.js +31 -0
- package/dist/src/checker/checker.js.map +1 -0
- package/dist/src/checker/declarations.d.ts +9 -0
- package/dist/src/checker/declarations.js +15 -0
- package/dist/src/checker/declarations.js.map +1 -0
- package/dist/src/checker/flow.d.ts +21 -0
- package/dist/src/checker/flow.js +241 -0
- package/dist/src/checker/flow.js.map +1 -0
- package/dist/src/checker/globals.d.ts +9 -0
- package/dist/src/checker/globals.js +29 -0
- package/dist/src/checker/globals.js.map +1 -0
- package/dist/src/checker/source.d.ts +38 -0
- package/dist/src/checker/source.js +48 -0
- package/dist/src/checker/source.js.map +1 -0
- package/dist/src/checker/type-infer.d.ts +18 -0
- package/dist/src/checker/type-infer.js +173 -0
- package/dist/src/checker/type-infer.js.map +1 -0
- package/dist/src/checker/type-model.d.ts +73 -0
- package/dist/src/checker/type-model.js +151 -0
- package/dist/src/checker/type-model.js.map +1 -0
- package/dist/src/checker/type-system.d.ts +58 -0
- package/dist/src/checker/type-system.js +569 -0
- package/dist/src/checker/type-system.js.map +1 -0
- package/dist/src/checker/typecheck-types.d.ts +22 -0
- package/dist/src/checker/typecheck-types.js +109 -0
- package/dist/src/checker/typecheck-types.js.map +1 -0
- package/dist/src/checker/typecheck.d.ts +62 -0
- package/dist/src/checker/typecheck.js +574 -0
- package/dist/src/checker/typecheck.js.map +1 -0
- package/dist/src/checker/undefined.d.ts +14 -0
- package/dist/src/checker/undefined.js +32 -0
- package/dist/src/checker/undefined.js.map +1 -0
- package/dist/src/checker/walk.d.ts +10 -0
- package/dist/src/checker/walk.js +15 -0
- package/dist/src/checker/walk.js.map +1 -0
- package/dist/src/cli/help.d.ts +7 -0
- package/dist/src/cli/help.js +64 -0
- package/dist/src/cli/help.js.map +1 -0
- package/dist/src/cli/hints.js +2 -1
- package/dist/src/cli/hints.js.map +1 -1
- package/dist/src/cli/main.js +12 -48
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +8 -8
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +9 -4
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls/super.d.ts +9 -1
- package/dist/src/codegen/generator/calls/super.js +56 -5
- package/dist/src/codegen/generator/calls/super.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +13 -2
- package/dist/src/codegen/generator/context.js +25 -19
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +2 -1
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.d.ts +4 -1
- package/dist/src/codegen/generator/expressions/primary.js +68 -8
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/generator.js +11 -1
- package/dist/src/codegen/generator/generator.js.map +1 -1
- package/dist/src/codegen/generator/module.d.ts +3 -0
- package/dist/src/codegen/generator/module.js +116 -26
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.d.ts +11 -1
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/variables.js +26 -7
- package/dist/src/codegen/generator/statements/variables.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +2 -0
- package/dist/src/codegen/generator/tables.js +4 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +2 -0
- package/dist/src/driver/build-key.js +1 -0
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +5 -1
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +16 -1
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/types.d.ts +12 -0
- package/dist/src/driver/compiler.d.ts +1 -1
- package/dist/src/driver/compiler.js +3 -0
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/fingerprint.js +2 -1
- package/dist/src/driver/fingerprint.js.map +1 -1
- package/dist/src/driver/frontend.d.ts +8 -6
- package/dist/src/driver/frontend.js +4 -0
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/options.d.ts +6 -0
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/css.d.ts +26 -0
- package/dist/src/extensions/gui/css.js +100 -0
- package/dist/src/extensions/gui/css.js.map +1 -0
- package/dist/src/extensions/gui/html.js +28 -7
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +79 -2
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/gui/three.d.ts +16 -0
- package/dist/src/extensions/gui/three.js +22 -0
- package/dist/src/extensions/gui/three.js.map +1 -0
- package/dist/src/extensions/media/index.d.ts +6 -5
- package/dist/src/extensions/media/index.js +12 -14
- package/dist/src/extensions/media/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +38 -0
- package/dist/src/extensions/registry.js +10 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/declarations/classes.js +7 -0
- package/dist/src/parser/declarations/classes.js.map +1 -1
- package/dist/src/parser/expressions.js +14 -1
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/literals.js +6 -2
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/binder/binder.test.js +29 -0
- package/dist/tests/binder/binder.test.js.map +1 -1
- package/dist/tests/canonical.test.d.ts +1 -0
- package/dist/tests/canonical.test.js +19 -0
- package/dist/tests/canonical.test.js.map +1 -0
- package/dist/tests/checker/checker.test.d.ts +1 -0
- package/dist/tests/checker/checker.test.js +245 -0
- package/dist/tests/checker/checker.test.js.map +1 -0
- package/dist/tests/cli/check.test.js +20 -0
- package/dist/tests/cli/check.test.js.map +1 -1
- package/dist/tests/conformance/matrix.test.d.ts +6 -0
- package/dist/tests/conformance/matrix.test.js +23 -0
- package/dist/tests/conformance/matrix.test.js.map +1 -0
- package/dist/tests/conformance/test262/manifest.d.ts +115 -0
- package/dist/tests/conformance/test262/manifest.js +257 -0
- package/dist/tests/conformance/test262/manifest.js.map +1 -0
- package/dist/tests/conformance/test262.test.d.ts +11 -0
- package/dist/tests/conformance/test262.test.js +74 -0
- package/dist/tests/conformance/test262.test.js.map +1 -0
- package/dist/tests/docs/structure.test.js +9 -11
- package/dist/tests/docs/structure.test.js.map +1 -1
- package/dist/tests/e2e/child-process.test.js +3 -2
- package/dist/tests/e2e/child-process.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +45 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js +77 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/differential-syntax.test.d.ts +5 -0
- package/dist/tests/e2e/differential-syntax.test.js +95 -0
- package/dist/tests/e2e/differential-syntax.test.js.map +1 -0
- package/dist/tests/e2e/differential-values.test.js +15 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gui-browser.test.d.ts +13 -0
- package/dist/tests/e2e/gui-browser.test.js +163 -0
- package/dist/tests/e2e/gui-browser.test.js.map +1 -0
- package/dist/tests/e2e/gui-effects.test.d.ts +6 -0
- package/dist/tests/e2e/gui-effects.test.js +262 -0
- package/dist/tests/e2e/gui-effects.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-browser.test.js +2 -2
- package/dist/tests/e2e/gui-example-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-canvas.test.js +5 -4
- package/dist/tests/e2e/gui-example-canvas.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-svg.test.js +4 -3
- package/dist/tests/e2e/gui-example-svg.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-webgl.test.d.ts +10 -0
- package/dist/tests/e2e/gui-example-webgl.test.js +75 -0
- package/dist/tests/e2e/gui-example-webgl.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-webgl2.test.d.ts +8 -0
- package/dist/tests/e2e/gui-example-webgl2.test.js +72 -0
- package/dist/tests/e2e/gui-example-webgl2.test.js.map +1 -0
- package/dist/tests/e2e/gui-example.test.js +4 -3
- package/dist/tests/e2e/gui-example.test.js.map +1 -1
- package/dist/tests/e2e/gui-helpers.js +4 -3
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +48 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-media.test.js +10 -8
- package/dist/tests/e2e/gui-media.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl.test.d.ts +11 -0
- package/dist/tests/e2e/gui-webgl.test.js +179 -0
- package/dist/tests/e2e/gui-webgl.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2.test.js +238 -0
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -0
- package/dist/tests/e2e/harness.d.ts +9 -0
- package/dist/tests/e2e/harness.js +14 -2
- package/dist/tests/e2e/harness.js.map +1 -1
- package/dist/tests/e2e/native-extensions.test.js +2 -1
- package/dist/tests/e2e/native-extensions.test.js.map +1 -1
- package/dist/tests/e2e/property-descriptors.test.js +20 -0
- package/dist/tests/e2e/property-descriptors.test.js.map +1 -1
- package/dist/tests/e2e/unicode-output.test.js +5 -3
- package/dist/tests/e2e/unicode-output.test.js.map +1 -1
- package/dist/tests/e2e/weak-collections.test.js +16 -2
- package/dist/tests/e2e/weak-collections.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +41 -0
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/extensions/media.test.js +7 -3
- package/dist/tests/extensions/media.test.js.map +1 -1
- package/dist/tests/helpers.d.ts +1 -0
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/declarations.test.js +20 -0
- package/dist/tests/parser/declarations.test.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/dist/tests/platform.d.ts +32 -0
- package/dist/tests/platform.js +40 -0
- package/dist/tests/platform.js.map +1 -0
- package/dist/tests/platform.test.d.ts +12 -0
- package/dist/tests/platform.test.js +51 -0
- package/dist/tests/platform.test.js.map +1 -0
- package/dist/tests/version.test.js +4 -4
- package/dist/tests/version.test.js.map +1 -1
- package/doc/ai/README.md +10 -4
- package/doc/ai/build-recipe.md +1 -0
- package/doc/ai/cli.md +17 -5
- package/doc/ai/contributing.md +59 -2
- package/doc/ai/extensions.md +38 -7
- package/doc/ai/language-support.md +25 -16
- package/doc/ai/troubleshooting.md +12 -8
- package/doc/ai/zh-CN/README.md +9 -4
- package/doc/ai/zh-CN/build-recipe.md +1 -0
- package/doc/ai/zh-CN/cli.md +13 -3
- package/doc/ai/zh-CN/contributing.md +49 -3
- package/doc/ai/zh-CN/extensions.md +33 -6
- package/doc/ai/zh-CN/language-support.md +23 -14
- package/doc/ai/zh-CN/troubleshooting.md +10 -6
- package/doc/gui/api.md +47 -1
- package/doc/gui/build.md +72 -16
- package/doc/gui/canvas.md +11 -3
- package/doc/gui/dom.md +33 -18
- package/doc/gui/known-issues.md +58 -15
- package/doc/gui/layout.md +18 -0
- package/doc/gui/media.md +17 -13
- package/doc/gui/rendering.md +50 -3
- package/doc/gui/runtime.md +18 -0
- package/doc/gui/webgl.md +256 -0
- package/doc/gui-scripts.md +7 -0
- package/doc/gui.md +108 -17
- package/doc/implemented/binder.md +2 -0
- package/doc/implemented/checker.md +117 -0
- package/doc/implemented/cli.md +13 -1
- package/doc/implemented/codegen.md +3 -2
- package/doc/implemented/driver.md +2 -2
- package/doc/implemented/operators.md +2 -1
- package/doc/implemented/parser.md +3 -2
- package/doc/implemented/pipeline.md +8 -1
- package/doc/implemented/stdlib.md +2 -1
- package/doc/implemented/tests.md +3 -1
- package/doc/implemented.md +2 -0
- package/doc/npm-package.md +419 -0
- package/doc/requirements.md +22 -10
- package/doc/support-matrix.md +83 -0
- package/doc/unimplemented/classes.md +3 -0
- package/doc/unimplemented/deviations.md +3 -2
- package/doc/unimplemented/toolchain.md +1 -1
- package/doc/unimplemented/types.md +24 -8
- package/doc/unimplemented.md +1 -1
- package/doc/zh-CN/gui/api.md +43 -1
- package/doc/zh-CN/gui/build.md +64 -15
- package/doc/zh-CN/gui/canvas.md +9 -2
- package/doc/zh-CN/gui/dom.md +20 -7
- package/doc/zh-CN/gui/known-issues.md +46 -13
- package/doc/zh-CN/gui/layout.md +14 -0
- package/doc/zh-CN/gui/media.md +15 -11
- package/doc/zh-CN/gui/rendering.md +41 -4
- package/doc/zh-CN/gui/runtime.md +16 -0
- package/doc/zh-CN/gui/webgl.md +115 -0
- package/doc/zh-CN/gui-scripts.md +5 -0
- package/doc/zh-CN/gui.md +89 -14
- package/doc/zh-CN/implemented/binder.md +2 -0
- package/doc/zh-CN/implemented/checker.md +99 -0
- package/doc/zh-CN/implemented/cli.md +12 -1
- package/doc/zh-CN/implemented/codegen.md +3 -2
- package/doc/zh-CN/implemented/driver.md +2 -2
- package/doc/zh-CN/implemented/operators.md +1 -1
- package/doc/zh-CN/implemented/parser.md +3 -2
- package/doc/zh-CN/implemented/pipeline.md +3 -1
- package/doc/zh-CN/implemented/stdlib.md +2 -1
- package/doc/zh-CN/implemented/tests.md +3 -1
- package/doc/zh-CN/implemented.md +2 -0
- package/doc/zh-CN/npm-package.md +394 -0
- package/doc/zh-CN/post/announce.md +47 -47
- package/doc/zh-CN/requirements.md +16 -7
- package/doc/zh-CN/support-matrix.md +82 -0
- package/doc/zh-CN/unimplemented/classes.md +3 -0
- package/doc/zh-CN/unimplemented/deviations.md +3 -2
- package/doc/zh-CN/unimplemented/toolchain.md +1 -1
- package/doc/zh-CN/unimplemented/types.md +16 -6
- package/doc/zh-CN/unimplemented.md +1 -1
- package/llms.txt +6 -1
- package/package.json +2 -1
- package/runtime/ext_gui/audio.cpp +316 -0
- package/runtime/ext_gui/browser.cpp +573 -0
- package/runtime/ext_gui/browser_escape.cpp +85 -0
- package/runtime/ext_gui/browser_loop.cpp +83 -0
- package/runtime/ext_gui/canvas.cpp +12 -21
- package/runtime/ext_gui/canvas_internal.h +10 -0
- package/runtime/ext_gui/canvas_raster.cpp +79 -1
- package/runtime/ext_gui/clip_values.cpp +246 -0
- package/runtime/ext_gui/css.cpp +94 -0
- package/runtime/ext_gui/css.h +22 -1
- package/runtime/ext_gui/css_match.cpp +3 -0
- package/runtime/ext_gui/css_selector.cpp +9 -0
- package/runtime/ext_gui/css_sheet.cpp +89 -45
- package/runtime/ext_gui/document.cpp +4 -1
- package/runtime/ext_gui/document.h +2 -0
- package/runtime/ext_gui/dom.h +16 -0
- package/runtime/ext_gui/dom_api.cpp +37 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +17 -80
- package/runtime/ext_gui/dom_api_canvas_extra.cpp +130 -1
- package/runtime/ext_gui/dom_api_canvas_pending.cpp +41 -0
- package/runtime/ext_gui/dom_api_document.cpp +96 -5
- package/runtime/ext_gui/dom_api_events.cpp +20 -0
- package/runtime/ext_gui/dom_api_internal.h +278 -0
- package/runtime/ext_gui/dom_api_proto.cpp +6 -0
- package/runtime/ext_gui/dom_api_webgl.cpp +376 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +434 -0
- package/runtime/ext_gui/dom_api_webgl2_draw.cpp +269 -0
- package/runtime/ext_gui/dom_api_webgl_buffer.cpp +212 -0
- package/runtime/ext_gui/dom_api_webgl_rt.h +30 -0
- package/runtime/ext_gui/dom_api_webgl_shader.cpp +443 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +444 -0
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +445 -0
- package/runtime/ext_gui/effect_values.cpp +312 -0
- package/runtime/ext_gui/gradient_values.cpp +476 -0
- package/runtime/ext_gui/grid_values.cpp +230 -0
- package/runtime/ext_gui/gui.cpp +90 -23
- package/runtime/ext_gui/gui_canvas.cpp +50 -2
- package/runtime/ext_gui/gui_engine.h +71 -0
- package/runtime/ext_gui/gui_events.cpp +4 -1
- package/runtime/ext_gui/gui_media.cpp +1 -1
- package/runtime/ext_gui/gui_webgl.cpp +83 -0
- package/runtime/ext_gui/layout.cpp +21 -0
- package/runtime/ext_gui/layout_flow.cpp +81 -4
- package/runtime/ext_gui/layout_flow_internal.h +31 -0
- package/runtime/ext_gui/layout_grid.cpp +374 -0
- package/runtime/ext_gui/media.h +1 -1
- package/runtime/ext_gui/media_api.h +2 -2
- package/runtime/ext_gui/media_query.cpp +211 -0
- package/runtime/ext_gui/paint.cpp +111 -77
- package/runtime/ext_gui/paint.h +33 -3
- package/runtime/ext_gui/paint_background.cpp +229 -0
- package/runtime/ext_gui/paint_clip.cpp +268 -0
- package/runtime/ext_gui/paint_effects.cpp +324 -0
- package/runtime/ext_gui/paint_internal.h +85 -0
- package/runtime/ext_gui/renderer.cpp +8 -31
- package/runtime/ext_gui/renderer_clip.cpp +196 -0
- package/runtime/ext_gui/renderer_image.cpp +13 -8
- package/runtime/ext_gui/renderer_internal.h +15 -8
- package/runtime/ext_gui/renderer_text.cpp +6 -31
- package/runtime/ext_gui/style.cpp +343 -20
- package/runtime/ext_gui/style.h +144 -3
- package/runtime/ext_gui/style_print.cpp +134 -1
- package/runtime/ext_gui/style_values.cpp +152 -126
- package/runtime/ext_gui/style_values_internal.h +35 -0
- package/runtime/ext_gui/webgl.h +466 -0
- package/runtime/ext_gui/webgl2_constants.h +274 -0
- package/runtime/ext_gui/webgl_buffer.cpp +565 -0
- package/runtime/ext_gui/webgl_constants.h +317 -0
- package/runtime/ext_gui/webgl_context.cpp +466 -0
- package/runtime/ext_gui/webgl_draw.cpp +495 -0
- package/runtime/ext_gui/webgl_glsl.h +125 -0
- package/runtime/ext_gui/webgl_glsl_compile.cpp +431 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +349 -0
- package/runtime/ext_gui/webgl_glsl_scan.cpp +581 -0
- package/runtime/ext_gui/webgl_msl.cpp +62 -0
- package/runtime/ext_gui/webgl_msl.h +33 -0
- package/runtime/ext_gui/webgl_pipeline.cpp +274 -0
- package/runtime/ext_gui/webgl_program_internal.h +18 -0
- package/runtime/ext_gui/webgl_shader.cpp +582 -0
- package/runtime/ext_gui/webgl_texture.cpp +293 -0
- package/runtime/ext_gui/webgl_uniform.cpp +167 -0
- package/runtime/ext_gui/webgl_webgl2.cpp +224 -0
- package/runtime/ext_gui/window.cpp +9 -0
- package/runtime/ext_media/media.cpp +1 -1
- package/runtime/ext_media/media_bridge.c +9 -3
- package/runtime/ext_node/path/path.c +7 -7
- package/runtime/ext_node/url/url.c +4 -2
- package/runtime/rt.h +15 -0
- package/runtime/rt_internal.h +1 -0
- package/runtime/xt_constructors.c +2 -1
- package/runtime/xt_containers/access.inc +8 -0
- package/runtime/xt_containers/objects.inc +22 -2
- package/runtime/xt_io/exception.inc +4 -2
- package/runtime/xt_regex/api.inc +2 -0
- package/runtime/xt_regex/matcher.inc +16 -3
- package/runtime/xt_regex/parser.inc +8 -2
- package/runtime/xt_regex/types.inc +3 -0
- package/runtime/xt_stdlib/math.inc +62 -0
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/objects.inc +14 -0
- package/runtime/xt_stdlib2/regexp-match.inc +60 -21
- package/runtime/xt_stdlib2/regexp.inc +1 -0
- package/runtime/xt_typed_array.c +1 -1
- package/scripts/build-gui.ts +90 -3
- package/scripts/build-media.ts +323 -58
- package/scripts/setup-vs-toolchain.ps1 +152 -0
- package/scripts/support-matrix.ts +167 -0
- package/src/ast/common.ts +2 -0
- package/src/ast/declarations.ts +12 -1
- package/src/ast/expressions.ts +6 -0
- package/src/ast/kinds.ts +2 -0
- package/src/binder/binder.ts +3 -0
- package/src/binder/declarations.ts +70 -0
- package/src/binder/references.ts +97 -4
- package/src/binder/types.ts +30 -0
- package/src/canonical.ts +37 -0
- package/src/checker/assignability.ts +134 -0
- package/src/checker/calls.ts +135 -0
- package/src/checker/checker.ts +47 -0
- package/src/checker/declarations.ts +26 -0
- package/src/checker/flow.ts +236 -0
- package/src/checker/globals.ts +40 -0
- package/src/checker/source.ts +53 -0
- package/src/checker/type-infer.ts +185 -0
- package/src/checker/type-model.ts +212 -0
- package/src/checker/type-system.ts +578 -0
- package/src/checker/typecheck-types.ts +112 -0
- package/src/checker/typecheck.ts +586 -0
- package/src/checker/undefined.ts +43 -0
- package/src/checker/walk.ts +16 -0
- package/src/cli/help.ts +65 -0
- package/src/cli/hints.ts +2 -1
- package/src/cli/main.ts +12 -49
- package/src/codegen/generator/calls/access.ts +8 -8
- package/src/codegen/generator/calls/invocation.ts +8 -5
- package/src/codegen/generator/calls/super.ts +67 -5
- package/src/codegen/generator/context.ts +31 -19
- package/src/codegen/generator/debug.ts +2 -1
- package/src/codegen/generator/expressions/primary.ts +84 -13
- package/src/codegen/generator/generator.ts +11 -1
- package/src/codegen/generator/module.ts +115 -24
- package/src/codegen/generator/state.ts +11 -1
- package/src/codegen/generator/statements/variables.ts +26 -6
- package/src/codegen/generator/tables.ts +5 -0
- package/src/driver/build-key.ts +3 -0
- package/src/driver/bundler/graph.ts +6 -2
- package/src/driver/bundler/merge.ts +14 -1
- package/src/driver/bundler/types.ts +13 -0
- package/src/driver/compiler.ts +4 -1
- package/src/driver/fingerprint.ts +2 -1
- package/src/driver/frontend.ts +13 -2
- package/src/driver/options.ts +6 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/css.ts +113 -0
- package/src/extensions/gui/html.ts +31 -11
- package/src/extensions/gui/index.ts +81 -2
- package/src/extensions/gui/three.ts +25 -0
- package/src/extensions/media/index.ts +13 -16
- package/src/extensions/registry.ts +48 -0
- package/src/index.ts +1 -0
- package/src/parser/declarations/classes.ts +7 -0
- package/src/parser/expressions.ts +13 -1
- package/src/parser/literals.ts +6 -2
package/src/cli/help.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `--help` text.
|
|
3
|
+
*
|
|
4
|
+
* It lives apart from the command dispatch so the executable entry point stays
|
|
5
|
+
* under the repository's per-file line budget; the text is data, not logic.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { CONFIG_FILE_NAME } from "../driver/config.js";
|
|
9
|
+
import { COMPILER_VERSION } from "../driver/version.js";
|
|
10
|
+
|
|
11
|
+
export const HELP = `xbintsc ${COMPILER_VERSION} - TypeScript binary compiler
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
xbintsc build <file.ts> [options] Compile to a native binary
|
|
15
|
+
xbintsc run <file.ts> [-- args] Compile and execute
|
|
16
|
+
xbintsc check <file.ts> Parse, bind and check without linking
|
|
17
|
+
xbintsc watch <file.ts> [options] Rebuild whenever the source tree changes
|
|
18
|
+
xbintsc emit <file.ts> Print LLVM IR
|
|
19
|
+
xbintsc doctor Report the resolved toolchain
|
|
20
|
+
xbintsc version Print the version
|
|
21
|
+
xbintsc help Show this message
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
-o, --output <path> Output path
|
|
25
|
+
--out <dir> Output directory (default: build/)
|
|
26
|
+
--emit <kind> exe | obj | ir (default: exe)
|
|
27
|
+
-O0..-O3 Optimization level (default: -O2)
|
|
28
|
+
--ext <names> Comma separated extensions (e.g. node,gui,media)
|
|
29
|
+
--ext-native <m> Register a C++/Rust extension from a JSON manifest
|
|
30
|
+
(comma separated for several)
|
|
31
|
+
--config <path> Use a project config (default: auto-detect
|
|
32
|
+
${CONFIG_FILE_NAME})
|
|
33
|
+
--no-config Do not read any project config
|
|
34
|
+
--icon <path> Embed an application icon (PNG/ICO/ICNS)
|
|
35
|
+
--bundle macOS: also produce a .app bundle
|
|
36
|
+
--app-name <name> Bundle / display name
|
|
37
|
+
--app-id <id> macOS bundle identifier (e.g. com.example.demo)
|
|
38
|
+
--force Ignore the incremental cache
|
|
39
|
+
--verbose Print progress information
|
|
40
|
+
--time Print per-phase build timings
|
|
41
|
+
--debug Emit debug info (DWARF/CodeView) and keep frame pointers
|
|
42
|
+
--check Run the semantic checker (default)
|
|
43
|
+
--no-check Skip the semantic checker; only erase type syntax
|
|
44
|
+
--lto Compile program and runtime to LTO bitcode; link with lld
|
|
45
|
+
--pgo-generate [dir] Build an instrumented binary writing profiles to dir
|
|
46
|
+
--pgo-use [dir] Build with the profiles collected from --pgo-generate
|
|
47
|
+
--json Print diagnostics as a JSON array on stdout
|
|
48
|
+
--no-hints Do not append the "hint: … see <doc>" line to failures
|
|
49
|
+
|
|
50
|
+
xbintsc compiles a subset of TypeScript to a native binary. Types are erased;
|
|
51
|
+
only inference-free facts (names, redeclarations, call arity) are checked.
|
|
52
|
+
Node built-ins need --ext node, packages in node_modules are bundled at build
|
|
53
|
+
time, and clang 16+ is required to link.
|
|
54
|
+
|
|
55
|
+
Installed as a project dependency (npm):
|
|
56
|
+
npx xbintsc doctor
|
|
57
|
+
npx xbintsc build <entry.ts> --out build
|
|
58
|
+
npx xbintsc run <entry.ts>
|
|
59
|
+
The first build compiles the C runtime; later builds reuse the cache.
|
|
60
|
+
|
|
61
|
+
Docs: doc/ai/README.md (task guide) - doc/ai/language-support.md (subset) -
|
|
62
|
+
doc/ai/troubleshooting.md (failures) - llms.txt (index of every document).
|
|
63
|
+
When installed from npm, these live under node_modules/xbintsc/doc/ and
|
|
64
|
+
node_modules/xbintsc/doc/npm-package.md is the project guide.
|
|
65
|
+
`;
|
package/src/cli/hints.ts
CHANGED
|
@@ -173,7 +173,8 @@ export function documentationFor(diagnostic: Diagnostic): DocumentationPointer |
|
|
|
173
173
|
path: "doc/unimplemented/modules.md",
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
/* TS3001/TS3002 also reach here through the generic subset hint above;
|
|
177
|
+
* every checker code is emitted now, so they all share this pointer. */
|
|
177
178
|
case DiagnosticCode.TypeMismatch:
|
|
178
179
|
case DiagnosticCode.NotCallable:
|
|
179
180
|
case DiagnosticCode.PropertyNotFound:
|
package/src/cli/main.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
type ProjectConfig,
|
|
45
45
|
} from "../driver/config.js";
|
|
46
46
|
import { fingerprintTree, startWatching } from "./watch.js";
|
|
47
|
+
import { HELP } from "./help.js";
|
|
47
48
|
|
|
48
49
|
/** Sentinel: watch mode keeps the process alive instead of exiting. */
|
|
49
50
|
const KEEP_RUNNING = -1;
|
|
@@ -238,51 +239,6 @@ function reportConfigError(error: string, io: CliIo): number {
|
|
|
238
239
|
return 1;
|
|
239
240
|
}
|
|
240
241
|
|
|
241
|
-
const HELP = `xbintsc ${COMPILER_VERSION} - TypeScript binary compiler
|
|
242
|
-
|
|
243
|
-
Usage:
|
|
244
|
-
xbintsc build <file.ts> [options] Compile to a native binary
|
|
245
|
-
xbintsc run <file.ts> [-- args] Compile and execute
|
|
246
|
-
xbintsc check <file.ts> Parse and bind without linking
|
|
247
|
-
xbintsc watch <file.ts> [options] Rebuild whenever the source tree changes
|
|
248
|
-
xbintsc emit <file.ts> Print LLVM IR
|
|
249
|
-
xbintsc doctor Report the resolved toolchain
|
|
250
|
-
xbintsc version Print the version
|
|
251
|
-
xbintsc help Show this message
|
|
252
|
-
|
|
253
|
-
Options:
|
|
254
|
-
-o, --output <path> Output path
|
|
255
|
-
--out <dir> Output directory (default: build/)
|
|
256
|
-
--emit <kind> exe | obj | ir (default: exe)
|
|
257
|
-
-O0..-O3 Optimization level (default: -O2)
|
|
258
|
-
--ext <names> Comma separated extensions (e.g. node,gui,media)
|
|
259
|
-
--ext-native <m> Register a C++/Rust extension from a JSON manifest
|
|
260
|
-
(comma separated for several)
|
|
261
|
-
--config <path> Use a project config (default: auto-detect
|
|
262
|
-
${CONFIG_FILE_NAME})
|
|
263
|
-
--no-config Do not read any project config
|
|
264
|
-
--icon <path> Embed an application icon (PNG/ICO/ICNS)
|
|
265
|
-
--bundle macOS: also produce a .app bundle
|
|
266
|
-
--app-name <name> Bundle / display name
|
|
267
|
-
--app-id <id> macOS bundle identifier (e.g. com.example.demo)
|
|
268
|
-
--force Ignore the incremental cache
|
|
269
|
-
--verbose Print progress information
|
|
270
|
-
--time Print per-phase build timings
|
|
271
|
-
--debug Emit debug info (DWARF/CodeView) and keep frame pointers
|
|
272
|
-
--lto Compile program and runtime to LTO bitcode; link with lld
|
|
273
|
-
--pgo-generate [dir] Build an instrumented binary writing profiles to dir
|
|
274
|
-
--pgo-use [dir] Build with the profiles collected from --pgo-generate
|
|
275
|
-
--json Print diagnostics as a JSON array on stdout
|
|
276
|
-
--no-hints Do not append the "hint: … see <doc>" line to failures
|
|
277
|
-
|
|
278
|
-
xbintsc compiles a subset of TypeScript to a native binary. Types are erased
|
|
279
|
-
(never checked), Node built-ins need --ext node, packages in node_modules are
|
|
280
|
-
bundled at build time, and clang 16+ is required to link.
|
|
281
|
-
|
|
282
|
-
Docs: doc/ai/README.md (task guide) - doc/ai/language-support.md (subset) -
|
|
283
|
-
doc/ai/troubleshooting.md (failures) - llms.txt (index of every document)
|
|
284
|
-
`;
|
|
285
|
-
|
|
286
242
|
/**
|
|
287
243
|
* Report the resolved toolchain and runtime locations.
|
|
288
244
|
*
|
|
@@ -445,9 +401,12 @@ function dispatch(argv: readonly string[], io: CliIo): number {
|
|
|
445
401
|
const extNames = listFlag(args.flags, "ext") ?? resolved.config.extensions ?? [];
|
|
446
402
|
const nativeManifests = listFlag(args.flags, "ext-native") ?? resolved.config.extNative ?? [];
|
|
447
403
|
const registry = buildRegistry(extNames, nativeManifests);
|
|
448
|
-
/* Front-end only: parse, bundle and lower far enough to report
|
|
449
|
-
* unsupported-feature diagnostics, but never invoke clang or
|
|
450
|
-
|
|
404
|
+
/* Front-end only: parse, bundle, check and lower far enough to report
|
|
405
|
+
* semantic / unsupported-feature diagnostics, but never invoke clang or
|
|
406
|
+
* write output. The checker is on unless `--no-check` is passed. */
|
|
407
|
+
const { diagnostics } = compileEntry(entry, registry, {
|
|
408
|
+
check: !args.flags.has("no-check"),
|
|
409
|
+
});
|
|
451
410
|
const failed = diagnostics.some((diagnostic) => diagnostic.category === "error");
|
|
452
411
|
if (args.flags.has("json")) {
|
|
453
412
|
io.stdout(`${JSON.stringify(diagnostics)}\n`);
|
|
@@ -496,7 +455,10 @@ function dispatch(argv: readonly string[], io: CliIo): number {
|
|
|
496
455
|
const extNames = listFlag(args.flags, "ext") ?? resolved.config.extensions ?? [];
|
|
497
456
|
const nativeManifests = listFlag(args.flags, "ext-native") ?? resolved.config.extNative ?? [];
|
|
498
457
|
const registry = buildRegistry(extNames, nativeManifests);
|
|
499
|
-
const { ir, diagnostics } = compileEntry(entry, registry, {
|
|
458
|
+
const { ir, diagnostics } = compileEntry(entry, registry, {
|
|
459
|
+
debug: Boolean(args.flags.get("debug")),
|
|
460
|
+
check: !args.flags.has("no-check"),
|
|
461
|
+
});
|
|
500
462
|
if (diagnostics.some((d) => d.category === "error")) {
|
|
501
463
|
if (args.flags.has("json")) {
|
|
502
464
|
io.stdout(`${JSON.stringify(diagnostics)}\n`);
|
|
@@ -554,6 +516,7 @@ function dispatch(argv: readonly string[], io: CliIo): number {
|
|
|
554
516
|
extensions: registry,
|
|
555
517
|
app: mergeAppConfig(args.flags, config),
|
|
556
518
|
debug: Boolean(args.flags.get("debug")),
|
|
519
|
+
check: !args.flags.has("no-check"),
|
|
557
520
|
lto: Boolean(args.flags.get("lto")) || config.lto === true,
|
|
558
521
|
...(pgo ? { pgo } : {}),
|
|
559
522
|
...(pgoDir ? { pgoDir } : {}),
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "../../../ast/nodes.js";
|
|
15
15
|
import { i64, numberLiteral, XT_TRUE, XT_UNDEFINED } from "../../values.js";
|
|
16
16
|
import { MATH_CONSTANTS, NAMESPACE_PROPERTIES, NUMBER_CONSTANTS, SYMBOL_WELL_KNOWN, TYPED_ARRAYS } from "../tables.js";
|
|
17
|
+
import { isSuperKeyword } from "./super.js";
|
|
17
18
|
import type { Generator } from "../generator.js";
|
|
18
19
|
|
|
19
20
|
export interface AccessCallMethods {
|
|
@@ -50,12 +51,8 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
50
51
|
},
|
|
51
52
|
|
|
52
53
|
emitPropertyAccess(node: PropertyAccessExpression): string {
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
const proto = this.reg();
|
|
56
|
-
this.emit(` ${proto} = call i64 @xt_object_get_prototype(i64 ${thisValue})`);
|
|
57
|
-
const parentProto = this.reg();
|
|
58
|
-
this.emit(` ${parentProto} = call i64 @xt_object_get_prototype(i64 ${proto})`);
|
|
54
|
+
if (isSuperKeyword(node.expression)) {
|
|
55
|
+
const parentProto = this.emitSuperHolder();
|
|
59
56
|
const key = this.stringValue(node.name.text);
|
|
60
57
|
const value = this.reg();
|
|
61
58
|
this.emit(` ${value} = call i64 @xt_get(i64 ${parentProto}, i64 ${key})`);
|
|
@@ -139,13 +136,16 @@ export const accessCallMethods: AccessCallMethods = {
|
|
|
139
136
|
},
|
|
140
137
|
|
|
141
138
|
emitElementAccess(node: ElementAccessExpression): string {
|
|
142
|
-
|
|
139
|
+
/* `super[key]` reads from the parent prototype (or the parent constructor
|
|
140
|
+
* inside a `static` method), not from the `super` keyword itself. */
|
|
141
|
+
const isSuper = isSuperKeyword(node.expression);
|
|
142
|
+
const object = isSuper ? this.emitSuperHolder() : this.emitExpression(node.expression);
|
|
143
143
|
const access = (): string => {
|
|
144
144
|
const key = this.emitExpression(node.argumentExpression);
|
|
145
145
|
const result = this.reg();
|
|
146
146
|
/* Array-index reads are not object property layouts, so skip the IC for
|
|
147
147
|
* a numeric literal; every other key may benefit from it. */
|
|
148
|
-
if (node.argumentExpression.kind === SyntaxKind.NumericLiteral) {
|
|
148
|
+
if (isSuper || node.argumentExpression.kind === SyntaxKind.NumericLiteral) {
|
|
149
149
|
this.emit(` ${result} = call i64 @xt_get(i64 ${object}, i64 ${key})`);
|
|
150
150
|
} else {
|
|
151
151
|
const cache = this.icCachePointer();
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
MATH_FUNCTIONS,
|
|
25
25
|
NAMESPACE_STATICS,
|
|
26
26
|
} from "../tables.js";
|
|
27
|
+
import { isSuperKeyword } from "./super.js";
|
|
27
28
|
import type { Generator } from "../generator.js";
|
|
28
29
|
|
|
29
30
|
export interface InvocationCallMethods {
|
|
@@ -72,9 +73,7 @@ export const invocationCallMethods: InvocationCallMethods = {
|
|
|
72
73
|
const access = callee as PropertyAccessExpression;
|
|
73
74
|
const special = this.tryEmitBuiltinCall(node, access);
|
|
74
75
|
if (special) return special;
|
|
75
|
-
if (access.expression
|
|
76
|
-
return this.emitSuperCall(node, access);
|
|
77
|
-
}
|
|
76
|
+
if (isSuperKeyword(access.expression)) return this.emitSuperCall(node, access);
|
|
78
77
|
const object = this.emitExpression(access.expression);
|
|
79
78
|
const name = this.stringValue(access.name.text);
|
|
80
79
|
const args = this.emitArguments(node.arguments);
|
|
@@ -84,6 +83,7 @@ export const invocationCallMethods: InvocationCallMethods = {
|
|
|
84
83
|
}
|
|
85
84
|
if (callee.kind === SyntaxKind.ElementAccessExpression) {
|
|
86
85
|
const access = callee as ElementAccessExpression;
|
|
86
|
+
if (isSuperKeyword(access.expression)) return this.emitSuperElementCall(node, access);
|
|
87
87
|
const object = this.emitExpression(access.expression);
|
|
88
88
|
const name = this.emitExpression(access.argumentExpression);
|
|
89
89
|
const args = this.emitArguments(node.arguments);
|
|
@@ -111,8 +111,11 @@ export const invocationCallMethods: InvocationCallMethods = {
|
|
|
111
111
|
const fn = declaration ? this.binding.functionOfNode.get(declaration) : undefined;
|
|
112
112
|
/* Generator and `async` functions are not called directly: the call
|
|
113
113
|
* must create a suspended generator / start a coroutine, so fall
|
|
114
|
-
* through to the closure-call path.
|
|
115
|
-
|
|
114
|
+
* through to the closure-call path. The same applies to a function that
|
|
115
|
+
* captures outer bindings (or `this`): the direct call passes no
|
|
116
|
+
* environment, so its free variables would read `undefined` and writes
|
|
117
|
+
* to them would be lost. */
|
|
118
|
+
if (fn && !fn.isGenerator && !fn.isAsync && fn.captures.length === 0 && !fn.capturesThis) {
|
|
116
119
|
const args = this.emitArguments(node.arguments);
|
|
117
120
|
const result = this.reg();
|
|
118
121
|
this.emit(
|
|
@@ -3,14 +3,29 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
SyntaxKind,
|
|
6
7
|
type CallExpression,
|
|
8
|
+
type ElementAccessExpression,
|
|
9
|
+
type Expression,
|
|
10
|
+
type Identifier,
|
|
7
11
|
type PropertyAccessExpression,
|
|
8
12
|
} from "../../../ast/nodes.js";
|
|
9
13
|
import type { Generator } from "../generator.js";
|
|
10
14
|
|
|
15
|
+
/** True when `node` is the `super` keyword (it never binds to a symbol). */
|
|
16
|
+
export function isSuperKeyword(node: Expression): boolean {
|
|
17
|
+
return node.kind === SyntaxKind.Identifier && (node as Identifier).text === "super";
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
export interface SuperCallMethods {
|
|
12
21
|
emitSuperConstructor(this: Generator, node: CallExpression): string;
|
|
13
22
|
emitSuperCall(this: Generator, node: CallExpression, access: PropertyAccessExpression): string;
|
|
23
|
+
/** `super[key](...)`: look the method up on the parent holder and call it
|
|
24
|
+
* with the current `this`. */
|
|
25
|
+
emitSuperElementCall(this: Generator, node: CallExpression, access: ElementAccessExpression): string;
|
|
26
|
+
/** The object `super.x` reads from: the parent prototype for an instance
|
|
27
|
+
* method, the parent constructor for a `static` method or static block. */
|
|
28
|
+
emitSuperHolder(this: Generator): string;
|
|
14
29
|
}
|
|
15
30
|
|
|
16
31
|
export const superCallMethods: SuperCallMethods = {
|
|
@@ -28,8 +43,16 @@ export const superCallMethods: SuperCallMethods = {
|
|
|
28
43
|
);
|
|
29
44
|
return result;
|
|
30
45
|
}
|
|
46
|
+
/* The parent prototype is decided by the *class* whose constructor is
|
|
47
|
+
* running, never by walking `this`: an instance of a subclass sits at the
|
|
48
|
+
* bottom of a longer chain, so `getPrototype(getPrototype(this))` from a
|
|
49
|
+
* base constructor resolves to that very class again (`C extends B extends
|
|
50
|
+
* A`: inside `B`, the walk answers `B.prototype`) and `super()` recurses
|
|
51
|
+
* forever. `getPrototype(getPrototype(C))` is `C.prototype`'s parent, which
|
|
52
|
+
* is what the heritage clause installed. */
|
|
53
|
+
const owner = classInfo ? this.emitClassReference(classInfo) : thisValue;
|
|
31
54
|
const proto = this.reg();
|
|
32
|
-
this.emit(` ${proto} = call i64 @
|
|
55
|
+
this.emit(` ${proto} = call i64 @xt_function_get_prototype(i64 ${owner})`);
|
|
33
56
|
const parentProto = this.reg();
|
|
34
57
|
this.emit(` ${parentProto} = call i64 @xt_object_get_prototype(i64 ${proto})`);
|
|
35
58
|
const key = this.stringValue("__ctor");
|
|
@@ -43,10 +66,7 @@ export const superCallMethods: SuperCallMethods = {
|
|
|
43
66
|
|
|
44
67
|
emitSuperCall(node: CallExpression, access: PropertyAccessExpression): string {
|
|
45
68
|
const thisValue = this.emitThis();
|
|
46
|
-
const
|
|
47
|
-
this.emit(` ${proto} = call i64 @xt_object_get_prototype(i64 ${thisValue})`);
|
|
48
|
-
const parentProto = this.reg();
|
|
49
|
-
this.emit(` ${parentProto} = call i64 @xt_object_get_prototype(i64 ${proto})`);
|
|
69
|
+
const parentProto = this.emitSuperHolder();
|
|
50
70
|
const key = this.stringValue(access.name.text);
|
|
51
71
|
const method = this.reg();
|
|
52
72
|
this.emit(` ${method} = call i64 @xt_get(i64 ${parentProto}, i64 ${key})`);
|
|
@@ -55,4 +75,46 @@ export const superCallMethods: SuperCallMethods = {
|
|
|
55
75
|
this.emit(` ${result} = call i64 @xt_call_with_this(i64 ${method}, i64 ${thisValue}, i32 ${args.argc}, i64* ${args.ptr})`);
|
|
56
76
|
return result;
|
|
57
77
|
},
|
|
78
|
+
|
|
79
|
+
emitSuperElementCall(node: CallExpression, access: ElementAccessExpression): string {
|
|
80
|
+
const thisValue = this.emitThis();
|
|
81
|
+
const parentProto = this.emitSuperHolder();
|
|
82
|
+
const key = this.emitExpression(access.argumentExpression);
|
|
83
|
+
const method = this.reg();
|
|
84
|
+
this.emit(` ${method} = call i64 @xt_get(i64 ${parentProto}, i64 ${key})`);
|
|
85
|
+
const args = this.emitArguments(node.arguments);
|
|
86
|
+
const result = this.reg();
|
|
87
|
+
this.emit(` ${result} = call i64 @xt_call_with_this(i64 ${method}, i64 ${thisValue}, i32 ${args.argc}, i64* ${args.ptr})`);
|
|
88
|
+
return result;
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
emitSuperHolder(): string {
|
|
92
|
+
/* Same reasoning as `emitSuperConstructor`: the holder is a property of the
|
|
93
|
+
* *class*, not of the receiver. Walking `this` would resolve `super.foo()`
|
|
94
|
+
* inside a base method to the receiver's own prototype, so a subclass
|
|
95
|
+
* instance would call the override it was trying to bypass. */
|
|
96
|
+
const classInfo = this.current.fn.classInfo;
|
|
97
|
+
if (classInfo) {
|
|
98
|
+
const owner = this.emitClassReference(classInfo);
|
|
99
|
+
/* A static context has the constructor as `this`, and its own prototype
|
|
100
|
+
* already is the parent constructor (static inheritance). */
|
|
101
|
+
if (this.current.fn.isStatic) {
|
|
102
|
+
const parentCtor = this.reg();
|
|
103
|
+
this.emit(` ${parentCtor} = call i64 @xt_object_get_prototype(i64 ${owner})`);
|
|
104
|
+
return parentCtor;
|
|
105
|
+
}
|
|
106
|
+
const ownProto = this.reg();
|
|
107
|
+
this.emit(` ${ownProto} = call i64 @xt_function_get_prototype(i64 ${owner})`);
|
|
108
|
+
const parentProto = this.reg();
|
|
109
|
+
this.emit(` ${parentProto} = call i64 @xt_object_get_prototype(i64 ${ownProto})`);
|
|
110
|
+
return parentProto;
|
|
111
|
+
}
|
|
112
|
+
const thisValue = this.emitThis();
|
|
113
|
+
const holder = this.reg();
|
|
114
|
+
this.emit(` ${holder} = call i64 @xt_object_get_prototype(i64 ${thisValue})`);
|
|
115
|
+
if (this.current.fn.isStatic) return holder;
|
|
116
|
+
const parentProto = this.reg();
|
|
117
|
+
this.emit(` ${parentProto} = call i64 @xt_object_get_prototype(i64 ${holder})`);
|
|
118
|
+
return parentProto;
|
|
119
|
+
},
|
|
58
120
|
};
|
|
@@ -14,6 +14,7 @@ import { i64, XT_UNDEFINED } from "../values.js";
|
|
|
14
14
|
import type {
|
|
15
15
|
BuiltinFunction,
|
|
16
16
|
ExtensionModule,
|
|
17
|
+
GlobalValue,
|
|
17
18
|
ModuleExport,
|
|
18
19
|
ModuleExports,
|
|
19
20
|
} from "../../extensions/registry.js";
|
|
@@ -25,6 +26,8 @@ export class GeneratorContext {
|
|
|
25
26
|
readonly sourceFile: SourceFileNode;
|
|
26
27
|
readonly diagnostics: DiagnosticBag;
|
|
27
28
|
readonly builtins: Readonly<Record<string, BuiltinFunction>>;
|
|
29
|
+
/** Extension-provided global values, read through a nullary runtime getter. */
|
|
30
|
+
readonly globalValues: Readonly<Record<string, GlobalValue>>;
|
|
28
31
|
readonly modules: Readonly<Record<string, ExtensionModule>>;
|
|
29
32
|
/** Module specifier -> extension name for known but unregistered extensions. */
|
|
30
33
|
readonly moduleHints: Readonly<Record<string, string>>;
|
|
@@ -85,17 +88,31 @@ export class GeneratorContext {
|
|
|
85
88
|
debugUnit?: string;
|
|
86
89
|
debugFlags: string[] = [];
|
|
87
90
|
debugSubroutineType?: string;
|
|
91
|
+
/** True when the checker already reported unresolved names (see `generate`). */
|
|
92
|
+
readonly check: boolean;
|
|
88
93
|
current!: FunctionState;
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
/**
|
|
96
|
+
* `binding` is passed by `generate`, which binds once and runs the checker on
|
|
97
|
+
* the same symbol table. It stays optional so a direct construction still
|
|
98
|
+
* works for tests and embedders.
|
|
99
|
+
*/
|
|
100
|
+
constructor(
|
|
101
|
+
sourceFile: SourceFileNode,
|
|
102
|
+
diagnostics: DiagnosticBag,
|
|
103
|
+
options: CodegenOptions = {},
|
|
104
|
+
binding?: BindResult,
|
|
105
|
+
) {
|
|
91
106
|
this.sourceFile = sourceFile;
|
|
92
107
|
this.diagnostics = diagnostics;
|
|
93
|
-
this.binding = bind(sourceFile);
|
|
108
|
+
this.binding = binding ?? bind(sourceFile);
|
|
94
109
|
this.builtins = options.builtins ?? {};
|
|
110
|
+
this.globalValues = options.globalValues ?? {};
|
|
95
111
|
this.modules = options.modules ?? {};
|
|
96
112
|
this.moduleHints = options.moduleHints ?? {};
|
|
97
113
|
this.target = options.target ?? { platform: process.platform, arch: process.arch };
|
|
98
114
|
this.debug = options.debug === true;
|
|
115
|
+
this.check = options.check !== false;
|
|
99
116
|
this.resolveImports();
|
|
100
117
|
}
|
|
101
118
|
|
|
@@ -346,31 +363,30 @@ export class GeneratorContext {
|
|
|
346
363
|
declareSlot(symbol: SymbolInfo, initial: string): void {
|
|
347
364
|
const globalName = this.moduleGlobals.get(symbol.id);
|
|
348
365
|
if (globalName) {
|
|
366
|
+
let boxed = initial;
|
|
349
367
|
if (symbol.boxed) {
|
|
350
|
-
|
|
351
|
-
this.emit(` ${
|
|
352
|
-
this.emit(` store i64 ${box}, i64* ${globalName}`);
|
|
353
|
-
} else {
|
|
354
|
-
this.emit(` store i64 ${initial}, i64* ${globalName}`);
|
|
368
|
+
boxed = this.reg();
|
|
369
|
+
this.emit(` ${boxed} = call i64 @xt_box_new(i64 ${initial})`);
|
|
355
370
|
}
|
|
371
|
+
this.emit(` store i64 ${boxed}, i64* ${globalName}`);
|
|
356
372
|
this.current.slots.set(symbol.id, { ptr: globalName, boxed: symbol.boxed });
|
|
357
373
|
return;
|
|
358
374
|
}
|
|
359
375
|
const ptr = this.alloca();
|
|
376
|
+
let stored = initial;
|
|
360
377
|
if (symbol.boxed) {
|
|
361
|
-
|
|
362
|
-
this.emit(` ${
|
|
363
|
-
this.emit(` store i64 ${box}, i64* ${ptr}`);
|
|
364
|
-
} else {
|
|
365
|
-
this.emit(` store i64 ${initial}, i64* ${ptr}`);
|
|
378
|
+
stored = this.reg();
|
|
379
|
+
this.emit(` ${stored} = call i64 @xt_box_new(i64 ${initial})`);
|
|
366
380
|
}
|
|
381
|
+
this.emit(` store i64 ${stored}, i64* ${ptr}`);
|
|
367
382
|
this.current.slots.set(symbol.id, { ptr, boxed: symbol.boxed });
|
|
368
383
|
}
|
|
369
384
|
|
|
385
|
+
/** Bind a capture: the environment carries the symbol's box, so reads and
|
|
386
|
+
* writes inside the closure see the enclosing binding. */
|
|
370
387
|
defineCaptureSlot(symbol: SymbolInfo, box: string): void {
|
|
371
388
|
const ptr = this.alloca();
|
|
372
389
|
this.emit(` store i64 ${box}, i64* ${ptr}`);
|
|
373
|
-
// A captured symbol is always boxed; the environment holds the box.
|
|
374
390
|
this.current.slots.set(symbol.id, { ptr, boxed: true });
|
|
375
391
|
}
|
|
376
392
|
|
|
@@ -577,10 +593,6 @@ function requireSpecifier(node: Node): string | undefined {
|
|
|
577
593
|
|
|
578
594
|
/** A bare module specifier (`fs`, `node:fs`, `@scope/pkg`), not a file path. */
|
|
579
595
|
function isBareSpecifier(specifier: string): boolean {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
!specifier.startsWith("/") &&
|
|
583
|
-
!specifier.startsWith("\\") &&
|
|
584
|
-
!/^[A-Za-z]:[\\/]/.test(specifier)
|
|
585
|
-
);
|
|
596
|
+
const relative = [".", "/", "\\"].some((prefix) => specifier.startsWith(prefix));
|
|
597
|
+
return !relative && !/^[A-Za-z]:[\\/]/.test(specifier);
|
|
586
598
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import type { Node } from "../../ast/nodes.js";
|
|
14
14
|
import type { FunctionInfo } from "../../binder/binder.js";
|
|
15
|
+
import { artifactPath } from "../../canonical.js";
|
|
15
16
|
import { escapeBytes, utf8Bytes } from "./tables.js";
|
|
16
17
|
import type { Generator } from "./generator.js";
|
|
17
18
|
|
|
@@ -71,7 +72,7 @@ export const debugMethods: DebugMethods = {
|
|
|
71
72
|
},
|
|
72
73
|
|
|
73
74
|
debugFileFor(fileName) {
|
|
74
|
-
const normalized = fileName
|
|
75
|
+
const normalized = artifactPath(fileName);
|
|
75
76
|
const existing = this.debugFiles.get(normalized);
|
|
76
77
|
if (existing) return existing;
|
|
77
78
|
const slash = normalized.lastIndexOf("/");
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
type PostfixUnaryExpression,
|
|
21
21
|
type PrefixUnaryExpression,
|
|
22
22
|
type PropertyAccessExpression,
|
|
23
|
+
type SequenceExpression,
|
|
23
24
|
type TaggedTemplateExpression,
|
|
24
25
|
type TemplateLiteral,
|
|
25
26
|
type YieldExpression,
|
|
@@ -28,12 +29,20 @@ import {
|
|
|
28
29
|
import { SymbolKind, type SymbolInfo } from "../../../binder/binder.js";
|
|
29
30
|
import { DiagnosticCode } from "../../../diagnostics/diagnostic.js";
|
|
30
31
|
import { i64, numberLiteral, XT_FALSE, XT_NULL, XT_TRUE, XT_UNDEFINED } from "../../values.js";
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
BUILTIN_FUNCTION_VALUES,
|
|
34
|
+
CTOR_FUNCTIONS,
|
|
35
|
+
ERROR_CONSTRUCTORS,
|
|
36
|
+
FIRST_CLASS_CONSTRUCTORS,
|
|
37
|
+
NAMESPACE_VALUES,
|
|
38
|
+
} from "../tables.js";
|
|
39
|
+
import type { GlobalValue } from "../../../extensions/registry.js";
|
|
32
40
|
import type { Generator } from "../generator.js";
|
|
33
41
|
|
|
34
42
|
export interface PrimaryExpressionMethods {
|
|
35
43
|
emitExpression(this: Generator, node: Expression): string;
|
|
36
44
|
emitIdentifier(this: Generator, identifier: Identifier): string;
|
|
45
|
+
emitGlobalValue(this: Generator, value: GlobalValue): string;
|
|
37
46
|
emitFunctionValue(this: Generator, symbol: SymbolInfo): string;
|
|
38
47
|
emitTemplate(this: Generator, node: TemplateLiteral): string;
|
|
39
48
|
emitTaggedTemplate(this: Generator, node: TaggedTemplateExpression): string;
|
|
@@ -41,6 +50,7 @@ export interface PrimaryExpressionMethods {
|
|
|
41
50
|
emitNew(this: Generator, node: NewExpression): string;
|
|
42
51
|
emitAwait(this: Generator, node: AwaitExpression): string;
|
|
43
52
|
emitYield(this: Generator, node: YieldExpression): string;
|
|
53
|
+
emitSequence(this: Generator, node: SequenceExpression): string;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
export const primaryExpressionMethods: PrimaryExpressionMethods = {
|
|
@@ -135,6 +145,8 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
|
|
|
135
145
|
return this.emitPostfix(node as PostfixUnaryExpression);
|
|
136
146
|
case SyntaxKind.ConditionalExpression:
|
|
137
147
|
return this.emitConditional(node as ConditionalExpression);
|
|
148
|
+
case SyntaxKind.SequenceExpression:
|
|
149
|
+
return this.emitSequence(node as SequenceExpression);
|
|
138
150
|
case SyntaxKind.CallExpression:
|
|
139
151
|
return this.emitCall(node as CallExpression);
|
|
140
152
|
case SyntaxKind.PropertyAccessExpression:
|
|
@@ -218,6 +230,21 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
|
|
|
218
230
|
return rest;
|
|
219
231
|
}
|
|
220
232
|
default: {
|
|
233
|
+
const namespaceValue = NAMESPACE_VALUES[identifier.text];
|
|
234
|
+
if (namespaceValue) {
|
|
235
|
+
/* `Math` is a namespace at call sites (`Math.max(a, b)` becomes
|
|
236
|
+
* `xt_math_call`) and an object as a value: `const cos = Math.cos`,
|
|
237
|
+
* `const { sqrt, PI } = Math`. */
|
|
238
|
+
this.extraDeclarations.add(`declare i64 @${namespaceValue}(i32, i64*)`);
|
|
239
|
+
const result = this.reg();
|
|
240
|
+
this.emit(` ${result} = call i64 @${namespaceValue}(i32 0, i64* null)`);
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
const extensionGlobal = this.globalValues[identifier.text];
|
|
244
|
+
if (extensionGlobal) {
|
|
245
|
+
// `window`, `document`, `AudioContext`: a host-provided global value.
|
|
246
|
+
return this.emitGlobalValue(extensionGlobal);
|
|
247
|
+
}
|
|
221
248
|
if (FIRST_CLASS_CONSTRUCTORS.has(identifier.text)) {
|
|
222
249
|
// `const A = Array`, `arr.filter(Boolean)`, `new (Map)()`: the
|
|
223
250
|
// constructor is an ordinary function value backed by the runtime.
|
|
@@ -249,27 +276,56 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
|
|
|
249
276
|
* error has already been reported; "Cannot find name '<error>'" is
|
|
250
277
|
* pure noise on top of it. */
|
|
251
278
|
if (identifier.text === "<error>") return i64(XT_UNDEFINED);
|
|
252
|
-
this
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.
|
|
257
|
-
|
|
279
|
+
/* The checker runs before code generation and owns this diagnostic
|
|
280
|
+
* (including the "is it a runtime global?" decision). Keeping the
|
|
281
|
+
* fallback for `--no-check` avoids reporting the same name twice. */
|
|
282
|
+
if (!this.check) {
|
|
283
|
+
this.diagnostics.error(
|
|
284
|
+
DiagnosticCode.CannotFindName,
|
|
285
|
+
`Cannot find name '${identifier.text}'`,
|
|
286
|
+
identifier,
|
|
287
|
+
this.fileNameOf(identifier),
|
|
288
|
+
);
|
|
289
|
+
}
|
|
258
290
|
return i64(XT_UNDEFINED);
|
|
259
291
|
}
|
|
260
292
|
}
|
|
261
293
|
},
|
|
262
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Read an extension-provided global (`window`, `document`, `new Image()`).
|
|
297
|
+
* The getter is a normal runtime call with the uniform ABI; the optional
|
|
298
|
+
* argument is how one getter serves a whole family of host types.
|
|
299
|
+
*/
|
|
300
|
+
emitGlobalValue(value: GlobalValue): string {
|
|
301
|
+
this.extraDeclarations.add(`declare i64 @${value.symbol}(i32, i64*)`);
|
|
302
|
+
let argc = "0";
|
|
303
|
+
let pointer = "i64* null";
|
|
304
|
+
if (value.argument !== undefined) {
|
|
305
|
+
const argument = this.stringValue(value.argument);
|
|
306
|
+
const slot = `%gval${this.current.allocas.length}`;
|
|
307
|
+
this.current.allocas.push(`${slot} = alloca i64, i32 1`);
|
|
308
|
+
const cell = this.reg();
|
|
309
|
+
this.emit(` ${cell} = getelementptr i64, i64* ${slot}, i32 0`);
|
|
310
|
+
this.emit(` store i64 ${argument}, i64* ${cell}`);
|
|
311
|
+
argc = "1";
|
|
312
|
+
pointer = `i64* ${slot}`;
|
|
313
|
+
}
|
|
314
|
+
const result = this.reg();
|
|
315
|
+
this.emit(` ${result} = call i64 @${value.symbol}(i32 ${argc}, ${pointer})`);
|
|
316
|
+
return result;
|
|
317
|
+
},
|
|
318
|
+
|
|
263
319
|
emitFunctionValue(symbol: SymbolInfo): string {
|
|
264
320
|
const declaration = symbol.declarations[0];
|
|
265
321
|
const fn = declaration ? this.binding.functionOfNode.get(declaration) : undefined;
|
|
266
322
|
if (!fn) return i64(XT_UNDEFINED);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return
|
|
323
|
+
/* A declared function is a value like any closure: it captures the outer
|
|
324
|
+
* bindings its body mentions, so build the environment instead of calling
|
|
325
|
+
* `xt_closure_new` with a null one. A null environment silently turns every
|
|
326
|
+
* free variable into `undefined` and drops the writes back to the box
|
|
327
|
+
* (`function bump() { count += 1 }` never advanced `count`). */
|
|
328
|
+
return this.emitClosureValue(fn);
|
|
273
329
|
},
|
|
274
330
|
|
|
275
331
|
emitThis(): string {
|
|
@@ -299,6 +355,13 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
|
|
|
299
355
|
return result;
|
|
300
356
|
},
|
|
301
357
|
|
|
358
|
+
/** `a, b, c`: evaluate in order for their side effects, yield the last. */
|
|
359
|
+
emitSequence(node: SequenceExpression): string {
|
|
360
|
+
let value = i64(XT_UNDEFINED);
|
|
361
|
+
for (const expression of node.expressions) value = this.emitExpression(expression);
|
|
362
|
+
return value;
|
|
363
|
+
},
|
|
364
|
+
|
|
302
365
|
emitNew(node: NewExpression): string {
|
|
303
366
|
const callee = node.expression;
|
|
304
367
|
// A `new` expression is where the innermost frame's line should point for
|
|
@@ -326,6 +389,14 @@ export const primaryExpressionMethods: PrimaryExpressionMethods = {
|
|
|
326
389
|
this.emit(` ${result} = call i64 @${ctor}(i32 ${args.argc}, i64* ${args.ptr})`);
|
|
327
390
|
return result;
|
|
328
391
|
}
|
|
392
|
+
const extensionConstructor = this.globalValues[identifier.text];
|
|
393
|
+
if (extensionConstructor) {
|
|
394
|
+
const ctorValue = this.emitGlobalValue(extensionConstructor);
|
|
395
|
+
const args = this.emitArguments(node.arguments);
|
|
396
|
+
const result = this.reg();
|
|
397
|
+
this.emit(` ${result} = call i64 @xt_new(i64 ${ctorValue}, i32 ${args.argc}, i64* ${args.ptr})`);
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
329
400
|
if (identifier.text === "Object") {
|
|
330
401
|
if (node.arguments.length > 0) return this.emitExpression(node.arguments[0]!);
|
|
331
402
|
return this.runtimeCall("xt_object_new", []);
|