cella-lang 0.1.202611040521 → 0.1.202611041233

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/CHANGES.md CHANGED
@@ -5,6 +5,10 @@
5
5
 
6
6
  ## 未發佈
7
7
 
8
+ - `compile_program_component(language, programJson, fuel)` 多收一個可選的 `fuel`:模型的步數上限,不給(或給 `undefined`)時照舊是 1,000,000;
9
+ 要是非負整數,否則拒絕。WIT 與 `run` 的形狀不變。
10
+ - 元件裡超過 i64 的 `Nat` 改由模組自己算(加減乘除餘、比較、字面量):之前元件沒有宿主的大數,走到就中止(V8 與 jco 報 unreachable、WAMR 報
11
+ operand stack overflow),Arduino 的程式在核心的浮點常數就停下來。元件照舊只匯入介面上的函式;瀏覽器版照舊用 BigInt。
8
12
  - 新匯出 `compile_program_component(language, programJson)`:把 C、C++、Arduino、Python 的程式 JSON(和 `<語言>.verdict` 收的相同)編成元件,
9
13
  照 cos-mos 的 `world console-batch-app`:匯出 `run: func(input: string)`(整段標準輸入)與 `cabi_realloc`,跑語言的模型,把標準輸出寫到
10
14
  console 的 stdout、把判決 JSON 交給 `report`。`@[wit]` 也多收兩種:匯出可以帶字串參數,WIT 的 enum 對到只有無參數建構子的資料型別。
package/README.md CHANGED
@@ -236,6 +236,17 @@ const component = m.compile_component(source); // after init_stdlib_cached
236
236
  console.log(m.wit_of(source));
