Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug reportado pelo Diogo Medeiros na execução de para com passo dinâmico no VisuAlg. #608

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,24 @@ export class InterpretadorVisuAlgComDepuracao extends InterpretadorComDepuracao
}

async visitarDeclaracaoPara(declaracao: Para): Promise<any> {
if (!declaracao.inicializada && declaracao.inicializador !== null) {
await this.avaliar(declaracao.inicializador as any);
if (declaracao.incrementar !== null) {
await comum.resolverIncrementoPara(this, declaracao);
}
}

declaracao.inicializada = true;

// Aqui precisamos clonar a declaração `Para` porque inserimos
// ao final dela o incremento. Diferente de declarações `Para` de
// outros dialetos, o incremento dessa declaração é implícito.
const cloneDeclaracao = _.cloneDeep(declaracao) as Para;
const corpoExecucao = cloneDeclaracao.corpo as Bloco;
if (cloneDeclaracao.inicializador !== null) {
await this.avaliar(cloneDeclaracao.inicializador as any);
// O incremento vai ao final do bloco de escopo.
if (cloneDeclaracao.incrementar !== null) {
await comum.resolverIncrementoPara(this, cloneDeclaracao);
corpoExecucao.declaracoes.push(cloneDeclaracao.incrementar);
}
// O incremento vai ao final do bloco de escopo.
if (cloneDeclaracao.incrementar !== null) {
await comum.resolverIncrementoPara(this, cloneDeclaracao);
corpoExecucao.declaracoes.push(cloneDeclaracao.incrementar);
}

const escopoAtual = this.pilhaEscoposExecucao.topoDaPilha();
Expand Down
Loading