@designliquido/delegua 1.18.4 → 1.19.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/README.md +7 -1
- package/analisador-semantico/analisador-semantico-base.d.ts +3 -1
- package/analisador-semantico/analisador-semantico-base.d.ts.map +1 -1
- package/analisador-semantico/analisador-semantico-base.js +6 -0
- package/analisador-semantico/analisador-semantico-base.js.map +1 -1
- package/analisador-semantico/analisador-semantico.d.ts.map +1 -1
- package/analisador-semantico/analisador-semantico.js +3 -0
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/analisador-semantico/dialetos/analisador-semantico-pitugues.d.ts +4 -1
- package/analisador-semantico/dialetos/analisador-semantico-pitugues.d.ts.map +1 -1
- package/analisador-semantico/dialetos/analisador-semantico-pitugues.js +57 -0
- package/analisador-semantico/dialetos/analisador-semantico-pitugues.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts +2 -0
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +44 -2
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +1 -0
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +54 -13
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.js +6 -0
- package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico.d.ts +1 -0
- package/avaliador-sintatico/micro-avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico.js +18 -0
- package/avaliador-sintatico/micro-avaliador-sintatico.js.map +1 -1
- package/bibliotecas/biblioteca-global.d.ts.map +1 -1
- package/bibliotecas/biblioteca-global.js +6 -3
- package/bibliotecas/biblioteca-global.js.map +1 -1
- package/bin/package.json +1 -1
- package/construtos/bote.d.ts +13 -0
- package/construtos/bote.d.ts.map +1 -0
- package/construtos/bote.js +22 -0
- package/construtos/bote.js.map +1 -0
- package/construtos/index.d.ts +2 -0
- package/construtos/index.d.ts.map +1 -1
- package/construtos/index.js +2 -0
- package/construtos/index.js.map +1 -1
- package/construtos/morsa.d.ts +14 -0
- package/construtos/morsa.d.ts.map +1 -0
- package/construtos/morsa.js +22 -0
- package/construtos/morsa.js.map +1 -0
- package/declaracoes/propriedade-classe.d.ts +3 -2
- package/declaracoes/propriedade-classe.d.ts.map +1 -1
- package/declaracoes/propriedade-classe.js +2 -1
- package/declaracoes/propriedade-classe.js.map +1 -1
- package/formatadores/formatador-delegua.d.ts.map +1 -1
- package/formatadores/formatador-delegua.js.map +1 -1
- package/formatadores/formatador-pitugues.d.ts +5 -3
- package/formatadores/formatador-pitugues.d.ts.map +1 -1
- package/formatadores/formatador-pitugues.js +10 -0
- package/formatadores/formatador-pitugues.js.map +1 -1
- package/inferenciador.d.ts.map +1 -1
- package/inferenciador.js +5 -1
- package/inferenciador.js.map +1 -1
- package/interfaces/visitante-pitugues-interface.d.ts +7 -0
- package/interfaces/visitante-pitugues-interface.d.ts.map +1 -0
- package/interfaces/visitante-pitugues-interface.js +3 -0
- package/interfaces/visitante-pitugues-interface.js.map +1 -0
- package/interpretador/dialetos/pitugues/interpretador-pitugues.d.ts +7 -2
- package/interpretador/dialetos/pitugues/interpretador-pitugues.d.ts.map +1 -1
- package/interpretador/dialetos/pitugues/interpretador-pitugues.js +68 -3
- package/interpretador/dialetos/pitugues/interpretador-pitugues.js.map +1 -1
- package/interpretador/estruturas/descritor-tipo-classe.d.ts +1 -0
- package/interpretador/estruturas/descritor-tipo-classe.d.ts.map +1 -1
- package/interpretador/estruturas/descritor-tipo-classe.js +1 -0
- package/interpretador/estruturas/descritor-tipo-classe.js.map +1 -1
- package/interpretador/estruturas/objeto-delegua-classe.d.ts.map +1 -1
- package/interpretador/estruturas/objeto-delegua-classe.js +7 -1
- package/interpretador/estruturas/objeto-delegua-classe.js.map +1 -1
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +4 -1
- package/interpretador/interpretador-base.js.map +1 -1
- package/lexador/dialetos/lexador-pitugues.d.ts.map +1 -1
- package/lexador/dialetos/lexador-pitugues.js +22 -4
- package/lexador/dialetos/lexador-pitugues.js.map +1 -1
- package/package.json +1 -1
- package/tipos-de-simbolos/pitugues.d.ts +3 -0
- package/tipos-de-simbolos/pitugues.d.ts.map +1 -1
- package/tipos-de-simbolos/pitugues.js +3 -0
- package/tipos-de-simbolos/pitugues.js.map +1 -1
- package/tradutores/tradutor-assembly-arm.js +151 -151
- package/tradutores/tradutor-assembly-risc-v.js +85 -85
- package/tradutores/tradutor-assembly-x64.js +176 -176
- package/tradutores/tradutor-mermaidjs.d.ts +2 -1
- package/tradutores/tradutor-mermaidjs.d.ts.map +1 -1
- package/tradutores/tradutor-mermaidjs.js +5 -0
- package/tradutores/tradutor-mermaidjs.js.map +1 -1
- package/tradutores/tradutor-webassembly.js +29 -29
- package/umd/delegua.js +1137 -919
|
@@ -55,10 +55,10 @@ class TradutorAssemblyRISCV {
|
|
|
55
55
|
Var: this.traduzirDeclaracaoVar.bind(this),
|
|
56
56
|
};
|
|
57
57
|
this.indentacao = 0;
|
|
58
|
-
this.text = `
|
|
59
|
-
.text
|
|
60
|
-
.global _start
|
|
61
|
-
|
|
58
|
+
this.text = `
|
|
59
|
+
.text
|
|
60
|
+
.global _start
|
|
61
|
+
|
|
62
62
|
_start:`;
|
|
63
63
|
}
|
|
64
64
|
gerarDigitoAleatorio() {
|
|
@@ -124,9 +124,9 @@ _start:`;
|
|
|
124
124
|
const reg = this.obterRegistrador();
|
|
125
125
|
this.text += `\n la ${reg}, ${nomeVar}`;
|
|
126
126
|
this.emitirCarga('a0', indice);
|
|
127
|
-
this.text += `
|
|
128
|
-
slli a0, a0, 3 # multiplicar índice por 8 (palavra de 64 bits)
|
|
129
|
-
add ${reg}, ${reg}, a0
|
|
127
|
+
this.text += `
|
|
128
|
+
slli a0, a0, 3 # multiplicar índice por 8 (palavra de 64 bits)
|
|
129
|
+
add ${reg}, ${reg}, a0
|
|
130
130
|
ld a0, 0(${reg})`;
|
|
131
131
|
this.liberarRegistrador(reg);
|
|
132
132
|
return 'a0';
|
|
@@ -150,8 +150,8 @@ _start:`;
|
|
|
150
150
|
const reg = this.obterRegistrador();
|
|
151
151
|
this.text += `\n la ${reg}, ${nomeVar}`;
|
|
152
152
|
this.emitirCarga('a1', indice);
|
|
153
|
-
this.text += `
|
|
154
|
-
slli a1, a1, 3 # multiplicar índice por 8
|
|
153
|
+
this.text += `
|
|
154
|
+
slli a1, a1, 3 # multiplicar índice por 8
|
|
155
155
|
add ${reg}, ${reg}, a1`;
|
|
156
156
|
this.emitirCarga('a1', valor);
|
|
157
157
|
this.text += `\n sd a1, 0(${reg})`;
|
|
@@ -171,8 +171,8 @@ _start:`;
|
|
|
171
171
|
this.variaveis.set(nomeVar, varLabel);
|
|
172
172
|
}
|
|
173
173
|
this.emitirCarga('a0', valor);
|
|
174
|
-
this.text += `
|
|
175
|
-
la a1, ${this.variaveis.get(nomeVar)}
|
|
174
|
+
this.text += `
|
|
175
|
+
la a1, ${this.variaveis.get(nomeVar)}
|
|
176
176
|
sd a0, 0(a1)`;
|
|
177
177
|
}
|
|
178
178
|
traduzirConstrutoBinario(construto) {
|
|
@@ -256,18 +256,18 @@ _start:`;
|
|
|
256
256
|
const objeto = this.dicionarioConstrutos[construto.objeto.constructor.name](construto.objeto);
|
|
257
257
|
const valor = this.dicionarioConstrutos[construto.valor.constructor.name](construto.valor);
|
|
258
258
|
this.emitirCarga('a0', valor);
|
|
259
|
-
this.text += `
|
|
260
|
-
la a1, ${objeto}
|
|
259
|
+
this.text += `
|
|
260
|
+
la a1, ${objeto}
|
|
261
261
|
sd a0, 0(a1)`;
|
|
262
262
|
}
|
|
263
263
|
traduzirFuncaoConstruto(construto) {
|
|
264
264
|
const labelFuncao = `func_${this.gerarDigitoAleatorio()}`;
|
|
265
|
-
this.text += `
|
|
266
|
-
|
|
267
|
-
${labelFuncao}:
|
|
268
|
-
addi sp, sp, -16
|
|
269
|
-
sd ra, 8(sp)
|
|
270
|
-
sd s0, 0(sp)
|
|
265
|
+
this.text += `
|
|
266
|
+
|
|
267
|
+
${labelFuncao}:
|
|
268
|
+
addi sp, sp, -16
|
|
269
|
+
sd ra, 8(sp)
|
|
270
|
+
sd s0, 0(sp)
|
|
271
271
|
addi s0, sp, 16`;
|
|
272
272
|
if (construto.corpo && Array.isArray(construto.corpo)) {
|
|
273
273
|
construto.corpo.forEach((declaracao) => {
|
|
@@ -276,10 +276,10 @@ ${labelFuncao}:
|
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
|
-
this.text += `
|
|
280
|
-
ld ra, 8(sp)
|
|
281
|
-
ld s0, 0(sp)
|
|
282
|
-
addi sp, sp, 16
|
|
279
|
+
this.text += `
|
|
280
|
+
ld ra, 8(sp)
|
|
281
|
+
ld s0, 0(sp)
|
|
282
|
+
addi sp, sp, 16
|
|
283
283
|
ret`;
|
|
284
284
|
}
|
|
285
285
|
traduzirConstrutoLiteral(construto) {
|
|
@@ -303,21 +303,21 @@ ${labelFuncao}:
|
|
|
303
303
|
if (operador === 'e' || operador === '&&') {
|
|
304
304
|
this.text += `\n beqz a0, ${labelFim}`;
|
|
305
305
|
this.emitirCarga('a0', direita);
|
|
306
|
-
this.text += `
|
|
307
|
-
beqz a0, ${labelFim}
|
|
308
|
-
${labelVerdadeiro}:
|
|
309
|
-
li a0, 1
|
|
306
|
+
this.text += `
|
|
307
|
+
beqz a0, ${labelFim}
|
|
308
|
+
${labelVerdadeiro}:
|
|
309
|
+
li a0, 1
|
|
310
310
|
${labelFim}:`;
|
|
311
311
|
}
|
|
312
312
|
else if (operador === 'ou' || operador === '||') {
|
|
313
313
|
this.text += `\n bnez a0, ${labelVerdadeiro}`;
|
|
314
314
|
this.emitirCarga('a0', direita);
|
|
315
|
-
this.text += `
|
|
316
|
-
bnez a0, ${labelVerdadeiro}
|
|
317
|
-
li a0, 0
|
|
318
|
-
j ${labelFim}
|
|
319
|
-
${labelVerdadeiro}:
|
|
320
|
-
li a0, 1
|
|
315
|
+
this.text += `
|
|
316
|
+
bnez a0, ${labelVerdadeiro}
|
|
317
|
+
li a0, 0
|
|
318
|
+
j ${labelFim}
|
|
319
|
+
${labelVerdadeiro}:
|
|
320
|
+
li a0, 1
|
|
321
321
|
${labelFim}:`;
|
|
322
322
|
}
|
|
323
323
|
return 'a0';
|
|
@@ -342,8 +342,8 @@ ${labelFim}:`;
|
|
|
342
342
|
const nomeVar = construto.simbolo?.lexema;
|
|
343
343
|
if (nomeVar && this.variaveis.has(nomeVar)) {
|
|
344
344
|
const varLabel = this.variaveis.get(nomeVar);
|
|
345
|
-
this.text += `
|
|
346
|
-
la a0, ${varLabel}
|
|
345
|
+
this.text += `
|
|
346
|
+
la a0, ${varLabel}
|
|
347
347
|
ld a0, 0(a0)`;
|
|
348
348
|
return 'a0';
|
|
349
349
|
}
|
|
@@ -359,8 +359,8 @@ ${labelFim}:`;
|
|
|
359
359
|
if (this.dicionarioConstrutos[valor.constructor.name]) {
|
|
360
360
|
const valorTraduzido = this.dicionarioConstrutos[valor.constructor.name](valor);
|
|
361
361
|
this.emitirCarga('a0', valorTraduzido);
|
|
362
|
-
this.text += `
|
|
363
|
-
la a1, ${labelVetor}
|
|
362
|
+
this.text += `
|
|
363
|
+
la a1, ${labelVetor}
|
|
364
364
|
sd a0, ${index * 8}(a1)`;
|
|
365
365
|
}
|
|
366
366
|
});
|
|
@@ -388,8 +388,8 @@ ${labelFim}:`;
|
|
|
388
388
|
if (this.dicionarioDeclaracoes[declaracao.corpo.constructor.name]) {
|
|
389
389
|
this.dicionarioDeclaracoes[declaracao.corpo.constructor.name](declaracao.corpo);
|
|
390
390
|
}
|
|
391
|
-
this.text += `
|
|
392
|
-
j ${labelInicio}
|
|
391
|
+
this.text += `
|
|
392
|
+
j ${labelInicio}
|
|
393
393
|
${labelFim}:`;
|
|
394
394
|
}
|
|
395
395
|
traduzirDeclaracaoEscolha(declaracao) {
|
|
@@ -410,8 +410,8 @@ ${labelFim}:`;
|
|
|
410
410
|
}
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
|
-
this.text += `
|
|
414
|
-
j ${labelFim}
|
|
413
|
+
this.text += `
|
|
414
|
+
j ${labelFim}
|
|
415
415
|
${labelProximo}:`;
|
|
416
416
|
}
|
|
417
417
|
});
|
|
@@ -455,20 +455,20 @@ ${labelProximo}:`;
|
|
|
455
455
|
mensagem = this.dicionarioConstrutos[explicacao.constructor.name](explicacao);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
this.text += `
|
|
459
|
-
# Falhar com mensagem: ${mensagem}
|
|
460
|
-
li a0, 1
|
|
461
|
-
li a7, 93 # sys_exit
|
|
458
|
+
this.text += `
|
|
459
|
+
# Falhar com mensagem: ${mensagem}
|
|
460
|
+
li a0, 1
|
|
461
|
+
li a7, 93 # sys_exit
|
|
462
462
|
ecall`;
|
|
463
463
|
}
|
|
464
464
|
traduzirDeclaracaoFuncao(declaracao) {
|
|
465
465
|
const nomeFuncao = declaracao.simbolo?.lexema || 'funcao';
|
|
466
|
-
this.text += `
|
|
467
|
-
|
|
468
|
-
${nomeFuncao}:
|
|
469
|
-
addi sp, sp, -16
|
|
470
|
-
sd ra, 8(sp)
|
|
471
|
-
sd s0, 0(sp)
|
|
466
|
+
this.text += `
|
|
467
|
+
|
|
468
|
+
${nomeFuncao}:
|
|
469
|
+
addi sp, sp, -16
|
|
470
|
+
sd ra, 8(sp)
|
|
471
|
+
sd s0, 0(sp)
|
|
472
472
|
addi s0, sp, 16`;
|
|
473
473
|
if (declaracao.funcao &&
|
|
474
474
|
declaracao.funcao.corpo &&
|
|
@@ -479,10 +479,10 @@ ${nomeFuncao}:
|
|
|
479
479
|
}
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
|
-
this.text += `
|
|
483
|
-
ld ra, 8(sp)
|
|
484
|
-
ld s0, 0(sp)
|
|
485
|
-
addi sp, sp, 16
|
|
482
|
+
this.text += `
|
|
483
|
+
ld ra, 8(sp)
|
|
484
|
+
ld s0, 0(sp)
|
|
485
|
+
addi sp, sp, 16
|
|
486
486
|
ret`;
|
|
487
487
|
}
|
|
488
488
|
traduzirDeclaracaoImportar(declaracao) {
|
|
@@ -502,11 +502,11 @@ ${nomeFuncao}:
|
|
|
502
502
|
this.bss += ` ${varLabel}: .space 256\n`;
|
|
503
503
|
this.variaveis.set(nomeVar, varLabel);
|
|
504
504
|
}
|
|
505
|
-
this.text += `
|
|
506
|
-
li a0, 0 # fd stdin
|
|
507
|
-
la a1, ${this.variaveis.get(nomeVar)}
|
|
508
|
-
li a2, 256
|
|
509
|
-
li a7, 63 # sys_read
|
|
505
|
+
this.text += `
|
|
506
|
+
li a0, 0 # fd stdin
|
|
507
|
+
la a1, ${this.variaveis.get(nomeVar)}
|
|
508
|
+
li a2, 256
|
|
509
|
+
li a7, 63 # sys_read
|
|
510
510
|
ecall`;
|
|
511
511
|
}
|
|
512
512
|
traduzirDeclaracaoPara(declaracao) {
|
|
@@ -537,8 +537,8 @@ ${nomeFuncao}:
|
|
|
537
537
|
this.dicionarioConstrutos[declaracao.incrementar.constructor.name](declaracao.incrementar);
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
-
this.text += `
|
|
541
|
-
j ${labelInicio}
|
|
540
|
+
this.text += `
|
|
541
|
+
j ${labelInicio}
|
|
542
542
|
${labelFim}:`;
|
|
543
543
|
}
|
|
544
544
|
traduzirDeclaracaoParaCada(declaracao) {
|
|
@@ -550,17 +550,17 @@ ${labelFim}:`;
|
|
|
550
550
|
tamanhoVetor = vetor.tamanho || 0;
|
|
551
551
|
}
|
|
552
552
|
// t0: contador; t1: limite (caller-saved, seguros aqui)
|
|
553
|
-
this.text += `
|
|
554
|
-
li t0, 0 # contador
|
|
555
|
-
li t1, ${tamanhoVetor}
|
|
556
|
-
${labelInicio}:
|
|
553
|
+
this.text += `
|
|
554
|
+
li t0, 0 # contador
|
|
555
|
+
li t1, ${tamanhoVetor}
|
|
556
|
+
${labelInicio}:
|
|
557
557
|
bge t0, t1, ${labelFim}`;
|
|
558
558
|
if (this.dicionarioDeclaracoes[declaracao.corpo.constructor.name]) {
|
|
559
559
|
this.dicionarioDeclaracoes[declaracao.corpo.constructor.name](declaracao.corpo);
|
|
560
560
|
}
|
|
561
|
-
this.text += `
|
|
562
|
-
addi t0, t0, 1
|
|
563
|
-
j ${labelInicio}
|
|
561
|
+
this.text += `
|
|
562
|
+
addi t0, t0, 1
|
|
563
|
+
j ${labelInicio}
|
|
564
564
|
${labelFim}:`;
|
|
565
565
|
}
|
|
566
566
|
traduzirDeclaracaoRetorna(declaracao) {
|
|
@@ -568,10 +568,10 @@ ${labelFim}:`;
|
|
|
568
568
|
const valor = this.dicionarioConstrutos[declaracao.valor.constructor.name](declaracao.valor);
|
|
569
569
|
this.emitirCarga('a0', valor);
|
|
570
570
|
}
|
|
571
|
-
this.text += `
|
|
572
|
-
ld ra, 8(sp)
|
|
573
|
-
ld s0, 0(sp)
|
|
574
|
-
addi sp, sp, 16
|
|
571
|
+
this.text += `
|
|
572
|
+
ld ra, 8(sp)
|
|
573
|
+
ld s0, 0(sp)
|
|
574
|
+
addi sp, sp, 16
|
|
575
575
|
ret`;
|
|
576
576
|
}
|
|
577
577
|
traduzirDeclaracaoSe(declaracao) {
|
|
@@ -585,8 +585,8 @@ ${labelFim}:`;
|
|
|
585
585
|
if (this.dicionarioDeclaracoes[declaracao.caminhoEntao.constructor.name]) {
|
|
586
586
|
this.dicionarioDeclaracoes[declaracao.caminhoEntao.constructor.name](declaracao.caminhoEntao);
|
|
587
587
|
}
|
|
588
|
-
this.text += `
|
|
589
|
-
j ${labelFim}
|
|
588
|
+
this.text += `
|
|
589
|
+
j ${labelFim}
|
|
590
590
|
${labelSenao}:`;
|
|
591
591
|
if (declaracao.caminhoSenao &&
|
|
592
592
|
this.dicionarioDeclaracoes[declaracao.caminhoSenao.constructor.name]) {
|
|
@@ -632,8 +632,8 @@ ${labelSenao}:`;
|
|
|
632
632
|
else if (this.dicionarioConstrutos[tipoInicializador]) {
|
|
633
633
|
const valor = this.dicionarioConstrutos[tipoInicializador](declaracao.inicializador);
|
|
634
634
|
this.emitirCarga('a0', valor);
|
|
635
|
-
this.text += `
|
|
636
|
-
la a1, ${varLabel}
|
|
635
|
+
this.text += `
|
|
636
|
+
la a1, ${varLabel}
|
|
637
637
|
sd a0, 0(a1)`;
|
|
638
638
|
}
|
|
639
639
|
}
|
|
@@ -660,17 +660,17 @@ ${labelSenao}:`;
|
|
|
660
660
|
tamanhoString = String(stringValue.length);
|
|
661
661
|
}
|
|
662
662
|
// sys_write(fd=1, buf, count): a7=64, a0=fd, a1=buf, a2=count
|
|
663
|
-
this.text += `
|
|
664
|
-
la a1, ${nomeStringLiteral}
|
|
665
|
-
li a2, ${tamanhoString}
|
|
666
|
-
li a0, 1 # fd stdout
|
|
667
|
-
li a7, 64 # sys_write
|
|
663
|
+
this.text += `
|
|
664
|
+
la a1, ${nomeStringLiteral}
|
|
665
|
+
li a2, ${tamanhoString}
|
|
666
|
+
li a0, 1 # fd stdout
|
|
667
|
+
li a7, 64 # sys_write
|
|
668
668
|
ecall`;
|
|
669
669
|
}
|
|
670
670
|
saidaSistema() {
|
|
671
|
-
this.text += `
|
|
672
|
-
li a0, 0 # código de saída
|
|
673
|
-
li a7, 93 # sys_exit
|
|
671
|
+
this.text += `
|
|
672
|
+
li a0, 0 # código de saída
|
|
673
|
+
li a7, 93 # sys_exit
|
|
674
674
|
ecall`;
|
|
675
675
|
}
|
|
676
676
|
traduzir(declaracoes) {
|