@scriptc/compiler 0.0.25 → 0.0.27
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/ambient/scriptc-node-fallback.d.ts +15 -7
- package/dist/backend/cc.d.ts +22 -0
- package/dist/backend/cc.js +128 -10
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +81 -10
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +14 -1
- package/dist/backend/emission/emitter.js +126 -13
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +11 -1
- package/dist/backend/emission/may-throw.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +11 -0
- package/dist/backend/ffi-callbacks.js +33 -0
- package/dist/backend/ffi-callbacks.js.map +1 -0
- package/dist/backend/llvm/classes.js +21 -21
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +7 -4
- package/dist/backend/llvm/dyn.js +145 -141
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +7 -1
- package/dist/backend/llvm/emitter.js +961 -303
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +4 -0
- package/dist/backend/llvm/shapes.js +26 -24
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/unsupported.js +1 -1
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -0
- package/dist/backend/llvm/walkers.js +50 -46
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.js +3 -2
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/ffi/profile.d.ts +20 -2
- package/dist/ffi/profile.js +130 -6
- package/dist/ffi/profile.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +58 -22
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +17 -7
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +5 -0
- package/dist/frontend/lowering/lower-server.js +129 -37
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +8 -1
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +3 -2
- package/dist/frontend/lowering/surfaces.js +4 -3
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm.d.ts +16 -0
- package/dist/frontend/npm.js +257 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +188 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +54 -13
- package/dist/ir/nodes.js +49 -7
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +10 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/profile.d.ts +11 -0
- package/dist/library/profile.js +74 -2
- package/dist/library/profile.js.map +1 -1
- package/dist/wasi-paths.d.ts +5 -0
- package/dist/wasi-paths.js +22 -0
- package/dist/wasi-paths.js.map +1 -0
- package/package.json +2 -2
- package/surface-manifest.json +2 -2
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* ToBoolean/ToString coercion helpers, and field/element reads and writes
|
|
6
6
|
* (FieldTarget). */
|
|
7
7
|
import * as ts from "../ts7/adapter.js";
|
|
8
|
-
import { dirname } from "node:path";
|
|
8
|
+
import { dirname, posix } from "node:path";
|
|
9
|
+
import { wasiGuestPath } from "../../wasi-paths.js";
|
|
9
10
|
import { BOOL, CAUGHT, DYN, DYN_HANDLE_KINDS, F64, JSVAL, NULL_T, REF_TRUTHY_KINDS, REGEX, RUNTIME_ERROR_CLASSES, SEARCH_PARAMS_T, STRING, UNDEFINED_T, VOID, arrayOf, canAdaptDynFuncTo, canBoxFuncIntoDyn, canDynCheckTo, funcOf, isJsonSafeType, isUnitType, jsOpResultKind, shapeHasAccessorSlots, typeEquals, typeKey, unionFuncSetArmsOk } from "../../ir/nodes.js";
|
|
10
11
|
import { cjsClassExprWholeExportOf, cjsExportAssignmentOf, cjsExportDiscardReason, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isModuleExportsAccess, isNodeEsmFile, locOf } from "../program.js";
|
|
11
12
|
import { ARRAY_METHODS, builtinConstLit, builtinFenceHintOf, builtinModuleConstOf, builtinModulesArrayLit, builtinModuleFnOf, ISLAND_SURFACE, isChildSurfaceMember, MAP_METHODS, NARROW_FIRST, SET_METHODS, STR_METHODS, UNSUPPORTED_EXPR, sideEffectFreeOptionValue, stdlibGlobalNameOf } from "./surfaces.js";
|
|
@@ -675,18 +676,27 @@ function lowerExprInner(L, expr) {
|
|
|
675
676
|
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc };
|
|
676
677
|
}
|
|
677
678
|
// `__dirname` / `__filename` — the CommonJS module globals: per-
|
|
678
|
-
// MODULE compile-time constants, the containing file's
|
|
679
|
-
//
|
|
680
|
-
//
|
|
681
|
-
// syntax Node never defines them
|
|
682
|
-
// than invent a value there.
|
|
679
|
+
// MODULE compile-time constants, the containing file's location
|
|
680
|
+
// (Node's exact values when the same tree runs in place; WASI uses
|
|
681
|
+
// the equivalent guest-visible path; locals shadowing the names
|
|
682
|
+
// resolved above). In a file with ESM syntax Node never defines them
|
|
683
|
+
// (ReferenceError) — fence rather than invent a value there.
|
|
683
684
|
if ((expr.text === "__dirname" || expr.text === "__filename") &&
|
|
684
685
|
L.isStdlibGlobal(expr, expr.text)) {
|
|
685
686
|
const sf = expr.getSourceFile();
|
|
686
687
|
if (isNodeEsmFile(sf)) {
|
|
687
688
|
L.unsupported("SC1090", expr, `'${expr.text}' in an ES module (Node defines the CJS module globals only in CommonJS modules)`);
|
|
688
689
|
}
|
|
689
|
-
|
|
690
|
+
// The WASI runner mounts the host cwd at guest `/` and the host temp
|
|
691
|
+
// directory at `/tmp`. Bake the matching GUEST spelling so resource
|
|
692
|
+
// lookups relative to these CommonJS globals stay inside the exposed
|
|
693
|
+
// capability instead of naming an unreachable host-absolute path.
|
|
694
|
+
const fileName = L.targetPlatform === "wasi"
|
|
695
|
+
? wasiGuestPath(sf.fileName) ?? sf.fileName.replace(/\\/g, "/")
|
|
696
|
+
: sf.fileName;
|
|
697
|
+
const value = expr.text === "__dirname"
|
|
698
|
+
? (L.targetPlatform === "wasi" ? posix.dirname(fileName) : dirname(fileName))
|
|
699
|
+
: fileName;
|
|
690
700
|
return { kind: "strLit", value, type: STRING, loc };
|
|
691
701
|
}
|
|
692
702
|
const sig = L.fnSigOf(expr);
|