mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
Remove streams c and wasm gen
This commit is contained in:
@@ -631,7 +631,8 @@ class BuilderC {
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
async build(fd) {
|
||||
const encoder = new TextEncoder("utf-8");
|
||||
const code=new BigArray();
|
||||
this._buildHeader(code);
|
||||
this._buildSizes(code);
|
||||
@@ -643,7 +644,17 @@ class BuilderC {
|
||||
this._buildMapIsInput(code);
|
||||
this._buildWit2Sig(code);
|
||||
this._buildCircuitVar(code);
|
||||
return streamFromMultiArray(code);
|
||||
await writeCode(code);
|
||||
|
||||
async function writeCode(c) {
|
||||
if (c.push) {
|
||||
for (let i=0; i<c.length; i++) {
|
||||
await writeCode(c[i]);
|
||||
}
|
||||
} else if (typeof c === "string") {
|
||||
await fd.write(encoder.encode(c + "\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -990,7 +990,8 @@ class BuilderWasm {
|
||||
}
|
||||
|
||||
|
||||
build(outType) {
|
||||
async build(fd, outType) {
|
||||
const encoder = new TextEncoder("utf-8");
|
||||
let module;
|
||||
if (outType == "wasm") {
|
||||
module=new ModuleBuilder();
|
||||
@@ -1017,12 +1018,25 @@ class BuilderWasm {
|
||||
|
||||
module.setMemory(2000);
|
||||
if (outType == "wasm") {
|
||||
return streamFromArrayBin(module.build());
|
||||
const bytes = module.build();
|
||||
const bytesArr = new Uint8Array(bytes);
|
||||
await fd.write(bytesArr);
|
||||
} else if (outType == "wat") {
|
||||
return streamFromArrayTxt(module.build());
|
||||
const code = module.build();
|
||||
await writeCode(code);
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
async function writeCode(c) {
|
||||
if (c.push) {
|
||||
for (let i=0; i<c.length; i++) {
|
||||
await writeCode(c[i]);
|
||||
}
|
||||
} else if (typeof c === "string") {
|
||||
await fd.write(encoder.encode(c + "\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user