@scriptc/compiler 0.1.5 → 0.1.6

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.
Files changed (45) hide show
  1. package/dist/backend/c/exprs.js +36 -8
  2. package/dist/backend/c/exprs.js.map +1 -1
  3. package/dist/backend/llvm/expr-containers.js +28 -2
  4. package/dist/backend/llvm/expr-containers.js.map +1 -1
  5. package/dist/backend/llvm/lib-filesystem.js +8 -0
  6. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  7. package/dist/backend/llvm/lib-process.js +4 -3
  8. package/dist/backend/llvm/lib-process.js.map +1 -1
  9. package/dist/backend/llvm/lib-shared.js +1 -0
  10. package/dist/backend/llvm/lib-shared.js.map +1 -1
  11. package/dist/coverage/surface-manifest.js +6 -1
  12. package/dist/coverage/surface-manifest.js.map +1 -1
  13. package/dist/frontend/lowering/array-indexed-mutation.d.ts +8 -0
  14. package/dist/frontend/lowering/array-indexed-mutation.js +176 -0
  15. package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -0
  16. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +7 -0
  17. package/dist/frontend/lowering/containers/string-and-regexp.js +190 -13
  18. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  19. package/dist/frontend/lowering/indexed-comparison.d.ts +6 -0
  20. package/dist/frontend/lowering/indexed-comparison.js +30 -0
  21. package/dist/frontend/lowering/indexed-comparison.js.map +1 -0
  22. package/dist/frontend/lowering/lower-builtins.d.ts +1 -1
  23. package/dist/frontend/lowering/lower-builtins.js +6 -6
  24. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  25. package/dist/frontend/lowering/lower-calls.js +266 -10
  26. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  27. package/dist/frontend/lowering/lower-classes.js +3 -27
  28. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  29. package/dist/frontend/lowering/lower-containers.d.ts +8 -2
  30. package/dist/frontend/lowering/lower-containers.js +454 -104
  31. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  32. package/dist/frontend/lowering/lower-exprs.js +18 -2
  33. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  34. package/dist/frontend/lowering/surfaces.d.ts +2 -0
  35. package/dist/frontend/lowering/surfaces.js +13 -1
  36. package/dist/frontend/lowering/surfaces.js.map +1 -1
  37. package/dist/ir/ir.d.ts +15 -2
  38. package/dist/ir/ir.js +2 -0
  39. package/dist/ir/ir.js.map +1 -1
  40. package/dist/ir/validate.js +43 -26
  41. package/dist/ir/validate.js.map +1 -1
  42. package/dist/ir/validate.test.js +17 -0
  43. package/dist/ir/validate.test.js.map +1 -1
  44. package/package.json +17 -17
  45. package/surface-manifest.json +36 -4
@@ -11,11 +11,12 @@ import { pathToFileURL } from "node:url";
11
11
  import { wasiGuestPath } from "../../wasi-paths.js";
12
12
  import { BIGINT_T, 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, funcOf, isDynTypedRefType, isJsonSafeType, isSupportedArrayElem, isUnitType, jsOpResultKind, shapeHasAccessorSlots, typeEquals, typeKey, unionFuncSetArmsOk } from "../../ir/ir.js";
13
13
  import { cjsClassExprWholeExportOf, cjsExportAssignmentOf, cjsExportDiscardReason, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isModuleExportsAccess, isNodeEsmFile, locOf } from "../program.js";
14
- import { ARRAY_METHODS, builtinConstLit, builtinFenceHintOf, builtinModuleConstOf, builtinModulesArrayLit, builtinModuleFnOf, COMPOUND_ASSIGN_OPS, ISLAND_SURFACE, isChildSurfaceMember, MAP_METHODS, NARROW_FIRST, SET_METHODS, STR_METHODS, UNSUPPORTED_EXPR, sideEffectFreeOptionValue, stdlibGlobalNameOf } from "./surfaces.js";
14
+ import { ARRAY_METHODS, builtinConstLit, builtinFenceHintOf, builtinModuleConstOf, builtinModulesArrayLit, builtinModuleFnOf, COMPOUND_ASSIGN_OPS, ISLAND_SURFACE, isChildSurfaceMember, MAP_METHODS, NARROW_FIRST, SET_METHODS, STRING_INDEX_METHODS, STR_METHODS, UNSUPPORTED_EXPR, sideEffectFreeOptionValue, stdlibGlobalNameOf } from "./surfaces.js";
15
15
  import { blockedBindingUseDiag, requiresDynamicPackageDiag, unsupportedDiag } from "../../diagnostics/diagnostic.js";
