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

alterando os valores logicos primitivos #655

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
38 changes: 24 additions & 14 deletions fontes/interpretador/interpretador-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ export class InterpretadorBase implements InterpretadorInterface {

regexInterpolacao = /\${(.*?)}/g;
private tiposNumericos = [
tipoDeDadosDelegua.INTEIRO,
tipoDeDadosDelegua.NUMERO,
tipoDeDadosDelegua.NÚMERO,
tipoDeDadosDelegua.INTEIRO,
tipoDeDadosDelegua.NUMERO,
tipoDeDadosDelegua.NÚMERO,
tipoDeDadosDelegua.REAL
];

Expand Down Expand Up @@ -217,12 +217,12 @@ export class InterpretadorBase implements InterpretadorInterface {
const match = texto.match(/^([\/~@;%#'])(.*?)\1([gimsuy]*)$/);
return match
? new RegExp(
match[2],
match[3]
.split('')
.filter((char, pos, flagArr) => flagArr.indexOf(char) === pos)
.join('')
)
match[2],
match[3]
.split('')
.filter((char, pos, flagArr) => flagArr.indexOf(char) === pos)
.join('')
)
: new RegExp(texto);
}

Expand Down Expand Up @@ -501,13 +501,13 @@ export class InterpretadorBase implements InterpretadorInterface {
const tipoDireita: string = direita.tipo
? direita.tipo
: typeof direita === tipoDeDadosPrimitivos.NUMERO
? tipoDeDadosDelegua.NUMERO
: String(NaN);
? tipoDeDadosDelegua.NUMERO
: String(NaN);
const tipoEsquerda: string = esquerda.tipo
? esquerda.tipo
: typeof esquerda === tipoDeDadosPrimitivos.NUMERO
? tipoDeDadosDelegua.NUMERO
: String(NaN);
? tipoDeDadosDelegua.NUMERO
: String(NaN);

if (this.tiposNumericos.includes(tipoDireita) && this.tiposNumericos.includes(tipoEsquerda)) return;

Expand Down Expand Up @@ -1634,7 +1634,17 @@ export class InterpretadorBase implements InterpretadorInterface {
}
}
}
if (typeof objeto === tipoDeDadosPrimitivos.OBJETO) return JSON.stringify(objeto);
if (typeof objeto === tipoDeDadosPrimitivos.OBJETO) {
for (const obj in objeto) {
let valor = objeto[obj]
if (typeof valor === tipoDeDadosPrimitivos.BOOLEANO) {
valor = valor ? 'verdadeiro' : 'falso';

objeto[obj] = valor;
}
}
return JSON.stringify(objeto);
}

return objeto.toString();
}
Expand Down
Loading