Skip to content

Commit

Permalink
Compiler updated (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
hecmas authored Nov 27, 2023
1 parent 52c32cf commit 14097d5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require("path");
const fs = require("fs");
const util = require('util');
const { config } = require("process");
const { get } = require("http");
const zkasm_parser = require("../build/zkasm_parser.js").parser;
const command_parser = require("../build/command_parser.js").parser;
const stringifyBigInts = require("ffjavascript").utils.stringifyBigInts;
Expand Down Expand Up @@ -72,12 +73,21 @@ module.exports = async function compile(fileName, ctx, config = {}) {
scope: "GLOBAL",
offset: ctx.lastGlobalVarAssigned + 1
}
ctx.lastGlobalVarAssigned += l.count;
if (typeof l.count === 'string') {
ctx.lastGlobalVarAssigned += Number(getConstantValue(ctx, l.count));
} else {
ctx.lastGlobalVarAssigned += l.count;
}
} else if (l.scope == "CTX") {
ctx.vars[l.name] = {
scope: "CTX",
offset: ctx.lastLocalVarCtxAssigned + 1
}
if (typeof l.count === 'string') {
ctx.lastGlobalVarAssigned += Number(getConstantValue(ctx, l.count));
} else {
ctx.lastGlobalVarAssigned += l.count;
}
ctx.lastLocalVarCtxAssigned += l.count;
} else {
throw error(l, `Invalid scope ${l.scope}`);
Expand Down

0 comments on commit 14097d5

Please sign in to comment.