@designliquido/delegua 1.23.2 → 1.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analisador-semantico/analisador-semantico.d.ts.map +1 -1
- package/analisador-semantico/analisador-semantico.js +1 -3
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +87 -61
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +90 -35
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/bin/package.json +1 -1
- package/construtos/binario.d.ts.map +1 -1
- package/construtos/binario.js +15 -0
- package/construtos/binario.js.map +1 -1
- package/interpretador/estruturas/delegua-funcao.d.ts +1 -1
- package/interpretador/estruturas/delegua-funcao.d.ts.map +1 -1
- package/interpretador/estruturas/delegua-funcao.js +21 -8
- package/interpretador/estruturas/delegua-funcao.js.map +1 -1
- package/interpretador/interpretador-base.d.ts +5 -0
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +52 -13
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/interpretador.d.ts.map +1 -1
- package/interpretador/interpretador.js +30 -0
- package/interpretador/interpretador.js.map +1 -1
- package/package.json +1 -1
- package/umd/delegua.js +297 -121
package/umd/delegua.js
CHANGED
|
@@ -712,9 +712,7 @@ class AnalisadorSemantico extends analisador_semantico_base_1.AnalisadorSemantic
|
|
|
712
712
|
}
|
|
713
713
|
async visitarExpressaoDeChamada(expressao) {
|
|
714
714
|
for (const argumento of expressao.argumentos) {
|
|
715
|
-
|
|
716
|
-
this.gerenciadorEscopos.marcarComoUsada(argumento.simbolo.lexema);
|
|
717
|
-
}
|
|
715
|
+
this.marcarVariaveisUsadasEmExpressao(argumento);
|
|
718
716
|
}
|
|
719
717
|
switch (expressao.entidadeChamada.constructor) {
|
|
720
718
|
case construtos_1.AcessoMetodo:
|
|
@@ -2408,6 +2406,28 @@ const primitivas_dicionario_1 = __importDefault(require("../bibliotecas/primitiv
|
|
|
2408
2406
|
const primitivas_numero_1 = __importDefault(require("../bibliotecas/primitivas-numero"));
|
|
2409
2407
|
const primitivas_texto_1 = __importDefault(require("../bibliotecas/primitivas-texto"));
|
|
2410
2408
|
const primitivas_vetor_1 = __importDefault(require("../bibliotecas/primitivas-vetor"));
|
|
2409
|
+
// Constante usada em "declaracaoRetorna()"
|
|
2410
|
+
const simbolosInicioExpressao = new Set([
|
|
2411
|
+
delegua_2.default.CHAVE_ESQUERDA,
|
|
2412
|
+
delegua_2.default.COLCHETE_ESQUERDO,
|
|
2413
|
+
delegua_2.default.FALSO,
|
|
2414
|
+
delegua_2.default.FUNCAO,
|
|
2415
|
+
delegua_2.default.FUNÇÃO,
|
|
2416
|
+
delegua_2.default.IDENTIFICADOR,
|
|
2417
|
+
delegua_2.default.ISTO,
|
|
2418
|
+
delegua_2.default.NAO,
|
|
2419
|
+
delegua_2.default.NEGACAO,
|
|
2420
|
+
delegua_2.default.NUMERO,
|
|
2421
|
+
delegua_2.default.NULO,
|
|
2422
|
+
delegua_2.default.PARENTESE_ESQUERDO,
|
|
2423
|
+
delegua_2.default.SUPER,
|
|
2424
|
+
delegua_2.default.TEXTO,
|
|
2425
|
+
delegua_2.default.VERDADEIRO,
|
|
2426
|
+
delegua_2.default.ADICAO,
|
|
2427
|
+
delegua_2.default.SUBTRACAO,
|
|
2428
|
+
delegua_2.default.INCREMENTAR,
|
|
2429
|
+
delegua_2.default.DECREMENTAR
|
|
2430
|
+
]);
|
|
2411
2431
|
/**
|
|
2412
2432
|
* O avaliador sintático (_Parser_) é responsável por transformar os símbolos do Lexador em estruturas de alto nível.
|
|
2413
2433
|
* Essas estruturas de alto nível são as partes que executam lógica de programação de fato.
|
|
@@ -2753,7 +2773,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
2753
2773
|
this.avancarEDevolverAnterior();
|
|
2754
2774
|
valores = [];
|
|
2755
2775
|
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.COLCHETE_DIREITO)) {
|
|
2756
|
-
return new construtos_1.Vetor(this.hashArquivo,
|
|
2776
|
+
return new construtos_1.Vetor(this.hashArquivo, simboloAtual.linha, [], 'qualquer[]');
|
|
2757
2777
|
}
|
|
2758
2778
|
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.PARENTESE_ESQUERDO)) {
|
|
2759
2779
|
return this.construtoTupla();
|
|
@@ -2788,21 +2808,34 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
2788
2808
|
const valoresSemComentarios = valores.filter((v) => v.constructor !== construtos_1.ComentarioComoConstruto);
|
|
2789
2809
|
let elementoSeparador = false; // O primeiro elemento não pode ser separador.
|
|
2790
2810
|
for (const elemento of valoresSemComentarios) {
|
|
2811
|
+
const simboloErro = elemento.simbolo || simboloAtual;
|
|
2791
2812
|
if (elementoSeparador) {
|
|
2792
2813
|
if (elemento.constructor !== construtos_1.Separador) {
|
|
2793
|
-
throw this.erro(
|
|
2814
|
+
throw this.erro(simboloErro, 'Os itens dos vetores devem ser separados através de uma vírgula.');
|
|
2794
2815
|
}
|
|
2795
2816
|
elementoSeparador = false;
|
|
2796
2817
|
}
|
|
2797
2818
|
else {
|
|
2798
2819
|
if (elemento.constructor === construtos_1.Separador) {
|
|
2799
|
-
throw this.erro(
|
|
2820
|
+
throw this.erro(simboloErro, 'Não podem haver duas vírgulas seguidas em uma definição de vetor, ou definição de vetor começando em vírgula.');
|
|
2800
2821
|
}
|
|
2801
2822
|
elementoSeparador = true;
|
|
2802
2823
|
}
|
|
2803
2824
|
}
|
|
2804
2825
|
const valoresSemSeparadores = valoresSemComentarios.filter((v) => v.constructor !== construtos_1.Separador);
|
|
2805
|
-
|
|
2826
|
+
let tipoVetor;
|
|
2827
|
+
if (valoresSemSeparadores.length === 0) {
|
|
2828
|
+
tipoVetor = 'qualquer[]';
|
|
2829
|
+
}
|
|
2830
|
+
else {
|
|
2831
|
+
const primeiroElemento = valoresSemSeparadores[0];
|
|
2832
|
+
if (primeiroElemento instanceof construtos_1.Vetor) {
|
|
2833
|
+
tipoVetor = primeiroElemento.tipo + '[]';
|
|
2834
|
+
}
|
|
2835
|
+
else {
|
|
2836
|
+
tipoVetor = (0, inferenciador_1.inferirTipoVariavel)(valoresSemSeparadores);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2806
2839
|
return new construtos_1.Vetor(this.hashArquivo, Number(simboloAtual.linha), valores, tipoVetor);
|
|
2807
2840
|
case delegua_2.default.ENQUANTO:
|
|
2808
2841
|
this.avancarEDevolverAnterior();
|
|
@@ -4017,24 +4050,9 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
4017
4050
|
}
|
|
4018
4051
|
async declaracaoRetorna() {
|
|
4019
4052
|
const simboloChave = this.simbolos[this.atual - 1];
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
delegua_2.default.COLCHETE_ESQUERDO,
|
|
4024
|
-
delegua_2.default.FALSO,
|
|
4025
|
-
delegua_2.default.FUNCAO,
|
|
4026
|
-
delegua_2.default.FUNÇÃO,
|
|
4027
|
-
delegua_2.default.IDENTIFICADOR,
|
|
4028
|
-
delegua_2.default.ISTO,
|
|
4029
|
-
delegua_2.default.NAO,
|
|
4030
|
-
delegua_2.default.NEGACAO,
|
|
4031
|
-
delegua_2.default.NUMERO,
|
|
4032
|
-
delegua_2.default.NULO,
|
|
4033
|
-
delegua_2.default.PARENTESE_ESQUERDO,
|
|
4034
|
-
delegua_2.default.SUPER,
|
|
4035
|
-
delegua_2.default.TEXTO,
|
|
4036
|
-
delegua_2.default.VERDADEIRO,
|
|
4037
|
-
].includes(this.simbolos[this.atual].tipo)) {
|
|
4053
|
+
const simboloAtual = this.simbolos[this.atual];
|
|
4054
|
+
let valor;
|
|
4055
|
+
if (simboloAtual && simbolosInicioExpressao.has(simboloAtual.tipo)) {
|
|
4038
4056
|
valor = await this.expressao();
|
|
4039
4057
|
}
|
|
4040
4058
|
// Ponto-e-vírgula é opcional aqui.
|
|
@@ -4234,17 +4252,28 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
4234
4252
|
}
|
|
4235
4253
|
switch (inicializador.constructor) {
|
|
4236
4254
|
case construtos_1.AcessoIndiceVariavel:
|
|
4237
|
-
const
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4255
|
+
const acessoAtual = inicializador;
|
|
4256
|
+
let entidade = acessoAtual.entidadeChamada;
|
|
4257
|
+
let numeroIndices = 1;
|
|
4258
|
+
// Percorre a cadeia de acessos aninhados para contar quantos índices existem
|
|
4259
|
+
// Cada índice consome um nível de vetor, então removemos um '[]' por acesso.
|
|
4260
|
+
while (entidade.constructor === construtos_1.AcessoIndiceVariavel) {
|
|
4261
|
+
numeroIndices++;
|
|
4262
|
+
entidade = entidade
|
|
4263
|
+
.entidadeChamada;
|
|
4264
|
+
}
|
|
4265
|
+
const tipoBase = entidade.tipo;
|
|
4266
|
+
if (tipoBase.endsWith('[]')) {
|
|
4267
|
+
let tipoResultante = tipoBase;
|
|
4268
|
+
for (let i = 0; i < numeroIndices; i++) {
|
|
4269
|
+
if (tipoResultante.endsWith('[]')) {
|
|
4270
|
+
tipoResultante = tipoResultante.slice(0, -2);
|
|
4271
|
+
}
|
|
4272
|
+
else
|
|
4273
|
+
break;
|
|
4274
|
+
}
|
|
4275
|
+
return tipoResultante;
|
|
4246
4276
|
}
|
|
4247
|
-
// Normalmente, `entidadeChamadaAcessoIndiceVariavel.tipo` aqui será 'vetor'.
|
|
4248
4277
|
return 'qualquer';
|
|
4249
4278
|
case construtos_1.Chamada:
|
|
4250
4279
|
const entidadeChamadaChamada = inicializador.entidadeChamada;
|
|
@@ -4326,51 +4355,46 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
4326
4355
|
*/
|
|
4327
4356
|
async declaracaoDeVariaveis() {
|
|
4328
4357
|
const simboloVariavel = this.simboloAnterior();
|
|
4329
|
-
const identificadores = [];
|
|
4330
|
-
const retorno = [];
|
|
4331
|
-
let tipo = 'qualquer';
|
|
4332
4358
|
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.CHAVE_ESQUERDA)) {
|
|
4333
4359
|
return await this.declaracaoDesestruturacaoVariavel();
|
|
4334
4360
|
}
|
|
4361
|
+
const identificadores = [];
|
|
4335
4362
|
do {
|
|
4336
4363
|
identificadores.push(this.consumir(delegua_2.default.IDENTIFICADOR, 'Esperado nome da variável.'));
|
|
4337
4364
|
} while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.VIRGULA));
|
|
4365
|
+
let tipo = 'qualquer';
|
|
4338
4366
|
let tipoExplicito = false;
|
|
4339
4367
|
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.DOIS_PONTOS)) {
|
|
4340
4368
|
tipo = this.verificarDefinicaoTipoAtual();
|
|
4341
4369
|
tipoExplicito = true;
|
|
4342
4370
|
this.avancarEDevolverAnterior();
|
|
4343
4371
|
}
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4372
|
+
const retorno = [];
|
|
4373
|
+
const decoradores = Array.from(this.pilhaDecoradores);
|
|
4374
|
+
const temAtribuicao = this.verificarSeSimboloAtualEIgualA(delegua_2.default.IGUAL, delegua_2.default.SETA_ESQUERDA);
|
|
4375
|
+
if (!temAtribuicao) {
|
|
4376
|
+
for (const identificador of identificadores) {
|
|
4347
4377
|
this.pilhaEscopos.definirInformacoesVariavel(identificador.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(identificador.lexema, tipo));
|
|
4348
|
-
retorno.push(new declaracoes_1.Var(identificador, undefined, tipo, tipoExplicito,
|
|
4378
|
+
retorno.push(new declaracoes_1.Var(identificador, undefined, tipo, tipoExplicito, decoradores));
|
|
4349
4379
|
}
|
|
4350
|
-
this.verificarSeSimboloAtualEIgualA(delegua_2.default.PONTO_E_VIRGULA);
|
|
4351
|
-
this.pilhaDecoradores = [];
|
|
4352
|
-
return retorno;
|
|
4353
|
-
}
|
|
4354
|
-
const inicializadores = [];
|
|
4355
|
-
do {
|
|
4356
|
-
inicializadores.push(await this.expressao());
|
|
4357
|
-
} while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.VIRGULA));
|
|
4358
|
-
if (identificadores.length !== inicializadores.length) {
|
|
4359
|
-
throw this.erro(simboloVariavel, 'Quantidade de identificadores à esquerda do igual é diferente da quantidade de valores à direita.');
|
|
4360
4380
|
}
|
|
4361
|
-
|
|
4362
|
-
const
|
|
4363
|
-
|
|
4364
|
-
this.
|
|
4365
|
-
|
|
4366
|
-
|
|
4381
|
+
else {
|
|
4382
|
+
const inicializadores = [];
|
|
4383
|
+
do {
|
|
4384
|
+
inicializadores.push(await this.expressao());
|
|
4385
|
+
} while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.VIRGULA));
|
|
4386
|
+
if (identificadores.length !== inicializadores.length) {
|
|
4387
|
+
throw this.erro(simboloVariavel, 'Quantidade de identificadores à esquerda do igual é diferente da quantidade de valores à direita.');
|
|
4367
4388
|
}
|
|
4368
|
-
|
|
4369
|
-
const
|
|
4370
|
-
this.
|
|
4389
|
+
for (let [indice, identificador] of identificadores.entries()) {
|
|
4390
|
+
const inicializador = inicializadores[indice];
|
|
4391
|
+
const tipoInferido = this.logicaComumInferenciaTiposVariaveisEConstantes(inicializador, tipo) ?? tipo;
|
|
4392
|
+
const informacaoSintatica = tipo === 'dicionário'
|
|
4393
|
+
? this.resolverInformacaoElementoSintaticoDeDicionario(inicializador)
|
|
4394
|
+
: new informacao_elemento_sintatico_1.InformacaoElementoSintatico(identificador.lexema, tipoInferido);
|
|
4395
|
+
this.pilhaEscopos.definirInformacoesVariavel(identificador.lexema, informacaoSintatica);
|
|
4396
|
+
retorno.push(new declaracoes_1.Var(identificador, inicializador, tipoInferido, tipoExplicito, decoradores, tipo));
|
|
4371
4397
|
}
|
|
4372
|
-
retorno.push(new declaracoes_1.Var(identificador, inicializadores[indice], tipo, tipoExplicito, Array.from(this.pilhaDecoradores), tipoOriginal // Passa o tipo original para o construtor
|
|
4373
|
-
));
|
|
4374
4398
|
}
|
|
4375
4399
|
this.verificarSeSimboloAtualEIgualA(delegua_2.default.PONTO_E_VIRGULA);
|
|
4376
4400
|
this.pilhaDecoradores = [];
|
|
@@ -6368,19 +6392,31 @@ class AvaliadorSintaticoPitugues {
|
|
|
6368
6392
|
throw new erro_avaliador_sintatico_1.ErroAvaliadorSintatico(entidadeChamada.simbolo, `Primitiva '${entidadeChamada.simbolo.lexema}' não existe.`);
|
|
6369
6393
|
}
|
|
6370
6394
|
logicaComumInferenciaTiposVariaveisEConstantes(inicializador, tipoPrevio) {
|
|
6371
|
-
if (tipoPrevio !== 'qualquer')
|
|
6395
|
+
if (tipoPrevio !== 'qualquer')
|
|
6372
6396
|
return tipoPrevio;
|
|
6373
|
-
}
|
|
6374
6397
|
switch (inicializador.constructor) {
|
|
6375
6398
|
case construtos_1.AcessoIndiceVariavel:
|
|
6376
|
-
const
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6399
|
+
const acessoAtual = inicializador;
|
|
6400
|
+
let entidade = acessoAtual.entidadeChamada;
|
|
6401
|
+
let numeroIndices = 1;
|
|
6402
|
+
// Percorre acessos aninhados como `vetor[1][2]` contando quantos índices foram aplicados.
|
|
6403
|
+
// Cada índice consome um nível de vetor, então removemos um '[]' por acesso.
|
|
6404
|
+
while (entidade.constructor === construtos_1.AcessoIndiceVariavel) {
|
|
6405
|
+
numeroIndices++;
|
|
6406
|
+
entidade = entidade
|
|
6407
|
+
.entidadeChamada;
|
|
6408
|
+
}
|
|
6409
|
+
const tipoBase = entidade.tipo;
|
|
6410
|
+
if (tipoBase.endsWith('[]')) {
|
|
6411
|
+
let tipoResultante = tipoBase;
|
|
6412
|
+
for (let i = 0; i < numeroIndices; i++) {
|
|
6413
|
+
if (tipoResultante.endsWith('[]')) {
|
|
6414
|
+
tipoResultante = tipoResultante.slice(0, -2);
|
|
6415
|
+
}
|
|
6416
|
+
else
|
|
6417
|
+
break;
|
|
6418
|
+
}
|
|
6419
|
+
return tipoResultante;
|
|
6384
6420
|
}
|
|
6385
6421
|
// Normalmente, `entidadeChamadaAcessoIndiceVariavel.tipo` aqui será 'vetor'.
|
|
6386
6422
|
return 'qualquer';
|
|
@@ -6403,7 +6439,16 @@ class AvaliadorSintaticoPitugues {
|
|
|
6403
6439
|
return entidadeChamadaReferenciaFuncao.tipo;
|
|
6404
6440
|
case construtos_1.Variavel:
|
|
6405
6441
|
const entidadeChamadaVariavel = entidadeChamadaChamada;
|
|
6406
|
-
|
|
6442
|
+
const tipoBruto = entidadeChamadaVariavel.tipo;
|
|
6443
|
+
if (tipoBruto &&
|
|
6444
|
+
tipoBruto.startsWith('função<') &&
|
|
6445
|
+
tipoBruto.endsWith('>')) {
|
|
6446
|
+
return tipoBruto.substring(7, tipoBruto.length - 1);
|
|
6447
|
+
}
|
|
6448
|
+
else if (tipoBruto === 'função') {
|
|
6449
|
+
return 'qualquer';
|
|
6450
|
+
}
|
|
6451
|
+
return tipoBruto;
|
|
6407
6452
|
}
|
|
6408
6453
|
break;
|
|
6409
6454
|
case construtos_1.FuncaoConstruto:
|
|
@@ -6583,15 +6628,13 @@ class AvaliadorSintaticoPitugues {
|
|
|
6583
6628
|
const qtdIdentificadores = identificadores.length;
|
|
6584
6629
|
const qtdValores = inicializadores.length;
|
|
6585
6630
|
const ehDesempacotamento = qtdIdentificadores > 1 && qtdValores === 1;
|
|
6586
|
-
if (indexResto > -1) {
|
|
6587
|
-
if (
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
throw this.erro(this.simboloAnterior(), 'Quantidade insuficiente de valores para desempacotamento com operador de resto.');
|
|
6591
|
-
}
|
|
6631
|
+
if (indexResto > -1 && qtdValores < qtdIdentificadores - 1) {
|
|
6632
|
+
if (!ehDesempacotamento ||
|
|
6633
|
+
(ehDesempacotamento && inicializadores[0] instanceof construtos_1.Literal)) {
|
|
6634
|
+
throw this.erro(this.simboloAnterior(), 'Quantidade insuficiente de valores para desempacotamento com operador de resto.');
|
|
6592
6635
|
}
|
|
6593
6636
|
}
|
|
6594
|
-
else {
|
|
6637
|
+
else if (indexResto === -1) {
|
|
6595
6638
|
if (!ehDesempacotamento && qtdIdentificadores !== qtdValores) {
|
|
6596
6639
|
throw this.erro(this.simboloAnterior(), 'Quantidade de inicializadores à esquerda do igual é diferente da quantidade de identificadores à direita.');
|
|
6597
6640
|
}
|
|
@@ -6604,41 +6647,52 @@ class AvaliadorSintaticoPitugues {
|
|
|
6604
6647
|
}
|
|
6605
6648
|
const retorno = [];
|
|
6606
6649
|
let origemParaAtribuicao = inicializadores[0];
|
|
6607
|
-
// Injeção de
|
|
6650
|
+
// Injeção de código para variáveis temporárias
|
|
6608
6651
|
if (ehDesempacotamento && !(inicializadores[0] instanceof construtos_1.Vetor)) {
|
|
6609
6652
|
const linha = identificadores[0].linha;
|
|
6610
|
-
// Cria variável temporária para evitar reavaliar a expressão original múltiplas vezes
|
|
6611
6653
|
const nomeVarTemp = `__temp_desempacotamento_${new Date().getTime()}_${Math.floor(Math.random() * 1000)}`;
|
|
6612
6654
|
const simboloVarTemp = new lexador_1.Simbolo(pitugues_2.default.IDENTIFICADOR, nomeVarTemp, null, linha, -1);
|
|
6613
6655
|
retorno.push(new declaracoes_1.Var(simboloVarTemp, inicializadores[0], 'qualquer[]'));
|
|
6614
6656
|
origemParaAtribuicao = new construtos_1.Variavel(this.hashArquivo, simboloVarTemp);
|
|
6615
|
-
// Injeta validação de tamanho se não houver operador de resto
|
|
6616
6657
|
if (indexResto === -1) {
|
|
6617
6658
|
retorno.push(this.construirValidacaoDesempacotamento(identificadores[0], origemParaAtribuicao, qtdIdentificadores));
|
|
6618
6659
|
}
|
|
6619
6660
|
}
|
|
6620
|
-
let cursorValores = 0;
|
|
6621
6661
|
const qtdParaResto = qtdValores - (qtdIdentificadores - 1);
|
|
6622
|
-
|
|
6662
|
+
const elementosAposResto = qtdIdentificadores - 1 - indexResto;
|
|
6663
|
+
let cursorValores = 0;
|
|
6664
|
+
let cursorDesempacotamento = 0;
|
|
6665
|
+
for (let i = 0; i < qtdIdentificadores; i++) {
|
|
6623
6666
|
const identificador = identificadores[i];
|
|
6624
6667
|
let inicializador;
|
|
6625
6668
|
let tipo = 'qualquer';
|
|
6626
6669
|
if (i === indexResto) {
|
|
6627
|
-
|
|
6670
|
+
let valoresResto;
|
|
6671
|
+
if (ehDesempacotamento && inicializadores[0] instanceof construtos_1.Vetor) {
|
|
6672
|
+
const vetorLiteral = inicializadores[0];
|
|
6673
|
+
valoresResto = vetorLiteral.valores.slice(cursorDesempacotamento, vetorLiteral.valores.length - elementosAposResto);
|
|
6674
|
+
cursorDesempacotamento += valoresResto.length;
|
|
6675
|
+
}
|
|
6676
|
+
else {
|
|
6677
|
+
valoresResto = inicializadores.slice(cursorValores, cursorValores + qtdParaResto);
|
|
6678
|
+
cursorValores += qtdParaResto;
|
|
6679
|
+
}
|
|
6628
6680
|
let tipoInferido = (0, inferenciador_1.inferirTipoVariavel)(valoresResto);
|
|
6629
|
-
if (!tipoInferido.endsWith('[]'))
|
|
6681
|
+
if (!tipoInferido.endsWith('[]')) {
|
|
6630
6682
|
tipoInferido = `${tipoInferido}[]`;
|
|
6683
|
+
}
|
|
6631
6684
|
inicializador = new construtos_1.Vetor(identificador.hashArquivo, identificador.linha, valoresResto, tipoInferido);
|
|
6632
6685
|
tipo = tipoInferido;
|
|
6633
|
-
cursorValores += qtdParaResto;
|
|
6634
6686
|
}
|
|
6635
6687
|
else if (ehDesempacotamento) {
|
|
6636
6688
|
if (inicializadores[0] instanceof construtos_1.Vetor) {
|
|
6637
|
-
|
|
6689
|
+
const vetorLiteral = inicializadores[0];
|
|
6690
|
+
inicializador = vetorLiteral.valores[cursorDesempacotamento];
|
|
6638
6691
|
}
|
|
6639
6692
|
else {
|
|
6640
6693
|
inicializador = new construtos_1.AcessoIndiceVariavel(this.hashArquivo, origemParaAtribuicao, new construtos_1.Literal(this.hashArquivo, identificador.linha, i, 'número'), new lexador_1.Simbolo(pitugues_2.default.COLCHETE_DIREITO, ']', null, identificador.linha, -1));
|
|
6641
6694
|
}
|
|
6695
|
+
cursorDesempacotamento++;
|
|
6642
6696
|
}
|
|
6643
6697
|
else {
|
|
6644
6698
|
inicializador = inicializadores[cursorValores];
|
|
@@ -6788,6 +6842,9 @@ class AvaliadorSintaticoPitugues {
|
|
|
6788
6842
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.COLCHETE_DIREITO)) {
|
|
6789
6843
|
return new construtos_1.Vetor(this.hashArquivo, simboloAtual.linha, [], 'qualquer[]');
|
|
6790
6844
|
}
|
|
6845
|
+
if (this.verificarTipoSimboloAtual(pitugues_2.default.VIRGULA)) {
|
|
6846
|
+
throw this.erro(this.simboloAtual(), 'Não podem haver duas vírgulas seguidas em uma definição de vetor, ou definição de vetor começando em vírgula.');
|
|
6847
|
+
}
|
|
6791
6848
|
// Ao resolver a expressão aqui, identificadores dentro da expressão de compreensão
|
|
6792
6849
|
// de lista serão tratados como 'qualquer', para evitar erros de tipo.
|
|
6793
6850
|
this.intuirTipoQualquerParaIdentificadores = true;
|
|
@@ -6798,13 +6855,35 @@ class AvaliadorSintaticoPitugues {
|
|
|
6798
6855
|
}
|
|
6799
6856
|
// Aqui já sabemos que não é uma compreensão de lista.
|
|
6800
6857
|
const valoresVetor = [retornoExpressaoOuPrimeiroValor];
|
|
6858
|
+
this.ignorarComentarios();
|
|
6801
6859
|
while (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.COLCHETE_DIREITO)) {
|
|
6802
|
-
this.
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6860
|
+
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA)) {
|
|
6861
|
+
this.ignorarComentarios();
|
|
6862
|
+
if (this.verificarTipoSimboloAtual(pitugues_2.default.VIRGULA)) {
|
|
6863
|
+
throw this.erro(this.simboloAtual(), 'Não podem haver duas vírgulas seguidas em uma definição de vetor, ou definição de vetor começando em vírgula.');
|
|
6864
|
+
}
|
|
6865
|
+
}
|
|
6866
|
+
else {
|
|
6867
|
+
throw this.erro(this.simboloAtual() || simboloAtual, 'Os itens dos vetores devem ser separados através de uma vírgula.');
|
|
6868
|
+
}
|
|
6869
|
+
if (!this.verificarTipoSimboloAtual(pitugues_2.default.COLCHETE_DIREITO)) {
|
|
6870
|
+
valoresVetor.push(await this.atribuir());
|
|
6871
|
+
this.ignorarComentarios();
|
|
6872
|
+
}
|
|
6873
|
+
}
|
|
6874
|
+
let tipoVetor;
|
|
6875
|
+
if (valoresVetor.length === 0) {
|
|
6876
|
+
tipoVetor = 'qualquer[]';
|
|
6877
|
+
}
|
|
6878
|
+
else {
|
|
6879
|
+
const primeiroElemento = valoresVetor[0];
|
|
6880
|
+
if (primeiroElemento instanceof construtos_1.Vetor) {
|
|
6881
|
+
tipoVetor = primeiroElemento.tipo + '[]';
|
|
6882
|
+
}
|
|
6883
|
+
else {
|
|
6884
|
+
tipoVetor = (0, inferenciador_1.inferirTipoVariavel)(valoresVetor);
|
|
6885
|
+
}
|
|
6806
6886
|
}
|
|
6807
|
-
const tipoVetor = (0, inferenciador_1.inferirTipoVariavel)(valoresVetor);
|
|
6808
6887
|
return new construtos_1.Vetor(this.hashArquivo, simboloAtual.linha, valoresVetor, tipoVetor);
|
|
6809
6888
|
case pitugues_2.default.COMENTARIO:
|
|
6810
6889
|
const simboloComentario = this.avancarEDevolverAnterior();
|
|
@@ -7761,10 +7840,10 @@ class AvaliadorSintaticoPitugues {
|
|
|
7761
7840
|
this.tiposDefinidosEmCodigo[definicaoClasse.simbolo.lexema] = definicaoClasse;
|
|
7762
7841
|
return definicaoClasse;
|
|
7763
7842
|
}
|
|
7764
|
-
declaracaoFalhar() {
|
|
7843
|
+
async declaracaoFalhar() {
|
|
7765
7844
|
const simboloFalha = this.simbolos[this.atual - 1];
|
|
7766
|
-
const
|
|
7767
|
-
return new declaracoes_1.Falhar(simboloFalha,
|
|
7845
|
+
const explicacao = await this.atribuir();
|
|
7846
|
+
return new declaracoes_1.Falhar(simboloFalha, explicacao);
|
|
7768
7847
|
}
|
|
7769
7848
|
/**
|
|
7770
7849
|
* Verifica se há pontos e vírgula no final de sentenças.
|
|
@@ -7874,7 +7953,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7874
7953
|
return this.declaracaoEscreva(simboloEscrevaOuImprima);
|
|
7875
7954
|
case pitugues_2.default.FALHAR:
|
|
7876
7955
|
this.avancarEDevolverAnterior();
|
|
7877
|
-
return this.declaracaoFalhar();
|
|
7956
|
+
return await this.declaracaoFalhar();
|
|
7878
7957
|
case pitugues_2.default.FAZER:
|
|
7879
7958
|
this.avancarEDevolverAnterior();
|
|
7880
7959
|
return this.declaracaoFazer();
|
|
@@ -14322,8 +14401,12 @@ exports.Atribuir = Atribuir;
|
|
|
14322
14401
|
|
|
14323
14402
|
},{"./variavel":95}],50:[function(require,module,exports){
|
|
14324
14403
|
"use strict";
|
|
14404
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14405
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14406
|
+
};
|
|
14325
14407
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14326
14408
|
exports.Binario = void 0;
|
|
14409
|
+
const delegua_1 = __importDefault(require("../tipos-de-simbolos/delegua"));
|
|
14327
14410
|
/**
|
|
14328
14411
|
* Binário é uma estrutura com um operador e dois operandos: esquerda e direita.
|
|
14329
14412
|
* Implementa as seguintes operações para Delégua e todos os dialetos:
|
|
@@ -14361,6 +14444,17 @@ class Binario {
|
|
|
14361
14444
|
* @returns O tipo deduzido.
|
|
14362
14445
|
*/
|
|
14363
14446
|
deduzirTipo() {
|
|
14447
|
+
if ([
|
|
14448
|
+
delegua_1.default.MAIOR,
|
|
14449
|
+
delegua_1.default.MAIOR_IGUAL,
|
|
14450
|
+
delegua_1.default.MENOR,
|
|
14451
|
+
delegua_1.default.MENOR_IGUAL,
|
|
14452
|
+
delegua_1.default.IGUAL,
|
|
14453
|
+
delegua_1.default.IGUAL_IGUAL,
|
|
14454
|
+
delegua_1.default.DIFERENTE,
|
|
14455
|
+
].includes(this.operador.tipo)) {
|
|
14456
|
+
return 'lógico';
|
|
14457
|
+
}
|
|
14364
14458
|
if (['logico', 'lógico'].includes(this.esquerda.tipo) ||
|
|
14365
14459
|
['logico', 'lógico'].includes(this.direita.tipo)) {
|
|
14366
14460
|
return 'lógico';
|
|
@@ -14392,7 +14486,7 @@ class Binario {
|
|
|
14392
14486
|
}
|
|
14393
14487
|
exports.Binario = Binario;
|
|
14394
14488
|
|
|
14395
|
-
},{}],51:[function(require,module,exports){
|
|
14489
|
+
},{"../tipos-de-simbolos/delegua":253}],51:[function(require,module,exports){
|
|
14396
14490
|
"use strict";
|
|
14397
14491
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14398
14492
|
exports.Bote = void 0;
|
|
@@ -20490,7 +20584,7 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
20490
20584
|
}
|
|
20491
20585
|
return argumentosResolvidos;
|
|
20492
20586
|
}
|
|
20493
|
-
resolverAmbiente(argumentos) {
|
|
20587
|
+
async resolverAmbiente(visitante, argumentos) {
|
|
20494
20588
|
const ambiente = new espaco_memoria_1.EspacoMemoria();
|
|
20495
20589
|
const parametros = this.declaracao.parametros || [];
|
|
20496
20590
|
for (let i = 0; i < parametros.length; i++) {
|
|
@@ -20506,15 +20600,28 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
20506
20600
|
};
|
|
20507
20601
|
}
|
|
20508
20602
|
else {
|
|
20509
|
-
let
|
|
20510
|
-
|
|
20511
|
-
|
|
20603
|
+
let valorFinal;
|
|
20604
|
+
const argumento = argumentos[i];
|
|
20605
|
+
const valorExtraido = (argumento && argumento.hasOwnProperty('valor'))
|
|
20606
|
+
? argumento.valor
|
|
20607
|
+
: argumento;
|
|
20608
|
+
if (i < argumentos.length &&
|
|
20609
|
+
valorExtraido !== undefined &&
|
|
20610
|
+
valorExtraido !== null) {
|
|
20611
|
+
valorFinal = valorExtraido;
|
|
20612
|
+
}
|
|
20613
|
+
else if (parametro.valorPadrao) {
|
|
20614
|
+
valorFinal = await visitante.avaliar(parametro.valorPadrao);
|
|
20512
20615
|
}
|
|
20513
|
-
|
|
20514
|
-
|
|
20616
|
+
else {
|
|
20617
|
+
valorFinal = null;
|
|
20618
|
+
}
|
|
20619
|
+
ambiente.valores[nome] = valorFinal;
|
|
20515
20620
|
// Se o argumento é `DeleguaFuncao`, para habilitar o recurso de _currying_,
|
|
20516
20621
|
// copiamos seu valor para o escopo atual. Nem sempre podemos contar com a tipagem explícita aqui.
|
|
20517
|
-
if (
|
|
20622
|
+
if (valorFinal &&
|
|
20623
|
+
typeof valorFinal === 'object' &&
|
|
20624
|
+
['funcao', 'função'].includes(valorFinal.tipo)) {
|
|
20518
20625
|
parametro.referencia = true;
|
|
20519
20626
|
}
|
|
20520
20627
|
}
|
|
@@ -20522,7 +20629,7 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
20522
20629
|
return ambiente;
|
|
20523
20630
|
}
|
|
20524
20631
|
async chamar(visitante, argumentos) {
|
|
20525
|
-
const ambiente = this.resolverAmbiente(argumentos);
|
|
20632
|
+
const ambiente = await this.resolverAmbiente(visitante, argumentos);
|
|
20526
20633
|
if (this.instancia !== undefined) {
|
|
20527
20634
|
ambiente.valores['isto'] = {
|
|
20528
20635
|
valor: this.instancia,
|
|
@@ -21905,7 +22012,28 @@ class InterpretadorBase {
|
|
|
21905
22012
|
throw new Error('Método não implementado.');
|
|
21906
22013
|
}
|
|
21907
22014
|
async visitarExpressaoFalhar(expressao) {
|
|
21908
|
-
|
|
22015
|
+
let valorAvaliado = expressao.explicacao;
|
|
22016
|
+
// Se for um construto (ex.: Variavel), avalia para obter seu valor real
|
|
22017
|
+
if (expressao.explicacao &&
|
|
22018
|
+
typeof expressao.explicacao.aceitar === 'function') {
|
|
22019
|
+
valorAvaliado = await this.avaliar(expressao.explicacao);
|
|
22020
|
+
}
|
|
22021
|
+
let textoFalha;
|
|
22022
|
+
if (valorAvaliado === null || valorAvaliado === undefined) {
|
|
22023
|
+
textoFalha = 'nulo';
|
|
22024
|
+
}
|
|
22025
|
+
else if (typeof valorAvaliado === 'string') {
|
|
22026
|
+
textoFalha = valorAvaliado;
|
|
22027
|
+
}
|
|
22028
|
+
else if (typeof valorAvaliado === 'object' &&
|
|
22029
|
+
'valor' in valorAvaliado) {
|
|
22030
|
+
// Objetos tipados como { valor: 'mensagem', tipo: 'texto' }
|
|
22031
|
+
textoFalha = String(valorAvaliado.valor);
|
|
22032
|
+
}
|
|
22033
|
+
else {
|
|
22034
|
+
// Caso incomum: usa a representação textual padrão
|
|
22035
|
+
textoFalha = this.paraTexto(valorAvaliado);
|
|
22036
|
+
}
|
|
21909
22037
|
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simbolo, textoFalha, expressao.linha);
|
|
21910
22038
|
}
|
|
21911
22039
|
async visitarExpressaoFimPara(_) {
|
|
@@ -22910,36 +23038,47 @@ class InterpretadorBase {
|
|
|
22910
23038
|
} while (!(retornoExecucao && retornoExecucao.valorRetornado instanceof quebras_1.Quebra) &&
|
|
22911
23039
|
this.eVerdadeiro(await this.avaliar(declaracao.condicaoEnquanto)));
|
|
22912
23040
|
}
|
|
23041
|
+
/**
|
|
23042
|
+
* Unifica a execução do bloco 'pegue', tratando tanto o caso de
|
|
23043
|
+
* declarações simples quanto o caso de função com parâmetro de erro.
|
|
23044
|
+
*/
|
|
23045
|
+
async executarBlocoPegue(pegue, erro) {
|
|
23046
|
+
if (Array.isArray(pegue)) {
|
|
23047
|
+
return await this.executarBloco(pegue);
|
|
23048
|
+
}
|
|
23049
|
+
// Caso seja FuncaoConstruto (pegue com parâmetro de erro)
|
|
23050
|
+
const literalErro = new construtos_1.Literal(pegue.hashArquivo, pegue.linha, erro.mensagem || erro.message || erro);
|
|
23051
|
+
const chamadaPegue = new construtos_1.Chamada(pegue.hashArquivo, pegue, [literalErro]);
|
|
23052
|
+
return await chamadaPegue.aceitar(this);
|
|
23053
|
+
}
|
|
22913
23054
|
/**
|
|
22914
23055
|
* Interpretação de uma declaração `tente`.
|
|
22915
23056
|
* @param declaracao O objeto da declaração.
|
|
22916
23057
|
*/
|
|
22917
23058
|
async visitarDeclaracaoTente(declaracao) {
|
|
22918
23059
|
let valorRetorno;
|
|
23060
|
+
let sucessoNoTente = false;
|
|
22919
23061
|
try {
|
|
22920
23062
|
this.emDeclaracaoTente = true;
|
|
22921
23063
|
try {
|
|
22922
23064
|
valorRetorno = await this.executarBloco(declaracao.caminhoTente);
|
|
23065
|
+
sucessoNoTente = true;
|
|
22923
23066
|
}
|
|
22924
23067
|
catch (erro) {
|
|
22925
23068
|
if (declaracao.caminhoPegue !== null) {
|
|
22926
|
-
|
|
22927
|
-
// ou um vetor de `Declaracao` (`pegue` sem parâmetros).
|
|
22928
|
-
// As execuções, portanto, são diferentes.
|
|
22929
|
-
if (Array.isArray(declaracao.caminhoPegue)) {
|
|
22930
|
-
valorRetorno = await this.executarBloco(declaracao.caminhoPegue);
|
|
22931
|
-
}
|
|
22932
|
-
else {
|
|
22933
|
-
const literalErro = new construtos_1.Literal(declaracao.hashArquivo, Number(declaracao.linha), erro.mensagem);
|
|
22934
|
-
const chamadaPegue = new construtos_1.Chamada(declaracao.caminhoPegue.hashArquivo, declaracao.caminhoPegue, [literalErro]);
|
|
22935
|
-
valorRetorno = await chamadaPegue.aceitar(this);
|
|
22936
|
-
}
|
|
23069
|
+
valorRetorno = await this.executarBlocoPegue(declaracao.caminhoPegue, erro);
|
|
22937
23070
|
}
|
|
23071
|
+
else
|
|
23072
|
+
throw erro;
|
|
23073
|
+
}
|
|
23074
|
+
if (sucessoNoTente && declaracao.caminhoSenao) {
|
|
23075
|
+
valorRetorno = await this.executarBloco(declaracao.caminhoSenao);
|
|
22938
23076
|
}
|
|
22939
23077
|
}
|
|
22940
23078
|
finally {
|
|
22941
|
-
if (declaracao.caminhoFinalmente)
|
|
23079
|
+
if (declaracao.caminhoFinalmente) {
|
|
22942
23080
|
valorRetorno = await this.executarBloco(declaracao.caminhoFinalmente);
|
|
23081
|
+
}
|
|
22943
23082
|
this.emDeclaracaoTente = false;
|
|
22944
23083
|
}
|
|
22945
23084
|
return valorRetorno;
|
|
@@ -23398,6 +23537,13 @@ class InterpretadorBase {
|
|
|
23398
23537
|
if (tipoObjeto === null || tipoObjeto === undefined) {
|
|
23399
23538
|
tipoObjeto = (0, inferenciador_1.inferirTipoVariavel)(variavelObjeto);
|
|
23400
23539
|
}
|
|
23540
|
+
// Trata qualquer tipo terminado em '[]' como vetor
|
|
23541
|
+
if (tipoObjeto && tipoObjeto.endsWith('[]')) {
|
|
23542
|
+
if (expressao.simbolo.lexema in primitivas_vetor_1.default) {
|
|
23543
|
+
const metodo = primitivas_vetor_1.default[expressao.simbolo.lexema].implementacao;
|
|
23544
|
+
return new metodo_primitiva_1.MetodoPrimitiva(nomeObjeto, objeto, metodo, expressao.simbolo.lexema, tipoObjeto);
|
|
23545
|
+
}
|
|
23546
|
+
}
|
|
23401
23547
|
// Caso 3: Vetor simples do JavaScript.
|
|
23402
23548
|
if (Array.isArray(objeto)) {
|
|
23403
23549
|
if (expressao.simbolo.lexema in primitivas_vetor_1.default) {
|
|
@@ -24665,6 +24811,23 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
24665
24811
|
if (tipoObjeto === null || tipoObjeto === undefined) {
|
|
24666
24812
|
tipoObjeto = (0, inferenciador_1.inferirTipoVariavel)(objeto);
|
|
24667
24813
|
}
|
|
24814
|
+
// Trata qualquer tipo terminado em '[]' como vetor
|
|
24815
|
+
if (tipoObjeto && tipoObjeto.endsWith('[]')) {
|
|
24816
|
+
if (expressao.nomeMetodo in primitivas_vetor_1.default) {
|
|
24817
|
+
const metodo = primitivas_vetor_1.default[expressao.nomeMetodo].implementacao;
|
|
24818
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodo, expressao.nomeMetodo, tipoObjeto);
|
|
24819
|
+
}
|
|
24820
|
+
else {
|
|
24821
|
+
const funcaoExt = this.encontrarMetodoExtensao(['vetor', 'objeto'], expressao.nomeMetodo, this.hashArquivoDeclaracaoAtual);
|
|
24822
|
+
if (funcaoExt)
|
|
24823
|
+
return funcaoExt.funcaoPorExtensao(objeto);
|
|
24824
|
+
throw new excecoes_1.ErroEmTempoDeExecucao({
|
|
24825
|
+
hashArquivo: this.hashArquivoDeclaracaoAtual,
|
|
24826
|
+
linha: this.linhaDeclaracaoAtual,
|
|
24827
|
+
lexema: expressao.nomeMetodo
|
|
24828
|
+
}, `Método de primitiva '${expressao.nomeMetodo}' não existe para o tipo ${tipoObjeto}.`, expressao.linha);
|
|
24829
|
+
}
|
|
24830
|
+
}
|
|
24668
24831
|
// Como internamente um dicionário de Delégua é simplesmente um objeto de
|
|
24669
24832
|
// JavaScript, as primitivas de dicionário, especificamente, são tratadas
|
|
24670
24833
|
// mais acima.
|
|
@@ -24840,6 +25003,19 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
24840
25003
|
if (tipoObjeto === null || tipoObjeto === undefined) {
|
|
24841
25004
|
tipoObjeto = (0, inferenciador_1.inferirTipoVariavel)(objeto);
|
|
24842
25005
|
}
|
|
25006
|
+
// Trata qualquer tipo terminado em '[]' como vetor
|
|
25007
|
+
if (tipoObjeto && tipoObjeto.endsWith('[]')) {
|
|
25008
|
+
if (expressao.simbolo.lexema in primitivas_vetor_1.default) {
|
|
25009
|
+
const metodo = primitivas_vetor_1.default[expressao.simbolo.lexema].implementacao;
|
|
25010
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodo, expressao.simbolo.lexema, tipoObjeto);
|
|
25011
|
+
}
|
|
25012
|
+
else {
|
|
25013
|
+
const funcaoExt = this.encontrarMetodoExtensao(['vetor', 'objeto'], expressao.simbolo.lexema, this.hashArquivoDeclaracaoAtual);
|
|
25014
|
+
if (funcaoExt)
|
|
25015
|
+
return funcaoExt.funcaoPorExtensao(objeto);
|
|
25016
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simbolo, `Método de primitiva '${expressao.simbolo.lexema}' não existe para o tipo ${tipoObjeto}.`, expressao.linha);
|
|
25017
|
+
}
|
|
25018
|
+
}
|
|
24843
25019
|
// Como internamente um dicionário de Delégua é simplesmente um objeto de
|
|
24844
25020
|
// JavaScript, as primitivas de dicionário, especificamente, são tratadas
|
|
24845
25021
|
// mais acima.
|