@divmain/jdm-asm 0.2.0 → 0.2.3

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 (395) hide show
  1. package/dist/index.js +2227 -29
  2. package/dist/index.js.map +1 -1
  3. package/package.json +8 -2
  4. package/.github/workflows/ci.yml +0 -53
  5. package/.oxfmtrc.json +0 -16
  6. package/.oxlintrc.json +0 -183
  7. package/AGENTS.md +0 -81
  8. package/asconfig.json +0 -23
  9. package/benchmarks/fixtures.ts +0 -111
  10. package/benchmarks/input-fixtures.ts +0 -80
  11. package/benchmarks/run.ts +0 -913
  12. package/benchmarks/worker-pool.ts +0 -223
  13. package/benchmarks/worker.ts +0 -374
  14. package/scripts/run-all-tests.ts +0 -220
  15. package/src/compiler/EXPRESSION_SUBSETS.md +0 -228
  16. package/src/compiler/asc-compiler.ts +0 -315
  17. package/src/compiler/ast-types.ts +0 -215
  18. package/src/compiler/build.ts +0 -56
  19. package/src/compiler/cache.ts +0 -414
  20. package/src/compiler/code-generators.ts +0 -211
  21. package/src/compiler/codegen/index.ts +0 -15
  22. package/src/compiler/codegen/js-marshal.ts +0 -999
  23. package/src/compiler/codegen/js-validation.ts +0 -243
  24. package/src/compiler/codegen.ts +0 -19
  25. package/src/compiler/compile-time-validation.ts +0 -507
  26. package/src/compiler/cst-visitor.ts +0 -434
  27. package/src/compiler/errors.ts +0 -227
  28. package/src/compiler/expression-parser.ts +0 -536
  29. package/src/compiler/graph.ts +0 -197
  30. package/src/compiler/index.ts +0 -199
  31. package/src/compiler/input-validation.ts +0 -33
  32. package/src/compiler/marshal-gen.ts +0 -21
  33. package/src/compiler/nodes/context-resolvers.ts +0 -197
  34. package/src/compiler/nodes/decision-table.ts +0 -507
  35. package/src/compiler/nodes/decision.ts +0 -292
  36. package/src/compiler/nodes/expression-compiler.ts +0 -526
  37. package/src/compiler/nodes/expression.ts +0 -425
  38. package/src/compiler/nodes/function.ts +0 -316
  39. package/src/compiler/nodes/input.ts +0 -60
  40. package/src/compiler/nodes/switch.ts +0 -547
  41. package/src/compiler/optimizer.ts +0 -948
  42. package/src/compiler/orchestrator.ts +0 -352
  43. package/src/compiler/parser.ts +0 -115
  44. package/src/compiler/result-selection.ts +0 -161
  45. package/src/compiler/runtime/index.ts +0 -26
  46. package/src/compiler/runtime-codegen.ts +0 -211
  47. package/src/compiler/runtime-validation-codegen.ts +0 -294
  48. package/src/compiler/runtime.ts +0 -452
  49. package/src/compiler/schema.ts +0 -245
  50. package/src/compiler/switch-branch-detection.ts +0 -92
  51. package/src/compiler/types.ts +0 -136
  52. package/src/compiler/unary-ast-transforms.ts +0 -148
  53. package/src/compiler/unary-parser.ts +0 -301
  54. package/src/compiler/unary-transform.ts +0 -161
  55. package/src/compiler/utils.ts +0 -27
  56. package/src/compiler/virtual-fs.ts +0 -90
  57. package/src/compiler/wasm-instantiate.ts +0 -127
  58. package/src/index.ts +0 -1
  59. package/src/runtime/arrays.ts +0 -579
  60. package/src/runtime/context.ts +0 -189
  61. package/src/runtime/expressions.ts +0 -1811
  62. package/src/runtime/index.ts +0 -8
  63. package/src/runtime/memory.ts +0 -607
  64. package/src/runtime/strings.ts +0 -260
  65. package/src/runtime/tables.ts +0 -96
  66. package/src/runtime/tsconfig.json +0 -4
  67. package/src/runtime/values.ts +0 -209
  68. package/test-data/README.md +0 -83
  69. package/test-data/decision-tables/basic/8k.json +0 -87992
  70. package/test-data/decision-tables/basic/affiliate-commission-calculator.json +0 -228
  71. package/test-data/decision-tables/basic/airline-loyalty-points-calculations.json +0 -285
  72. package/test-data/decision-tables/basic/airline-upgrade-eligibility.json +0 -466
  73. package/test-data/decision-tables/basic/auto-insurance-premium-calculator.json +0 -412
  74. package/test-data/decision-tables/basic/booking-personalization-system.json +0 -553
  75. package/test-data/decision-tables/basic/care-team-assignment-system.json +0 -585
  76. package/test-data/decision-tables/basic/claim-validation-system.json +0 -307
  77. package/test-data/decision-tables/basic/clinical-lab-result-interpreter.json +0 -433
  78. package/test-data/decision-tables/basic/clinical-treatment-protocol.json +0 -474
  79. package/test-data/decision-tables/basic/credit-limit-adjustment.json +0 -479
  80. package/test-data/decision-tables/basic/customer-eligibility-engine.json +0 -551
  81. package/test-data/decision-tables/basic/customer-lifetime-value.json +0 -200
  82. package/test-data/decision-tables/basic/customer-onboarding-kyc-verification.json +0 -611
  83. package/test-data/decision-tables/basic/customer-service-escalation.json +0 -191
  84. package/test-data/decision-tables/basic/decision-table-discounts.json +0 -168
  85. package/test-data/decision-tables/basic/decision-table-shipping.json +0 -398
  86. package/test-data/decision-tables/basic/delivery-route-optimizer.json +0 -271
  87. package/test-data/decision-tables/basic/device-compatibility-checker.json +0 -303
  88. package/test-data/decision-tables/basic/disaster-relief-fund-allocation.json +0 -296
  89. package/test-data/decision-tables/basic/dynamic-fx-rate-pricing-system.json +0 -237
  90. package/test-data/decision-tables/basic/dynamic-marketplace-comission-calculator.json +0 -242
  91. package/test-data/decision-tables/basic/dynamic-shipping-cost-calculator.json +0 -378
  92. package/test-data/decision-tables/basic/dynamic-tarrif-engine.json +0 -289
  93. package/test-data/decision-tables/basic/dynamic-ticket-pricing.json +0 -325
  94. package/test-data/decision-tables/basic/empty-column-with-space.json +0 -100
  95. package/test-data/decision-tables/basic/empty-column-without-space.json +0 -100
  96. package/test-data/decision-tables/basic/environment-compliance-assessment.json +0 -386
  97. package/test-data/decision-tables/basic/expression-table-map.json +0 -313
  98. package/test-data/decision-tables/basic/flash-sale-eligibility.json +0 -366
  99. package/test-data/decision-tables/basic/flight-dispatch-decision-system.json +0 -455
  100. package/test-data/decision-tables/basic/flight-rebooking-fee-calculator.json +0 -406
  101. package/test-data/decision-tables/basic/government-assistance.json +0 -299
  102. package/test-data/decision-tables/basic/grant-funding-distribution.json +0 -307
  103. package/test-data/decision-tables/basic/hazardous-materials-management-system.json +0 -414
  104. package/test-data/decision-tables/basic/immigration-eligibility-evaluator.json +0 -765
  105. package/test-data/decision-tables/basic/import-duties-calculator.json +0 -318
  106. package/test-data/decision-tables/basic/insurance-agent-commission.json +0 -228
  107. package/test-data/decision-tables/basic/insurance-coverage-calculator.json +0 -362
  108. package/test-data/decision-tables/basic/insurance-underwriting-risk.json +0 -321
  109. package/test-data/decision-tables/basic/international-roaming-policy-manager.json +0 -199
  110. package/test-data/decision-tables/basic/legacy-plan-management.json +0 -434
  111. package/test-data/decision-tables/basic/marketplace-listing-verification-system.json +0 -334
  112. package/test-data/decision-tables/basic/medication-dosage-calculator.json +0 -318
  113. package/test-data/decision-tables/basic/merch-bags.json +0 -171
  114. package/test-data/decision-tables/basic/municipal-permit-evaluation-system.json +0 -364
  115. package/test-data/decision-tables/basic/mvno-partner-enablement.json +0 -313
  116. package/test-data/decision-tables/basic/partner-revenue-sharing.json +0 -244
  117. package/test-data/decision-tables/basic/payment-routing-and-fee-calculator.json +0 -475
  118. package/test-data/decision-tables/basic/policy-discount-calculator.json +0 -307
  119. package/test-data/decision-tables/basic/policy-eligibility-analyzer.json +0 -299
  120. package/test-data/decision-tables/basic/product-listing-scoring.json +0 -358
  121. package/test-data/decision-tables/basic/realtime-fraud-detection.json +0 -235
  122. package/test-data/decision-tables/basic/regional-compliance-manager.json +0 -278
  123. package/test-data/decision-tables/basic/returns-and-refund-policy.json +0 -366
  124. package/test-data/decision-tables/basic/returns-processing-system.json +0 -448
  125. package/test-data/decision-tables/basic/school-district-resource-allocation.json +0 -282
  126. package/test-data/decision-tables/basic/seat-map-optimization.json +0 -325
  127. package/test-data/decision-tables/basic/seller-fee-calculator.json +0 -307
  128. package/test-data/decision-tables/basic/service-level-agreement-enforcement.json +0 -575
  129. package/test-data/decision-tables/basic/smart-financial-product-matcher.json +0 -249
  130. package/test-data/decision-tables/basic/supply-chain-risk.json +0 -316
  131. package/test-data/decision-tables/basic/table-loop.json +0 -93
  132. package/test-data/decision-tables/basic/table.json +0 -76
  133. package/test-data/decision-tables/basic/traffic-violation-penalty-calculator.json +0 -436
  134. package/test-data/decision-tables/basic/transaction-compliance-classifier.json +0 -525
  135. package/test-data/decision-tables/basic/vehicle-claims-resolution.json +0 -310
  136. package/test-data/decision-tables/basic/warehouse-storage-location.json +0 -345
  137. package/test-data/decision-tables/hit-policy-collect/collect-multiple-matches.json +0 -127
  138. package/test-data/decision-tables/hit-policy-collect/collect-no-match.json +0 -95
  139. package/test-data/decision-tables/hit-policy-first/first-match.json +0 -103
  140. package/test-data/decision-tables/hit-policy-first/no-match.json +0 -95
  141. package/test-data/decision-tables/hit-policy-output-order/output-order-respected.json +0 -94
  142. package/test-data/decision-tables/hit-policy-output-order/string-output-order.json +0 -94
  143. package/test-data/decision-tables/hit-policy-priority/priority-respected.json +0 -86
  144. package/test-data/decision-tables/hit-policy-rule-order/rule-order-respected.json +0 -94
  145. package/test-data/decision-tables/hit-policy-unique/all-match-error.json +0 -89
  146. package/test-data/decision-tables/hit-policy-unique/multiple-match-error.json +0 -89
  147. package/test-data/decision-tables/hit-policy-unique/no-match.json +0 -88
  148. package/test-data/decision-tables/hit-policy-unique/unique-match.json +0 -99
  149. package/test-data/expressions/arithmetic/error-cyclic.json +0 -114
  150. package/test-data/expressions/arithmetic/error-missing-input.json +0 -54
  151. package/test-data/expressions/arithmetic/error-missing-output.json +0 -54
  152. package/test-data/expressions/arithmetic/expression-default.json +0 -93
  153. package/test-data/expressions/arithmetic/expression-fields.json +0 -94
  154. package/test-data/expressions/arithmetic/expression-loop.json +0 -94
  155. package/test-data/expressions/arithmetic/expression-passthrough.json +0 -108
  156. package/test-data/expressions/arithmetic/expression.json +0 -69
  157. package/test-data/expressions/arithmetic/nested-request.json +0 -125
  158. package/test-data/expressions/arithmetic/number-function.json +0 -58
  159. package/test-data/expressions/arithmetic/test-number-functions.json +0 -68
  160. package/test-data/expressions/functions/all.json +0 -149
  161. package/test-data/expressions/functions/avg.json +0 -89
  162. package/test-data/expressions/functions/filter.json +0 -109
  163. package/test-data/expressions/functions/flat.json +0 -167
  164. package/test-data/expressions/functions/map-strings.json +0 -65
  165. package/test-data/expressions/functions/map.json +0 -73
  166. package/test-data/expressions/functions/reduce.json +0 -49
  167. package/test-data/expressions/functions/some.json +0 -175
  168. package/test-data/expressions/functions/sort-strings.json +0 -97
  169. package/test-data/expressions/functions/sort.json +0 -97
  170. package/test-data/expressions/logical/logical-and.json +0 -116
  171. package/test-data/expressions/logical/logical-complex.json +0 -260
  172. package/test-data/expressions/logical/logical-not.json +0 -111
  173. package/test-data/expressions/logical/logical-or.json +0 -123
  174. package/test-data/expressions/string/string-comparison.json +0 -128
  175. package/test-data/expressions/string/string-concat.json +0 -106
  176. package/test-data/expressions/string/string-contains.json +0 -125
  177. package/test-data/expressions/string/string-endsWith.json +0 -113
  178. package/test-data/expressions/string/string-indexOf.json +0 -131
  179. package/test-data/expressions/string/string-join.json +0 -92
  180. package/test-data/expressions/string/string-lower.json +0 -94
  181. package/test-data/expressions/string/string-replace.json +0 -130
  182. package/test-data/expressions/string/string-split.json +0 -101
  183. package/test-data/expressions/string/string-startsWith.json +0 -113
  184. package/test-data/expressions/string/string-substring.json +0 -138
  185. package/test-data/expressions/string/string-trim.json +0 -100
  186. package/test-data/expressions/string/string-upper.json +0 -94
  187. package/test-data/other/custom.json +0 -51
  188. package/test-data/other/customer-input-schema.json +0 -34
  189. package/test-data/other/customer-output-schema.json +0 -34
  190. package/test-data/other/passthrough.json +0 -31
  191. package/test-data/sub-decisions/basic/$nodes-child.json +0 -31
  192. package/test-data/sub-decisions/basic/$nodes-parent.json +0 -49
  193. package/test-data/sub-decisions/basic/recursive-table1.json +0 -49
  194. package/test-data/sub-decisions/basic/recursive-table2.json +0 -49
  195. package/test-data/sub-decisions/complex-multi/approval-decision.json +0 -31
  196. package/test-data/sub-decisions/complex-multi/complex-dag.json +0 -175
  197. package/test-data/sub-decisions/complex-multi/credit-check.json +0 -31
  198. package/test-data/sub-decisions/complex-multi/customer-segmentation.json +0 -31
  199. package/test-data/sub-decisions/complex-multi/discount-eligibility.json +0 -31
  200. package/test-data/sub-decisions/complex-multi/eligibility-check.json +0 -31
  201. package/test-data/sub-decisions/complex-multi/final-offer.json +0 -31
  202. package/test-data/sub-decisions/complex-multi/income-verification.json +0 -31
  203. package/test-data/sub-decisions/complex-multi/linear-chain.json +0 -121
  204. package/test-data/sub-decisions/complex-multi/pricing-calculation.json +0 -31
  205. package/test-data/sub-decisions/complex-multi/product-eligibility.json +0 -31
  206. package/test-data/sub-decisions/complex-multi/risk-assessment.json +0 -31
  207. package/test-data/sub-decisions/complex-multi/shared-validation.json +0 -31
  208. package/test-data/sub-decisions/complex-multi/validation.json +0 -31
  209. package/test-data/sub-decisions/diamond/decision-a.json +0 -31
  210. package/test-data/sub-decisions/diamond/decision-b.json +0 -31
  211. package/test-data/sub-decisions/diamond/decision-c.json +0 -31
  212. package/test-data/sub-decisions/diamond/decision-shared.json +0 -31
  213. package/test-data/sub-decisions/diamond/diamond-pattern.json +0 -109
  214. package/test-data/sub-decisions/error-propagation/parent-calls-error.json +0 -44
  215. package/test-data/sub-decisions/error-propagation/sub-decision-with-error.json +0 -60
  216. package/test-data/switch-nodes/basic/account-dormancy-management.json +0 -245
  217. package/test-data/switch-nodes/basic/application-risk-assessment.json +0 -474
  218. package/test-data/switch-nodes/basic/cellular-data-rollover-system.json +0 -281
  219. package/test-data/switch-nodes/basic/clinical-pathway-selection.json +0 -454
  220. package/test-data/switch-nodes/basic/insurance-prior-authorization.json +0 -467
  221. package/test-data/switch-nodes/basic/last-mile-delivery-assignment.json +0 -373
  222. package/test-data/switch-nodes/basic/loan-approval.json +0 -469
  223. package/test-data/switch-nodes/basic/multi-switch.json +0 -498
  224. package/test-data/switch-nodes/basic/online-checkin-eligibility.json +0 -285
  225. package/test-data/switch-nodes/basic/order-consolidation-system.json +0 -493
  226. package/test-data/switch-nodes/basic/seller-approval-workflow.json +0 -383
  227. package/test-data/switch-nodes/basic/set-fee.json +0 -243
  228. package/test-data/switch-nodes/basic/shipping-carrier-selector.json +0 -379
  229. package/test-data/switch-nodes/basic/switch-node.json +0 -167
  230. package/test-data/switch-nodes/basic/switch-performance-2.json +0 -1307
  231. package/test-data/switch-nodes/basic/switch-performance.json +0 -691
  232. package/test-data/switch-nodes/basic/tax-exemption.json +0 -295
  233. package/test-data/switch-nodes/basic/warehouse-cross-docking.json +0 -313
  234. package/test-data/switch-nodes/default-cases/switch-with-default.json +0 -134
  235. package/test-data/zen-reference/$nodes-child.json +0 -69
  236. package/test-data/zen-reference/$nodes-parent.json +0 -34
  237. package/test-data/zen-reference/8k.json +0 -87992
  238. package/test-data/zen-reference/credit-analysis.json +0 -324
  239. package/test-data/zen-reference/custom.json +0 -51
  240. package/test-data/zen-reference/customer-input-schema.json +0 -34
  241. package/test-data/zen-reference/customer-output-schema.json +0 -34
  242. package/test-data/zen-reference/error-cyclic.json +0 -114
  243. package/test-data/zen-reference/error-missing-input.json +0 -54
  244. package/test-data/zen-reference/error-missing-output.json +0 -54
  245. package/test-data/zen-reference/expression.json +0 -69
  246. package/test-data/zen-reference/function-v2.json +0 -48
  247. package/test-data/zen-reference/function.json +0 -46
  248. package/test-data/zen-reference/graphs/account-dormancy-management.json +0 -245
  249. package/test-data/zen-reference/graphs/affiliate-commission-calculator.json +0 -228
  250. package/test-data/zen-reference/graphs/airline-loyalty-points-calculations.json +0 -285
  251. package/test-data/zen-reference/graphs/airline-upgrade-eligibility.json +0 -466
  252. package/test-data/zen-reference/graphs/aml.json +0 -537
  253. package/test-data/zen-reference/graphs/application-risk-assessment.json +0 -474
  254. package/test-data/zen-reference/graphs/auto-insurance-premium-calculator.json +0 -412
  255. package/test-data/zen-reference/graphs/booking-personalization-system.json +0 -553
  256. package/test-data/zen-reference/graphs/care-team-assignment-system.json +0 -585
  257. package/test-data/zen-reference/graphs/cellular-data-rollover-system.json +0 -281
  258. package/test-data/zen-reference/graphs/claim-validation-system.json +0 -307
  259. package/test-data/zen-reference/graphs/clinical-lab-result-interpreter.json +0 -433
  260. package/test-data/zen-reference/graphs/clinical-pathway-selection.json +0 -454
  261. package/test-data/zen-reference/graphs/clinical-treatment-protocol.json +0 -474
  262. package/test-data/zen-reference/graphs/company-analysis.json +0 -390
  263. package/test-data/zen-reference/graphs/credit-limit-adjustment.json +0 -479
  264. package/test-data/zen-reference/graphs/customer-eligibility-engine.json +0 -551
  265. package/test-data/zen-reference/graphs/customer-lifetime-value.json +0 -200
  266. package/test-data/zen-reference/graphs/customer-onboarding-kyc-verification.json +0 -611
  267. package/test-data/zen-reference/graphs/customer-service-escalation.json +0 -191
  268. package/test-data/zen-reference/graphs/decision-table-discounts.json +0 -168
  269. package/test-data/zen-reference/graphs/decision-table-shipping.json +0 -398
  270. package/test-data/zen-reference/graphs/delivery-route-optimizer.json +0 -271
  271. package/test-data/zen-reference/graphs/device-compatibility-checker.json +0 -303
  272. package/test-data/zen-reference/graphs/disaster-relief-fund-allocation.json +0 -296
  273. package/test-data/zen-reference/graphs/dynamic-fx-rate-pricing-system.json +0 -237
  274. package/test-data/zen-reference/graphs/dynamic-marketplace-comission-calculator.json +0 -242
  275. package/test-data/zen-reference/graphs/dynamic-shipping-cost-calculator.json +0 -378
  276. package/test-data/zen-reference/graphs/dynamic-tarrif-engine.json +0 -289
  277. package/test-data/zen-reference/graphs/dynamic-ticket-pricing.json +0 -325
  278. package/test-data/zen-reference/graphs/empty-column-with-space.json +0 -100
  279. package/test-data/zen-reference/graphs/empty-column-without-space.json +0 -100
  280. package/test-data/zen-reference/graphs/environment-compliance-assessment.json +0 -386
  281. package/test-data/zen-reference/graphs/expression-default.json +0 -93
  282. package/test-data/zen-reference/graphs/expression-fields.json +0 -94
  283. package/test-data/zen-reference/graphs/expression-loop.json +0 -94
  284. package/test-data/zen-reference/graphs/expression-passthrough.json +0 -108
  285. package/test-data/zen-reference/graphs/expression-table-map.json +0 -313
  286. package/test-data/zen-reference/graphs/flash-sale-eligibility.json +0 -366
  287. package/test-data/zen-reference/graphs/flight-dispatch-decision-system.json +0 -455
  288. package/test-data/zen-reference/graphs/flight-rebooking-fee-calculator.json +0 -406
  289. package/test-data/zen-reference/graphs/government-assistance.json +0 -299
  290. package/test-data/zen-reference/graphs/grant-funding-distribution.json +0 -307
  291. package/test-data/zen-reference/graphs/hazardous-materials-management-system.json +0 -414
  292. package/test-data/zen-reference/graphs/immigration-eligibility-evaluator.json +0 -765
  293. package/test-data/zen-reference/graphs/import-duties-calculator.json +0 -318
  294. package/test-data/zen-reference/graphs/insurance-agent-commission.json +0 -228
  295. package/test-data/zen-reference/graphs/insurance-breakdown.json +0 -421
  296. package/test-data/zen-reference/graphs/insurance-coverage-calculator.json +0 -362
  297. package/test-data/zen-reference/graphs/insurance-prior-authorization.json +0 -467
  298. package/test-data/zen-reference/graphs/insurance-underwriting-risk.json +0 -321
  299. package/test-data/zen-reference/graphs/international-roaming-policy-manager.json +0 -199
  300. package/test-data/zen-reference/graphs/last-mile-delivery-assignment.json +0 -373
  301. package/test-data/zen-reference/graphs/legacy-plan-management.json +0 -434
  302. package/test-data/zen-reference/graphs/loan-approval.json +0 -469
  303. package/test-data/zen-reference/graphs/marketplace-listing-verification-system.json +0 -334
  304. package/test-data/zen-reference/graphs/medication-dosage-calculator.json +0 -318
  305. package/test-data/zen-reference/graphs/merch-bags.json +0 -171
  306. package/test-data/zen-reference/graphs/multi-switch.json +0 -498
  307. package/test-data/zen-reference/graphs/municipal-permit-evaluation-system.json +0 -364
  308. package/test-data/zen-reference/graphs/mvno-partner-enablement.json +0 -313
  309. package/test-data/zen-reference/graphs/nested-request.json +0 -125
  310. package/test-data/zen-reference/graphs/online-checkin-eligibility.json +0 -285
  311. package/test-data/zen-reference/graphs/order-consolidation-system.json +0 -493
  312. package/test-data/zen-reference/graphs/partner-revenue-sharing.json +0 -244
  313. package/test-data/zen-reference/graphs/payment-routing-and-fee-calculator.json +0 -475
  314. package/test-data/zen-reference/graphs/policy-discount-calculator.json +0 -307
  315. package/test-data/zen-reference/graphs/policy-eligibility-analyzer.json +0 -299
  316. package/test-data/zen-reference/graphs/product-listing-scoring.json +0 -358
  317. package/test-data/zen-reference/graphs/realtime-fraud-detection.json +0 -235
  318. package/test-data/zen-reference/graphs/regional-compliance-manager.json +0 -278
  319. package/test-data/zen-reference/graphs/returns-and-refund-policy.json +0 -366
  320. package/test-data/zen-reference/graphs/returns-processing-system.json +0 -448
  321. package/test-data/zen-reference/graphs/school-district-resource-allocation.json +0 -282
  322. package/test-data/zen-reference/graphs/seat-map-optimization.json +0 -325
  323. package/test-data/zen-reference/graphs/seller-approval-workflow.json +0 -383
  324. package/test-data/zen-reference/graphs/seller-fee-calculator.json +0 -307
  325. package/test-data/zen-reference/graphs/service-level-agreement-enforcement.json +0 -575
  326. package/test-data/zen-reference/graphs/set-fee.json +0 -243
  327. package/test-data/zen-reference/graphs/shipping-carrier-selector.json +0 -379
  328. package/test-data/zen-reference/graphs/smart-financial-product-matcher.json +0 -249
  329. package/test-data/zen-reference/graphs/supply-chain-risk.json +0 -316
  330. package/test-data/zen-reference/graphs/table-loop.json +0 -93
  331. package/test-data/zen-reference/graphs/tax-exemption.json +0 -295
  332. package/test-data/zen-reference/graphs/traffic-violation-penalty-calculator.json +0 -436
  333. package/test-data/zen-reference/graphs/transaction-compliance-classifier.json +0 -525
  334. package/test-data/zen-reference/graphs/vehicle-claims-resolution.json +0 -310
  335. package/test-data/zen-reference/graphs/warehouse-cross-docking.json +0 -313
  336. package/test-data/zen-reference/graphs/warehouse-storage-location.json +0 -345
  337. package/test-data/zen-reference/http-function.json +0 -34
  338. package/test-data/zen-reference/infinite-function.json +0 -46
  339. package/test-data/zen-reference/js/imports.js +0 -25
  340. package/test-data/zen-reference/passthrough.json +0 -31
  341. package/test-data/zen-reference/recursive-table1.json +0 -49
  342. package/test-data/zen-reference/recursive-table2.json +0 -49
  343. package/test-data/zen-reference/sleep-function.json +0 -34
  344. package/test-data/zen-reference/switch-node.json +0 -167
  345. package/test-data/zen-reference/switch-performance-2.json +0 -1307
  346. package/test-data/zen-reference/switch-performance.json +0 -691
  347. package/test-data/zen-reference/table.json +0 -76
  348. package/tests/helpers/index.ts +0 -73
  349. package/tests/helpers/mock-context.ts +0 -231
  350. package/tests/helpers/round-trip.ts +0 -398
  351. package/tests/helpers/test-harness-comparison.ts +0 -325
  352. package/tests/helpers/test-harness-wasm.ts +0 -710
  353. package/tests/helpers/test-harness.ts +0 -28
  354. package/tests/helpers/wasm-test.ts +0 -659
  355. package/tests/integration/compilation-errors.test.ts +0 -864
  356. package/tests/integration/decision-tables.test.ts +0 -531
  357. package/tests/integration/edge-cases.test.ts +0 -787
  358. package/tests/integration/expressions.test.ts +0 -513
  359. package/tests/integration/function-node-integration.test.ts +0 -182
  360. package/tests/integration/sub-decisions.test.ts +0 -108
  361. package/tests/integration/switch-nodes.test.ts +0 -399
  362. package/tests/integration/unary-or-matching.test.ts +0 -53
  363. package/tests/integration/wasm-data-types.test.ts +0 -398
  364. package/tests/integration/wasm-errors.test.ts +0 -199
  365. package/tests/integration/wasm-execution.test.ts +0 -348
  366. package/tests/integration/wasm-memory.test.ts +0 -228
  367. package/tests/scripts/analyze-coverage.ts +0 -166
  368. package/tests/scripts/categorize-tests.ts +0 -396
  369. package/tests/scripts/coverage-analysis.ts +0 -836
  370. package/tests/unit/compiler/cache.test.ts +0 -238
  371. package/tests/unit/compiler/errors.test.ts +0 -316
  372. package/tests/unit/compiler/graph-scalability.test.ts +0 -510
  373. package/tests/unit/compiler/graph.test.ts +0 -878
  374. package/tests/unit/compiler/input-validation.test.ts +0 -447
  375. package/tests/unit/compiler/logical-and-parser.test.ts +0 -143
  376. package/tests/unit/compiler/logical-not-parser.test.ts +0 -107
  377. package/tests/unit/compiler/logical-or-parser.test.ts +0 -236
  378. package/tests/unit/compiler/marshal-gen/marshal-gen.test.ts +0 -97
  379. package/tests/unit/compiler/nodes/decision-table.test.ts +0 -103
  380. package/tests/unit/compiler/nodes/decision.test.ts +0 -182
  381. package/tests/unit/compiler/nodes/function-compile.test.ts +0 -204
  382. package/tests/unit/compiler/nodes/function.test.ts +0 -176
  383. package/tests/unit/compiler/nodes/input.test.ts +0 -30
  384. package/tests/unit/compiler/nodes/switch.test.ts +0 -127
  385. package/tests/unit/compiler/optimizer-cache.test.ts +0 -327
  386. package/tests/unit/compiler/optimizer-implementation.test.ts +0 -625
  387. package/tests/unit/compiler/parser.test.ts +0 -508
  388. package/tests/unit/compiler/runtime-error-cleanup.test.ts +0 -426
  389. package/tests/unit/compiler/runtime-validation.test.ts +0 -303
  390. package/tests/unit/compiler/runtime.test.ts +0 -221
  391. package/tests/unit/compiler/schema/schema.test.ts +0 -248
  392. package/tests/unit/compiler/unary-ast-transforms.test.ts +0 -245
  393. package/tsconfig.json +0 -27
  394. package/tsup.config.ts +0 -11
  395. package/vitest.config.ts +0 -12
