@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,347 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Binder,
|
|
3
|
+
LibrarySymbolReference,
|
|
4
|
+
namekey,
|
|
5
|
+
refkey,
|
|
6
|
+
REFKEYABLE,
|
|
7
|
+
TO_SYMBOL,
|
|
8
|
+
useBinder,
|
|
9
|
+
} from "@alloy-js/core";
|
|
10
|
+
import { basename } from "pathe";
|
|
11
|
+
import { FunctionSymbol, GoSymbol, PackageSymbol } from "./index.js";
|
|
12
|
+
import { NamedTypeSymbol } from "./symbols/named-type.js";
|
|
13
|
+
|
|
14
|
+
export interface MemberDescriptor {
|
|
15
|
+
kind: string;
|
|
16
|
+
type?: LibrarySymbolReference | (() => LibrarySymbolReference);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FieldDescriptor extends MemberDescriptor {
|
|
20
|
+
kind: "field";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface FunctionDescriptor extends MemberDescriptor {
|
|
24
|
+
kind: "function";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MethodDescriptor extends MemberDescriptor {
|
|
28
|
+
kind: "method";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface VariableDescriptor extends MemberDescriptor {
|
|
32
|
+
kind: "var";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface EmbedDescriptor extends MemberDescriptor {
|
|
36
|
+
kind: "embed";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface NamedTypeDescriptor<M extends Record<string, Descriptor>> {
|
|
40
|
+
kind: string;
|
|
41
|
+
members: M;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TypeDescriptor<M extends Record<string, Descriptor>>
|
|
45
|
+
extends NamedTypeDescriptor<M> {
|
|
46
|
+
kind: "type";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface PackageDescriptor<M extends Record<string, Descriptor>>
|
|
50
|
+
extends NamedTypeDescriptor<M> {
|
|
51
|
+
kind: "package";
|
|
52
|
+
path?: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
members: M;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface StructDescriptor<M extends Record<string, Descriptor>>
|
|
58
|
+
extends NamedTypeDescriptor<M> {
|
|
59
|
+
kind: "struct";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface InterfaceDescriptor<M extends Record<string, Descriptor>>
|
|
63
|
+
extends NamedTypeDescriptor<M> {
|
|
64
|
+
kind: "interface";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type Descriptor =
|
|
68
|
+
| PackageDescriptor<any>
|
|
69
|
+
| FieldDescriptor
|
|
70
|
+
| FunctionDescriptor
|
|
71
|
+
| MethodDescriptor
|
|
72
|
+
| VariableDescriptor
|
|
73
|
+
| StructDescriptor<any>
|
|
74
|
+
| InterfaceDescriptor<any>
|
|
75
|
+
| TypeDescriptor<any>
|
|
76
|
+
| EmbedDescriptor;
|
|
77
|
+
|
|
78
|
+
export type StrictDescriptor =
|
|
79
|
+
| PackageDescriptor<Record<string, StrictDescriptor>>
|
|
80
|
+
| FieldDescriptor
|
|
81
|
+
| FunctionDescriptor
|
|
82
|
+
| MethodDescriptor
|
|
83
|
+
| VariableDescriptor
|
|
84
|
+
| StructDescriptor<Record<string, StrictDescriptor>>
|
|
85
|
+
| InterfaceDescriptor<Record<string, StrictDescriptor>>
|
|
86
|
+
| TypeDescriptor<Record<string, StrictDescriptor>>
|
|
87
|
+
| EmbedDescriptor;
|
|
88
|
+
|
|
89
|
+
export type ResolveDescriptor<D> =
|
|
90
|
+
D extends NamedTypeDescriptor<infer M> ?
|
|
91
|
+
LibrarySymbolReference & { [K in keyof M]: ResolveDescriptor<M[K]> }
|
|
92
|
+
: LibrarySymbolReference;
|
|
93
|
+
|
|
94
|
+
export type LibraryFrom<T> = ResolveDescriptor<T> & LibrarySymbolReference;
|
|
95
|
+
|
|
96
|
+
interface InternalContext {
|
|
97
|
+
ownerSymbol(binder: Binder | undefined): GoSymbol | null;
|
|
98
|
+
builtin: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function createModule<T extends PackageDescriptor<any>>(
|
|
102
|
+
name: string,
|
|
103
|
+
props: T,
|
|
104
|
+
builtin: boolean = false,
|
|
105
|
+
): LibraryFrom<T> {
|
|
106
|
+
return createSymbolEntry(name, props, {
|
|
107
|
+
ownerSymbol(_binder: Binder | undefined) {
|
|
108
|
+
return null;
|
|
109
|
+
},
|
|
110
|
+
builtin,
|
|
111
|
+
}) as LibraryFrom<T>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function createSymbolEntry(
|
|
115
|
+
name: string,
|
|
116
|
+
descriptor: Descriptor,
|
|
117
|
+
context: InternalContext,
|
|
118
|
+
): LibrarySymbolReference {
|
|
119
|
+
const symbols = new WeakMap<Binder, GoSymbol>();
|
|
120
|
+
|
|
121
|
+
function getSymbol(binder: Binder | undefined) {
|
|
122
|
+
// We cache symbols per binder to ensure we only create one symbol. We also
|
|
123
|
+
// track an unbound symbol for cases where there is no binder (mostly
|
|
124
|
+
// tests).
|
|
125
|
+
return mapGet(symbols, binder, () =>
|
|
126
|
+
createSymbolFromDescriptor(
|
|
127
|
+
name,
|
|
128
|
+
binder,
|
|
129
|
+
descriptor,
|
|
130
|
+
context,
|
|
131
|
+
initializeMembers,
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const newContext: InternalContext = {
|
|
137
|
+
ownerSymbol(binder) {
|
|
138
|
+
return getSymbol(binder) as NamedTypeSymbol;
|
|
139
|
+
},
|
|
140
|
+
builtin: context.builtin,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
function initializeMembers() {
|
|
144
|
+
for (const key of Object.keys(obj)) {
|
|
145
|
+
if (typeof key === "symbol") continue;
|
|
146
|
+
(obj as any)[key][TO_SYMBOL]();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const obj: LibrarySymbolReference & Record<string, unknown> = {
|
|
151
|
+
[REFKEYABLE]() {
|
|
152
|
+
return getSymbol(useBinder()).refkeys[0];
|
|
153
|
+
},
|
|
154
|
+
[TO_SYMBOL]() {
|
|
155
|
+
return getSymbol(useBinder());
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
switch (descriptor.kind) {
|
|
160
|
+
case "package":
|
|
161
|
+
case "struct":
|
|
162
|
+
case "interface":
|
|
163
|
+
for (const [memberName, memberDesc] of Object.entries(
|
|
164
|
+
descriptor.members,
|
|
165
|
+
) as any) {
|
|
166
|
+
obj[memberName] = createSymbolEntry(memberName, memberDesc, newContext);
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return obj;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function createSymbolFromDescriptor(
|
|
175
|
+
name: string,
|
|
176
|
+
binder: Binder | undefined,
|
|
177
|
+
descriptor: Descriptor,
|
|
178
|
+
context: InternalContext,
|
|
179
|
+
lazyMemberInitializer: () => void,
|
|
180
|
+
): GoSymbol {
|
|
181
|
+
const ownerSymbol = context.ownerSymbol(binder) as GoSymbol;
|
|
182
|
+
|
|
183
|
+
if (ownerSymbol === null && descriptor.kind !== "package") {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Cannot create a non-package symbol (${name}) without an owner symbol.`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
switch (descriptor.kind) {
|
|
190
|
+
case "package":
|
|
191
|
+
if (ownerSymbol === null) {
|
|
192
|
+
const dname = basename(name);
|
|
193
|
+
const packageName = descriptor.name ?? dname;
|
|
194
|
+
const packageSymbol = new PackageSymbol(packageName, undefined, {
|
|
195
|
+
binder,
|
|
196
|
+
refkeys: refkey(),
|
|
197
|
+
lazyMemberInitializer,
|
|
198
|
+
path: descriptor.path,
|
|
199
|
+
builtin: context.builtin,
|
|
200
|
+
});
|
|
201
|
+
return packageSymbol;
|
|
202
|
+
}
|
|
203
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`Cannot create a package symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
if (ownerSymbol.members.symbolNames.has(name)) {
|
|
209
|
+
return ownerSymbol.members.symbolNames.get(name)! as PackageSymbol;
|
|
210
|
+
}
|
|
211
|
+
return new PackageSymbol(name, ownerSymbol as PackageSymbol, {
|
|
212
|
+
binder,
|
|
213
|
+
refkeys: refkey(),
|
|
214
|
+
lazyMemberInitializer,
|
|
215
|
+
path: descriptor.path,
|
|
216
|
+
builtin: context.builtin,
|
|
217
|
+
});
|
|
218
|
+
case "struct":
|
|
219
|
+
case "interface":
|
|
220
|
+
case "type":
|
|
221
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Cannot create a named type symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
return new NamedTypeSymbol(
|
|
227
|
+
namekey(name),
|
|
228
|
+
ownerSymbol.members,
|
|
229
|
+
descriptor.kind,
|
|
230
|
+
{
|
|
231
|
+
binder,
|
|
232
|
+
refkeys: refkey(),
|
|
233
|
+
lazyMemberInitializer,
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
case "function":
|
|
237
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
`Cannot create a function symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return new FunctionSymbol(namekey(name), ownerSymbol.members, {
|
|
243
|
+
binder,
|
|
244
|
+
refkeys: refkey(),
|
|
245
|
+
});
|
|
246
|
+
case "field":
|
|
247
|
+
if (!(ownerSymbol instanceof NamedTypeSymbol)) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
`Cannot create a field symbol (${name}) with a non-named-type owner symbol (${ownerSymbol.name}).`,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
return new NamedTypeSymbol(
|
|
253
|
+
namekey(name),
|
|
254
|
+
ownerSymbol.members,
|
|
255
|
+
ownerSymbol.typeKind === "interface" ?
|
|
256
|
+
"interface-member"
|
|
257
|
+
: "struct-member",
|
|
258
|
+
{
|
|
259
|
+
binder,
|
|
260
|
+
refkeys: refkey(),
|
|
261
|
+
type:
|
|
262
|
+
descriptor.type === undefined ? undefined
|
|
263
|
+
: typeof descriptor.type === "function" ?
|
|
264
|
+
descriptor.type()[TO_SYMBOL]()
|
|
265
|
+
: descriptor.type[TO_SYMBOL](),
|
|
266
|
+
lazyMemberInitializer,
|
|
267
|
+
},
|
|
268
|
+
);
|
|
269
|
+
case "embed": {
|
|
270
|
+
if (!(ownerSymbol instanceof NamedTypeSymbol)) {
|
|
271
|
+
throw new Error(
|
|
272
|
+
`Cannot create a field symbol (${name}) with a non-named-type owner symbol (${ownerSymbol.name}).`,
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
const symbol = new NamedTypeSymbol(
|
|
276
|
+
namekey(name),
|
|
277
|
+
ownerSymbol.members,
|
|
278
|
+
ownerSymbol.typeKind === "interface" ?
|
|
279
|
+
"interface-member"
|
|
280
|
+
: "struct-member",
|
|
281
|
+
{
|
|
282
|
+
binder,
|
|
283
|
+
refkeys: refkey(),
|
|
284
|
+
type:
|
|
285
|
+
descriptor.type === undefined ? undefined
|
|
286
|
+
: typeof descriptor.type === "function" ?
|
|
287
|
+
descriptor.type()[TO_SYMBOL]()
|
|
288
|
+
: descriptor.type[TO_SYMBOL](),
|
|
289
|
+
lazyMemberInitializer,
|
|
290
|
+
},
|
|
291
|
+
);
|
|
292
|
+
symbol.copyMembersTo(ownerSymbol);
|
|
293
|
+
return symbol;
|
|
294
|
+
}
|
|
295
|
+
case "var":
|
|
296
|
+
if (!(ownerSymbol instanceof PackageSymbol)) {
|
|
297
|
+
throw new Error(
|
|
298
|
+
`Cannot create a variable symbol (${name}) with a non-package owner symbol (${ownerSymbol.name}).`,
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
return new GoSymbol(namekey(name), ownerSymbol.members, {
|
|
302
|
+
binder,
|
|
303
|
+
refkeys: refkey(),
|
|
304
|
+
type:
|
|
305
|
+
descriptor.type === undefined ? undefined
|
|
306
|
+
: typeof descriptor.type === "function" ?
|
|
307
|
+
descriptor.type()[TO_SYMBOL]()
|
|
308
|
+
: descriptor.type[TO_SYMBOL](),
|
|
309
|
+
});
|
|
310
|
+
default:
|
|
311
|
+
throw "Unsupported";
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const defaultsPerMap = new WeakMap<object, unknown>();
|
|
316
|
+
|
|
317
|
+
function mapGet<T extends WeakKey, V>(
|
|
318
|
+
map: WeakMap<T, V>,
|
|
319
|
+
key: T | undefined,
|
|
320
|
+
): V | undefined;
|
|
321
|
+
function mapGet<T extends WeakKey, V>(
|
|
322
|
+
map: WeakMap<T, V>,
|
|
323
|
+
key: T | undefined,
|
|
324
|
+
init: () => V,
|
|
325
|
+
): V;
|
|
326
|
+
function mapGet<T extends WeakKey, V>(
|
|
327
|
+
map: WeakMap<T, V>,
|
|
328
|
+
key: T | undefined,
|
|
329
|
+
init?: () => V,
|
|
330
|
+
): V | undefined {
|
|
331
|
+
if (key === undefined) {
|
|
332
|
+
// Use a per-map default store when callers request a value for an undefined key.
|
|
333
|
+
let value = defaultsPerMap.get(map as unknown as object) as V | undefined;
|
|
334
|
+
if (value === undefined && init) {
|
|
335
|
+
value = init();
|
|
336
|
+
defaultsPerMap.set(map as unknown as object, value);
|
|
337
|
+
}
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let value = map.get(key);
|
|
342
|
+
if (value === undefined && init) {
|
|
343
|
+
value = init();
|
|
344
|
+
map.set(key, value);
|
|
345
|
+
}
|
|
346
|
+
return value;
|
|
347
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createNamePolicy, NamePolicy, useNamePolicy } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
export type GoElements =
|
|
4
|
+
| "parameter"
|
|
5
|
+
| "type-parameter"
|
|
6
|
+
| "function"
|
|
7
|
+
| "type"
|
|
8
|
+
| "variable"
|
|
9
|
+
| "struct-member"
|
|
10
|
+
| "interface-member";
|
|
11
|
+
|
|
12
|
+
const GLOBAL_RESERVED_WORDS = new Set([
|
|
13
|
+
"break",
|
|
14
|
+
"case",
|
|
15
|
+
"chan",
|
|
16
|
+
"const",
|
|
17
|
+
"continue",
|
|
18
|
+
"default",
|
|
19
|
+
"defer",
|
|
20
|
+
"else",
|
|
21
|
+
"fallthrough",
|
|
22
|
+
"for",
|
|
23
|
+
"func",
|
|
24
|
+
"go",
|
|
25
|
+
"goto",
|
|
26
|
+
"if",
|
|
27
|
+
"import",
|
|
28
|
+
"interface",
|
|
29
|
+
"map",
|
|
30
|
+
"package",
|
|
31
|
+
"range",
|
|
32
|
+
"return",
|
|
33
|
+
"select",
|
|
34
|
+
"struct",
|
|
35
|
+
"switch",
|
|
36
|
+
"type",
|
|
37
|
+
"var",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Ensures a valid Go identifier for the given element kind.
|
|
42
|
+
* @param name - The name to validate.
|
|
43
|
+
* @param element - The Go element kind.
|
|
44
|
+
* @returns A Go-safe name.
|
|
45
|
+
*/
|
|
46
|
+
function ensureNonReservedName(name: string, _element: GoElements): string {
|
|
47
|
+
const suffix = "_";
|
|
48
|
+
|
|
49
|
+
// Global reserved words always need handling
|
|
50
|
+
if (GLOBAL_RESERVED_WORDS.has(name)) {
|
|
51
|
+
return `${name}${suffix}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return name;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createGoNamePolicy(): NamePolicy<GoElements> {
|
|
58
|
+
return createNamePolicy((name, element) => {
|
|
59
|
+
return ensureNonReservedName(name, element);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function useGoNamePolicy(): NamePolicy<GoElements> {
|
|
64
|
+
return useNamePolicy();
|
|
65
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
|
|
7
|
+
export function useGoScope() {
|
|
8
|
+
const scope = useScope();
|
|
9
|
+
if (!(scope instanceof GoScope)) {
|
|
10
|
+
throw new Error("Expected a Go scope, got a different kind of scope.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return scope;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useNamedTypeScope() {
|
|
17
|
+
const scope = useGoScope();
|
|
18
|
+
if (!(scope instanceof GoNamedTypeScope)) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"Expected a named type scope, got a " + scope.constructor.name,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return scope;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useFuncScope() {
|
|
28
|
+
const scope = useGoScope();
|
|
29
|
+
if (!(scope instanceof GoFunctionScope)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Expected a function scope, but got ${scope.constructor.name}.`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return scope;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useLexicalScope() {
|
|
38
|
+
const scope = useGoScope();
|
|
39
|
+
if (!(scope instanceof GoLexicalScope)) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Expected a lexical scope, but got ${scope.constructor.name}.`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return scope;
|
|
45
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamedTypeSymbol } from "../symbols/named-type.js";
|
|
3
|
+
import { useGoScope } from "./contexts.js";
|
|
4
|
+
import { GoFunctionScope } from "./function.js";
|
|
5
|
+
import { GoNamedTypeScope } from "./named-type.js";
|
|
6
|
+
import { GoSourceFileScope } from "./source-file.js";
|
|
7
|
+
|
|
8
|
+
export function createNamedTypeScope(
|
|
9
|
+
ownerSymbol: NamedTypeSymbol,
|
|
10
|
+
options: OutputScopeOptions = {},
|
|
11
|
+
) {
|
|
12
|
+
const currentScope = useGoScope();
|
|
13
|
+
if (
|
|
14
|
+
!(currentScope instanceof GoNamedTypeScope) &&
|
|
15
|
+
!(currentScope instanceof GoSourceFileScope)
|
|
16
|
+
) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"Can't create Go type declaration scope inside of " +
|
|
19
|
+
currentScope.constructor.name,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return new GoNamedTypeScope(ownerSymbol, currentScope, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createFunctionScope(options: OutputScopeOptions = {}) {
|
|
27
|
+
const parentScope = useGoScope();
|
|
28
|
+
return new GoFunctionScope("function scope", parentScope, options);
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OutputSpace } from "@alloy-js/core";
|
|
2
|
+
import { GoLexicalScope } from "./lexical.js";
|
|
3
|
+
|
|
4
|
+
export class GoFunctionScope extends GoLexicalScope {
|
|
5
|
+
public static readonly declarationSpaces = [
|
|
6
|
+
"local-variables",
|
|
7
|
+
"parameters",
|
|
8
|
+
"type-parameters",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
get localVariables(): OutputSpace {
|
|
12
|
+
return this.spaceFor("local-variables")!;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get parameters(): OutputSpace {
|
|
16
|
+
return this.spaceFor("parameters")!;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get typeParameters(): OutputSpace {
|
|
20
|
+
return this.spaceFor("type-parameters")!;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/scopes/go.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OutputScope, OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { PackageSymbol } from "../symbols/package.js";
|
|
3
|
+
|
|
4
|
+
export class GoScope extends OutputScope {
|
|
5
|
+
constructor(
|
|
6
|
+
name: string,
|
|
7
|
+
parent: GoScope | undefined,
|
|
8
|
+
options?: OutputScopeOptions,
|
|
9
|
+
) {
|
|
10
|
+
super(name, parent, options);
|
|
11
|
+
this.#packageSymbol = parent?.enclosingPackage;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#packageSymbol: PackageSymbol | undefined;
|
|
15
|
+
get enclosingPackage() {
|
|
16
|
+
return this.#packageSymbol;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OutputSpace } from "@alloy-js/core";
|
|
2
|
+
import { GoScope } from "./go.js";
|
|
3
|
+
|
|
4
|
+
export class GoLexicalScope extends GoScope {
|
|
5
|
+
public static readonly declarationSpaces = ["values", "types"];
|
|
6
|
+
|
|
7
|
+
get values(): OutputSpace {
|
|
8
|
+
return this.spaceFor("values")!;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get types(): OutputSpace {
|
|
12
|
+
return this.spaceFor("types")!;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OutputScope, useScope } from "@alloy-js/core";
|
|
2
|
+
import { GoScope } from "./go.js";
|
|
3
|
+
|
|
4
|
+
export class GoModuleScope extends GoScope {
|
|
5
|
+
constructor(name: string, builtin = false) {
|
|
6
|
+
super(name, undefined);
|
|
7
|
+
this.#builtin = builtin;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
#builtin: boolean;
|
|
11
|
+
get builtin() {
|
|
12
|
+
return this.#builtin;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createGoModuleScope(name: string) {
|
|
17
|
+
const parentScope = useScope();
|
|
18
|
+
if (parentScope) {
|
|
19
|
+
throw new Error("Modules can only be created at the top level");
|
|
20
|
+
}
|
|
21
|
+
const scope = new GoModuleScope(name);
|
|
22
|
+
return scope;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useModule() {
|
|
26
|
+
let scope: OutputScope | undefined = useScope();
|
|
27
|
+
while (scope) {
|
|
28
|
+
if (scope instanceof GoModuleScope) {
|
|
29
|
+
return scope;
|
|
30
|
+
}
|
|
31
|
+
scope = scope.parent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
throw new Error("A module is not in scope");
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamedTypeSymbol } from "../symbols/named-type.js";
|
|
3
|
+
import { GoScope } from "./go.js";
|
|
4
|
+
import { GoModuleScope } from "./module.js";
|
|
5
|
+
import { GoSourceFileScope } from "./source-file.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This scope contains NamedTypeSymbols for types that are declared in
|
|
9
|
+
* containers like packages. This scope is a member scope which whose
|
|
10
|
+
* member symbol is a NamedTypeSymbol.
|
|
11
|
+
*/
|
|
12
|
+
export class GoNamedTypeScope extends GoScope {
|
|
13
|
+
public static readonly declarationSpaces = [];
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
ownerSymbol: NamedTypeSymbol,
|
|
17
|
+
parentScope:
|
|
18
|
+
| GoNamedTypeScope
|
|
19
|
+
| GoSourceFileScope
|
|
20
|
+
| GoModuleScope
|
|
21
|
+
| undefined,
|
|
22
|
+
options: OutputScopeOptions = {},
|
|
23
|
+
) {
|
|
24
|
+
super(`${ownerSymbol.name} scope`, parentScope, {
|
|
25
|
+
ownerSymbol,
|
|
26
|
+
...options,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get ownerSymbol(): NamedTypeSymbol {
|
|
31
|
+
return super.ownerSymbol as NamedTypeSymbol;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get enclosingPackage() {
|
|
35
|
+
return this.ownerSymbol.enclosingPackage;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get members() {
|
|
39
|
+
return this.ownerSymbol.members;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* For now, we stuff type parameters into the member scope. This is to ensure
|
|
44
|
+
* name conflicts are handled correctly.
|
|
45
|
+
*/
|
|
46
|
+
get typeParameters() {
|
|
47
|
+
return this.ownerSymbol.members;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OutputScope, useScope } from "@alloy-js/core";
|
|
2
|
+
import type { PackageSymbol } from "../symbols/package.js";
|
|
3
|
+
import { GoModuleScope } from "./module.js";
|
|
4
|
+
import { GoNamedTypeScope } from "./named-type.js";
|
|
5
|
+
|
|
6
|
+
export class GoPackageScope extends GoNamedTypeScope {
|
|
7
|
+
constructor(
|
|
8
|
+
packageSymbol: PackageSymbol,
|
|
9
|
+
parentScope?: GoPackageScope | GoModuleScope,
|
|
10
|
+
) {
|
|
11
|
+
super(packageSymbol, parentScope, { binder: packageSymbol.binder });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get ownerSymbol() {
|
|
15
|
+
return super.ownerSymbol as PackageSymbol;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createGoPackageScope(packageSymbol: PackageSymbol) {
|
|
20
|
+
const parentScope = useScope();
|
|
21
|
+
if (
|
|
22
|
+
parentScope &&
|
|
23
|
+
!(
|
|
24
|
+
parentScope instanceof GoPackageScope ||
|
|
25
|
+
parentScope instanceof GoModuleScope
|
|
26
|
+
)
|
|
27
|
+
) {
|
|
28
|
+
throw new Error("Packages can only be created within a package or module");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const scope = new GoPackageScope(packageSymbol, parentScope);
|
|
32
|
+
|
|
33
|
+
return scope;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function useEnclosingPackageScope(): GoPackageScope | undefined {
|
|
37
|
+
const currentScope = useScope();
|
|
38
|
+
if (!(currentScope instanceof GoPackageScope)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return currentScope;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function usePackage() {
|
|
46
|
+
let scope: OutputScope | undefined = useScope();
|
|
47
|
+
while (scope) {
|
|
48
|
+
if (scope instanceof GoPackageScope) {
|
|
49
|
+
return scope;
|
|
50
|
+
}
|
|
51
|
+
scope = scope.parent;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
throw new Error("A package is not in scope");
|
|
55
|
+
}
|