@alloy-js/go 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/LICENSE +7 -0
- package/api-extractor.json +4 -0
- package/dist/src/builtins/fmt/fmt.d.ts +147 -0
- package/dist/src/builtins/fmt/fmt.d.ts.map +1 -0
- package/dist/src/builtins/fmt/fmt.js +148 -0
- package/dist/src/builtins/fmt/fmt.js.map +1 -0
- package/dist/src/builtins/index.d.ts +2004 -0
- package/dist/src/builtins/index.d.ts.map +1 -0
- package/dist/src/builtins/index.js +9 -0
- package/dist/src/builtins/index.js.map +1 -0
- package/dist/src/builtins/io/io.d.ts +648 -0
- package/dist/src/builtins/io/io.d.ts.map +1 -0
- package/dist/src/builtins/io/io.js +650 -0
- package/dist/src/builtins/io/io.js.map +1 -0
- package/dist/src/builtins/net/net.d.ts +1210 -0
- package/dist/src/builtins/net/net.d.ts.map +1 -0
- package/dist/src/builtins/net/net.js +1212 -0
- package/dist/src/builtins/net/net.js.map +1 -0
- package/dist/src/components/ImportStatement.d.ts +15 -0
- package/dist/src/components/ImportStatement.d.ts.map +1 -0
- package/dist/src/components/ImportStatement.js +90 -0
- package/dist/src/components/ImportStatement.js.map +1 -0
- package/dist/src/components/ModuleDirectory.d.ts +8 -0
- package/dist/src/components/ModuleDirectory.d.ts.map +1 -0
- package/dist/src/components/ModuleDirectory.js +20 -0
- package/dist/src/components/ModuleDirectory.js.map +1 -0
- package/dist/src/components/Name.d.ts +2 -0
- package/dist/src/components/Name.d.ts.map +1 -0
- package/dist/src/components/Name.js +12 -0
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/Reference.d.ts +6 -0
- package/dist/src/components/Reference.d.ts.map +1 -0
- package/dist/src/components/Reference.js +15 -0
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SourceDirectory.d.ts +6 -0
- package/dist/src/components/SourceDirectory.d.ts.map +1 -0
- package/dist/src/components/SourceDirectory.js +30 -0
- package/dist/src/components/SourceDirectory.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +16 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -0
- package/dist/src/components/SourceFile.js +75 -0
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/doc/comment.d.ts +21 -0
- package/dist/src/components/doc/comment.d.ts.map +1 -0
- package/dist/src/components/doc/comment.js +30 -0
- package/dist/src/components/doc/comment.js.map +1 -0
- package/dist/src/components/doc/comment.test.d.ts +2 -0
- package/dist/src/components/doc/comment.test.d.ts.map +1 -0
- package/dist/src/components/doc/comment.test.js +215 -0
- package/dist/src/components/doc/comment.test.js.map +1 -0
- package/dist/src/components/function/function.d.ts +31 -0
- package/dist/src/components/function/function.d.ts.map +1 -0
- package/dist/src/components/function/function.js +134 -0
- package/dist/src/components/function/function.js.map +1 -0
- package/dist/src/components/function/function.test.d.ts +2 -0
- package/dist/src/components/function/function.test.d.ts.map +1 -0
- package/dist/src/components/function/function.test.js +410 -0
- package/dist/src/components/function/function.test.js.map +1 -0
- package/dist/src/components/index.d.ts +16 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +16 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/declaration.d.ts +68 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -0
- package/dist/src/components/interface/declaration.js +181 -0
- package/dist/src/components/interface/declaration.js.map +1 -0
- package/dist/src/components/interface/interface.test.d.ts +2 -0
- package/dist/src/components/interface/interface.test.d.ts.map +1 -0
- package/dist/src/components/interface/interface.test.js +517 -0
- package/dist/src/components/interface/interface.test.js.map +1 -0
- package/dist/src/components/package.test.d.ts +2 -0
- package/dist/src/components/package.test.d.ts.map +1 -0
- package/dist/src/components/package.test.js +89 -0
- package/dist/src/components/package.test.js.map +1 -0
- package/dist/src/components/parameters/parameters.d.ts +15 -0
- package/dist/src/components/parameters/parameters.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.js +58 -0
- package/dist/src/components/parameters/parameters.js.map +1 -0
- package/dist/src/components/parameters/typeparameters.d.ts +25 -0
- package/dist/src/components/parameters/typeparameters.d.ts.map +1 -0
- package/dist/src/components/parameters/typeparameters.js +53 -0
- package/dist/src/components/parameters/typeparameters.js.map +1 -0
- package/dist/src/components/pointer/pointer.d.ts +9 -0
- package/dist/src/components/pointer/pointer.d.ts.map +1 -0
- package/dist/src/components/pointer/pointer.js +8 -0
- package/dist/src/components/pointer/pointer.js.map +1 -0
- package/dist/src/components/stc/index.d.ts +27 -0
- package/dist/src/components/stc/index.d.ts.map +1 -0
- package/dist/src/components/stc/index.js +27 -0
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/components/struct/declaration.d.ts +62 -0
- package/dist/src/components/struct/declaration.d.ts.map +1 -0
- package/dist/src/components/struct/declaration.js +161 -0
- package/dist/src/components/struct/declaration.js.map +1 -0
- package/dist/src/components/struct/struct.test.d.ts +2 -0
- package/dist/src/components/struct/struct.test.d.ts.map +1 -0
- package/dist/src/components/struct/struct.test.js +741 -0
- package/dist/src/components/struct/struct.test.js.map +1 -0
- package/dist/src/components/type/declaration.d.ts +29 -0
- package/dist/src/components/type/declaration.d.ts.map +1 -0
- package/dist/src/components/type/declaration.js +63 -0
- package/dist/src/components/type/declaration.js.map +1 -0
- package/dist/src/components/var/declaration.d.ts +27 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -0
- package/dist/src/components/var/declaration.js +84 -0
- package/dist/src/components/var/declaration.js.map +1 -0
- package/dist/src/components/var/var-declaration.test.d.ts +2 -0
- package/dist/src/components/var/var-declaration.test.d.ts.map +1 -0
- package/dist/src/components/var/var-declaration.test.js +340 -0
- package/dist/src/components/var/var-declaration.test.js.map +1 -0
- package/dist/src/context/package.d.ts +9 -0
- package/dist/src/context/package.d.ts.map +1 -0
- package/dist/src/context/package.js +6 -0
- package/dist/src/context/package.js.map +1 -0
- package/dist/src/create-module.d.ts +47 -0
- package/dist/src/create-module.d.ts.map +1 -0
- package/dist/src/create-module.js +158 -0
- package/dist/src/create-module.js.map +1 -0
- package/dist/src/create-module.test.d.ts +2 -0
- package/dist/src/create-module.test.d.ts.map +1 -0
- package/dist/src/create-module.test.js +147 -0
- package/dist/src/create-module.test.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/name-policy.d.ts +5 -0
- package/dist/src/name-policy.d.ts.map +1 -0
- package/dist/src/name-policy.js +27 -0
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/scopes/contexts.d.ts +9 -0
- package/dist/src/scopes/contexts.d.ts.map +1 -0
- package/dist/src/scopes/contexts.js +34 -0
- package/dist/src/scopes/contexts.js.map +1 -0
- package/dist/src/scopes/factories.d.ts +7 -0
- package/dist/src/scopes/factories.d.ts.map +1 -0
- package/dist/src/scopes/factories.js +16 -0
- package/dist/src/scopes/factories.js.map +1 -0
- package/dist/src/scopes/function.d.ts +9 -0
- package/dist/src/scopes/function.d.ts.map +1 -0
- package/dist/src/scopes/function.js +14 -0
- package/dist/src/scopes/function.js.map +1 -0
- package/dist/src/scopes/go.d.ts +8 -0
- package/dist/src/scopes/go.d.ts.map +1 -0
- package/dist/src/scopes/go.js +12 -0
- package/dist/src/scopes/go.js.map +1 -0
- package/dist/src/scopes/index.d.ts +10 -0
- package/dist/src/scopes/index.d.ts.map +1 -0
- package/dist/src/scopes/index.js +10 -0
- package/dist/src/scopes/index.js.map +1 -0
- package/dist/src/scopes/lexical.d.ts +8 -0
- package/dist/src/scopes/lexical.d.ts.map +1 -0
- package/dist/src/scopes/lexical.js +11 -0
- package/dist/src/scopes/lexical.js.map +1 -0
- package/dist/src/scopes/module.d.ts +9 -0
- package/dist/src/scopes/module.d.ts.map +1 -0
- package/dist/src/scopes/module.js +31 -0
- package/dist/src/scopes/module.js.map +1 -0
- package/dist/src/scopes/named-type.d.ts +23 -0
- package/dist/src/scopes/named-type.d.ts.map +1 -0
- package/dist/src/scopes/named-type.js +33 -0
- package/dist/src/scopes/named-type.js.map +1 -0
- package/dist/src/scopes/package.d.ts +11 -0
- package/dist/src/scopes/package.d.ts.map +1 -0
- package/dist/src/scopes/package.js +39 -0
- package/dist/src/scopes/package.js.map +1 -0
- package/dist/src/scopes/source-file.d.ts +17 -0
- package/dist/src/scopes/source-file.d.ts.map +1 -0
- package/dist/src/scopes/source-file.js +42 -0
- package/dist/src/scopes/source-file.js.map +1 -0
- package/dist/src/symbols/factories.d.ts +25 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +114 -0
- package/dist/src/symbols/factories.js.map +1 -0
- package/dist/src/symbols/function.d.ts +10 -0
- package/dist/src/symbols/function.d.ts.map +1 -0
- package/dist/src/symbols/function.js +12 -0
- package/dist/src/symbols/function.js.map +1 -0
- package/dist/src/symbols/go.d.ts +22 -0
- package/dist/src/symbols/go.d.ts.map +1 -0
- package/dist/src/symbols/go.js +56 -0
- package/dist/src/symbols/go.js.map +1 -0
- package/dist/src/symbols/index.d.ts +7 -0
- package/dist/src/symbols/index.d.ts.map +1 -0
- package/dist/src/symbols/index.js +7 -0
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/named-type.d.ts +24 -0
- package/dist/src/symbols/named-type.d.ts.map +1 -0
- package/dist/src/symbols/named-type.js +53 -0
- package/dist/src/symbols/named-type.js.map +1 -0
- package/dist/src/symbols/package.d.ts +18 -0
- package/dist/src/symbols/package.d.ts.map +1 -0
- package/dist/src/symbols/package.js +38 -0
- package/dist/src/symbols/package.js.map +1 -0
- package/dist/src/symbols/reference.d.ts +3 -0
- package/dist/src/symbols/reference.d.ts.map +1 -0
- package/dist/src/symbols/reference.js +76 -0
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/test/utils.d.ts +8 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/test/utils.js +68 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -0
- package/src/builtins/fmt/fmt.ts +78 -0
- package/src/builtins/index.ts +9 -0
- package/src/builtins/io/io.ts +355 -0
- package/src/builtins/net/net.ts +502 -0
- package/src/components/ImportStatement.tsx +115 -0
- package/src/components/ModuleDirectory.tsx +18 -0
- package/src/components/Name.tsx +11 -0
- package/src/components/Reference.tsx +18 -0
- package/src/components/SourceDirectory.tsx +32 -0
- package/src/components/SourceFile.tsx +74 -0
- package/src/components/doc/comment.test.tsx +278 -0
- package/src/components/doc/comment.tsx +40 -0
- package/src/components/function/function.test.tsx +387 -0
- package/src/components/function/function.tsx +194 -0
- package/src/components/index.ts +15 -0
- package/src/components/interface/declaration.tsx +250 -0
- package/src/components/interface/interface.test.tsx +390 -0
- package/src/components/package.test.tsx +63 -0
- package/src/components/parameters/parameters.tsx +74 -0
- package/src/components/parameters/typeparameters.tsx +78 -0
- package/src/components/pointer/pointer.tsx +12 -0
- package/src/components/stc/index.ts +27 -0
- package/src/components/struct/declaration.tsx +228 -0
- package/src/components/struct/struct.test.tsx +558 -0
- package/src/components/type/declaration.tsx +93 -0
- package/src/components/var/declaration.tsx +138 -0
- package/src/components/var/var-declaration.test.tsx +236 -0
- package/src/context/package.ts +13 -0
- package/src/create-module.test.tsx +128 -0
- package/src/create-module.ts +347 -0
- package/src/index.ts +5 -0
- package/src/name-policy.ts +65 -0
- package/src/scopes/contexts.ts +45 -0
- package/src/scopes/factories.ts +29 -0
- package/src/scopes/function.ts +22 -0
- package/src/scopes/go.ts +18 -0
- package/src/scopes/index.ts +9 -0
- package/src/scopes/lexical.ts +14 -0
- package/src/scopes/module.ts +35 -0
- package/src/scopes/named-type.ts +49 -0
- package/src/scopes/package.ts +55 -0
- package/src/scopes/source-file.ts +66 -0
- package/src/symbols/factories.ts +234 -0
- package/src/symbols/function.ts +17 -0
- package/src/symbols/go.ts +82 -0
- package/src/symbols/index.ts +6 -0
- package/src/symbols/named-type.ts +90 -0
- package/src/symbols/package.ts +54 -0
- package/src/symbols/reference.ts +87 -0
- package/temp/api.json +8753 -0
- package/test/utils.tsx +77 -0
- package/test/vitest.setup.ts +1 -0
- package/tsconfig.json +15 -0
- package/tsdoc-metadata.json +11 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LibrarySymbolReference } from "@alloy-js/core";
|
|
2
|
+
export interface MemberDescriptor {
|
|
3
|
+
kind: string;
|
|
4
|
+
type?: LibrarySymbolReference | (() => LibrarySymbolReference);
|
|
5
|
+
}
|
|
6
|
+
export interface FieldDescriptor extends MemberDescriptor {
|
|
7
|
+
kind: "field";
|
|
8
|
+
}
|
|
9
|
+
export interface FunctionDescriptor extends MemberDescriptor {
|
|
10
|
+
kind: "function";
|
|
11
|
+
}
|
|
12
|
+
export interface MethodDescriptor extends MemberDescriptor {
|
|
13
|
+
kind: "method";
|
|
14
|
+
}
|
|
15
|
+
export interface VariableDescriptor extends MemberDescriptor {
|
|
16
|
+
kind: "var";
|
|
17
|
+
}
|
|
18
|
+
export interface EmbedDescriptor extends MemberDescriptor {
|
|
19
|
+
kind: "embed";
|
|
20
|
+
}
|
|
21
|
+
export interface NamedTypeDescriptor<M extends Record<string, Descriptor>> {
|
|
22
|
+
kind: string;
|
|
23
|
+
members: M;
|
|
24
|
+
}
|
|
25
|
+
export interface TypeDescriptor<M extends Record<string, Descriptor>> extends NamedTypeDescriptor<M> {
|
|
26
|
+
kind: "type";
|
|
27
|
+
}
|
|
28
|
+
export interface PackageDescriptor<M extends Record<string, Descriptor>> extends NamedTypeDescriptor<M> {
|
|
29
|
+
kind: "package";
|
|
30
|
+
path?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
members: M;
|
|
33
|
+
}
|
|
34
|
+
export interface StructDescriptor<M extends Record<string, Descriptor>> extends NamedTypeDescriptor<M> {
|
|
35
|
+
kind: "struct";
|
|
36
|
+
}
|
|
37
|
+
export interface InterfaceDescriptor<M extends Record<string, Descriptor>> extends NamedTypeDescriptor<M> {
|
|
38
|
+
kind: "interface";
|
|
39
|
+
}
|
|
40
|
+
export type Descriptor = PackageDescriptor<any> | FieldDescriptor | FunctionDescriptor | MethodDescriptor | VariableDescriptor | StructDescriptor<any> | InterfaceDescriptor<any> | TypeDescriptor<any> | EmbedDescriptor;
|
|
41
|
+
export type StrictDescriptor = PackageDescriptor<Record<string, StrictDescriptor>> | FieldDescriptor | FunctionDescriptor | MethodDescriptor | VariableDescriptor | StructDescriptor<Record<string, StrictDescriptor>> | InterfaceDescriptor<Record<string, StrictDescriptor>> | TypeDescriptor<Record<string, StrictDescriptor>> | EmbedDescriptor;
|
|
42
|
+
export type ResolveDescriptor<D> = D extends NamedTypeDescriptor<infer M> ? LibrarySymbolReference & {
|
|
43
|
+
[K in keyof M]: ResolveDescriptor<M[K]>;
|
|
44
|
+
} : LibrarySymbolReference;
|
|
45
|
+
export type LibraryFrom<T> = ResolveDescriptor<T> & LibrarySymbolReference;
|
|
46
|
+
export declare function createModule<T extends PackageDescriptor<any>>(name: string, props: T, builtin?: boolean): LibraryFrom<T>;
|
|
47
|
+
//# sourceMappingURL=create-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-module.d.ts","sourceRoot":"","sources":["../../src/create-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EAMvB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,sBAAsB,GAAG,CAAC,MAAM,sBAAsB,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;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ChB,kBAAkB,GAClB,gBAAgB,CAAC,GAAG,CAAC,GACrB,mBAAmB,CAAC,GAAG,CAAC,GACxB,cAAc,CAAC,GAAG,CAAC,GACnB,eAAe,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,GACnD,eAAe,GACf,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,GAClD,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,GACrD,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,GAChD,eAAe,CAAC;AAEpB,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC7B,CAAC,SAAS,mBAAmB,CAAC,MAAM,CAAC,CAAC,GACpC,sBAAsB,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACpE,sBAAsB,CAAC;AAE3B,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC;AAO3E,wBAAgB,YAAY,CAAC,CAAC,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAC3D,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,OAAe,GACvB,WAAW,CAAC,CAAC,CAAC,CAOhB"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { namekey, refkey, REFKEYABLE, TO_SYMBOL, useBinder } from "@alloy-js/core";
|
|
2
|
+
import { basename } from "pathe";
|
|
3
|
+
import { FunctionSymbol, GoSymbol, PackageSymbol } from "./index.js";
|
|
4
|
+
import { NamedTypeSymbol } from "./symbols/named-type.js";
|
|
5
|
+
export function createModule(name, props, builtin = false) {
|
|
6
|
+
return createSymbolEntry(name, props, {
|
|
7
|
+
ownerSymbol(_binder) {
|
|
8
|
+
return null;
|
|
9
|
+
},
|
|
10
|
+
builtin
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function createSymbolEntry(name, descriptor, context) {
|
|
14
|
+
const symbols = new WeakMap();
|
|
15
|
+
function getSymbol(binder) {
|
|
16
|
+
// We cache symbols per binder to ensure we only create one symbol. We also
|
|
17
|
+
// track an unbound symbol for cases where there is no binder (mostly
|
|
18
|
+
// tests).
|
|
19
|
+
return mapGet(symbols, binder, () => createSymbolFromDescriptor(name, binder, descriptor, context, initializeMembers));
|
|
20
|
+
}
|
|
21
|
+
const newContext = {
|
|
22
|
+
ownerSymbol(binder) {
|
|
23
|
+
return getSymbol(binder);
|
|
24
|
+
},
|
|
25
|
+
builtin: context.builtin
|
|
26
|
+
};
|
|
27
|
+
function initializeMembers() {
|
|
28
|
+
for (const key of Object.keys(obj)) {
|
|
29
|
+
if (typeof key === "symbol") continue;
|
|
30
|
+
obj[key][TO_SYMBOL]();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const obj = {
|
|
34
|
+
[REFKEYABLE]() {
|
|
35
|
+
return getSymbol(useBinder()).refkeys[0];
|
|
36
|
+
},
|
|
37
|
+
[TO_SYMBOL]() {
|
|
38
|
+
return getSymbol(useBinder());
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
switch (descriptor.kind) {
|
|
42
|
+
case "package":
|
|
43
|
+
case "struct":
|
|
44
|
+
case "interface":
|
|
45
|
+
for (const [memberName, memberDesc] of Object.entries(descriptor.members)) {
|
|
46
|
+
obj[memberName] = createSymbolEntry(memberName, memberDesc, newContext);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
function createSymbolFromDescriptor(name, binder, descriptor, context, lazyMemberInitializer) {
|
|
53
|
+
const ownerSymbol = context.ownerSymbol(binder);
|
|
54
|
+
if (ownerSymbol === null && descriptor.kind !== "package") {
|
|
55
|
+
throw new Error(`Cannot create a non-package symbol (${name}) without an owner symbol.`);
|
|
56
|
+
}
|
|
57
|
+
switch (descriptor.kind) {
|
|
58
|
+
case "package":
|
|
59
|
+
if (ownerSymbol === null) {
|
|
60
|
+
const dname = basename(name);
|
|
61
|
+
const packageName = descriptor.name ?? dname;
|
|
62
|
+
const packageSymbol = new PackageSymbol(packageName, undefined, {
|
|
63
|
+
binder,
|
|
64
|
+
refkeys: refkey(),
|
|
65
|
+
lazyMemberInitializer,
|
|
66
|
+
path: descriptor.path,
|
|
67
|
+
builtin: context.builtin
|
|
68
|
+
});
|
|
69
|
+
return packageSymbol;
|
|
70
|
+
}
|
|
71
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
72
|
+
throw new Error(`Cannot create a package symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`);
|
|
73
|
+
}
|
|
74
|
+
if (ownerSymbol.members.symbolNames.has(name)) {
|
|
75
|
+
return ownerSymbol.members.symbolNames.get(name);
|
|
76
|
+
}
|
|
77
|
+
return new PackageSymbol(name, ownerSymbol, {
|
|
78
|
+
binder,
|
|
79
|
+
refkeys: refkey(),
|
|
80
|
+
lazyMemberInitializer,
|
|
81
|
+
path: descriptor.path,
|
|
82
|
+
builtin: context.builtin
|
|
83
|
+
});
|
|
84
|
+
case "struct":
|
|
85
|
+
case "interface":
|
|
86
|
+
case "type":
|
|
87
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
88
|
+
throw new Error(`Cannot create a named type symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`);
|
|
89
|
+
}
|
|
90
|
+
return new NamedTypeSymbol(namekey(name), ownerSymbol.members, descriptor.kind, {
|
|
91
|
+
binder,
|
|
92
|
+
refkeys: refkey(),
|
|
93
|
+
lazyMemberInitializer
|
|
94
|
+
});
|
|
95
|
+
case "function":
|
|
96
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
97
|
+
throw new Error(`Cannot create a function symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`);
|
|
98
|
+
}
|
|
99
|
+
return new FunctionSymbol(namekey(name), ownerSymbol.members, {
|
|
100
|
+
binder,
|
|
101
|
+
refkeys: refkey()
|
|
102
|
+
});
|
|
103
|
+
case "field":
|
|
104
|
+
if (!(ownerSymbol instanceof NamedTypeSymbol)) {
|
|
105
|
+
throw new Error(`Cannot create a field symbol (${name}) with a non-named-type owner symbol (${ownerSymbol.name}).`);
|
|
106
|
+
}
|
|
107
|
+
return new NamedTypeSymbol(namekey(name), ownerSymbol.members, ownerSymbol.typeKind === "interface" ? "interface-member" : "struct-member", {
|
|
108
|
+
binder,
|
|
109
|
+
refkeys: refkey(),
|
|
110
|
+
type: descriptor.type === undefined ? undefined : typeof descriptor.type === "function" ? descriptor.type()[TO_SYMBOL]() : descriptor.type[TO_SYMBOL](),
|
|
111
|
+
lazyMemberInitializer
|
|
112
|
+
});
|
|
113
|
+
case "embed":
|
|
114
|
+
{
|
|
115
|
+
if (!(ownerSymbol instanceof NamedTypeSymbol)) {
|
|
116
|
+
throw new Error(`Cannot create a field symbol (${name}) with a non-named-type owner symbol (${ownerSymbol.name}).`);
|
|
117
|
+
}
|
|
118
|
+
const symbol = new NamedTypeSymbol(namekey(name), ownerSymbol.members, ownerSymbol.typeKind === "interface" ? "interface-member" : "struct-member", {
|
|
119
|
+
binder,
|
|
120
|
+
refkeys: refkey(),
|
|
121
|
+
type: descriptor.type === undefined ? undefined : typeof descriptor.type === "function" ? descriptor.type()[TO_SYMBOL]() : descriptor.type[TO_SYMBOL](),
|
|
122
|
+
lazyMemberInitializer
|
|
123
|
+
});
|
|
124
|
+
symbol.copyMembersTo(ownerSymbol);
|
|
125
|
+
return symbol;
|
|
126
|
+
}
|
|
127
|
+
case "var":
|
|
128
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
129
|
+
throw new Error(`Cannot create a variable symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`);
|
|
130
|
+
}
|
|
131
|
+
return new GoSymbol(namekey(name), ownerSymbol.members, {
|
|
132
|
+
binder,
|
|
133
|
+
refkeys: refkey(),
|
|
134
|
+
type: descriptor.type === undefined ? undefined : typeof descriptor.type === "function" ? descriptor.type()[TO_SYMBOL]() : descriptor.type[TO_SYMBOL]()
|
|
135
|
+
});
|
|
136
|
+
default:
|
|
137
|
+
throw "Unsupported";
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const defaultsPerMap = new WeakMap();
|
|
141
|
+
function mapGet(map, key, init) {
|
|
142
|
+
if (key === undefined) {
|
|
143
|
+
// Use a per-map default store when callers request a value for an undefined key.
|
|
144
|
+
let value = defaultsPerMap.get(map);
|
|
145
|
+
if (value === undefined && init) {
|
|
146
|
+
value = init();
|
|
147
|
+
defaultsPerMap.set(map, value);
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
let value = map.get(key);
|
|
152
|
+
if (value === undefined && init) {
|
|
153
|
+
value = init();
|
|
154
|
+
map.set(key, value);
|
|
155
|
+
}
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=create-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["namekey","refkey","REFKEYABLE","TO_SYMBOL","useBinder","basename","FunctionSymbol","GoSymbol","PackageSymbol","NamedTypeSymbol","createModule","name","props","builtin","createSymbolEntry","ownerSymbol","_binder","descriptor","context","symbols","WeakMap","getSymbol","binder","mapGet","createSymbolFromDescriptor","initializeMembers","newContext","key","Object","keys","obj","refkeys","kind","memberName","memberDesc","entries","members","lazyMemberInitializer","Error","dname","packageName","packageSymbol","undefined","path","symbolNames","has","get","typeKind","type","symbol","copyMembersTo","defaultsPerMap","map","init","value","set"],"sources":["../../src/create-module.ts"],"sourcesContent":[null],"mappings":"AAAA,SAGEA,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,SAAS,EACTC,SAAS,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,KAAK,GAAGD,IAAI,CAAC,CAAC;IACdD,GAAG,CAACG,GAAG,CAAC5B,GAAG,EAAE2B,KAAK,CAAC;EACrB;EACA,OAAOA,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-module.test.d.ts","sourceRoot":"","sources":["../../src/create-module.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { TestPackage } from "#test/utils.js";
|
|
3
|
+
import { namekey, toRefkey } from "@alloy-js/core";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { fmt } from "./builtins/fmt/fmt.js";
|
|
6
|
+
import { VariableDeclaration } from "./components/index.js";
|
|
7
|
+
import { createModule } from "./create-module.js";
|
|
8
|
+
it("Can reference types which haven't been created yet", () => {
|
|
9
|
+
const std1 = createModule("std1", {
|
|
10
|
+
kind: "package",
|
|
11
|
+
members: {
|
|
12
|
+
SomeType: {
|
|
13
|
+
kind: "struct",
|
|
14
|
+
members: {
|
|
15
|
+
Special: {
|
|
16
|
+
kind: "field",
|
|
17
|
+
type: () => std2.SomeType2
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const std2 = createModule("std2", {
|
|
24
|
+
kind: "package",
|
|
25
|
+
members: {
|
|
26
|
+
SomeType2: {
|
|
27
|
+
kind: "struct",
|
|
28
|
+
members: {
|
|
29
|
+
Hello: {
|
|
30
|
+
kind: "field"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const test = namekey("test");
|
|
37
|
+
expect(_$createComponent(TestPackage, {
|
|
38
|
+
get children() {
|
|
39
|
+
return _$createComponent(VariableDeclaration, {
|
|
40
|
+
name: test,
|
|
41
|
+
get type() {
|
|
42
|
+
return std1.SomeType;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
})).toRenderTo(`
|
|
47
|
+
package alloy
|
|
48
|
+
|
|
49
|
+
import "std1"
|
|
50
|
+
|
|
51
|
+
var test std1.SomeType
|
|
52
|
+
`);
|
|
53
|
+
});
|
|
54
|
+
it("renders as a refkey", () => {
|
|
55
|
+
const mod = createModule("std", {
|
|
56
|
+
kind: "package",
|
|
57
|
+
members: {
|
|
58
|
+
BinaryReader: {
|
|
59
|
+
kind: "struct",
|
|
60
|
+
members: {}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
expect(_$createComponent(TestPackage, {
|
|
65
|
+
get children() {
|
|
66
|
+
return _$createComponent(VariableDeclaration, {
|
|
67
|
+
name: "test",
|
|
68
|
+
get type() {
|
|
69
|
+
return mod.BinaryReader;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
})).toRenderTo(`
|
|
74
|
+
package alloy
|
|
75
|
+
|
|
76
|
+
import "std"
|
|
77
|
+
|
|
78
|
+
var test std.BinaryReader
|
|
79
|
+
`);
|
|
80
|
+
});
|
|
81
|
+
it("has a refkey getter", () => {
|
|
82
|
+
const std = createModule("std", {
|
|
83
|
+
kind: "package",
|
|
84
|
+
members: {
|
|
85
|
+
SomeType: {
|
|
86
|
+
kind: "struct",
|
|
87
|
+
members: {
|
|
88
|
+
Special: {
|
|
89
|
+
kind: "field"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const ioKey = toRefkey(std);
|
|
96
|
+
expect(ioKey).toBeDefined();
|
|
97
|
+
const brKey = toRefkey(std.SomeType);
|
|
98
|
+
expect(brKey).toBeDefined();
|
|
99
|
+
});
|
|
100
|
+
it("has built-ins available", () => {
|
|
101
|
+
const template = _$createComponent(TestPackage, {
|
|
102
|
+
get children() {
|
|
103
|
+
return [_$memo(() => fmt.Println), "(\"Hello, World!\")"];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
expect(template).toRenderTo(`
|
|
107
|
+
package alloy
|
|
108
|
+
|
|
109
|
+
import "fmt"
|
|
110
|
+
|
|
111
|
+
fmt.Println("Hello, World!")
|
|
112
|
+
`);
|
|
113
|
+
});
|
|
114
|
+
it("can render multiple times", () => {
|
|
115
|
+
const mod = createModule("std", {
|
|
116
|
+
kind: "package",
|
|
117
|
+
members: {
|
|
118
|
+
BinaryReader: {
|
|
119
|
+
kind: "struct",
|
|
120
|
+
members: {}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
expect(_$createComponent(TestPackage, {
|
|
125
|
+
get children() {
|
|
126
|
+
return mod.BinaryReader;
|
|
127
|
+
}
|
|
128
|
+
})).toRenderTo(`
|
|
129
|
+
package alloy
|
|
130
|
+
|
|
131
|
+
import "std"
|
|
132
|
+
|
|
133
|
+
std.BinaryReader
|
|
134
|
+
`);
|
|
135
|
+
expect(_$createComponent(TestPackage, {
|
|
136
|
+
get children() {
|
|
137
|
+
return mod.BinaryReader;
|
|
138
|
+
}
|
|
139
|
+
})).toRenderTo(`
|
|
140
|
+
package alloy
|
|
141
|
+
|
|
142
|
+
import "std"
|
|
143
|
+
|
|
144
|
+
std.BinaryReader
|
|
145
|
+
`);
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=create-module.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TestPackage","namekey","toRefkey","expect","it","fmt","VariableDeclaration","createModule","std1","kind","members","SomeType","Special","type","std2","SomeType2","Hello","test","_$createComponent","children","name","toRenderTo","mod","BinaryReader","std","ioKey","toBeDefined","brKey","template","_$memo","Println"],"sources":["../../src/create-module.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,WAAW;AACpB,SAASC,OAAO,EAAEC,QAAQ,QAAQ,gBAAgB;AAClD,SAASC,MAAM,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,YAAY,CAAC,KAAK,EAAE;IAC9BE,IAAI,EAAE,SAAS;IACfC,OAAO,EAAE;MACPa,YAAY,EAAE;QACZd,IAAI,EAAE,QAAQ;QACdC,OAAO,EAAE,CAAC;MACZ;IACF;EACF,CAA4B,CAAC;EAE7BP,MAAM,CAAAe,iBAAA,CAAElB,WAAW;IAAA,IAAAmB,SAAA;MAAA,OAAEG,GAAG,CAACC,YAAY;IAAA;EAAA,EAAe,CAAC,CAACF,UAAU,CAAC;AACnE;AACA;AACA;AACA;AACA;AACA,GAAG,CAAC;EACFlB,MAAM,CAAAe,iBAAA,CAAElB,WAAW;IAAA,IAAAmB,SAAA;MAAA,OAAEG,GAAG,CAACC,YAAY;IAAA;EAAA,EAAe,CAAC,CAACF,UAAU,CAAC;AACnE;AACA;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NamePolicy } from "@alloy-js/core";
|
|
2
|
+
export type GoElements = "parameter" | "type-parameter" | "function" | "type" | "variable" | "struct-member" | "interface-member";
|
|
3
|
+
export declare function createGoNamePolicy(): NamePolicy<GoElements>;
|
|
4
|
+
export declare function useGoNamePolicy(): NamePolicy<GoElements>;
|
|
5
|
+
//# sourceMappingURL=name-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,UAAU,EAAiB,MAAM,gBAAgB,CAAC;AAE7E,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,gBAAgB,GAChB,UAAU,GACV,MAAM,GACN,UAAU,GACV,eAAe,GACf,kBAAkB,CAAC;AA+CvB,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,UAAU,CAAC,CAI3D;AAED,wBAAgB,eAAe,IAAI,UAAU,CAAC,UAAU,CAAC,CAExD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createNamePolicy, useNamePolicy } from "@alloy-js/core";
|
|
2
|
+
const GLOBAL_RESERVED_WORDS = new Set(["break", "case", "chan", "const", "continue", "default", "defer", "else", "fallthrough", "for", "func", "go", "goto", "if", "import", "interface", "map", "package", "range", "return", "select", "struct", "switch", "type", "var"]);
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ensures a valid Go identifier for the given element kind.
|
|
6
|
+
* @param name - The name to validate.
|
|
7
|
+
* @param element - The Go element kind.
|
|
8
|
+
* @returns A Go-safe name.
|
|
9
|
+
*/
|
|
10
|
+
function ensureNonReservedName(name, _element) {
|
|
11
|
+
const suffix = "_";
|
|
12
|
+
|
|
13
|
+
// Global reserved words always need handling
|
|
14
|
+
if (GLOBAL_RESERVED_WORDS.has(name)) {
|
|
15
|
+
return `${name}${suffix}`;
|
|
16
|
+
}
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
export function createGoNamePolicy() {
|
|
20
|
+
return createNamePolicy((name, element) => {
|
|
21
|
+
return ensureNonReservedName(name, element);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function useGoNamePolicy() {
|
|
25
|
+
return useNamePolicy();
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=name-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createNamePolicy","useNamePolicy","GLOBAL_RESERVED_WORDS","Set","ensureNonReservedName","name","_element","suffix","has","createGoNamePolicy","element","useGoNamePolicy"],"sources":["../../src/name-policy.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,gBAAgB,EAAcC,aAAa,QAAQ,gBAAgB;AAW5E,MAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAAC,CACpC,OAAO,EACP,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,aAAa,EACb,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,CACN,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,qBAAqBA,CAACC,IAAY,EAAEC,QAAoB,EAAU;EACzE,MAAMC,MAAM,GAAG,GAAG;;EAElB;EACA,IAAIL,qBAAqB,CAACM,GAAG,CAACH,IAAI,CAAC,EAAE;IACnC,OAAO,GAAGA,IAAI,GAAGE,MAAM,EAAE;EAC3B;EAEA,OAAOF,IAAI;AACb;AAEA,OAAO,SAASI,kBAAkBA,CAAA,EAA2B;EAC3D,OAAOT,gBAAgB,CAAC,CAACK,IAAI,EAAEK,OAAO,KAAK;IACzC,OAAON,qBAAqB,CAACC,IAAI,EAAEK,OAAO,CAAC;EAC7C,CAAC,CAAC;AACJ;AAEA,OAAO,SAASC,eAAeA,CAAA,EAA2B;EACxD,OAAOV,aAAa,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GoFunctionScope } from "./function.js";
|
|
2
|
+
import { GoScope } from "./go.js";
|
|
3
|
+
import { GoLexicalScope } from "./lexical.js";
|
|
4
|
+
import { GoNamedTypeScope } from "./named-type.js";
|
|
5
|
+
export declare function useGoScope(): GoScope;
|
|
6
|
+
export declare function useNamedTypeScope(): GoNamedTypeScope;
|
|
7
|
+
export declare function useFuncScope(): GoFunctionScope;
|
|
8
|
+
export declare function useLexicalScope(): GoLexicalScope;
|
|
9
|
+
//# sourceMappingURL=contexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/scopes/contexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,wBAAgB,UAAU,YAOzB;AAED,wBAAgB,iBAAiB,qBAShC;AAED,wBAAgB,YAAY,oBAQ3B;AAED,wBAAgB,eAAe,mBAQ9B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useScope } from "@alloy-js/core";
|
|
2
|
+
import { GoFunctionScope } from "./function.js";
|
|
3
|
+
import { GoScope } from "./go.js";
|
|
4
|
+
import { GoLexicalScope } from "./lexical.js";
|
|
5
|
+
import { GoNamedTypeScope } from "./named-type.js";
|
|
6
|
+
export function useGoScope() {
|
|
7
|
+
const scope = useScope();
|
|
8
|
+
if (!(scope instanceof GoScope)) {
|
|
9
|
+
throw new Error("Expected a Go scope, got a different kind of scope.");
|
|
10
|
+
}
|
|
11
|
+
return scope;
|
|
12
|
+
}
|
|
13
|
+
export function useNamedTypeScope() {
|
|
14
|
+
const scope = useGoScope();
|
|
15
|
+
if (!(scope instanceof GoNamedTypeScope)) {
|
|
16
|
+
throw new Error("Expected a named type scope, got a " + scope.constructor.name);
|
|
17
|
+
}
|
|
18
|
+
return scope;
|
|
19
|
+
}
|
|
20
|
+
export function useFuncScope() {
|
|
21
|
+
const scope = useGoScope();
|
|
22
|
+
if (!(scope instanceof GoFunctionScope)) {
|
|
23
|
+
throw new Error(`Expected a function scope, but got ${scope.constructor.name}.`);
|
|
24
|
+
}
|
|
25
|
+
return scope;
|
|
26
|
+
}
|
|
27
|
+
export function useLexicalScope() {
|
|
28
|
+
const scope = useGoScope();
|
|
29
|
+
if (!(scope instanceof GoLexicalScope)) {
|
|
30
|
+
throw new Error(`Expected a lexical scope, but got ${scope.constructor.name}.`);
|
|
31
|
+
}
|
|
32
|
+
return scope;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=contexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useScope","GoFunctionScope","GoScope","GoLexicalScope","GoNamedTypeScope","useGoScope","scope","Error","useNamedTypeScope","constructor","name","useFuncScope","useLexicalScope"],"sources":["../../../src/scopes/contexts.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,cAAc,QAAQ,cAAc;AAC7C,SAASC,gBAAgB,QAAQ,iBAAiB;AAElD,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3B,MAAMC,KAAK,GAAGN,QAAQ,CAAC,CAAC;EACxB,IAAI,EAAEM,KAAK,YAAYJ,OAAO,CAAC,EAAE;IAC/B,MAAM,IAAIK,KAAK,CAAC,qDAAqD,CAAC;EACxE;EAEA,OAAOD,KAAK;AACd;AAEA,OAAO,SAASE,iBAAiBA,CAAA,EAAG;EAClC,MAAMF,KAAK,GAAGD,UAAU,CAAC,CAAC;EAC1B,IAAI,EAAEC,KAAK,YAAYF,gBAAgB,CAAC,EAAE;IACxC,MAAM,IAAIG,KAAK,CACb,qCAAqC,GAAGD,KAAK,CAACG,WAAW,CAACC,IAC5D,CAAC;EACH;EAEA,OAAOJ,KAAK;AACd;AAEA,OAAO,SAASK,YAAYA,CAAA,EAAG;EAC7B,MAAML,KAAK,GAAGD,UAAU,CAAC,CAAC;EAC1B,IAAI,EAAEC,KAAK,YAAYL,eAAe,CAAC,EAAE;IACvC,MAAM,IAAIM,KAAK,CACb,sCAAsCD,KAAK,CAACG,WAAW,CAACC,IAAI,GAC9D,CAAC;EACH;EACA,OAAOJ,KAAK;AACd;AAEA,OAAO,SAASM,eAAeA,CAAA,EAAG;EAChC,MAAMN,KAAK,GAAGD,UAAU,CAAC,CAAC;EAC1B,IAAI,EAAEC,KAAK,YAAYH,cAAc,CAAC,EAAE;IACtC,MAAM,IAAII,KAAK,CACb,qCAAqCD,KAAK,CAACG,WAAW,CAACC,IAAI,GAC7D,CAAC;EACH;EACA,OAAOJ,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamedTypeSymbol } from "../symbols/named-type.js";
|
|
3
|
+
import { GoFunctionScope } from "./function.js";
|
|
4
|
+
import { GoNamedTypeScope } from "./named-type.js";
|
|
5
|
+
export declare function createNamedTypeScope(ownerSymbol: NamedTypeSymbol, options?: OutputScopeOptions): GoNamedTypeScope;
|
|
6
|
+
export declare function createFunctionScope(options?: OutputScopeOptions): GoFunctionScope;
|
|
7
|
+
//# sourceMappingURL=factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/scopes/factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,kBAAuB,oBAcjC;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,kBAAuB,mBAGnE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useGoScope } from "./contexts.js";
|
|
2
|
+
import { GoFunctionScope } from "./function.js";
|
|
3
|
+
import { GoNamedTypeScope } from "./named-type.js";
|
|
4
|
+
import { GoSourceFileScope } from "./source-file.js";
|
|
5
|
+
export function createNamedTypeScope(ownerSymbol, options = {}) {
|
|
6
|
+
const currentScope = useGoScope();
|
|
7
|
+
if (!(currentScope instanceof GoNamedTypeScope) && !(currentScope instanceof GoSourceFileScope)) {
|
|
8
|
+
throw new Error("Can't create Go type declaration scope inside of " + currentScope.constructor.name);
|
|
9
|
+
}
|
|
10
|
+
return new GoNamedTypeScope(ownerSymbol, currentScope, options);
|
|
11
|
+
}
|
|
12
|
+
export function createFunctionScope(options = {}) {
|
|
13
|
+
const parentScope = useGoScope();
|
|
14
|
+
return new GoFunctionScope("function scope", parentScope, options);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=factories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useGoScope","GoFunctionScope","GoNamedTypeScope","GoSourceFileScope","createNamedTypeScope","ownerSymbol","options","currentScope","Error","constructor","name","createFunctionScope","parentScope"],"sources":["../../../src/scopes/factories.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,UAAU,QAAQ,eAAe;AAC1C,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,iBAAiB,QAAQ,kBAAkB;AAEpD,OAAO,SAASC,oBAAoBA,CAClCC,WAA4B,EAC5BC,OAA2B,GAAG,CAAC,CAAC,EAChC;EACA,MAAMC,YAAY,GAAGP,UAAU,CAAC,CAAC;EACjC,IACE,EAAEO,YAAY,YAAYL,gBAAgB,CAAC,IAC3C,EAAEK,YAAY,YAAYJ,iBAAiB,CAAC,EAC5C;IACA,MAAM,IAAIK,KAAK,CACb,mDAAmD,GACjDD,YAAY,CAACE,WAAW,CAACC,IAC7B,CAAC;EACH;EAEA,OAAO,IAAIR,gBAAgB,CAACG,WAAW,EAAEE,YAAY,EAAED,OAAO,CAAC;AACjE;AAEA,OAAO,SAASK,mBAAmBA,CAACL,OAA2B,GAAG,CAAC,CAAC,EAAE;EACpE,MAAMM,WAAW,GAAGZ,UAAU,CAAC,CAAC;EAChC,OAAO,IAAIC,eAAe,CAAC,gBAAgB,EAAEW,WAAW,EAAEN,OAAO,CAAC;AACpE","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OutputSpace } from "@alloy-js/core";
|
|
2
|
+
import { GoLexicalScope } from "./lexical.js";
|
|
3
|
+
export declare class GoFunctionScope extends GoLexicalScope {
|
|
4
|
+
static readonly declarationSpaces: string[];
|
|
5
|
+
get localVariables(): OutputSpace;
|
|
6
|
+
get parameters(): OutputSpace;
|
|
7
|
+
get typeParameters(): OutputSpace;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/scopes/function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,qBAAa,eAAgB,SAAQ,cAAc;IACjD,gBAAuB,iBAAiB,WAItC;IAEF,IAAI,cAAc,IAAI,WAAW,CAEhC;IAED,IAAI,UAAU,IAAI,WAAW,CAE5B;IAED,IAAI,cAAc,IAAI,WAAW,CAEhC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GoLexicalScope } from "./lexical.js";
|
|
2
|
+
export class GoFunctionScope extends GoLexicalScope {
|
|
3
|
+
static declarationSpaces = ["local-variables", "parameters", "type-parameters"];
|
|
4
|
+
get localVariables() {
|
|
5
|
+
return this.spaceFor("local-variables");
|
|
6
|
+
}
|
|
7
|
+
get parameters() {
|
|
8
|
+
return this.spaceFor("parameters");
|
|
9
|
+
}
|
|
10
|
+
get typeParameters() {
|
|
11
|
+
return this.spaceFor("type-parameters");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GoLexicalScope","GoFunctionScope","declarationSpaces","localVariables","spaceFor","parameters","typeParameters"],"sources":["../../../src/scopes/function.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,cAAc,QAAQ,cAAc;AAE7C,OAAO,MAAMC,eAAe,SAASD,cAAc,CAAC;EAClD,OAAuBE,iBAAiB,GAAG,CACzC,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,CAClB;EAED,IAAIC,cAAcA,CAAA,EAAgB;IAChC,OAAO,IAAI,CAACC,QAAQ,CAAC,iBAAiB,CAAC;EACzC;EAEA,IAAIC,UAAUA,CAAA,EAAgB;IAC5B,OAAO,IAAI,CAACD,QAAQ,CAAC,YAAY,CAAC;EACpC;EAEA,IAAIE,cAAcA,CAAA,EAAgB;IAChC,OAAO,IAAI,CAACF,QAAQ,CAAC,iBAAiB,CAAC;EACzC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OutputScope, OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { PackageSymbol } from "../symbols/package.js";
|
|
3
|
+
export declare class GoScope extends OutputScope {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(name: string, parent: GoScope | undefined, options?: OutputScopeOptions);
|
|
6
|
+
get enclosingPackage(): PackageSymbol | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=go.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../../src/scopes/go.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,qBAAa,OAAQ,SAAQ,WAAW;;gBAEpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,OAAO,CAAC,EAAE,kBAAkB;IAO9B,IAAI,gBAAgB,8BAEnB;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OutputScope } from "@alloy-js/core";
|
|
2
|
+
export class GoScope extends OutputScope {
|
|
3
|
+
constructor(name, parent, options) {
|
|
4
|
+
super(name, parent, options);
|
|
5
|
+
this.#packageSymbol = parent?.enclosingPackage;
|
|
6
|
+
}
|
|
7
|
+
#packageSymbol;
|
|
8
|
+
get enclosingPackage() {
|
|
9
|
+
return this.#packageSymbol;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=go.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OutputScope","GoScope","constructor","name","parent","options","packageSymbol","enclosingPackage"],"sources":["../../../src/scopes/go.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAA4B,gBAAgB;AAGhE,OAAO,MAAMC,OAAO,SAASD,WAAW,CAAC;EACvCE,WAAWA,CACTC,IAAY,EACZC,MAA2B,EAC3BC,OAA4B,EAC5B;IACA,KAAK,CAACF,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;IAC5B,IAAI,CAAC,CAACC,aAAa,GAAGF,MAAM,EAAEG,gBAAgB;EAChD;EAEA,CAACD,aAAa;EACd,IAAIC,gBAAgBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAAC,CAACD,aAAa;EAC5B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./contexts.js";
|
|
2
|
+
export * from "./factories.js";
|
|
3
|
+
export * from "./function.js";
|
|
4
|
+
export * from "./go.js";
|
|
5
|
+
export * from "./lexical.js";
|
|
6
|
+
export * from "./module.js";
|
|
7
|
+
export * from "./named-type.js";
|
|
8
|
+
export * from "./package.js";
|
|
9
|
+
export * from "./source-file.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scopes/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./contexts.js";
|
|
2
|
+
export * from "./factories.js";
|
|
3
|
+
export * from "./function.js";
|
|
4
|
+
export * from "./go.js";
|
|
5
|
+
export * from "./lexical.js";
|
|
6
|
+
export * from "./module.js";
|
|
7
|
+
export * from "./named-type.js";
|
|
8
|
+
export * from "./package.js";
|
|
9
|
+
export * from "./source-file.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|