-
Notifications
You must be signed in to change notification settings - Fork 0
/
piglet_interface.mjs
36 lines (28 loc) · 1.01 KB
/
piglet_interface.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as url from "node:url"
import * as path from "node:path"
import NodeCompiler from "piglet-lang/node/NodeCompiler.mjs"
import {
deref,
intern,
module_registry,
qsym,
resolve,
symbol,
} from "piglet-lang"
import {PIGLET_PKG} from "piglet-lang/lang/util.mjs"
let vscode = null
let context = null
export async function init(inject) {
vscode = inject.vscode
context = inject.context
global.$piglet$ = module_registry.index
const compiler = new NodeCompiler()
await compiler.load_package(path.join(url.fileURLToPath(deref(resolve(symbol('piglet:lang:*current-location*')))), "../../../packages/piglet"))
intern(symbol('piglet:lang:*compiler*'), compiler)
await compiler.load(qsym(`${PIGLET_PKG}:lang`))
await compiler.load(qsym(`${PIGLET_PKG}:pdp-client`))
const vscode_mod = module_registry.find_package(PIGLET_PKG).ensure_module("vscode")
vscode_mod.required = true
vscode_mod.intern("vscode", vscode)
vscode_mod.intern("context", context)
}