@designliquido/delegua 0.48.1 → 0.49.0
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/bibliotecas/primitivas-dicionario.d.ts.map +1 -1
- package/bibliotecas/primitivas-dicionario.js +4 -4
- package/bibliotecas/primitivas-dicionario.js.map +1 -1
- package/bibliotecas/primitivas-numero.js +3 -3
- package/bibliotecas/primitivas-numero.js.map +1 -1
- package/bibliotecas/primitivas-texto.d.ts.map +1 -1
- package/bibliotecas/primitivas-texto.js +13 -13
- package/bibliotecas/primitivas-texto.js.map +1 -1
- package/bibliotecas/primitivas-vetor.d.ts.map +1 -1
- package/bibliotecas/primitivas-vetor.js +31 -18
- package/bibliotecas/primitivas-vetor.js.map +1 -1
- package/bin/package.json +2 -10
- package/interpretador/estruturas/metodo-primitiva.d.ts +2 -1
- package/interpretador/estruturas/metodo-primitiva.d.ts.map +1 -1
- package/interpretador/estruturas/metodo-primitiva.js +3 -2
- package/interpretador/estruturas/metodo-primitiva.js.map +1 -1
- package/interpretador/interpretador-base.d.ts +9 -0
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +18 -1
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/interpretador.d.ts.map +1 -1
- package/interpretador/interpretador.js +15 -9
- package/interpretador/interpretador.js.map +1 -1
- package/package.json +2 -10
- package/umd/delegua.js +87 -50
package/umd/delegua.js
CHANGED
|
@@ -5840,7 +5840,7 @@ const contemComum = (nome) => {
|
|
|
5840
5840
|
argumentos: [
|
|
5841
5841
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('chave', 'qualquer', true, [], 'O elemento como chave do dicionário.')
|
|
5842
5842
|
],
|
|
5843
|
-
implementacao: (interpretador, valor, chave) => Promise.resolve(chave in valor),
|
|
5843
|
+
implementacao: (interpretador, nomePrimitiva, valor, chave) => Promise.resolve(chave in valor),
|
|
5844
5844
|
assinaturaFormato: `dicionário.${nome}(chave: qualquer)`,
|
|
5845
5845
|
documentacao: `# \`dicionário.${nome}(chave)\`\n\n` +
|
|
5846
5846
|
'Retorna verdadeiro se o elemento passado como parâmetro existe como chave do dicionário. Devolve falso em caso contrário.\n' +
|
|
@@ -5857,7 +5857,7 @@ exports.default = {
|
|
|
5857
5857
|
chaves: {
|
|
5858
5858
|
tipoRetorno: 'texto[]',
|
|
5859
5859
|
argumentos: [],
|
|
5860
|
-
implementacao: (interpretador, valor) => {
|
|
5860
|
+
implementacao: (interpretador, nomePrimitiva, valor) => {
|
|
5861
5861
|
return Promise.resolve(Object.keys(valor));
|
|
5862
5862
|
},
|
|
5863
5863
|
assinaturaFormato: 'dicionário.chaves()',
|
|
@@ -5875,13 +5875,13 @@ exports.default = {
|
|
|
5875
5875
|
remover: {
|
|
5876
5876
|
tipoRetorno: 'lógico',
|
|
5877
5877
|
argumentos: [new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('chave', 'texto')],
|
|
5878
|
-
implementacao: (interpretador, valor, chave) => Promise.resolve(delete valor[chave]),
|
|
5878
|
+
implementacao: (interpretador, nomePrimitiva, valor, chave) => Promise.resolve(delete valor[chave]),
|
|
5879
5879
|
assinaturaFormato: `dicionário.remover(chave: qualquer)`,
|
|
5880
5880
|
},
|
|
5881
5881
|
valores: {
|
|
5882
5882
|
tipoRetorno: 'qualquer[]',
|
|
5883
5883
|
argumentos: [],
|
|
5884
|
-
implementacao: (interpretador, valor) => {
|
|
5884
|
+
implementacao: (interpretador, nomePrimitiva, valor) => {
|
|
5885
5885
|
return Promise.resolve(Object.values(valor));
|
|
5886
5886
|
},
|
|
5887
5887
|
},
|
|
@@ -5894,7 +5894,7 @@ exports.default = {
|
|
|
5894
5894
|
absoluto: {
|
|
5895
5895
|
tipoRetorno: 'número',
|
|
5896
5896
|
argumentos: [],
|
|
5897
|
-
implementacao: (interpretador, valor) => {
|
|
5897
|
+
implementacao: (interpretador, nomePrimitiva, valor) => {
|
|
5898
5898
|
return Promise.resolve(Math.abs(valor));
|
|
5899
5899
|
},
|
|
5900
5900
|
assinaturaFormato: 'número.absoluto()',
|
|
@@ -5910,7 +5910,7 @@ exports.default = {
|
|
|
5910
5910
|
arredondarParaBaixo: {
|
|
5911
5911
|
tipoRetorno: 'número',
|
|
5912
5912
|
argumentos: [],
|
|
5913
|
-
implementacao: (interpretador, valor) => {
|
|
5913
|
+
implementacao: (interpretador, nomePrimitiva, valor) => {
|
|
5914
5914
|
return Promise.resolve(Math.floor(valor));
|
|
5915
5915
|
},
|
|
5916
5916
|
assinaturaFormato: 'número.arredondarParaBaixo()',
|
|
@@ -5926,7 +5926,7 @@ exports.default = {
|
|
|
5926
5926
|
arredondarParaCima: {
|
|
5927
5927
|
tipoRetorno: 'número',
|
|
5928
5928
|
argumentos: [],
|
|
5929
|
-
implementacao: (interpretador, valor) => {
|
|
5929
|
+
implementacao: (interpretador, nomePrimitiva, valor) => {
|
|
5930
5930
|
return Promise.resolve(Math.ceil(valor));
|
|
5931
5931
|
},
|
|
5932
5932
|
assinaturaFormato: 'número.arredondarParaCima()',
|
|
@@ -5949,7 +5949,7 @@ exports.default = {
|
|
|
5949
5949
|
aparar: {
|
|
5950
5950
|
tipoRetorno: 'texto',
|
|
5951
5951
|
argumentos: [],
|
|
5952
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.trim()),
|
|
5952
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.trim()),
|
|
5953
5953
|
assinaturaFormato: 'texto.aparar()',
|
|
5954
5954
|
documentacao: '# `texto.aparar()` \n \n' +
|
|
5955
5955
|
'Remove espaços em branco no início e no fim de um texto.' +
|
|
@@ -5962,7 +5962,7 @@ exports.default = {
|
|
|
5962
5962
|
apararFim: {
|
|
5963
5963
|
tipoRetorno: 'texto',
|
|
5964
5964
|
argumentos: [],
|
|
5965
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.trimEnd()),
|
|
5965
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.trimEnd()),
|
|
5966
5966
|
assinaturaFormato: 'texto.apararFim()',
|
|
5967
5967
|
documentacao: '# `texto.apararFim()` \n \n' +
|
|
5968
5968
|
'Remove espaços em branco no no fim de um texto.' +
|
|
@@ -5975,7 +5975,7 @@ exports.default = {
|
|
|
5975
5975
|
apararInicio: {
|
|
5976
5976
|
tipoRetorno: 'texto',
|
|
5977
5977
|
argumentos: [],
|
|
5978
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.trimStart()),
|
|
5978
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.trimStart()),
|
|
5979
5979
|
assinaturaFormato: 'texto.apararInicio()',
|
|
5980
5980
|
documentacao: '# `texto.apararInicio()` \n \n' +
|
|
5981
5981
|
'Remover espaços em branco no início e no fim de um texto.' +
|
|
@@ -5990,7 +5990,7 @@ exports.default = {
|
|
|
5990
5990
|
argumentos: [
|
|
5991
5991
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('outroTexto', 'texto', true, [], 'O texto a ser concatenado.')
|
|
5992
5992
|
],
|
|
5993
|
-
implementacao: (interpretador, ...texto) => Promise.resolve(''.concat(...texto)),
|
|
5993
|
+
implementacao: (interpretador, nomePrimitiva, ...texto) => Promise.resolve(''.concat(...texto)),
|
|
5994
5994
|
assinaturaFormato: 'texto.concatenar(...outroTexto: texto)',
|
|
5995
5995
|
documentacao: '# `texto.concatenar(outroTexto)` \n \n' +
|
|
5996
5996
|
'Realiza a junção de palavras/textos.' +
|
|
@@ -6007,7 +6007,7 @@ exports.default = {
|
|
|
6007
6007
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('delimitador', 'texto', true, [], 'O delimitador usado para dividir o texto.'),
|
|
6008
6008
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('limite', 'número', false, [], '(Opcional) Número limite de elementos a serem retornados.'),
|
|
6009
6009
|
],
|
|
6010
|
-
implementacao: (interpretador, texto, divisor, limite) => {
|
|
6010
|
+
implementacao: (interpretador, nomePrimitiva, texto, divisor, limite) => {
|
|
6011
6011
|
if (limite) {
|
|
6012
6012
|
return Promise.resolve(texto.split(divisor, limite));
|
|
6013
6013
|
}
|
|
@@ -6028,7 +6028,7 @@ exports.default = {
|
|
|
6028
6028
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('inicio', 'número', true, [], 'A posição inicial da fatia.'),
|
|
6029
6029
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('fim', 'número', false, [], '(Opcional) A posição final da fatia. Se não fornecido, seleciona até o final do texto.'),
|
|
6030
6030
|
],
|
|
6031
|
-
implementacao: (interpretador, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim)),
|
|
6031
|
+
implementacao: (interpretador, nomePrimitiva, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim)),
|
|
6032
6032
|
assinaturaFormato: 'texto.fatiar(inicio: número, fim?: número)',
|
|
6033
6033
|
documentacao: '# `texto.fatiar(inicio)` \n \n' +
|
|
6034
6034
|
'Extrai uma fatia do texto, dadas posições de início e fim.' +
|
|
@@ -6047,7 +6047,7 @@ exports.default = {
|
|
|
6047
6047
|
argumentos: [
|
|
6048
6048
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('elemento', 'texto', true, [], 'O elemento a ser verificado se está contido no texto.')
|
|
6049
6049
|
],
|
|
6050
|
-
implementacao: (interpretador, texto, elemento) => Promise.resolve(texto.includes(elemento)),
|
|
6050
|
+
implementacao: (interpretador, nomePrimitiva, texto, elemento) => Promise.resolve(texto.includes(elemento)),
|
|
6051
6051
|
assinaturaFormato: 'inclui(elemento: texto)',
|
|
6052
6052
|
documentacao: '# `texto.inclui(elemento)` \n \n' +
|
|
6053
6053
|
'Devolve verdadeiro se elemento passado por parâmetro está contido no texto, e falso em caso contrário.' +
|
|
@@ -6061,7 +6061,7 @@ exports.default = {
|
|
|
6061
6061
|
inverter: {
|
|
6062
6062
|
tipoRetorno: 'texto',
|
|
6063
6063
|
argumentos: [],
|
|
6064
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.split('').reduce((texto, caracter) => (texto = caracter + texto), '')),
|
|
6064
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.split('').reduce((texto, caracter) => (texto = caracter + texto), '')),
|
|
6065
6065
|
assinaturaFormato: 'texto.inverter()',
|
|
6066
6066
|
documentacao: '# `texto.inverter()` \n \n' +
|
|
6067
6067
|
'Inverte as letras de um texto.' +
|
|
@@ -6074,7 +6074,7 @@ exports.default = {
|
|
|
6074
6074
|
maiusculo: {
|
|
6075
6075
|
tipoRetorno: 'texto',
|
|
6076
6076
|
argumentos: [],
|
|
6077
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.toUpperCase()),
|
|
6077
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.toUpperCase()),
|
|
6078
6078
|
assinaturaFormato: 'texto.maiusculo()',
|
|
6079
6079
|
documentacao: '# `texto.maiusculo()` \n \n' +
|
|
6080
6080
|
'Converte todos os caracteres alfabéticos para suas respectivas formas em maiúsculo.' +
|
|
@@ -6087,7 +6087,7 @@ exports.default = {
|
|
|
6087
6087
|
minusculo: {
|
|
6088
6088
|
tipoRetorno: 'texto',
|
|
6089
6089
|
argumentos: [],
|
|
6090
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.toLowerCase()),
|
|
6090
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.toLowerCase()),
|
|
6091
6091
|
assinaturaFormato: 'texto.minusculo()',
|
|
6092
6092
|
documentacao: '# `texto.minusculo()` \n \n' +
|
|
6093
6093
|
'Converte todos os caracteres alfabéticos para suas respectivas formas em minúsculo.' +
|
|
@@ -6103,7 +6103,7 @@ exports.default = {
|
|
|
6103
6103
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('textoASerSubstituido', 'texto', true, [], 'Texto a ser substituído.'),
|
|
6104
6104
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('substituto', 'texto', true, [], 'A substituição'),
|
|
6105
6105
|
],
|
|
6106
|
-
implementacao: (interpretador, texto, elemento, substituto) => Promise.resolve(texto.replace(elemento, substituto)),
|
|
6106
|
+
implementacao: (interpretador, nomePrimitiva, texto, elemento, substituto) => Promise.resolve(texto.replace(elemento, substituto)),
|
|
6107
6107
|
assinaturaFormato: 'texto.substituir(textoASerSubstituido: texto, substituto: texto)',
|
|
6108
6108
|
documentacao: '# `texto.substituir(textoASerSubstituido, substituto)` \n \n' +
|
|
6109
6109
|
'Substitui a primeira ocorrência no texto do primeiro parâmetro pelo segundo parâmetro.' +
|
|
@@ -6119,7 +6119,7 @@ exports.default = {
|
|
|
6119
6119
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('inicio', 'inteiro', true, [], 'A posição de início do texto a ser extraído.'),
|
|
6120
6120
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('fim', 'inteiro', true, [], 'A posição de fim do texto a ser extraído.'),
|
|
6121
6121
|
],
|
|
6122
|
-
implementacao: (interpretador, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim)),
|
|
6122
|
+
implementacao: (interpretador, nomePrimitiva, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim)),
|
|
6123
6123
|
assinaturaFormato: 'texto.subtexto(inicio: inteiro, fim: inteiro)',
|
|
6124
6124
|
documentacao: '# `texto.subtexto(inicio, fim)` \n\n' +
|
|
6125
6125
|
'Extrai uma fatia do texto, dadas posições de início e fim.' +
|
|
@@ -6132,7 +6132,7 @@ exports.default = {
|
|
|
6132
6132
|
tamanho: {
|
|
6133
6133
|
tipoRetorno: 'inteiro',
|
|
6134
6134
|
argumentos: [],
|
|
6135
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.length),
|
|
6135
|
+
implementacao: (interpretador, nomePrimitiva, texto) => Promise.resolve(texto.length),
|
|
6136
6136
|
assinaturaFormato: 'texto.tamanho()',
|
|
6137
6137
|
documentacao: '# `texto.tamanho()` \n\n' +
|
|
6138
6138
|
'Devolve um número inteiro com o número de caracteres do texto.' +
|
|
@@ -6154,7 +6154,7 @@ exports.default = {
|
|
|
6154
6154
|
argumentos: [
|
|
6155
6155
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('elemento', 'qualquer', true, [], 'Os elementos a serem adicionados ao vetor.')
|
|
6156
6156
|
],
|
|
6157
|
-
implementacao: (interpretador, vetor, elemento) => {
|
|
6157
|
+
implementacao: (interpretador, nomePrimitiva, vetor, elemento) => {
|
|
6158
6158
|
vetor.push(elemento);
|
|
6159
6159
|
return Promise.resolve(vetor);
|
|
6160
6160
|
},
|
|
@@ -6174,7 +6174,7 @@ exports.default = {
|
|
|
6174
6174
|
argumentos: [
|
|
6175
6175
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('outroVetor', 'qualquer[]', true, [], 'O outro vetorm ou outros vetores, a serem concatenados a este vetor.')
|
|
6176
6176
|
],
|
|
6177
|
-
implementacao: (interpretador, vetor, outroVetor) => {
|
|
6177
|
+
implementacao: (interpretador, nomePrimitiva, vetor, outroVetor) => {
|
|
6178
6178
|
return Promise.resolve(vetor.concat(outroVetor));
|
|
6179
6179
|
},
|
|
6180
6180
|
assinaturaFormato: 'vetor.concatenar(...outroVetor: qualquer[])',
|
|
@@ -6191,7 +6191,7 @@ exports.default = {
|
|
|
6191
6191
|
argumentos: [
|
|
6192
6192
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('elemento', 'qualquer', true, [], '')
|
|
6193
6193
|
],
|
|
6194
|
-
implementacao: (interpretador, vetor, elemento) => {
|
|
6194
|
+
implementacao: (interpretador, nomePrimitiva, vetor, elemento) => {
|
|
6195
6195
|
vetor.push(elemento);
|
|
6196
6196
|
return Promise.resolve(vetor);
|
|
6197
6197
|
},
|
|
@@ -6214,7 +6214,7 @@ exports.default = {
|
|
|
6214
6214
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('excluirQuantidade', 'número'),
|
|
6215
6215
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('itens', 'qualquer[]'),
|
|
6216
6216
|
],
|
|
6217
|
-
implementacao: (interpretador, vetor, inicio, excluirQuantidade, ...itens) => {
|
|
6217
|
+
implementacao: (interpretador, nomePrimitiva, vetor, inicio, excluirQuantidade, ...itens) => {
|
|
6218
6218
|
let elementos = [];
|
|
6219
6219
|
if (excluirQuantidade || excluirQuantidade === 0) {
|
|
6220
6220
|
elementos = !itens.length
|
|
@@ -6233,7 +6233,7 @@ exports.default = {
|
|
|
6233
6233
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('inicio', 'número', false, [], 'A posição de início do vetor a ser fatiado. Se não fornecido, retorna o vetor inteiro.'),
|
|
6234
6234
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('fim', 'número', false, [], 'A posição de fim do vetor a ser fatiado.'),
|
|
6235
6235
|
],
|
|
6236
|
-
implementacao: (interpretador, vetor, inicio, fim) => Promise.resolve(vetor.slice(inicio, fim)),
|
|
6236
|
+
implementacao: (interpretador, nomePrimitiva, vetor, inicio, fim) => Promise.resolve(vetor.slice(inicio, fim)),
|
|
6237
6237
|
assinaturaFormato: 'vetor.fatiar(inicio?: número, fim?: número)',
|
|
6238
6238
|
documentacao: '# `vetor.fatiar(inicio, fim)` \n \n' +
|
|
6239
6239
|
'Extrai uma fatia do vetor, dadas posições de início e fim. \n' +
|
|
@@ -6252,7 +6252,7 @@ exports.default = {
|
|
|
6252
6252
|
argumentos: [
|
|
6253
6253
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('funcao', 'função', true, [], 'A função de filtragem.')
|
|
6254
6254
|
],
|
|
6255
|
-
implementacao: async (interpretador, vetor, funcao) => {
|
|
6255
|
+
implementacao: async (interpretador, nomePrimitiva, vetor, funcao) => {
|
|
6256
6256
|
if (funcao === undefined || funcao === null) {
|
|
6257
6257
|
return Promise.reject("É necessário passar uma função para o método 'filtrarPor'");
|
|
6258
6258
|
}
|
|
@@ -6280,7 +6280,7 @@ exports.default = {
|
|
|
6280
6280
|
argumentos: [
|
|
6281
6281
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('elemento', 'qualquer', true, [], 'O elemento a ser verificado se está presente no vetor.')
|
|
6282
6282
|
],
|
|
6283
|
-
implementacao: (interpretador, vetor, elemento) => Promise.resolve(vetor.includes(elemento)),
|
|
6283
|
+
implementacao: (interpretador, nomePrimitiva, vetor, elemento) => Promise.resolve(vetor.includes(elemento)),
|
|
6284
6284
|
assinaturaFormato: 'vetor.inclui(elemento: qualquer)',
|
|
6285
6285
|
documentacao: '# `vetor.inclui(elemento)` \n \n' +
|
|
6286
6286
|
'Verifica se o elemento existe no vetor. Devolve `verdadeiro` se existe, e `falso` em caso contrário.\n' +
|
|
@@ -6294,7 +6294,7 @@ exports.default = {
|
|
|
6294
6294
|
inverter: {
|
|
6295
6295
|
tipoRetorno: 'qualquer[]',
|
|
6296
6296
|
argumentos: [],
|
|
6297
|
-
implementacao: (interpretador, vetor) => Promise.resolve(vetor.reverse()),
|
|
6297
|
+
implementacao: (interpretador, nomePrimitiva, vetor) => Promise.resolve(vetor.reverse()),
|
|
6298
6298
|
assinaturaFormato: 'vetor.inverter()',
|
|
6299
6299
|
documentacao: '# `vetor.inverter()` \n \n' +
|
|
6300
6300
|
'Inverte a ordem dos elementos de um vetor.\n' +
|
|
@@ -6309,7 +6309,7 @@ exports.default = {
|
|
|
6309
6309
|
argumentos: [
|
|
6310
6310
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('separador', 'texto', true, [], 'O separador entre elementos do vetor para o texto.')
|
|
6311
6311
|
],
|
|
6312
|
-
implementacao: (interpretador, vetor, separador) => Promise.resolve(vetor.join(separador)),
|
|
6312
|
+
implementacao: (interpretador, nomePrimitiva, vetor, separador) => Promise.resolve(vetor.join(separador)),
|
|
6313
6313
|
assinaturaFormato: 'vetor.juntar(separador: texto)',
|
|
6314
6314
|
documentacao: '# `vetor.juntar(separador)` \n \n' +
|
|
6315
6315
|
'Junta todos os elementos de um vetor em um texto, separando cada elemento pelo separador passado como parâmetro.\n' +
|
|
@@ -6324,7 +6324,7 @@ exports.default = {
|
|
|
6324
6324
|
argumentos: [
|
|
6325
6325
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('funcao', 'função', true, [], 'A função que transforma cada elemento de um vetor em outro elemento a ser retornado em um novo vetor.')
|
|
6326
6326
|
],
|
|
6327
|
-
implementacao: async (interpretador, vetor, funcao) => {
|
|
6327
|
+
implementacao: async (interpretador, nomePrimitiva, vetor, funcao) => {
|
|
6328
6328
|
if (funcao === undefined || funcao === null) {
|
|
6329
6329
|
return Promise.reject("É necessário passar uma função para o método 'mapear'");
|
|
6330
6330
|
}
|
|
@@ -6351,7 +6351,7 @@ exports.default = {
|
|
|
6351
6351
|
argumentos: [
|
|
6352
6352
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('funcaoOrdenacao', 'função', false, [], '(Opcional) Função para guiar a ordenação.')
|
|
6353
6353
|
],
|
|
6354
|
-
implementacao: async (interpretador, vetor, funcaoOrdenacao) => {
|
|
6354
|
+
implementacao: async (interpretador, nomePrimitiva, vetor, funcaoOrdenacao) => {
|
|
6355
6355
|
if (funcaoOrdenacao !== undefined && funcaoOrdenacao !== null) {
|
|
6356
6356
|
for (let i = 0; i < vetor.length - 1; i++) {
|
|
6357
6357
|
for (let j = 1; j < vetor.length; j++) {
|
|
@@ -6365,12 +6365,25 @@ exports.default = {
|
|
|
6365
6365
|
}
|
|
6366
6366
|
}
|
|
6367
6367
|
}
|
|
6368
|
+
if (nomePrimitiva !== '') {
|
|
6369
|
+
interpretador.pilhaEscoposExecucao.atribuirVariavel({
|
|
6370
|
+
lexema: nomePrimitiva,
|
|
6371
|
+
}, vetor);
|
|
6372
|
+
}
|
|
6368
6373
|
return vetor;
|
|
6369
6374
|
}
|
|
6370
6375
|
if (!vetor.every((v) => typeof v === 'number')) {
|
|
6371
|
-
|
|
6376
|
+
vetor.sort();
|
|
6377
|
+
}
|
|
6378
|
+
else {
|
|
6379
|
+
vetor.sort((a, b) => a - b);
|
|
6372
6380
|
}
|
|
6373
|
-
|
|
6381
|
+
if (nomePrimitiva !== '') {
|
|
6382
|
+
interpretador.pilhaEscoposExecucao.atribuirVariavel({
|
|
6383
|
+
lexema: nomePrimitiva,
|
|
6384
|
+
}, vetor);
|
|
6385
|
+
}
|
|
6386
|
+
return vetor;
|
|
6374
6387
|
},
|
|
6375
6388
|
assinaturaFormato: 'vetor.ordenar()',
|
|
6376
6389
|
documentacao: '# `vetor.ordenar()` \n \n' +
|
|
@@ -6390,7 +6403,7 @@ exports.default = {
|
|
|
6390
6403
|
argumentos: [
|
|
6391
6404
|
new informacao_variavel_ou_constante_1.InformacaoVariavelOuConstante('elemento', 'qualquer', true, [], 'O elemento a ser removido do vetor.')
|
|
6392
6405
|
],
|
|
6393
|
-
implementacao: (interpretador, vetor, elemento) => {
|
|
6406
|
+
implementacao: (interpretador, nomePrimitiva, vetor, elemento) => {
|
|
6394
6407
|
const index = vetor.indexOf(elemento);
|
|
6395
6408
|
if (index !== -1)
|
|
6396
6409
|
vetor.splice(index, 1);
|
|
@@ -6409,7 +6422,7 @@ exports.default = {
|
|
|
6409
6422
|
removerPrimeiro: {
|
|
6410
6423
|
tipoRetorno: 'qualquer',
|
|
6411
6424
|
argumentos: [],
|
|
6412
|
-
implementacao: (interpretador, vetor) => {
|
|
6425
|
+
implementacao: (interpretador, nomePrimitiva, vetor) => {
|
|
6413
6426
|
let elemento = vetor.shift();
|
|
6414
6427
|
return Promise.resolve(elemento);
|
|
6415
6428
|
},
|
|
@@ -6427,7 +6440,7 @@ exports.default = {
|
|
|
6427
6440
|
removerUltimo: {
|
|
6428
6441
|
tipoRetorno: 'qualquer',
|
|
6429
6442
|
argumentos: [],
|
|
6430
|
-
implementacao: (interpretador, vetor) => {
|
|
6443
|
+
implementacao: (interpretador, nomePrimitiva, vetor) => {
|
|
6431
6444
|
let elemento = vetor.pop();
|
|
6432
6445
|
return Promise.resolve(elemento);
|
|
6433
6446
|
},
|
|
@@ -6445,7 +6458,7 @@ exports.default = {
|
|
|
6445
6458
|
somar: {
|
|
6446
6459
|
tipoRetorno: 'qualquer',
|
|
6447
6460
|
argumentos: [],
|
|
6448
|
-
implementacao: (interpretador, vetor) => {
|
|
6461
|
+
implementacao: (interpretador, nomePrimitiva, vetor) => {
|
|
6449
6462
|
return Promise.resolve(vetor.reduce((acc, item) => acc + (typeof item === 'number' ? item : item.valor), 0));
|
|
6450
6463
|
},
|
|
6451
6464
|
assinaturaFormato: 'vetor.somar()',
|
|
@@ -6460,7 +6473,7 @@ exports.default = {
|
|
|
6460
6473
|
tamanho: {
|
|
6461
6474
|
tipoRetorno: 'número',
|
|
6462
6475
|
argumentos: [],
|
|
6463
|
-
implementacao: (interpretador, vetor) => Promise.resolve(vetor.length),
|
|
6476
|
+
implementacao: (interpretador, nomePrimitiva, vetor) => Promise.resolve(vetor.length),
|
|
6464
6477
|
assinaturaFormato: 'vetor.tamanho()',
|
|
6465
6478
|
documentacao: '# `vetor.tamanho()` \n \n' +
|
|
6466
6479
|
'Retorna o número de elementos que compõem o vetor.\n' +
|
|
@@ -9899,14 +9912,15 @@ const chamavel_1 = require("./chamavel");
|
|
|
9899
9912
|
* primeiro parâmetro é sempre a referência para a primitiva.
|
|
9900
9913
|
*/
|
|
9901
9914
|
class MetodoPrimitiva extends chamavel_1.Chamavel {
|
|
9902
|
-
constructor(primitiva, metodo) {
|
|
9915
|
+
constructor(nome, primitiva, metodo) {
|
|
9903
9916
|
super();
|
|
9917
|
+
this.nome = nome;
|
|
9904
9918
|
this.primitiva = primitiva;
|
|
9905
9919
|
this.metodo = metodo;
|
|
9906
9920
|
this.valorAridade = metodo.length - 1;
|
|
9907
9921
|
}
|
|
9908
9922
|
async chamar(interpretador, argumentos = []) {
|
|
9909
|
-
return await this.metodo(interpretador, this.primitiva, ...argumentos);
|
|
9923
|
+
return await this.metodo(interpretador, this.nome, this.primitiva, ...argumentos);
|
|
9910
9924
|
}
|
|
9911
9925
|
/**
|
|
9912
9926
|
* Método utilizado por Delégua para inspecionar este método em depuração.
|
|
@@ -10174,6 +10188,23 @@ class InterpretadorBase {
|
|
|
10174
10188
|
this.pilhaEscoposExecucao.empilhar(escopoExecucao);
|
|
10175
10189
|
(0, comum_1.carregarBibliotecasGlobais)(this.pilhaEscoposExecucao);
|
|
10176
10190
|
}
|
|
10191
|
+
/**
|
|
10192
|
+
* Usado para chamadas de métodos de primitiva.
|
|
10193
|
+
* Sendo uma variável ou constante, a primitiva precisa atualizar a referência
|
|
10194
|
+
* para o objeto que está sendo acessado.
|
|
10195
|
+
* @param {Construto} objetoAcessado O objeto que está sendo acessado.
|
|
10196
|
+
* @returns O nome desse objeto, se ele for uma variável ou constante.
|
|
10197
|
+
* @see resolverValor
|
|
10198
|
+
*/
|
|
10199
|
+
resolverNomeObjectoAcessado(objetoAcessado) {
|
|
10200
|
+
if (objetoAcessado instanceof construtos_1.Variavel) {
|
|
10201
|
+
return objetoAcessado.simbolo.lexema;
|
|
10202
|
+
}
|
|
10203
|
+
if (objetoAcessado instanceof construtos_1.Constante) {
|
|
10204
|
+
return objetoAcessado.simbolo.lexema;
|
|
10205
|
+
}
|
|
10206
|
+
return '';
|
|
10207
|
+
}
|
|
10177
10208
|
resolverValor(objeto) {
|
|
10178
10209
|
if (objeto === null || objeto === undefined) {
|
|
10179
10210
|
return objeto;
|
|
@@ -11265,7 +11296,7 @@ class InterpretadorBase {
|
|
|
11265
11296
|
if (objeto.constructor === Object) {
|
|
11266
11297
|
if (expressao.simbolo.lexema in primitivas_dicionario_1.default) {
|
|
11267
11298
|
const metodoDePrimitivaDicionario = primitivas_dicionario_1.default[expressao.simbolo.lexema].implementacao;
|
|
11268
|
-
return new metodo_primitiva_1.MetodoPrimitiva(objeto, metodoDePrimitivaDicionario);
|
|
11299
|
+
return new metodo_primitiva_1.MetodoPrimitiva("", objeto, metodoDePrimitivaDicionario);
|
|
11269
11300
|
}
|
|
11270
11301
|
return objeto[expressao.simbolo.lexema];
|
|
11271
11302
|
}
|
|
@@ -11565,6 +11596,9 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11565
11596
|
return this.resolverReferenciaMontao(objeto);
|
|
11566
11597
|
}
|
|
11567
11598
|
if (objeto.hasOwnProperty('valor')) {
|
|
11599
|
+
if (Array.isArray(objeto.valor)) {
|
|
11600
|
+
return this.resolverValor(objeto.valor);
|
|
11601
|
+
}
|
|
11568
11602
|
if (objeto.valor instanceof estruturas_1.ReferenciaMontao) {
|
|
11569
11603
|
return this.resolverReferenciaMontao(objeto.valor);
|
|
11570
11604
|
}
|
|
@@ -11721,6 +11755,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11721
11755
|
}, 'Somente listas, dicionários, classes e objetos podem ter seus valores indexados.', expressao.linha));
|
|
11722
11756
|
}
|
|
11723
11757
|
async visitarExpressaoAcessoMetodo(expressao) {
|
|
11758
|
+
const nomeObjeto = this.resolverNomeObjectoAcessado(expressao.objeto);
|
|
11724
11759
|
let variavelObjeto = await this.avaliar(expressao.objeto);
|
|
11725
11760
|
// Este caso acontece quando há encadeamento de métodos.
|
|
11726
11761
|
// Por exemplo, `objeto1.metodo1().metodo2()`.
|
|
@@ -11737,7 +11772,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11737
11772
|
if (objeto.constructor === Object) {
|
|
11738
11773
|
if (expressao.nomeMetodo in primitivas_dicionario_1.default) {
|
|
11739
11774
|
const metodoDePrimitivaDicionario = primitivas_dicionario_1.default[expressao.nomeMetodo].implementacao;
|
|
11740
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaDicionario);
|
|
11775
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaDicionario);
|
|
11741
11776
|
}
|
|
11742
11777
|
return objeto[expressao.nomeMetodo] || null;
|
|
11743
11778
|
}
|
|
@@ -11770,13 +11805,13 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11770
11805
|
case delegua_1.default.NÚMERO:
|
|
11771
11806
|
const metodoDePrimitivaNumero = primitivas_numero_1.default[expressao.nomeMetodo].implementacao;
|
|
11772
11807
|
if (metodoDePrimitivaNumero) {
|
|
11773
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaNumero);
|
|
11808
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaNumero);
|
|
11774
11809
|
}
|
|
11775
11810
|
break;
|
|
11776
11811
|
case delegua_1.default.TEXTO:
|
|
11777
11812
|
const metodoDePrimitivaTexto = primitivas_texto_1.default[expressao.nomeMetodo].implementacao;
|
|
11778
11813
|
if (metodoDePrimitivaTexto) {
|
|
11779
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaTexto);
|
|
11814
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaTexto);
|
|
11780
11815
|
}
|
|
11781
11816
|
break;
|
|
11782
11817
|
case delegua_1.default.VETOR:
|
|
@@ -11785,7 +11820,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11785
11820
|
case delegua_1.default.VETOR_TEXTO:
|
|
11786
11821
|
const metodoDePrimitivaVetor = primitivas_vetor_1.default[expressao.nomeMetodo].implementacao;
|
|
11787
11822
|
if (metodoDePrimitivaVetor) {
|
|
11788
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaVetor);
|
|
11823
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaVetor);
|
|
11789
11824
|
}
|
|
11790
11825
|
break;
|
|
11791
11826
|
}
|
|
@@ -11804,6 +11839,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11804
11839
|
* @returns A primitiva encontrada.
|
|
11805
11840
|
*/
|
|
11806
11841
|
async visitarExpressaoAcessoMetodoOuPropriedade(expressao) {
|
|
11842
|
+
const nomeObjeto = this.resolverNomeObjectoAcessado(expressao.objeto);
|
|
11807
11843
|
let variavelObjeto = await this.avaliar(expressao.objeto);
|
|
11808
11844
|
// Este caso acontece quando há encadeamento de métodos.
|
|
11809
11845
|
// Por exemplo, `objeto1.metodo1().metodo2()`.
|
|
@@ -11820,7 +11856,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11820
11856
|
if (objeto.constructor === Object) {
|
|
11821
11857
|
if (expressao.simbolo.lexema in primitivas_dicionario_1.default) {
|
|
11822
11858
|
const metodoDePrimitivaDicionario = primitivas_dicionario_1.default[expressao.simbolo.lexema].implementacao;
|
|
11823
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaDicionario);
|
|
11859
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaDicionario);
|
|
11824
11860
|
}
|
|
11825
11861
|
return objeto[expressao.simbolo.lexema];
|
|
11826
11862
|
}
|
|
@@ -11842,13 +11878,13 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11842
11878
|
case delegua_1.default.NÚMERO:
|
|
11843
11879
|
const metodoDePrimitivaNumero = primitivas_numero_1.default[expressao.simbolo.lexema].implementacao;
|
|
11844
11880
|
if (metodoDePrimitivaNumero) {
|
|
11845
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaNumero);
|
|
11881
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaNumero);
|
|
11846
11882
|
}
|
|
11847
11883
|
break;
|
|
11848
11884
|
case delegua_1.default.TEXTO:
|
|
11849
11885
|
const metodoDePrimitivaTexto = primitivas_texto_1.default[expressao.simbolo.lexema].implementacao;
|
|
11850
11886
|
if (metodoDePrimitivaTexto) {
|
|
11851
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaTexto);
|
|
11887
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaTexto);
|
|
11852
11888
|
}
|
|
11853
11889
|
break;
|
|
11854
11890
|
case delegua_1.default.VETOR:
|
|
@@ -11861,7 +11897,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11861
11897
|
case delegua_1.default.VETOR_TEXTO:
|
|
11862
11898
|
const metodoDePrimitivaVetor = primitivas_vetor_1.default[expressao.simbolo.lexema].implementacao;
|
|
11863
11899
|
if (metodoDePrimitivaVetor) {
|
|
11864
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaVetor);
|
|
11900
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaVetor);
|
|
11865
11901
|
}
|
|
11866
11902
|
break;
|
|
11867
11903
|
}
|
|
@@ -11874,6 +11910,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11874
11910
|
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(null, `Método ou propriedade para objeto ou primitiva não encontrado: ${expressao.simbolo.lexema}.`, expressao.linha));
|
|
11875
11911
|
}
|
|
11876
11912
|
async visitarExpressaoAcessoPropriedade(expressao) {
|
|
11913
|
+
const nomeObjeto = this.resolverNomeObjectoAcessado(expressao.objeto);
|
|
11877
11914
|
let variavelObjeto = await this.avaliar(expressao.objeto);
|
|
11878
11915
|
// Este caso acontece quando há encadeamento de métodos.
|
|
11879
11916
|
// Por exemplo, `objeto1.metodo1().metodo2()`.
|
|
@@ -11893,7 +11930,7 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
11893
11930
|
if (objeto.constructor === Object) {
|
|
11894
11931
|
if (expressao.nomePropriedade in primitivas_dicionario_1.default) {
|
|
11895
11932
|
const metodoDePrimitivaDicionario = primitivas_dicionario_1.default[expressao.nomePropriedade].implementacao;
|
|
11896
|
-
return new estruturas_1.MetodoPrimitiva(objeto, metodoDePrimitivaDicionario);
|
|
11933
|
+
return new estruturas_1.MetodoPrimitiva(nomeObjeto, objeto, metodoDePrimitivaDicionario);
|
|
11897
11934
|
}
|
|
11898
11935
|
return objeto[expressao.nomePropriedade] || null;
|
|
11899
11936
|
}
|