Skip to content

Commit

Permalink
Corrigir uso de constantes em inicialização de arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dgadelha committed Dec 26, 2023
1 parent ef89403 commit 274ce63
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/runtime/src/PortugolJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ export class PortugolJs extends AbstractParseTreeVisitor<string> implements Port

sb.append(this.PAD(), `const runtime = new PortugolRuntime(initScope);`, `\n\n`);
sb.append(this.PAD(), `self.runtime = runtime;`, `\n\n`);
sb.append(this.PAD(), `let scope = runtime.globalScope;`, `\n\n`);
sb.append(super.visitChildren(ctx));
sb.append(`\n`, this.PAD(), `await runtime.callFunction("inicio");\n})`);

Expand Down Expand Up @@ -985,22 +986,22 @@ export class PortugolJs extends AbstractParseTreeVisitor<string> implements Port
const tam = arr.tamanhoArray();

if (tam) {
sb.append(`[\n`);
sb.append(`\n`);

this.pad++;

sb.append(
new Array(parseInt(tam.text, 10))
.fill(0)
.map(() => `${this.PAD()}new PortugolVar("${ctx.TIPO().text}", undefined)`)
.join(`,\n`),
);
sb.append(this.PAD(), `new Array(`, `\n`);

sb.append(`,\n`);
this.pad++;

sb.append(this.visit(tam.expressao()));
sb.append(this.PAD(), `.value`, `\n`);

this.pad--;

sb.append(this.PAD(), `]`);
sb.append(this.PAD(), `).fill(0).map(() => new PortugolVar("${ctx.TIPO().text}", undefined))`, `\n`);

this.pad--;
} else {
sb.append(`[]`);
}
Expand Down

0 comments on commit 274ce63

Please sign in to comment.