|
@ -116,6 +116,8 @@ function gen(ctx, ast) { |
|
|
return genFunctionCall(ctx, ast); |
|
|
return genFunctionCall(ctx, ast); |
|
|
} else if (ast.type == "BLOCK") { |
|
|
} else if (ast.type == "BLOCK") { |
|
|
return genBlock(ctx, ast); |
|
|
return genBlock(ctx, ast); |
|
|
|
|
|
} else if (ast.type == "COMPUTE") { |
|
|
|
|
|
return genCompute(ctx, ast); |
|
|
} else if (ast.type == "FOR") { |
|
|
} else if (ast.type == "FOR") { |
|
|
return genFor(ctx, ast); |
|
|
return genFor(ctx, ast); |
|
|
} else if (ast.type == "WHILE") { |
|
|
} else if (ast.type == "WHILE") { |
|
@ -256,6 +258,12 @@ function genWhile(ctx, ast) { |
|
|
return `while (bigInt(${condition}).neq(bigInt(0))) {\n${body}\n}\n`; |
|
|
return `while (bigInt(${condition}).neq(bigInt(0))) {\n${body}\n}\n`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function genCompute(ctx, ast) { |
|
|
|
|
|
const body = gen(ctx, ast.body); |
|
|
|
|
|
if (ctx.error) return; |
|
|
|
|
|
return `{\n${body}\n}\n`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function genIf(ctx, ast) { |
|
|
function genIf(ctx, ast) { |
|
|
const condition = gen(ctx, ast.condition); |
|
|
const condition = gen(ctx, ast.condition); |
|
|
if (ctx.error) return; |
|
|
if (ctx.error) return; |
|
|