237
237
  ```
238
238
 
239
+ `compile_program_component(language, programJson, fuel)` compiles a program of a language (`c`, `cpp`, `arduino`,
240
+ `python`: the JSON its `verdict` takes) to a component of cos-mos's `world console-batch-app`: `run(input)` runs the
241
+ language's model on the program with that standard input, writes the standard output to the console's stdout and
242
+ reports the verdict (the same JSON as the language's `verdict`). Load the language's package first. `fuel` is the
243
+ model's step limit, 1,000,000 when it is not given; past it the verdict is unknown (kind `fuel`). A `Nat` past 64 bits
244
+ is computed by the component itself, so it still imports only the console.
245
+
246
+ ```js
247
+ const app = m.compile_program_component('arduino', programJson, 50_000_000); // after loading @cella-lang/arduino
248
+ ```
249
+
239
250
  ## When to upgrade
240
251
 
241
252
  `package.json` carries two fingerprints:
package/cella.d.ts CHANGED
@@ -20,9 +20,11 @@ export function compile_component(source: string): Uint8Array;
20
20
  /**
21
21
  * Compiles a program of a language (`c`, `cpp`, `arduino`, `python`: the JSON its `verdict` takes) to a component of
22
22
  * cos-mos's `world console-batch-app`: the language's model runs on the program with the input `run` is given, writes
23
- * the standard output and reports the verdict (spec 677). Load the language's package first (`load_library_pack`).
23
+ * the standard output and reports the verdict. Load the language's package first (`load_library_pack`).
24
+ * `fuel` is the model's step limit (past it the verdict is unknown, kind `fuel`): a whole number of steps, 1,000,000
25
+ * when it is not given.
24
26
  */
25
- export function compile_program_component(language: string, program_json: string): Uint8Array;
27
+ export function compile_program_component(language: string, program_json: string, fuel?: number | null): Uint8Array;
26
28
 
27
29
  /**
28
30
  * F335:把程式編成 WasmGC 模組(與 CLI 的 `run --wasm` 同一個後端),由瀏覽器執行(`main.js` 實作 `env.*` 匯入)。
@@ -170,7 +172,7 @@ export interface InitOutput {
170
172
  readonly candidates: (a: number, b: number, c: number, d: number, e: number) => [number, number];
171
173
  readonly check: (a: number, b: number) => [number, number];
172
174
  readonly compile_component: (a: number, b: number) => [number, number, number, number];
173
- readonly compile_program_component: (a: number, b: number, c: number, d: number) => [number, number, number, number];
175
+ readonly compile_program_component: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
174
176
  readonly compile_wasm: (a: number, b: number) => [number, number, number, number];
175
177
  readonly compile_wasm_library: (a: number, b: number, c: number, d: number) => [number, number, number, number];
176
178
  readonly goals_at: (a: number, b: number, c: number, d: number) => [number, number];
package/cella.js CHANGED
@@ -66,17 +66,20 @@ export function compile_component(source) {
66
66
  /**
67
67
  * Compiles a program of a language (`c`, `cpp`, `arduino`, `python`: the JSON its `verdict` takes) to a component of
68
68
  * cos-mos's `world console-batch-app`: the language's model runs on the program with the input `run` is given, writes
69
- * the standard output and reports the verdict (spec 677). Load the language's package first (`load_library_pack`).
69
+ * the standard output and reports the verdict. Load the language's package first (`load_library_pack`).
70
+ * `fuel` is the model's step limit (past it the verdict is unknown, kind `fuel`): a whole number of steps, 1,000,000
71
+ * when it is not given.
70
72
  * @param {string} language
71
73
  * @param {string} program_json
74
+ * @param {number | null} [fuel]
72
75
  * @returns {Uint8Array}
73
76
  */
74
- export function compile_program_component(language, program_json) {
77
+ export function compile_program_component(language, program_json, fuel) {
75
78
  const ptr0 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
79
  const len0 = WASM_VECTOR_LEN;
77
80
  const ptr1 = passStringToWasm0(program_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
81
  const len1 = WASM_VECTOR_LEN;
79
- const ret = wasm.compile_program_component(ptr0, len0, ptr1, len1);
82
+ const ret = wasm.compile_program_component(ptr0, len0, ptr1, len1, !isLikeNone(fuel), isLikeNone(fuel) ? 0 : fuel);
80
83
  if (ret[3]) {
81
84
  throw takeFromExternrefTable0(ret[2]);
82
85
  }
package/cella_bg.wasm CHANGED
Binary file
@@ -4,7 +4,7 @@ export const memory: WebAssembly.Memory;
4
4
  export const candidates: (a: number, b: number, c: number, d: number, e: number) => [number, number];
5
5
  export const check: (a: number, b: number) => [number, number];
6
6
  export const compile_component: (a: number, b: number) => [number, number, number, number];
7
- export const compile_program_component: (a: number, b: number, c: number, d: number) => [number, number, number, number];
7
+ export const compile_program_component: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
8
8
  export const compile_wasm: (a: number, b: number) => [number, number, number, number];
9
9
  export const compile_wasm_library: (a: number, b: number, c: number, d: number) => [number, number, number, number];
10
10
  export const goals_at: (a: number, b: number, c: number, d: number) => [number, number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cella-lang",
3
- "version": "0.1.202611040521",
3
+ "version": "0.1.202611041233",
4
4
  "description": "Cella Lang: a formalization engine that says what it checked. The checker (cubical type theory with QTT) compiled to WebAssembly for browsers and Node; every check ends in Accept, Reject or Unknown, with the assumptions it rests on.",
5
5
  "type": "module",
6
6
  "main": "cella.js",
@@ -22,5 +22,5 @@
22
22
  "license": "Apache-2.0",
23
23
  "author": "SungYu Chang",
24
24
  "engines": { "node": ">=18" },
25
- "cella": { "checkerHash": "ee7191d202f1037b", "checkerSha256": "ee7191d202f1037bdb206d5104c529c9a59f25bc45756d35a55a434964262f50", "componentSha256": "a75fa274ab439c806ec211db1784f02a9af1e32093074410a6f6eab45747fd85", "semanticsHash": "5a71ea88342da141", "filesHash": "609d94609bba34c5", "commit": "30989e685aaf293f2047194cb25440d1b055f535" }
25
+ "cella": { "checkerHash": "ee7191d202f1037b", "checkerSha256": "ee7191d202f1037bdb206d5104c529c9a59f25bc45756d35a55a434964262f50", "componentSha256": "a75fa274ab439c806ec211db1784f02a9af1e32093074410a6f6eab45747fd85", "semanticsHash": "5a71ea88342da141", "filesHash": "cf8f74c6400355f6", "commit": "f4647ac03adfd050b423322a79505ce5af41c447" }
26
26
  }