@@ -1,8 +0,0 @@
1
- // Main entry point - exports runtime components
2
-
3
- export * from './values';
4
- export * from './context';
5
- export * from './expressions';
6
- export * from './tables';
7
- export * from './memory';
8
- export * from './strings';
@@ -1,607 +0,0 @@
1
- // assembly/runtime/memory.ts (AssemblyScript)
2
- // Memory layout and management utilities for WASM linear memory
3
-
4
- import { writeString } from './strings';
5
-
6
- // ============================================================================
7
- // Memory Layout Constants
8
- // ============================================================================
9
-
10
- // Reserved space for null pointer trap (first 4 bytes)
11
- // Accessing address 0 should trap, catching null/nullish pointer bugs
12
- export const NULL_POINTER_TRAP_SIZE: usize = 4;
13
-
14
- // Fixed memory region offsets
15
- export const INPUT_BUFFER_START: usize = NULL_POINTER_TRAP_SIZE; // 0x0004
16
-
17
- // Schema-specific field layouts require different buffer sizes. Computing sizes at
18
- // compile time based on actual schema ensures optimal memory usage per decision.
19
- export let INPUT_BUFFER_SIZE: usize = 0;
20
-
21
- // Variable-length input data starts after the fixed input buffer
22
- export let INPUT_VAR_START: usize = 0;
23
-
24
- // Output buffer follows input variable data
25
- export let OUTPUT_START: usize = 0;
26
-
27
- // Computed at compilation time based on input/output schema field sizes
28
- export let OUTPUT_BUFFER_SIZE: usize = 0;
29
-
30
- // Variable-length output data starts after the fixed output buffer
31
- export let OUTPUT_VAR_START: usize = 0;
32
-
33
- // Runtime heap for intermediate values (temporary arrays, string concat buffers, etc.)
34
- export let HEAP_START: usize = 0;
35
-
36
- // ============================================================================
37
- // Header Constants
38
- // ============================================================================
39
-
40
- // Schema hash size in bytes
41
- export const SCHEMA_HASH_SIZE: usize = 8;
42
-
43
- // String descriptor format: [offset (4 bytes)] [length (4 bytes)]
44
- export const STRING_DESC_SIZE: usize = 8;
45
-
46
- // Array descriptor format: [offset (4 bytes)] [length (4 bytes)]
47
- export const ARRAY_DESC_SIZE: usize = 8;
48
-
49
- // ============================================================================
50
- // Memory Allocation
51
- // ============================================================================
52
-
53
- // Decision evaluation is single-pass (no GC needed), and most allocations are temporary
54
- // (freed after result is marshaled). Linear bump allocator is fast and simple.
55
- let heapPointer: usize = 0;
56
-
57
- /**
58
- * Initialize memory layout.
59
- *
60
- * This function must be called once at startup with the computed sizes
61
- * for the input and output buffers based on the schema.
62
- *
63
- * @param inputFixedSize - Size of fixed input fields in bytes
64
- * @param outputFixedSize - Size of fixed output fields in bytes
65
- */
66
- export function initializeMemoryLayout(inputFixedSize: usize, outputFixedSize: usize): void {
67
- INPUT_BUFFER_SIZE = inputFixedSize;
68
- INPUT_VAR_START = INPUT_BUFFER_START + inputFixedSize;
69
-
70
- OUTPUT_BUFFER_SIZE = outputFixedSize;
71
- OUTPUT_START = INPUT_VAR_START; // Output follows input variable data
72
- OUTPUT_VAR_START = OUTPUT_START + outputFixedSize;
73
-
74
- HEAP_START = OUTPUT_VAR_START; // Heap follows output variable data
75
- heapPointer = HEAP_START; // Reset heap pointer
76
- }
77
-
78
- /**
79
- * Get the current memory layout info.
80
- *
81
- * @returns Object with all memory region offsets and sizes
82
- */
83
- export function getMemoryLayout(): MemoryLayout {
84
- return new MemoryLayout(
85
- NULL_POINTER_TRAP_SIZE,
86
- INPUT_BUFFER_START,
87
- INPUT_BUFFER_SIZE,
88
- INPUT_VAR_START,
89
- OUTPUT_START,
90
- OUTPUT_BUFFER_SIZE,
91
- OUTPUT_VAR_START,
92
- HEAP_START,
93
- );
94
- }
95
-
96
- /**
97
- * Memory layout information structure.
98
- */
99
- export class MemoryLayout {
100
- nullPointerTrapSize: usize;
101
- inputBufferStart: usize;
102
- inputBufferSize: usize;
103
- inputVarStart: usize;
104
- outputStart: usize;
105
- outputBufferSize: usize;
106
- outputVarStart: usize;
107
- heapStart: usize;
108
-
109
- constructor(
110
- nullPointerTrapSize: usize,
111
- inputBufferStart: usize,
112
- inputBufferSize: usize,
113
- inputVarStart: usize,
114
- outputStart: usize,
115
- outputBufferSize: usize,
116
- outputVarStart: usize,
117
- heapStart: usize,
118
- ) {
119
- this.nullPointerTrapSize = nullPointerTrapSize;
120
- this.inputBufferStart = inputBufferStart;
121
- this.inputBufferSize = inputBufferSize;
122
- this.inputVarStart = inputVarStart;
123
- this.outputStart = outputStart;
124
- this.outputBufferSize = outputBufferSize;
125
- this.outputVarStart = outputVarStart;
126
- this.heapStart = heapStart;
127
- }
128
- }
129
-
130
- // ============================================================================
131
- // Simple Linear Heap Allocator
132
- // ============================================================================
133
-
134
- /**
135
- * Allocate memory from the runtime heap.
136
- *
137
- * A simple linear allocator - memory is never freed during a single evaluation.
138
- * Suitable for short-lived operations like decision table evaluation.
139
- *
140
- * Memory is never freed during a single evaluation because:
141
- * (1) evaluations are short-lived (milliseconds),
142
- * (2) heap is reset between evaluations, and
143
- * (3) avoiding free list management simplifies allocator and improves performance.
144
- *
145
- * @param size - Number of bytes to allocate (must be > 0)
146
- * @returns Pointer to allocated memory
147
- * @throws Calls abort() on OUT_OF_MEMORY - this is a critical error that halts execution
148
- */
149
- export function heapAlloc(size: usize): usize {
150
- if (size == 0) return 0;
151
-
152
- // Get current memory size in bytes (1 page = 64KB = 65536 bytes)
153
- const memorySize: usize = (<usize>memory.size()) << 16;
154
-
155
- // Align the heap pointer to 8-byte boundary
156
- const alignedPtr = alignPtr(heapPointer, 8);
157
-
158
- // Check for overflow when computing aligned pointer
159
- // If alignedPtr wrapped around (became smaller than heapPointer), we've overflowed
160
- if (alignedPtr < heapPointer) {
161
- SetLastError(RuntimeErrorCode.OUT_OF_MEMORY);
162
- return 0;
163
- }
164
-
165
- // Check for overflow when computing new heap pointer
166
- // If newHeapPointer would wrap around, we've overflowed
167
- const maxAllowedSize = memorySize - alignedPtr;
168
- if (size > maxAllowedSize) {
169
- SetLastError(RuntimeErrorCode.OUT_OF_MEMORY);
170
- return 0;
171
- }
172
-
173
- const newHeapPointer = alignedPtr + size;
174
-
175
- // Bounds check: ensure new heap pointer doesn't exceed memory
176
- if (newHeapPointer > memorySize) {
177
- SetLastError(RuntimeErrorCode.OUT_OF_MEMORY);
178
- return 0;
179
- }
180
-
181
- // All checks passed, update heap pointer and return allocation
182
- heapPointer = newHeapPointer;
183
- return alignedPtr;
184
- }
185
-
186
- /**
187
- * Get the current heap pointer (next allocation will start here).
188
- *
189
- * @returns Current heap pointer address
190
- */
191
- export function getHeapPointer(): usize {
192
- return heapPointer;
193
- }
194
-
195
- /**
196
- * Reset the heap pointer to the start of the heap region.
197
- *
198
- * This allows reusing heap memory for multiple evaluations.
199
- */
200
- export function resetHeap(): void {
201
- heapPointer = HEAP_START;
202
- }
203
-
204
- /**
205
- * Save the current heap pointer state.
206
- *
207
- * @returns Current heap pointer address
208
- */
209
- export function saveHeapPointer(): usize {
210
- return heapPointer;
211
- }
212
-
213
- /**
214
- * Restore the heap pointer to a previously saved state.
215
- *
216
- * @param saved - Saved heap pointer address from saveHeapPointer()
217
- */
218
- export function restoreHeapPointer(saved: usize): usize {
219
- const old = heapPointer;
220
- heapPointer = saved;
221
- return old;
222
- }
223
-
224
- // ============================================================================
225
- // Pointer Utilities
226
- // ============================================================================
227
-
228
- /**
229
- * Align a pointer to the specified alignment boundary.
230
- *
231
- * @param ptr - Pointer to align
232
- * @param alignment - Alignment boundary (must be a power of 2)
233
- * @returns Aligned pointer
234
- */
235
- export function alignPtr(ptr: usize, alignment: usize): usize {
236
- return (ptr + alignment - 1) & ~(alignment - 1);
237
- }
238
-
239
- /**
240
- * Check if a pointer is null (0).
241
- *
242
- * @param ptr - Pointer to check
243
- * @returns true if pointer is 0, false otherwise
244
- */
245
- export function isNullPtr(ptr: usize): bool {
246
- return ptr == 0;
247
- }
248
-
249
- /**
250
- * Check if a pointer is valid (non-null and aligned).
251
- *
252
- * @param ptr - Pointer to check
253
- * @param alignment - Required alignment (default: 4 bytes)
254
- * @returns true if pointer is valid, false otherwise
255
- */
256
- export function isValidPtr(ptr: usize, alignment: usize = 4): bool {
257
- if (ptr == 0) return false;
258
- return (ptr & (alignment - 1)) == 0;
259
- }
260
-
261
- // ============================================================================
262
- // Buffer Access Helpers
263
- // ============================================================================
264
-
265
- /**
266
- * Get the pointer to a schema hash field.
267
- *
268
- * @param basePtr - Base pointer of the buffer
269
- * @returns Pointer to the schema hash field
270
- */
271
- export function getSchemaHashPtr(basePtr: usize): usize {
272
- return basePtr;
273
- }
274
-
275
- /**
276
- * Read a schema hash from a buffer.
277
- *
278
- * @param basePtr - Base pointer of the buffer
279
- * @returns Schema hash as u64
280
- */
281
- export function readSchemaHash(basePtr: usize): u64 {
282
- return load<u64>(basePtr);
283
- }
284
-
285
- /**
286
- * Write a schema hash to a buffer.
287
- *
288
- * @param basePtr - Base pointer of the buffer
289
- * @param hash - Schema hash to write
290
- */
291
- export function writeSchemaHash(basePtr: usize, hash: u64): void {
292
- store<u64>(basePtr, hash);
293
- }
294
-
295
- /**
296
- * Get the pointer to a field in a fixed-size buffer.
297
- *
298
- * @param bufferPtr - Base pointer of the buffer
299
- * @param fieldOffset - Offset of the field from the buffer start
300
- * @returns Pointer to the field
301
- */
302
- export function getFieldPtr(bufferPtr: usize, fieldOffset: usize): usize {
303
- return bufferPtr + fieldOffset;
304
- }
305
-
306
- // ============================================================================
307
- // String Descriptor Helpers
308
- // ============================================================================
309
-
310
- /**
311
- * Get the offset and length components of a string descriptor.
312
- *
313
- * String descriptor format: [offset (4 bytes)] [length (4 bytes)]
314
- *
315
- * @param descPtr - Pointer to the string descriptor
316
- * @returns Object with offset and length
317
- */
318
- export function readStringDesc(descPtr: usize): StringDesc {
319
- return new StringDesc(load<u32>(descPtr), load<u32>(descPtr + 4));
320
- }
321
-
322
- /**
323
- * Write a string descriptor.
324
- *
325
- * @param descPtr - Pointer to the string descriptor
326
- * @param offset - Offset to the string data
327
- * @param length - Length of the string data
328
- */
329
- export function writeStringDesc(descPtr: usize, offset: u32, length: u32): void {
330
- store<u32>(descPtr, offset);
331
- store<u32>(descPtr + 4, length);
332
- }
333
-
334
- /**
335
- * String descriptor structure.
336
- */
337
- export class StringDesc {
338
- offset: u32;
339
- length: u32;
340
-
341
- constructor(offset: u32, length: u32) {
342
- this.offset = offset;
343
- this.length = length;
344
- }
345
-
346
- isEmpty(): bool {
347
- return this.length == 0;
348
- }
349
- }
350
-
351
- // ============================================================================
352
- // Array Descriptor Helpers
353
- // ============================================================================
354
-
355
- /**
356
- * Get the offset and length components of an array descriptor.
357
- *
358
- * Array descriptor format: [offset (4 bytes)] [length (4 bytes)]
359
- *
360
- * @param descPtr - Pointer to the array descriptor
361
- * @returns Object with offset and length
362
- */
363
- export function readArrayDesc(descPtr: usize): ArrayDesc {
364
- return new ArrayDesc(load<u32>(descPtr), load<u32>(descPtr + 4));
365
- }
366
-
367
- /**
368
- * Write an array descriptor.
369
- *
370
- * @param descPtr - Pointer to the array descriptor
371
- * @param offset - Offset to the array data
372
- * @param length - Number of elements in the array
373
- */
374
- export function writeArrayDesc(descPtr: usize, offset: u32, length: u32): void {
375
- store<u32>(descPtr, offset);
376
- store<u32>(descPtr + 4, length);
377
- }
378
-
379
- /**
380
- * Array descriptor structure.
381
- */
382
- export class ArrayDesc {
383
- offset: u32;
384
- length: u32;
385
-
386
- constructor(offset: u32, length: u32) {
387
- this.offset = offset;
388
- this.length = length;
389
- }
390
-
391
- isEmpty(): bool {
392
- return this.length == 0;
393
- }
394
- }
395
-
396
- // ============================================================================
397
- // Runtime Error Handling
398
- // ============================================================================
399
-
400
- // Error codes for runtime failures
401
- export enum RuntimeErrorCode {
402
- NONE = 0,
403
- SCHEMA_MISMATCH = 1,
404
- NULL_POINTER = 2,
405
- INVALID_ACCESS = 3,
406
- EVALUATION_ERROR = 4,
407
- OUT_OF_MEMORY = 5,
408
- }
409
-
410
- // Last error that occurred during evaluation
411
- let lastErrorCode: RuntimeErrorCode = RuntimeErrorCode.NONE;
412
-
413
- // Optional error message (allocated on heap for variable-length messages)
414
- let errorMessagePtr: usize = 0;
415
-
416
- /**
417
- * Check if an error code represents a critical error that should abort execution.
418
- *
419
- * Critical errors are unrecoverable conditions where continuing execution would
420
- * likely lead to memory corruption, crashes, or incorrect results. These errors
421
- * call abort() to immediately halt the WASM module.
422
- *
423
- * Critical errors:
424
- * - OUT_OF_MEMORY: Memory allocation failed; continuing could corrupt state
425
- * - NULL_POINTER: Null pointer dereference; memory safety violation
426
- * - INVALID_ACCESS: Invalid memory access; memory safety violation
427
- *
428
- * Non-critical errors (set flag, caller must check hasError()):
429
- * - SCHEMA_MISMATCH: Input doesn't match schema; recoverable
430
- * - EVALUATION_ERROR: Logic error in decision evaluation; recoverable
431
- *
432
- * @param code - The error code to check
433
- * @returns true if the error is critical and should abort
434
- */
435
- export function isCriticalError(code: RuntimeErrorCode): bool {
436
- return (
437
- code === RuntimeErrorCode.OUT_OF_MEMORY ||
438
- code === RuntimeErrorCode.NULL_POINTER ||
439
- code === RuntimeErrorCode.INVALID_ACCESS
440
- );
441
- }
442
-
443
- /**
444
- * Get the last error code that occurred during evaluation.
445
- *
446
- * @returns The last error code
447
- */
448
- export function getLastError(): RuntimeErrorCode {
449
- return lastErrorCode;
450
- }
451
-
452
- /**
453
- * Set the last error code and optional message.
454
- *
455
- * For critical errors (OUT_OF_MEMORY, NULL_POINTER, INVALID_ACCESS), this function
456
- * calls abort() to immediately halt execution. Critical errors indicate unrecoverable
457
- * conditions where continuing would lead to memory corruption or undefined behavior.
458
- *
459
- * For non-critical errors (SCHEMA_MISMATCH, EVALUATION_ERROR), callers MUST check
460
- * hasError() after operations that can fail and handle the error appropriately.
461
- * Failure to check error state may result in incorrect evaluation results.
462
- *
463
- * @param code - The error code
464
- * @param message - Optional error message (allocated on heap)
465
- */
466
- export function SetLastError(code: RuntimeErrorCode, message: usize = 0): void {
467
- lastErrorCode = code;
468
- errorMessagePtr = message;
469
-
470
- // Critical errors abort immediately to prevent corrupted state propagation
471
- if (isCriticalError(code)) {
472
- abort();
473
- }
474
- }
475
-
476
- /**
477
- * Clear the last error (reset to NONE).
478
- */
479
- export function clearLastError(): void {
480
- lastErrorCode = RuntimeErrorCode.NONE;
481
- errorMessagePtr = 0;
482
- }
483
-
484
- /**
485
- * Set an error with a string message.
486
- *
487
- * This is a convenience function that combines SetLastError() with writeString().
488
- * The error message is allocated on the heap and will be freed by the next error.
489
- *
490
- * For critical errors (OUT_OF_MEMORY, NULL_POINTER, INVALID_ACCESS), this function
491
- * will call abort() after setting the error, immediately halting execution.
492
- *
493
- * For non-critical errors (SCHEMA_MISMATCH, EVALUATION_ERROR), callers MUST check
494
- * hasError() after operations that can fail.
495
- *
496
- * @param code - The error code
497
- * @param message - The error message string
498
- */
499
- export function SetLastErrorWithMessage(code: RuntimeErrorCode, message: string): void {
500
- const messagePtr = writeString(message);
501
- SetLastError(code, messagePtr);
502
- }
503
-
504
- /**
505
- * Get the pointer to the error message.
506
- *
507
- * @returns Pointer to error message (0 if no message)
508
- */
509
- export function getErrorMessagePtr(): usize {
510
- return errorMessagePtr;
511
- }
512
-
513
- /**
514
- * Check if an error occurred.
515
- *
516
- * Callers MUST check this function after operations that can set non-critical errors
517
- * (SCHEMA_MISMATCH, EVALUATION_ERROR). Critical errors (OUT_OF_MEMORY, NULL_POINTER,
518
- * INVALID_ACCESS) abort immediately and never reach this check.
519
- *
520
- * Example usage:
521
- * ```assemblyscript
522
- * let result = someOperationThatCanFail();
523
- * if (hasError()) {
524
- * // Handle error - return early, propagate error, etc.
525
- * return Value.Null();
526
- * }
527
- * // Continue with valid result
528
- * ```
529
- *
530
- * @returns true if a non-critical error occurred, false otherwise
531
- */
532
- export function hasError(): bool {
533
- return lastErrorCode !== RuntimeErrorCode.NONE;
534
- }
535
-
536
- // ============================================================================
537
- // Memory Validation Helpers
538
- // ============================================================================
539
-
540
- /**
541
- * Check if a pointer is within the valid memory range.
542
- *
543
- * This is a basic check that can help catch out-of-bounds accesses.
544
- * Note: In production, you may want to disable these checks for performance.
545
- *
546
- * @param ptr - Pointer to check
547
- * @param size - Size of the region to check
548
- * @return true if pointer is within valid range, false otherwise
549
- */
550
- export function isValidMemoryRange(ptr: usize, size: usize): bool {
551
- if (ptr == 0) return false;
552
-
553
- // Get current memory size (AssemblyScript runtime provides this)
554
- const memorySize: usize = memory.size() << 16; // 1 page = 64KB
555
-
556
- return ptr + size <= memorySize;
557
- }
558
-
559
- /**
560
- * Check if a pointer is within the input buffer region.
561
- *
562
- * @param ptr - Pointer to check
563
- * @return true if pointer is within input buffer, false otherwise
564
- */
565
- export function isWithinInputBuffer(ptr: usize): bool {
566
- return ptr >= INPUT_BUFFER_START && ptr < INPUT_VAR_START;
567
- }
568
-
569
- /**
570
- * Check if a pointer is within the input variable data region.
571
- *
572
- * @param ptr - Pointer to check
573
- * @return true if pointer is within input variable data, false otherwise
574
- */
575
- export function isWithinInputVar(ptr: usize): bool {
576
- return ptr >= INPUT_VAR_START && ptr < OUTPUT_START;
577
- }
578
-
579
- /**
580
- * Check if a pointer is within the output buffer region.
581
- *
582
- * @param ptr - Pointer to check
583
- * @return true if pointer is within output buffer, false otherwise
584
- */
585
- export function isWithinOutputBuffer(ptr: usize): bool {
586
- return ptr >= OUTPUT_START && ptr < OUTPUT_VAR_START;
587
- }
588
-
589
- /**
590
- * Check if a pointer is within the output variable data region.
591
- *
592
- * @param ptr - Pointer to check
593
- * @return true if pointer is within output variable data, false otherwise
594
- */
595
- export function isWithinOutputVar(ptr: usize): bool {
596
- return ptr >= OUTPUT_VAR_START && ptr < HEAP_START;
597
- }
598
-
599
- /**
600
- * Check if a pointer is within the heap region.
601
- *
602
- * @param ptr - Pointer to check
603
- * @return true if pointer is within heap, false otherwise
604
- */
605
- export function isWithinHeap(ptr: usize): bool {
606
- return ptr >= HEAP_START;
607
- }