semantifold 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -15
- package/build/index.d.ts +52 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +60 -8
- package/build/src/artifact-path.d.ts +23 -1
- package/build/src/artifact-path.d.ts.map +1 -1
- package/build/src/artifact-path.js +45 -3
- package/build/src/artifacts.d.ts.map +1 -1
- package/build/src/artifacts.js +66 -1
- package/build/src/backends/android.d.ts +49 -0
- package/build/src/backends/android.d.ts.map +1 -0
- package/build/src/backends/android.js +1274 -0
- package/build/src/backends/c-validation.d.ts.map +1 -1
- package/build/src/backends/c-validation.js +7 -3
- package/build/src/backends/cpp-validation.d.ts.map +1 -1
- package/build/src/backends/cpp-validation.js +7 -3
- package/build/src/backends/csharp.js +7 -1
- package/build/src/backends/dart-runtime.d.ts +2 -0
- package/build/src/backends/dart-runtime.d.ts.map +1 -0
- package/build/src/backends/dart-runtime.js +41 -0
- package/build/src/backends/dart.d.ts +20 -0
- package/build/src/backends/dart.d.ts.map +1 -0
- package/build/src/backends/dart.js +321 -0
- package/build/src/backends/effects.d.ts +60 -0
- package/build/src/backends/effects.d.ts.map +1 -0
- package/build/src/backends/effects.js +746 -0
- package/build/src/backends/go.js +18 -4
- package/build/src/backends/identifiers.d.ts +36 -4
- package/build/src/backends/identifiers.d.ts.map +1 -1
- package/build/src/backends/identifiers.js +160 -10
- package/build/src/backends/index.d.ts.map +1 -1
- package/build/src/backends/index.js +27 -4
- package/build/src/backends/ios.d.ts +68 -0
- package/build/src/backends/ios.d.ts.map +1 -0
- package/build/src/backends/ios.js +1503 -0
- package/build/src/backends/java.d.ts.map +1 -1
- package/build/src/backends/java.js +429 -36
- package/build/src/backends/javascript.d.ts +6 -0
- package/build/src/backends/javascript.d.ts.map +1 -1
- package/build/src/backends/javascript.js +380 -24
- package/build/src/backends/kotlin-runtime.d.ts +3 -0
- package/build/src/backends/kotlin-runtime.d.ts.map +1 -0
- package/build/src/backends/kotlin-runtime.js +29 -0
- package/build/src/backends/kotlin.d.ts +33 -0
- package/build/src/backends/kotlin.d.ts.map +1 -0
- package/build/src/backends/kotlin.js +138 -0
- package/build/src/backends/native-validation.d.ts +2 -2
- package/build/src/backends/native-validation.d.ts.map +1 -1
- package/build/src/backends/native-validation.js +2 -2
- package/build/src/backends/ordered-expressions.d.ts.map +1 -1
- package/build/src/backends/ordered-expressions.js +39 -7
- package/build/src/backends/php-stdlib-support.d.ts +19 -0
- package/build/src/backends/php-stdlib-support.d.ts.map +1 -0
- package/build/src/backends/php-stdlib-support.js +227 -0
- package/build/src/backends/php.d.ts.map +1 -1
- package/build/src/backends/php.js +448 -33
- package/build/src/backends/program.d.ts +83 -0
- package/build/src/backends/program.d.ts.map +1 -0
- package/build/src/backends/program.js +1309 -0
- package/build/src/backends/python.js +7 -1
- package/build/src/backends/ruby.d.ts.map +1 -1
- package/build/src/backends/ruby.js +310 -24
- package/build/src/backends/rust-runtime.d.ts +7 -0
- package/build/src/backends/rust-runtime.d.ts.map +1 -0
- package/build/src/backends/rust-runtime.js +32 -0
- package/build/src/backends/rust-validation.d.ts +9 -0
- package/build/src/backends/rust-validation.d.ts.map +1 -0
- package/build/src/backends/rust-validation.js +78 -0
- package/build/src/backends/rust.d.ts +24 -0
- package/build/src/backends/rust.d.ts.map +1 -0
- package/build/src/backends/rust.js +344 -0
- package/build/src/backends/scalars.d.ts +14 -6
- package/build/src/backends/scalars.d.ts.map +1 -1
- package/build/src/backends/scalars.js +167 -17
- package/build/src/backends/shared.d.ts +23 -4
- package/build/src/backends/shared.d.ts.map +1 -1
- package/build/src/backends/shared.js +2174 -62
- package/build/src/backends/stdlib-support.d.ts +14 -0
- package/build/src/backends/stdlib-support.d.ts.map +1 -0
- package/build/src/backends/stdlib-support.js +237 -0
- package/build/src/backends/swift-runtime.d.ts +3 -0
- package/build/src/backends/swift-runtime.d.ts.map +1 -0
- package/build/src/backends/swift-runtime.js +14 -0
- package/build/src/backends/swift.d.ts +8 -0
- package/build/src/backends/swift.d.ts.map +1 -0
- package/build/src/backends/swift.js +127 -0
- package/build/src/backends/typescript.d.ts.map +1 -1
- package/build/src/backends/typescript.js +344 -24
- package/build/src/backends/wasm.d.ts +43 -0
- package/build/src/backends/wasm.d.ts.map +1 -0
- package/build/src/backends/wasm.js +2164 -0
- package/build/src/backends/writer.d.ts +255 -4
- package/build/src/backends/writer.d.ts.map +1 -1
- package/build/src/backends/writer.js +491 -3
- package/build/src/diagnostic.d.ts +4 -3
- package/build/src/diagnostic.d.ts.map +1 -1
- package/build/src/diagnostic.js +5 -3
- package/build/src/frontends/c.d.ts.map +1 -1
- package/build/src/frontends/c.js +5 -3
- package/build/src/frontends/cpp.d.ts.map +1 -1
- package/build/src/frontends/cpp.js +5 -3
- package/build/src/frontends/csharp.d.ts.map +1 -1
- package/build/src/frontends/csharp.js +7 -3
- package/build/src/frontends/dart.d.ts +10 -0
- package/build/src/frontends/dart.d.ts.map +1 -0
- package/build/src/frontends/dart.js +913 -0
- package/build/src/frontends/index.d.ts +3 -1
- package/build/src/frontends/index.d.ts.map +1 -1
- package/build/src/frontends/index.js +15 -5
- package/build/src/frontends/java.d.ts +110 -1
- package/build/src/frontends/java.d.ts.map +1 -1
- package/build/src/frontends/java.js +1725 -70
- package/build/src/frontends/javascript-typescript.d.ts +69 -1
- package/build/src/frontends/javascript-typescript.d.ts.map +1 -1
- package/build/src/frontends/javascript-typescript.js +1825 -93
- package/build/src/frontends/kotlin.d.ts +10 -0
- package/build/src/frontends/kotlin.d.ts.map +1 -0
- package/build/src/frontends/kotlin.js +685 -0
- package/build/src/frontends/php.d.ts +118 -1
- package/build/src/frontends/php.d.ts.map +1 -1
- package/build/src/frontends/php.js +1583 -76
- package/build/src/frontends/program.d.ts +74 -0
- package/build/src/frontends/program.d.ts.map +1 -0
- package/build/src/frontends/program.js +989 -0
- package/build/src/frontends/ruby.d.ts +68 -1
- package/build/src/frontends/ruby.d.ts.map +1 -1
- package/build/src/frontends/ruby.js +1446 -101
- package/build/src/frontends/rust-parser.d.ts +11 -0
- package/build/src/frontends/rust-parser.d.ts.map +1 -0
- package/build/src/frontends/rust-parser.js +15 -0
- package/build/src/frontends/rust.d.ts +14 -0
- package/build/src/frontends/rust.d.ts.map +1 -0
- package/build/src/frontends/rust.js +715 -0
- package/build/src/frontends/scalars.d.ts +10 -0
- package/build/src/frontends/scalars.d.ts.map +1 -1
- package/build/src/frontends/scalars.js +28 -2
- package/build/src/frontends/swift.d.ts +10 -0
- package/build/src/frontends/swift.d.ts.map +1 -0
- package/build/src/frontends/swift.js +860 -0
- package/build/src/frontends/types.d.ts +186 -0
- package/build/src/frontends/types.d.ts.map +1 -0
- package/build/src/frontends/types.js +634 -0
- package/build/src/language-registry.d.ts +46 -4
- package/build/src/language-registry.d.ts.map +1 -1
- package/build/src/language-registry.js +177 -13
- package/build/src/mapping.d.ts +2 -2
- package/build/src/mapping.d.ts.map +1 -1
- package/build/src/mapping.js +31 -10
- package/build/src/semantic/capabilities.d.ts +66 -0
- package/build/src/semantic/capabilities.d.ts.map +1 -0
- package/build/src/semantic/capabilities.js +649 -0
- package/build/src/semantic/effects.d.ts +26 -0
- package/build/src/semantic/effects.d.ts.map +1 -0
- package/build/src/semantic/effects.js +764 -0
- package/build/src/semantic/generics.d.ts +23 -0
- package/build/src/semantic/generics.d.ts.map +1 -0
- package/build/src/semantic/generics.js +61 -0
- package/build/src/semantic/lifetime.d.ts +37 -0
- package/build/src/semantic/lifetime.d.ts.map +1 -0
- package/build/src/semantic/lifetime.js +527 -0
- package/build/src/semantic/provenance.d.ts +9 -2
- package/build/src/semantic/provenance.d.ts.map +1 -1
- package/build/src/semantic/provenance.js +462 -20
- package/build/src/semantic/scalars.d.ts +11 -0
- package/build/src/semantic/scalars.d.ts.map +1 -1
- package/build/src/semantic/scalars.js +16 -1
- package/build/src/semantic/stdlib.d.ts +254 -0
- package/build/src/semantic/stdlib.d.ts.map +1 -0
- package/build/src/semantic/stdlib.js +880 -0
- package/build/src/semantic/types.d.ts +3108 -178
- package/build/src/semantic/types.d.ts.map +1 -1
- package/build/src/semantic/types.js +730 -15
- package/build/src/semantic/validate.d.ts +85 -5
- package/build/src/semantic/validate.d.ts.map +1 -1
- package/build/src/semantic/validate.js +2576 -98
- package/build/src/stdlib-facades.d.ts +304 -0
- package/build/src/stdlib-facades.d.ts.map +1 -0
- package/build/src/stdlib-facades.js +1167 -0
- package/build/src/stdlib-negotiation.d.ts +69 -0
- package/build/src/stdlib-negotiation.d.ts.map +1 -0
- package/build/src/stdlib-negotiation.js +403 -0
- package/build/src/stdlib-providers.d.ts +72 -0
- package/build/src/stdlib-providers.d.ts.map +1 -0
- package/build/src/stdlib-providers.js +339 -0
- package/build/src/toolchains.d.ts +55 -1
- package/build/src/toolchains.d.ts.map +1 -1
- package/build/src/toolchains.js +15 -4
- package/docs/android.md +79 -0
- package/docs/architecture.md +47 -13
- package/docs/dart.md +60 -0
- package/docs/goals.md +3 -3
- package/docs/ios.md +121 -0
- package/docs/kotlin.md +42 -0
- package/docs/language-support.md +238 -26
- package/docs/multi-file-modules.md +52 -0
- package/docs/parser-qualification.md +121 -8
- package/docs/plans/2026-09-05-standard-library-portability.md +10 -10
- package/docs/rust.md +88 -0
- package/docs/source-maps.md +17 -7
- package/docs/specification.md +5 -0
- package/docs/standard-library-portability.md +39 -8
- package/docs/swift.md +44 -0
- package/docs/testing.md +381 -4
- package/docs/webassembly.md +52 -0
- package/index.js +66 -8
- package/node_modules/semantifold-tree-sitter-legacy-internal/README.md +2 -2
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/LICENSE +21 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/README.md +45 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/binding.gyp +30 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/binding.cc +20 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/binding_test.js +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/index.d.ts +28 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/index.js +11 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/grammar.js +1630 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/package.json +64 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/darwin-arm64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/darwin-x64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/linux-arm64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/linux-x64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/win32-arm64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/win32-x64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/queries/highlights.scm +159 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/queries/injections.scm +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/queries/tags.scm +60 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/grammar.json +9405 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/node-types.json +5399 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/parser.c +192569 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/scanner.c +393 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/tree_sitter/alloc.h +54 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/tree_sitter/array.h +290 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/tree_sitter/parser.h +266 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/tree-sitter-rust.wasm +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/tree-sitter.json +53 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/package.json +3 -2
- package/node_modules/semantifold-tree-sitter-legacy-internal/src/c.js +5 -4
- package/package.json +5 -2
- package/src/artifact-path.js +47 -2
- package/src/artifacts.js +67 -0
- package/src/backends/android.js +1370 -0
- package/src/backends/c-validation.js +6 -1
- package/src/backends/cpp-validation.js +6 -1
- package/src/backends/csharp.js +3 -0
- package/src/backends/dart-runtime.js +41 -0
- package/src/backends/dart.js +326 -0
- package/src/backends/effects.js +705 -0
- package/src/backends/go.js +14 -2
- package/src/backends/identifiers.js +166 -9
- package/src/backends/index.js +27 -2
- package/src/backends/ios.js +1612 -0
- package/src/backends/java.js +454 -36
- package/src/backends/javascript.js +389 -23
- package/src/backends/kotlin-runtime.js +29 -0
- package/src/backends/kotlin.js +144 -0
- package/src/backends/native-validation.js +1 -1
- package/src/backends/ordered-expressions.js +40 -6
- package/src/backends/php-stdlib-support.js +239 -0
- package/src/backends/php.js +469 -32
- package/src/backends/program.js +1408 -0
- package/src/backends/python.js +3 -0
- package/src/backends/ruby.js +326 -23
- package/src/backends/rust-runtime.js +34 -0
- package/src/backends/rust-validation.js +75 -0
- package/src/backends/rust.js +335 -0
- package/src/backends/scalars.js +141 -16
- package/src/backends/shared.js +2314 -115
- package/src/backends/stdlib-support.js +234 -0
- package/src/backends/swift-runtime.js +14 -0
- package/src/backends/swift.js +132 -0
- package/src/backends/typescript.js +349 -23
- package/src/backends/wasm.js +2208 -0
- package/src/backends/writer.js +545 -2
- package/src/diagnostic.js +4 -2
- package/src/frontends/c.js +4 -2
- package/src/frontends/cpp.js +4 -2
- package/src/frontends/csharp.js +4 -2
- package/src/frontends/dart.js +963 -0
- package/src/frontends/index.js +14 -4
- package/src/frontends/java.js +1977 -69
- package/src/frontends/javascript-typescript.js +2046 -102
- package/src/frontends/kotlin.js +713 -0
- package/src/frontends/php.js +1725 -79
- package/src/frontends/program.js +1062 -0
- package/src/frontends/ruby.js +1624 -98
- package/src/frontends/rust-parser.js +18 -0
- package/src/frontends/rust.js +714 -0
- package/src/frontends/scalars.js +31 -1
- package/src/frontends/swift.js +893 -0
- package/src/frontends/types.js +750 -0
- package/src/language-registry.js +182 -12
- package/src/mapping.js +33 -9
- package/src/semantic/capabilities.js +671 -0
- package/src/semantic/effects.js +737 -0
- package/src/semantic/generics.js +58 -0
- package/src/semantic/lifetime.js +517 -0
- package/src/semantic/provenance.js +412 -19
- package/src/semantic/scalars.js +17 -0
- package/src/semantic/stdlib.js +921 -0
- package/src/semantic/types.js +810 -14
- package/src/semantic/validate.js +2934 -209
- package/src/stdlib-facades.js +1211 -0
- package/src/stdlib-negotiation.js +446 -0
- package/src/stdlib-providers.js +377 -0
- package/src/toolchains.js +16 -3
package/src/language-registry.js
CHANGED
|
@@ -3,16 +3,27 @@
|
|
|
3
3
|
import {isDenseArray} from "./array.js"
|
|
4
4
|
import {SemantifoldDiagnostic, unsupportedRole} from "./diagnostic.js"
|
|
5
5
|
import {generateJava} from "./backends/java.js"
|
|
6
|
+
import {generateKotlin} from "./backends/kotlin.js"
|
|
6
7
|
import {generateCSharpProject} from "./backends/csharp.js"
|
|
7
8
|
import {generateGoModule} from "./backends/go.js"
|
|
9
|
+
import {generateRustProject} from "./backends/rust.js"
|
|
10
|
+
import {generateSwift} from "./backends/swift.js"
|
|
11
|
+
import {generateDartPackage} from "./backends/dart.js"
|
|
8
12
|
import {generateJavaScript} from "./backends/javascript.js"
|
|
9
13
|
import {generatePhp} from "./backends/php.js"
|
|
10
14
|
import {generatePython} from "./backends/python.js"
|
|
11
15
|
import {generateRuby} from "./backends/ruby.js"
|
|
12
16
|
import {generateTypeScript} from "./backends/typescript.js"
|
|
17
|
+
import {generateBrowserWasm} from "./backends/wasm.js"
|
|
18
|
+
import {generateIosApplication} from "./backends/ios.js"
|
|
19
|
+
import {generateAndroidApplication} from "./backends/android.js"
|
|
13
20
|
import {parseJava} from "./frontends/java.js"
|
|
21
|
+
import {parseKotlin} from "./frontends/kotlin.js"
|
|
14
22
|
import {parseCSharp} from "./frontends/csharp.js"
|
|
15
23
|
import {parseGo} from "./frontends/go.js"
|
|
24
|
+
import {parseRust} from "./frontends/rust.js"
|
|
25
|
+
import {parseSwift} from "./frontends/swift.js"
|
|
26
|
+
import {parseDart} from "./frontends/dart.js"
|
|
16
27
|
import {parseCpp} from "./frontends/cpp.js"
|
|
17
28
|
import {generateCpp} from "./backends/cpp.js"
|
|
18
29
|
import {parseC} from "./frontends/c.js"
|
|
@@ -27,22 +38,37 @@ const acceptanceStageOrder = ["parse", "generate", "restore", "compile", "link",
|
|
|
27
38
|
const acceptanceStages = new Map(acceptanceStageOrder.map((stage, index) => [stage, index]))
|
|
28
39
|
const registryKeys = new Set([
|
|
29
40
|
"acceptance", "applicationBackend", "artifactMultiplicity", "binaryBackend", "defaultFilename", "frontend", "id",
|
|
30
|
-
"interoperability", "mapping", "mediaType", "roundTrip", "textBackend"
|
|
41
|
+
"features", "interoperability", "mapping", "mediaType", "provider", "roundTrip", "textBackend"
|
|
31
42
|
])
|
|
32
43
|
|
|
33
44
|
/** @typedef {"frontend" | "textBackend" | "binaryBackend" | "applicationBackend" | "interoperability"} RegistryRole */
|
|
34
|
-
/** @typedef {(input: {filename: string, source: string}) => import("./semantic/types.js").SemanticModule} Frontend */
|
|
35
45
|
/** @typedef {(...values: unknown[]) => unknown} RegistryImplementation */
|
|
36
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @typedef FrontendInput
|
|
49
|
+
* @property {readonly import("./semantic/types.js").EffectCapabilityDeclaration[]} [capabilities] - Compiler-authorized declarations.
|
|
50
|
+
* @property {string} filename - Source filename.
|
|
51
|
+
* @property {string} source - Source text.
|
|
52
|
+
* @property {{isEntry: boolean, functions: Map<string, import("./semantic/types.js").FunctionDeclaration>, records: Map<string, import("./semantic/types.js").RecordDeclaration>, errors?: Map<string, import("./semantic/types.js").ErrorDeclaration>, valueRecords?: Map<string, import("./semantic/types.js").RecordDeclaration>}} [program] - Program conversion context.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @callback Frontend
|
|
57
|
+
* @param {FrontendInput} input - Frontend request.
|
|
58
|
+
* @returns {import("./semantic/types.js").SemanticModule} Semantic module.
|
|
59
|
+
*/
|
|
60
|
+
|
|
37
61
|
/**
|
|
38
62
|
* @typedef LanguageRegistryRecord
|
|
39
63
|
* @property {string} id - Stable identity.
|
|
40
64
|
* @property {{stages: import("./semantic/types.js").AcceptanceStage[], toolchains: string[]}} acceptance - Acceptance declaration.
|
|
41
65
|
* @property {"single" | "multiple"} artifactMultiplicity - Artifact multiplicity.
|
|
66
|
+
* @property {import("./semantic/types.js").LanguageFeatureCapabilities} features - Semantic feature capabilities.
|
|
42
67
|
* @property {import("./semantic/types.js").LanguageMappingCapabilities} mapping - Mapping capabilities.
|
|
43
68
|
* @property {boolean} roundTrip - Round-trip declaration.
|
|
44
69
|
* @property {string} [defaultFilename] - Default backend filename.
|
|
45
70
|
* @property {string} [mediaType] - Default backend media type.
|
|
71
|
+
* @property {boolean} [provider] - Target host stdlib provider/native-binding role.
|
|
46
72
|
* @property {RegistryImplementation} [frontend] - Frontend adapter.
|
|
47
73
|
* @property {RegistryImplementation} [textBackend] - Text backend.
|
|
48
74
|
* @property {RegistryImplementation} [binaryBackend] - Binary backend.
|
|
@@ -82,6 +108,9 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
82
108
|
}
|
|
83
109
|
if (recordsById.has(id)) invalidRegistry(`Duplicate registry ID '${id}'.`, id)
|
|
84
110
|
if (Object.keys(candidate).some((key) => !registryKeys.has(key))) invalidRegistry(`Registry record '${id}' has unknown fields.`, id)
|
|
111
|
+
if (candidate.provider !== undefined && typeof candidate.provider != "boolean") {
|
|
112
|
+
invalidRegistry(`Registry record '${id}' declares an invalid provider role.`, id)
|
|
113
|
+
}
|
|
85
114
|
|
|
86
115
|
for (const role of registryRoles) {
|
|
87
116
|
if (candidate[role] !== undefined && typeof candidate[role] != "function") {
|
|
@@ -94,6 +123,48 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
94
123
|
invalidRegistry(`Registry record '${id}' has an invalid artifact multiplicity.`, id)
|
|
95
124
|
}
|
|
96
125
|
if (typeof candidate.roundTrip != "boolean") invalidRegistry(`Registry record '${id}' requires a Boolean round-trip declaration.`, id)
|
|
126
|
+
const featuresCandidate = candidate.features ?? {
|
|
127
|
+
closedRecords: false,
|
|
128
|
+
conditionControlledLoops: false,
|
|
129
|
+
effectfulCapabilitiesAndResources: false,
|
|
130
|
+
generalFunctionsAndCalls: false,
|
|
131
|
+
immutableCollections: false,
|
|
132
|
+
optionalValues: false,
|
|
133
|
+
orderedListIteration: false,
|
|
134
|
+
orderedMapIteration: false,
|
|
135
|
+
referenceClasses: false,
|
|
136
|
+
typedErrors: false,
|
|
137
|
+
typeParametersAndGenerics: false
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!isPlainObject(featuresCandidate) ||
|
|
141
|
+
Object.keys(featuresCandidate).sort().join(",") != "closedRecords,conditionControlledLoops,effectfulCapabilitiesAndResources,generalFunctionsAndCalls,immutableCollections,optionalValues,orderedListIteration,orderedMapIteration,referenceClasses,typeParametersAndGenerics,typedErrors" ||
|
|
142
|
+
typeof featuresCandidate.closedRecords != "boolean" ||
|
|
143
|
+
typeof featuresCandidate.conditionControlledLoops != "boolean" ||
|
|
144
|
+
typeof featuresCandidate.effectfulCapabilitiesAndResources != "boolean" ||
|
|
145
|
+
typeof featuresCandidate.generalFunctionsAndCalls != "boolean" ||
|
|
146
|
+
typeof featuresCandidate.immutableCollections != "boolean" ||
|
|
147
|
+
typeof featuresCandidate.optionalValues != "boolean" ||
|
|
148
|
+
typeof featuresCandidate.orderedListIteration != "boolean" ||
|
|
149
|
+
typeof featuresCandidate.orderedMapIteration != "boolean" ||
|
|
150
|
+
typeof featuresCandidate.referenceClasses != "boolean" ||
|
|
151
|
+
typeof featuresCandidate.typedErrors != "boolean" ||
|
|
152
|
+
typeof featuresCandidate.typeParametersAndGenerics != "boolean") {
|
|
153
|
+
invalidRegistry(`Registry record '${id}' has an invalid feature declaration.`, id)
|
|
154
|
+
}
|
|
155
|
+
const features = deepFreeze(/** @type {import("./semantic/types.js").LanguageFeatureCapabilities} */ ({
|
|
156
|
+
closedRecords: featuresCandidate.closedRecords,
|
|
157
|
+
conditionControlledLoops: featuresCandidate.conditionControlledLoops,
|
|
158
|
+
effectfulCapabilitiesAndResources: featuresCandidate.effectfulCapabilitiesAndResources,
|
|
159
|
+
generalFunctionsAndCalls: featuresCandidate.generalFunctionsAndCalls,
|
|
160
|
+
immutableCollections: featuresCandidate.immutableCollections,
|
|
161
|
+
optionalValues: featuresCandidate.optionalValues,
|
|
162
|
+
orderedListIteration: featuresCandidate.orderedListIteration,
|
|
163
|
+
orderedMapIteration: featuresCandidate.orderedMapIteration,
|
|
164
|
+
referenceClasses: featuresCandidate.referenceClasses,
|
|
165
|
+
typedErrors: featuresCandidate.typedErrors,
|
|
166
|
+
typeParametersAndGenerics: featuresCandidate.typeParametersAndGenerics
|
|
167
|
+
}))
|
|
97
168
|
const mappingCandidate = candidate.mapping
|
|
98
169
|
|
|
99
170
|
if (!isPlainObject(mappingCandidate)) invalidRegistry(`Registry record '${id}' has an invalid mapping declaration.`, id)
|
|
@@ -151,7 +222,7 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
151
222
|
const hasApplicationBackend = typeof candidate.applicationBackend == "function"
|
|
152
223
|
const hasBackend = hasTextBackend || hasBinaryBackend || hasApplicationBackend
|
|
153
224
|
|
|
154
|
-
if ((mapping.richText || mapping.sourceMapV3) && !
|
|
225
|
+
if ((mapping.richText || mapping.sourceMapV3 || mapping.binaryRanges) && !hasBackend ||
|
|
155
226
|
mapping.sourceMapV3 && !mapping.richText ||
|
|
156
227
|
mapping.binaryRanges && !hasBinaryBackend && !hasApplicationBackend) {
|
|
157
228
|
invalidRegistry(`Registry record '${id}' declares mapping support without its required backend role.`, id)
|
|
@@ -163,11 +234,13 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
163
234
|
invalidRegistry(`Registry record '${id}' declares an acceptance stage without its required role.`, id)
|
|
164
235
|
}
|
|
165
236
|
|
|
166
|
-
|
|
237
|
+
const hasDefaultedBackend = hasTextBackend || hasBinaryBackend
|
|
238
|
+
|
|
239
|
+
if ((hasDefaultedBackend || candidate.defaultFilename !== undefined) &&
|
|
167
240
|
(typeof candidate.defaultFilename != "string" || candidate.defaultFilename.length == 0)) {
|
|
168
241
|
invalidRegistry(`Registry backend '${id}' requires a default filename.`, id)
|
|
169
242
|
}
|
|
170
|
-
if ((
|
|
243
|
+
if ((hasDefaultedBackend || candidate.mediaType !== undefined) &&
|
|
171
244
|
(typeof candidate.mediaType != "string" || candidate.mediaType.length == 0)) {
|
|
172
245
|
invalidRegistry(`Registry backend '${id}' requires a media type.`, id)
|
|
173
246
|
}
|
|
@@ -179,11 +252,13 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
179
252
|
const record = deepFreeze(/** @type {LanguageRegistryRecord} */ ({
|
|
180
253
|
acceptance,
|
|
181
254
|
artifactMultiplicity,
|
|
255
|
+
features,
|
|
182
256
|
id,
|
|
183
257
|
mapping,
|
|
184
258
|
roundTrip: candidate.roundTrip,
|
|
185
259
|
...(typeof candidate.defaultFilename == "string" ? {defaultFilename: candidate.defaultFilename} : {}),
|
|
186
260
|
...(typeof candidate.mediaType == "string" ? {mediaType: candidate.mediaType} : {}),
|
|
261
|
+
...(typeof candidate.provider == "boolean" ? {provider: candidate.provider} : {}),
|
|
187
262
|
...(typeof candidate.frontend == "function" ? {frontend: candidate.frontend} : {}),
|
|
188
263
|
...(typeof candidate.textBackend == "function" ? {textBackend: candidate.textBackend} : {}),
|
|
189
264
|
...(typeof candidate.binaryBackend == "function" ? {binaryBackend: candidate.binaryBackend} : {}),
|
|
@@ -193,6 +268,7 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
193
268
|
const descriptor = deepFreeze(/** @type {import("./semantic/types.js").LanguageCapabilities} */ ({
|
|
194
269
|
acceptance,
|
|
195
270
|
artifactMultiplicity,
|
|
271
|
+
features,
|
|
196
272
|
id,
|
|
197
273
|
mapping,
|
|
198
274
|
roles: {
|
|
@@ -200,6 +276,7 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
200
276
|
binaryBackend: typeof candidate.binaryBackend == "function",
|
|
201
277
|
frontend: typeof candidate.frontend == "function",
|
|
202
278
|
interoperability: typeof candidate.interoperability == "function",
|
|
279
|
+
provider: candidate.provider === true,
|
|
203
280
|
textBackend: typeof candidate.textBackend == "function"
|
|
204
281
|
},
|
|
205
282
|
roundTrip: candidate.roundTrip
|
|
@@ -240,31 +317,37 @@ export function createLanguageRegistry(candidateRecords) {
|
|
|
240
317
|
* PHP registry frontend wrapper.
|
|
241
318
|
* @type {Frontend}
|
|
242
319
|
*/
|
|
243
|
-
const phpFrontend = ({filename, source}) => parsePhp({filename, source})
|
|
320
|
+
const phpFrontend = ({capabilities, filename, program, source}) => parsePhp({capabilities, filename, program, source})
|
|
244
321
|
|
|
245
322
|
/**
|
|
246
323
|
* Ruby registry frontend wrapper.
|
|
247
324
|
* @type {Frontend}
|
|
248
325
|
*/
|
|
249
|
-
const rubyFrontend = ({filename, source}) => parseRuby({filename, source})
|
|
326
|
+
const rubyFrontend = ({capabilities, filename, program, source}) => parseRuby({capabilities, filename, program, source})
|
|
250
327
|
|
|
251
328
|
/**
|
|
252
329
|
* JavaScript registry frontend wrapper.
|
|
253
330
|
* @type {Frontend}
|
|
254
331
|
*/
|
|
255
|
-
const javaScriptFrontend = ({filename, source}) => parseJavaScriptTypeScript({filename, language: "javascript", source})
|
|
332
|
+
const javaScriptFrontend = ({capabilities, filename, program, source}) => parseJavaScriptTypeScript({capabilities, filename, language: "javascript", program, source})
|
|
256
333
|
|
|
257
334
|
/**
|
|
258
335
|
* TypeScript registry frontend wrapper.
|
|
259
336
|
* @type {Frontend}
|
|
260
337
|
*/
|
|
261
|
-
const typeScriptFrontend = ({filename, source}) => parseJavaScriptTypeScript({filename, language: "typescript", source})
|
|
338
|
+
const typeScriptFrontend = ({capabilities, filename, program, source}) => parseJavaScriptTypeScript({capabilities, filename, language: "typescript", program, source})
|
|
262
339
|
|
|
263
340
|
/**
|
|
264
341
|
* Java registry frontend wrapper.
|
|
265
342
|
* @type {Frontend}
|
|
266
343
|
*/
|
|
267
|
-
const javaFrontend = ({filename, source}) => parseJava({filename, source})
|
|
344
|
+
const javaFrontend = ({capabilities, filename, program, source}) => parseJava({capabilities, filename, program, source})
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Kotlin registry frontend wrapper.
|
|
348
|
+
* @type {Frontend}
|
|
349
|
+
*/
|
|
350
|
+
const kotlinFrontend = ({filename, source}) => parseKotlin({filename, source})
|
|
268
351
|
|
|
269
352
|
/**
|
|
270
353
|
* Python registry frontend wrapper.
|
|
@@ -284,9 +367,15 @@ const csharpFrontend = ({filename, source}) => parseCSharp({filename, source})
|
|
|
284
367
|
*/
|
|
285
368
|
const goFrontend = ({filename, source}) => parseGo({filename, source})
|
|
286
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Dart registry frontend wrapper.
|
|
372
|
+
* @type {Frontend}
|
|
373
|
+
*/
|
|
374
|
+
const dartFrontend = ({filename, source}) => parseDart({filename, source})
|
|
375
|
+
|
|
287
376
|
const records = [
|
|
288
377
|
language({
|
|
289
|
-
acceptance: {stages: ["parse", "generate", "execute"], toolchains: ["
|
|
378
|
+
acceptance: {stages: ["parse", "generate", "execute"], toolchains: ["php82"]},
|
|
290
379
|
defaultFilename: "program.php",
|
|
291
380
|
frontend: phpFrontend,
|
|
292
381
|
id: "php",
|
|
@@ -325,6 +414,14 @@ const records = [
|
|
|
325
414
|
mediaType: "text/x-java-source",
|
|
326
415
|
textBackend: generateJava
|
|
327
416
|
}),
|
|
417
|
+
language({
|
|
418
|
+
acceptance: {stages: ["parse", "generate", "compile", "execute"], toolchains: ["kotlinc", "java25"]},
|
|
419
|
+
defaultFilename: "Program.kt",
|
|
420
|
+
frontend: kotlinFrontend,
|
|
421
|
+
id: "kotlin",
|
|
422
|
+
mediaType: "text/x-kotlin",
|
|
423
|
+
textBackend: generateKotlin
|
|
424
|
+
}),
|
|
328
425
|
language({
|
|
329
426
|
acceptance: {stages: ["parse", "generate", "compile", "execute"], toolchains: ["python"]},
|
|
330
427
|
defaultFilename: "program.py",
|
|
@@ -363,7 +460,66 @@ const records = [
|
|
|
363
460
|
language({
|
|
364
461
|
acceptance: {stages: ["parse", "generate", "compile", "link", "execute"], toolchains: ["clangpp"]},
|
|
365
462
|
defaultFilename: "program.cpp", frontend: parseCpp, id: "cpp", mediaType: "text/x-c++src", textBackend: generateCpp
|
|
366
|
-
})
|
|
463
|
+
}),
|
|
464
|
+
language({
|
|
465
|
+
acceptance: {stages: ["parse", "generate", "compile", "validate", "execute"], toolchains: ["rustc", "cargo"]},
|
|
466
|
+
artifactMultiplicity: "multiple",
|
|
467
|
+
defaultFilename: "src/main.rs", frontend: parseRust, id: "rust", mediaType: "text/x-rust", textBackend: generateRustProject
|
|
468
|
+
}),
|
|
469
|
+
language({acceptance: {stages: ["parse", "generate", "compile", "execute"], toolchains: ["swiftc"]},
|
|
470
|
+
defaultFilename: "program.swift", frontend: parseSwift, id: "swift", mediaType: "text/x-swift", textBackend: generateSwift}),
|
|
471
|
+
language({
|
|
472
|
+
acceptance: {stages: ["parse", "generate", "restore", "compile", "validate", "execute"], toolchains: ["dart"]},
|
|
473
|
+
artifactMultiplicity: "multiple",
|
|
474
|
+
defaultFilename: "bin/program.dart",
|
|
475
|
+
features: {
|
|
476
|
+
closedRecords: false,
|
|
477
|
+
conditionControlledLoops: false,
|
|
478
|
+
effectfulCapabilitiesAndResources: false,
|
|
479
|
+
generalFunctionsAndCalls: true,
|
|
480
|
+
immutableCollections: false,
|
|
481
|
+
optionalValues: false,
|
|
482
|
+
orderedListIteration: false,
|
|
483
|
+
orderedMapIteration: false,
|
|
484
|
+
referenceClasses: false,
|
|
485
|
+
typedErrors: false,
|
|
486
|
+
typeParametersAndGenerics: false
|
|
487
|
+
},
|
|
488
|
+
frontend: dartFrontend,
|
|
489
|
+
id: "dart",
|
|
490
|
+
mediaType: "text/x-dart",
|
|
491
|
+
textBackend: generateDartPackage
|
|
492
|
+
}),
|
|
493
|
+
{
|
|
494
|
+
acceptance: {stages: ["generate", "validate", "instantiate", "execute"], toolchains: ["wasm-validate", "node", "chromium"]},
|
|
495
|
+
applicationBackend: generateBrowserWasm,
|
|
496
|
+
artifactMultiplicity: "multiple",
|
|
497
|
+
binaryBackend: generateBrowserWasm,
|
|
498
|
+
defaultFilename: "program.wasm",
|
|
499
|
+
features: {closedRecords: false, conditionControlledLoops: false, effectfulCapabilitiesAndResources: false, generalFunctionsAndCalls: false, immutableCollections: false, optionalValues: false, orderedListIteration: false, orderedMapIteration: false, referenceClasses: false, typedErrors: false, typeParametersAndGenerics: false},
|
|
500
|
+
id: "wasm",
|
|
501
|
+
mapping: {binaryRanges: true, richText: true, sourceMapV3: true},
|
|
502
|
+
mediaType: "application/wasm",
|
|
503
|
+
roundTrip: false
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
acceptance: {stages: ["generate", "compile", "validate", "instantiate", "execute"], toolchains: ["android"]},
|
|
507
|
+
applicationBackend: generateAndroidApplication,
|
|
508
|
+
artifactMultiplicity: "multiple",
|
|
509
|
+
features: {closedRecords: false, conditionControlledLoops: false, effectfulCapabilitiesAndResources: false, generalFunctionsAndCalls: false, immutableCollections: false, optionalValues: false, orderedListIteration: false, orderedMapIteration: false, referenceClasses: false, typedErrors: false, typeParametersAndGenerics: false},
|
|
510
|
+
id: "android",
|
|
511
|
+
mapping: {binaryRanges: true, richText: true, sourceMapV3: true},
|
|
512
|
+
roundTrip: false
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
acceptance: {stages: ["generate"], toolchains: []},
|
|
516
|
+
applicationBackend: generateIosApplication,
|
|
517
|
+
artifactMultiplicity: "multiple",
|
|
518
|
+
features: {closedRecords: false, conditionControlledLoops: false, effectfulCapabilitiesAndResources: false, generalFunctionsAndCalls: false, immutableCollections: false, optionalValues: false, orderedListIteration: false, orderedMapIteration: false, referenceClasses: false, typedErrors: false, typeParametersAndGenerics: false},
|
|
519
|
+
id: "ios",
|
|
520
|
+
mapping: {binaryRanges: true, richText: true, sourceMapV3: true},
|
|
521
|
+
roundTrip: false
|
|
522
|
+
}
|
|
367
523
|
]
|
|
368
524
|
|
|
369
525
|
export const languageRegistry = createLanguageRegistry(records)
|
|
@@ -381,7 +537,21 @@ export const supportedLanguages = Object.freeze(languageCapabilities
|
|
|
381
537
|
function language(values) {
|
|
382
538
|
return {
|
|
383
539
|
artifactMultiplicity: "single",
|
|
540
|
+
features: {
|
|
541
|
+
closedRecords: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
542
|
+
conditionControlledLoops: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
543
|
+
effectfulCapabilitiesAndResources: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
544
|
+
generalFunctionsAndCalls: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
545
|
+
immutableCollections: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
546
|
+
optionalValues: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
547
|
+
orderedListIteration: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
548
|
+
orderedMapIteration: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
549
|
+
referenceClasses: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
550
|
+
typedErrors: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
551
|
+
typeParametersAndGenerics: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id))
|
|
552
|
+
},
|
|
384
553
|
mapping: {binaryRanges: false, richText: true, sourceMapV3: true},
|
|
554
|
+
provider: ["php", "ruby", "javascript", "typescript", "java"].includes(String(values.id)),
|
|
385
555
|
roundTrip: true,
|
|
386
556
|
...values
|
|
387
557
|
}
|
package/src/mapping.js
CHANGED
|
@@ -514,7 +514,7 @@ export function composeSourceMaps(outer, inner) {
|
|
|
514
514
|
* @param {object} generated - Generated program.
|
|
515
515
|
* @param {string} generated.content - Exact generated content.
|
|
516
516
|
* @param {string} generated.filename - Generated filename.
|
|
517
|
-
* @param {import("./semantic/types.js").
|
|
517
|
+
* @param {import("./semantic/types.js").GeneratedTextLanguage} generated.language - Generated text language.
|
|
518
518
|
* @param {{filename: string, content: string, language?: import("./semantic/types.js").SemanticLanguage}[]} [generated.sources] - Exact source content overrides.
|
|
519
519
|
* @returns {import("./semantic/types.js").SemantifoldMapping} Imported rich map.
|
|
520
520
|
*/
|
|
@@ -712,7 +712,7 @@ export function validateMapping(value) {
|
|
|
712
712
|
const spans = mapping.spans
|
|
713
713
|
|
|
714
714
|
if (!generated || typeof generated != "object" || typeof Reflect.get(generated, "filename") != "string" ||
|
|
715
|
-
typeof Reflect.get(generated, "content") != "string" || !
|
|
715
|
+
typeof Reflect.get(generated, "content") != "string" || !isGeneratedLanguage(Reflect.get(generated, "language")) ||
|
|
716
716
|
!Array.isArray(mapping.sources) ||
|
|
717
717
|
!Array.isArray(mapping.nodes) || !Array.isArray(mapping.symbols) || !Array.isArray(spans)) {
|
|
718
718
|
throw new TypeError("Malformed SemantifoldMapping v1 envelope.")
|
|
@@ -728,7 +728,7 @@ export function validateMapping(value) {
|
|
|
728
728
|
for (const source of mapping.sources) {
|
|
729
729
|
if (!source || typeof source != "object" || typeof source.id != "string" || source.id.length == 0 || sourceIds.has(source.id) ||
|
|
730
730
|
typeof source.filename != "string" || source.filename.length == 0 || source.content !== null && typeof source.content != "string" ||
|
|
731
|
-
source.language !== null && !
|
|
731
|
+
source.language !== null && !isSemanticLanguage(source.language)) {
|
|
732
732
|
throw new TypeError("Malformed or duplicate SemantifoldMapping source.")
|
|
733
733
|
}
|
|
734
734
|
sourceIds.add(source.id)
|
|
@@ -763,8 +763,23 @@ export function validateMapping(value) {
|
|
|
763
763
|
|
|
764
764
|
for (const symbol of mapping.symbols) {
|
|
765
765
|
if (!symbol || typeof symbol != "object" || typeof symbol.id != "string" || symbol.id.length == 0 || symbolIds.has(symbol.id) ||
|
|
766
|
-
typeof symbol.name != "string" || symbol.name.length == 0 ||
|
|
767
|
-
!
|
|
766
|
+
typeof symbol.name != "string" || symbol.name.length == 0 ||
|
|
767
|
+
!["capability", "resource", "failure", "operation", "record", "class", "error", "field", "constructor", "method", "function", "typeParameter", "parameter", "local", "iteration", "catch"].includes(symbol.kind) ||
|
|
768
|
+
!nodeIds.has(symbol.declarationNodeId) || !Array.isArray(symbol.references) ||
|
|
769
|
+
symbol.semanticDeclarationId !== undefined && (typeof symbol.semanticDeclarationId != "string" || !(
|
|
770
|
+
symbol.kind == "function" && /^(?:[a-z][a-z0-9._-]*#)?function:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
771
|
+
symbol.kind == "record" && /^(?:[a-z][a-z0-9._-]*#)?record:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
772
|
+
symbol.kind == "class" && /^(?:[a-z][a-z0-9._-]*#)?class:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
773
|
+
symbol.kind == "error" && /^(?:[a-z][a-z0-9._-]*#)?error:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
774
|
+
symbol.kind == "field" && /^(?:[a-z][a-z0-9._-]*#)?(?:record|class):[0-9]+:field:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
775
|
+
symbol.kind == "constructor" && /^(?:[a-z][a-z0-9._-]*#)?class:[0-9]+:constructor$/u.test(symbol.semanticDeclarationId) ||
|
|
776
|
+
symbol.kind == "method" && /^(?:[a-z][a-z0-9._-]*#)?class:[0-9]+:method:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
777
|
+
symbol.kind == "typeParameter" && /^(?:[a-z][a-z0-9._-]*#)?(?:function|record):[0-9]+:type:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
778
|
+
symbol.kind == "capability" && /^(?:module:[0-9]+\/)?capability:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
779
|
+
symbol.kind == "resource" && /^(?:module:[0-9]+\/)?capability:[0-9]+\/resource:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
780
|
+
symbol.kind == "failure" && /^(?:module:[0-9]+\/)?capability:[0-9]+\/failure:[0-9]+$/u.test(symbol.semanticDeclarationId) ||
|
|
781
|
+
symbol.kind == "operation" && /^(?:module:[0-9]+\/)?capability:[0-9]+\/operation:[0-9]+$/u.test(symbol.semanticDeclarationId)
|
|
782
|
+
))) {
|
|
768
783
|
throw new TypeError("Malformed or duplicate semantic symbol identity.")
|
|
769
784
|
}
|
|
770
785
|
symbolIds.add(symbol.id)
|
|
@@ -785,7 +800,7 @@ export function validateMapping(value) {
|
|
|
785
800
|
validateLocationForSources(symbol.location, sourcesByFilename, sourceCoordinates)
|
|
786
801
|
for (const reference of symbol.references) {
|
|
787
802
|
if (!reference || typeof reference != "object" || !nodeIds.has(reference.nodeId) ||
|
|
788
|
-
!["declaration", "read", "write", "call"].includes(reference.role)) {
|
|
803
|
+
!["declaration", "type", "construct", "member", "read", "write", "call"].includes(reference.role)) {
|
|
789
804
|
throw new TypeError("Malformed semantic symbol reference.")
|
|
790
805
|
}
|
|
791
806
|
validateLocationForSources(reference.location, sourcesByFilename, sourceCoordinates)
|
|
@@ -1099,13 +1114,22 @@ function validPoint(value) {
|
|
|
1099
1114
|
}
|
|
1100
1115
|
|
|
1101
1116
|
/**
|
|
1102
|
-
* Tests a supported semantic language value.
|
|
1117
|
+
* Tests a supported semantic source-language value.
|
|
1103
1118
|
* @param {unknown} value - Candidate language.
|
|
1104
1119
|
* @returns {value is import("./semantic/types.js").SemanticLanguage} Whether supported.
|
|
1105
1120
|
*/
|
|
1106
|
-
function
|
|
1121
|
+
function isSemanticLanguage(value) {
|
|
1107
1122
|
return value == "php" || value == "ruby" || value == "javascript" || value == "typescript" || value == "java" ||
|
|
1108
|
-
value == "python" || value == "csharp" || value == "go" || value == "c" || value == "cpp"
|
|
1123
|
+
value == "kotlin" || value == "python" || value == "csharp" || value == "go" || value == "c" || value == "cpp" || value == "rust" || value == "swift" || value == "dart"
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Tests a supported generated text language value.
|
|
1128
|
+
* @param {unknown} value - Candidate language.
|
|
1129
|
+
* @returns {value is import("./semantic/types.js").GeneratedTextLanguage} Whether supported.
|
|
1130
|
+
*/
|
|
1131
|
+
function isGeneratedLanguage(value) {
|
|
1132
|
+
return value == "html" || isSemanticLanguage(value)
|
|
1109
1133
|
}
|
|
1110
1134
|
|
|
1111
1135
|
/**
|