16
16
  import { PoisonError, dynUndefinedExpr, jsFuncNameOf, neverTaintedJsType, nodeThrowExpr, own } from "./lowerer.js";
17
17
  import { lowerNpmStaticSafeIndexRead, lowerSafeIndexRead, strCharsCall, tryLowerNumericIndexRead } from "./lower-containers.js";
18
18
  import { arrayValueRead, arrayValueStore } from "./array-values.js";
19
+ import { tryLowerIndexedComparison } from "./indexed-comparison.js";
19
20
  import { npmStaticPackageOfPath } from "../npm-static.js";
20
21
  import { unsupportedModuleFeatureOf } from "../builtin-modules.js";
21
22
  import { fenceEnumObjectValue, lowerEnumAccess } from "./lower-enums.js";
@@ -554,6 +555,18 @@ function lowerExprInner(lowerer, expr) {
554
555
  return { kind: "strLit", value: "object", type: STRING, loc };
555
556
  }
556
557
  if (ts.isPropertyAccessExpression(expr.expression)) {
558
+ const member = expr.expression;
559
+ const prototype = member.expression;
560
+ if (STRING_INDEX_METHODS.has(member.name.text) && ts.isPropertyAccessExpression(prototype) &&
561
+ prototype.name.text === "prototype" && ts.isIdentifier(prototype.expression) &&
562
+ lowerer.isStdlibGlobal(prototype.expression, "String") && lowerer.isStdlibMember(member)) {
563
+ return { kind: "strLit", value: "function", type: STRING, loc };
564
+ }
565
+ if (member.name.text === "at" && ts.isPropertyAccessExpression(prototype) &&
566
+ prototype.name.text === "prototype" && ts.isIdentifier(prototype.expression) &&
567
+ lowerer.isStdlibGlobal(prototype.expression, "Array") && lowerer.isStdlibMember(member)) {
568
+ return { kind: "strLit", value: "function", type: STRING, loc };
569
+ }
557
570
  const presence = lowerPromiseThenPresence(lowerer, expr.expression, { kind: "strLit", value: "function", type: STRING, loc });
558
571
  if (presence !== null)
559
572
  return presence;
@@ -3399,7 +3412,7 @@ export function lowerIntrinsicProperty(lowerer, expr) {
3399
3412
  : { kind: "arrIntrinsic", method: "length", receiver, args: [], type: F64, loc: locOf(expr) };
3400
3413
  }
3401
3414
  if (kind === "string"
3402
- ? own(STR_METHODS, name) !== undefined || own(ISLAND_SURFACE.string, name) !== undefined
3415
+ ? own(STR_METHODS, name) !== undefined || STRING_INDEX_METHODS.has(name) || own(ISLAND_SURFACE.string, name) !== undefined
3403
3416
  : ARRAY_METHODS.has(name)) {
3404
3417
  lowerer.unsupported("SC1090", expr, `${kind} methods as values (call '${name}' directly)`);
3405
3418
  }
@@ -6276,6 +6289,9 @@ export function lowerBinary(lowerer, expr) {
6276
6289
  case ts.SyntaxKind.EqualsEqualsEqualsToken:
6277
6290
  case ts.SyntaxKind.ExclamationEqualsEqualsToken: {
6278
6291
  const negated = op === ts.SyntaxKind.ExclamationEqualsEqualsToken;
6292
+ const indexed = tryLowerIndexedComparison(lowerer, left, right, negated, loc);
6293
+ if (indexed)
6294
+ return indexed;
6279
6295
  if (plainBothNum)
6280
6296
  return { kind: "bin", op: negated ? "!==" : "===", left, right, type: BOOL, loc };
6281
6297
  if (bothStr)