@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.
Files changed (91) hide show
  1. package/README.md +7 -1
  2. package/analisador-semantico/analisador-semantico-base.d.ts +3 -1
  3. package/analisador-semantico/analisador-semantico-base.d.ts.map +1 -1
  4. package/analisador-semantico/analisador-semantico-base.js +6 -0
  5. package/analisador-semantico/analisador-semantico-base.js.map +1 -1
  6. package/analisador-semantico/analisador-semantico.d.ts.map +1 -1
  7. package/analisador-semantico/analisador-semantico.js +3 -0
  8. package/analisador-semantico/analisador-semantico.js.map +1 -1
  9. package/analisador-semantico/dialetos/analisador-semantico-pitugues.d.ts +4 -1
  10. package/analisador-semantico/dialetos/analisador-semantico-pitugues.d.ts.map +1 -1
  11. package/analisador-semantico/dialetos/analisador-semantico-pitugues.js +57 -0
  12. package/analisador-semantico/dialetos/analisador-semantico-pitugues.js.map +1 -1
  13. package/avaliador-sintatico/avaliador-sintatico.d.ts +2 -0
  14. package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
  15. package/avaliador-sintatico/avaliador-sintatico.js +44 -2
  16. package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
  17. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +1 -0
  18. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
  19. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +54 -13
  20. package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
  21. package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.d.ts.map +1 -1
  22. package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.js +6 -0
  23. package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.js.map +1 -1
  24. package/avaliador-sintatico/micro-avaliador-sintatico.d.ts +1 -0
  25. package/avaliador-sintatico/micro-avaliador-sintatico.d.ts.map +1 -1
  26. package/avaliador-sintatico/micro-avaliador-sintatico.js +18 -0
  27. package/avaliador-sintatico/micro-avaliador-sintatico.js.map +1 -1
  28. package/bibliotecas/biblioteca-global.d.ts.map +1 -1
  29. package/bibliotecas/biblioteca-global.js +6 -3
  30. package/bibliotecas/biblioteca-global.js.map +1 -1
  31. package/bin/package.json +1 -1
  32. package/construtos/bote.d.ts +13 -0
  33. package/construtos/bote.d.ts.map +1 -0
  34. package/construtos/bote.js +22 -0
  35. package/construtos/bote.js.map +1 -0
  36. package/construtos/index.d.ts +2 -0
  37. package/construtos/index.d.ts.map +1 -1
  38. package/construtos/index.js +2 -0
  39. package/construtos/index.js.map +1 -1
  40. package/construtos/morsa.d.ts +14 -0
  41. package/construtos/morsa.d.ts.map +1 -0
  42. package/construtos/morsa.js +22 -0
  43. package/construtos/morsa.js.map +1 -0
  44. package/declaracoes/propriedade-classe.d.ts +3 -2
  45. package/declaracoes/propriedade-classe.d.ts.map +1 -1
  46. package/declaracoes/propriedade-classe.js +2 -1
  47. package/declaracoes/propriedade-classe.js.map +1 -1
  48. package/formatadores/formatador-delegua.d.ts.map +1 -1
  49. package/formatadores/formatador-delegua.js.map +1 -1
  50. package/formatadores/formatador-pitugues.d.ts +5 -3
  51. package/formatadores/formatador-pitugues.d.ts.map +1 -1
  52. package/formatadores/formatador-pitugues.js +10 -0
  53. package/formatadores/formatador-pitugues.js.map +1 -1
  54. package/inferenciador.d.ts.map +1 -1
  55. package/inferenciador.js +5 -1
  56. package/inferenciador.js.map +1 -1
  57. package/interfaces/visitante-pitugues-interface.d.ts +7 -0
  58. package/interfaces/visitante-pitugues-interface.d.ts.map +1 -0
  59. package/interfaces/visitante-pitugues-interface.js +3 -0
  60. package/interfaces/visitante-pitugues-interface.js.map +1 -0
  61. package/interpretador/dialetos/pitugues/interpretador-pitugues.d.ts +7 -2
  62. package/interpretador/dialetos/pitugues/interpretador-pitugues.d.ts.map +1 -1
  63. package/interpretador/dialetos/pitugues/interpretador-pitugues.js +68 -3
  64. package/interpretador/dialetos/pitugues/interpretador-pitugues.js.map +1 -1
  65. package/interpretador/estruturas/descritor-tipo-classe.d.ts +1 -0
  66. package/interpretador/estruturas/descritor-tipo-classe.d.ts.map +1 -1
  67. package/interpretador/estruturas/descritor-tipo-classe.js +1 -0
  68. package/interpretador/estruturas/descritor-tipo-classe.js.map +1 -1
  69. package/interpretador/estruturas/objeto-delegua-classe.d.ts.map +1 -1
  70. package/interpretador/estruturas/objeto-delegua-classe.js +7 -1
  71. package/interpretador/estruturas/objeto-delegua-classe.js.map +1 -1
  72. package/interpretador/interpretador-base.d.ts.map +1 -1
  73. package/interpretador/interpretador-base.js +4 -1
  74. package/interpretador/interpretador-base.js.map +1 -1
  75. package/lexador/dialetos/lexador-pitugues.d.ts.map +1 -1
  76. package/lexador/dialetos/lexador-pitugues.js +22 -4
  77. package/lexador/dialetos/lexador-pitugues.js.map +1 -1
  78. package/package.json +1 -1
  79. package/tipos-de-simbolos/pitugues.d.ts +3 -0
  80. package/tipos-de-simbolos/pitugues.d.ts.map +1 -1
  81. package/tipos-de-simbolos/pitugues.js +3 -0
  82. package/tipos-de-simbolos/pitugues.js.map +1 -1
  83. package/tradutores/tradutor-assembly-arm.js +151 -151
  84. package/tradutores/tradutor-assembly-risc-v.js +85 -85
  85. package/tradutores/tradutor-assembly-x64.js +176 -176
  86. package/tradutores/tradutor-mermaidjs.d.ts +2 -1
  87. package/tradutores/tradutor-mermaidjs.d.ts.map +1 -1
  88. package/tradutores/tradutor-mermaidjs.js +5 -0
  89. package/tradutores/tradutor-mermaidjs.js.map +1 -1
  90. package/tradutores/tradutor-webassembly.js +29 -29
  91. package/umd/delegua.js +1137 -919
@@ -57,14 +57,14 @@ class TradutorAssemblyX64 {
57
57
  Escreva: this.traduzirDeclaracaoEscreva.bind(this),
58
58
  };
59
59
  this.indentacao = 0;
60
- this.textoSaida = `
61
- section .text
62
- ${this.alvo === 'linux' ? 'global _start' : 'global main'}
60
+ this.textoSaida = `
61
+ section .text
62
+ ${this.alvo === 'linux' ? 'global _start' : 'global main'}
63
63
  ${this.alvo === 'linux' ? '_start:' : 'main:'}`;
64
64
  if (this.alvo === 'windows') {
65
65
  this.textoSaida =
66
- `
67
- extern printf
66
+ `
67
+ extern printf
68
68
  ` + this.textoSaida;
69
69
  }
70
70
  }
@@ -124,8 +124,8 @@ extern printf
124
124
  }
125
125
  const indice = this.dicionarioConstrutos[construto.indice.constructor.name](construto.indice);
126
126
  const valor = this.dicionarioConstrutos[construto.valor.constructor.name](construto.valor);
127
- this.textoSaida += `
128
- mov rax, ${valor}
127
+ this.textoSaida += `
128
+ mov rax, ${valor}
129
129
  mov [${nomeVar} + ${indice} * 8], rax`;
130
130
  }
131
131
  traduzirConstrutoAtribuir(construto) {
@@ -143,8 +143,8 @@ extern printf
143
143
  this.bss += ` ${varLabel} resq 1\n`;
144
144
  this.variaveis.set(nomeVar, varLabel);
145
145
  }
146
- this.textoSaida += `
147
- mov rax, ${valor}
146
+ this.textoSaida += `
147
+ mov rax, ${valor}
148
148
  mov [${this.variaveis.get(nomeVar)}], rax`;
149
149
  }
150
150
  traduzirConstrutoBinario(construto) {
@@ -152,71 +152,71 @@ extern printf
152
152
  const direita = this.dicionarioConstrutos[construto.direita.constructor.name](construto.direita);
153
153
  const operador = construto.operador.lexema;
154
154
  const registrador = this.obterRegistrador();
155
- this.textoSaida += `
156
- mov rax, ${esquerda}
155
+ this.textoSaida += `
156
+ mov rax, ${esquerda}
157
157
  mov ${registrador}, ${direita}`;
158
158
  switch (operador) {
159
159
  case '+':
160
- this.textoSaida += `
160
+ this.textoSaida += `
161
161
  add rax, ${registrador}`;
162
162
  break;
163
163
  case '-':
164
- this.textoSaida += `
164
+ this.textoSaida += `
165
165
  sub rax, ${registrador}`;
166
166
  break;
167
167
  case '*':
168
- this.textoSaida += `
168
+ this.textoSaida += `
169
169
  imul rax, ${registrador}`;
170
170
  break;
171
171
  case '/':
172
- this.textoSaida += `
173
- xor rdx, rdx
172
+ this.textoSaida += `
173
+ xor rdx, rdx
174
174
  idiv ${registrador}`;
175
175
  break;
176
176
  case '%':
177
- this.textoSaida += `
178
- xor rdx, rdx
179
- idiv ${registrador}
177
+ this.textoSaida += `
178
+ xor rdx, rdx
179
+ idiv ${registrador}
180
180
  mov rax, rdx`;
181
181
  break;
182
182
  case '<':
183
- this.textoSaida += `
184
- cmp rax, ${registrador}
185
- setl al
183
+ this.textoSaida += `
184
+ cmp rax, ${registrador}
185
+ setl al
186
186
  movzx rax, al`;
187
187
  break;
188
188
  case '>':
189
- this.textoSaida += `
190
- cmp rax, ${registrador}
191
- setg al
189
+ this.textoSaida += `
190
+ cmp rax, ${registrador}
191
+ setg al
192
192
  movzx rax, al`;
193
193
  break;
194
194
  case '<=':
195
- this.textoSaida += `
196
- cmp rax, ${registrador}
197
- setle al
195
+ this.textoSaida += `
196
+ cmp rax, ${registrador}
197
+ setle al
198
198
  movzx rax, al`;
199
199
  break;
200
200
  case '>=':
201
- this.textoSaida += `
202
- cmp rax, ${registrador}
203
- setge al
201
+ this.textoSaida += `
202
+ cmp rax, ${registrador}
203
+ setge al
204
204
  movzx rax, al`;
205
205
  break;
206
206
  case '==':
207
- this.textoSaida += `
208
- cmp rax, ${registrador}
209
- sete al
207
+ this.textoSaida += `
208
+ cmp rax, ${registrador}
209
+ sete al
210
210
  movzx rax, al`;
211
211
  break;
212
212
  case '!=':
213
- this.textoSaida += `
214
- cmp rax, ${registrador}
215
- setne al
213
+ this.textoSaida += `
214
+ cmp rax, ${registrador}
215
+ setne al
216
216
  movzx rax, al`;
217
217
  break;
218
218
  default:
219
- this.textoSaida += `
219
+ this.textoSaida += `
220
220
  ; Operador ${operador} não implementado`;
221
221
  }
222
222
  this.liberarRegistrador(registrador);
@@ -234,28 +234,28 @@ extern printf
234
234
  construto.argumentos.forEach((arg, index) => {
235
235
  if (index < registrosArgs.length) {
236
236
  const valorArg = this.dicionarioConstrutos[arg.constructor.name](arg);
237
- this.textoSaida += `
237
+ this.textoSaida += `
238
238
  mov ${registrosArgs[index]}, ${valorArg}`;
239
239
  }
240
240
  else {
241
241
  // TODO: push extra args on stack according to target ABI
242
242
  }
243
243
  });
244
- this.textoSaida += `
244
+ this.textoSaida += `
245
245
  call ${nomeFuncao}`;
246
246
  }
247
247
  traduzirConstrutoDefinirValor(construto) {
248
248
  const objeto = this.dicionarioConstrutos[construto.objeto.constructor.name](construto.objeto);
249
249
  const valor = this.dicionarioConstrutos[construto.valor.constructor.name](construto.valor);
250
- this.textoSaida += `
251
- mov rax, ${valor}
250
+ this.textoSaida += `
251
+ mov rax, ${valor}
252
252
  mov [${objeto}], rax`;
253
253
  }
254
254
  traduzirFuncaoConstruto(construto) {
255
255
  const labelFuncao = `func_${this.gerarDigitoAleatorio()}`;
256
- this.textoSaida += `
257
- ${labelFuncao}:
258
- push rbp
256
+ this.textoSaida += `
257
+ ${labelFuncao}:
258
+ push rbp
259
259
  mov rbp, rsp`;
260
260
  // Traduzir corpo da função
261
261
  if (construto.corpo && Array.isArray(construto.corpo)) {
@@ -265,8 +265,8 @@ ${labelFuncao}:
265
265
  }
266
266
  });
267
267
  }
268
- this.textoSaida += `
269
- pop rbp
268
+ this.textoSaida += `
269
+ pop rbp
270
270
  ret`;
271
271
  }
272
272
  traduzirConstrutoLiteral(construto) {
@@ -281,29 +281,29 @@ ${labelFuncao}:
281
281
  const operador = construto.operador.lexema;
282
282
  const labelVerdadeiro = this.gerarLabel();
283
283
  const labelFim = this.gerarLabel();
284
- this.textoSaida += `
285
- mov rax, ${esquerda}
284
+ this.textoSaida += `
285
+ mov rax, ${esquerda}
286
286
  cmp rax, 0`;
287
287
  if (operador === 'e' || operador === '&&') {
288
- this.textoSaida += `
289
- je ${labelFim}
290
- mov rax, ${direita}
291
- cmp rax, 0
292
- je ${labelFim}
293
- ${labelVerdadeiro}:
294
- mov rax, 1
288
+ this.textoSaida += `
289
+ je ${labelFim}
290
+ mov rax, ${direita}
291
+ cmp rax, 0
292
+ je ${labelFim}
293
+ ${labelVerdadeiro}:
294
+ mov rax, 1
295
295
  ${labelFim}:`;
296
296
  }
297
297
  else if (operador === 'ou' || operador === '||') {
298
- this.textoSaida += `
299
- jne ${labelVerdadeiro}
300
- mov rax, ${direita}
301
- cmp rax, 0
302
- jne ${labelVerdadeiro}
303
- mov rax, 0
304
- jmp ${labelFim}
305
- ${labelVerdadeiro}:
306
- mov rax, 1
298
+ this.textoSaida += `
299
+ jne ${labelVerdadeiro}
300
+ mov rax, ${direita}
301
+ cmp rax, 0
302
+ jne ${labelVerdadeiro}
303
+ mov rax, 0
304
+ jmp ${labelFim}
305
+ ${labelVerdadeiro}:
306
+ mov rax, 1
307
307
  ${labelFim}:`;
308
308
  }
309
309
  return 'rax';
@@ -316,26 +316,26 @@ ${labelFim}:`;
316
316
  traduzirConstrutoUnario(construto) {
317
317
  const operando = this.dicionarioConstrutos[construto.operando.constructor.name](construto.operando);
318
318
  const operador = construto.operador.lexema;
319
- this.textoSaida += `
319
+ this.textoSaida += `
320
320
  mov rax, ${operando}`;
321
321
  if (operador === '-') {
322
- this.textoSaida += `
322
+ this.textoSaida += `
323
323
  neg rax`;
324
324
  }
325
325
  else if (operador === '!' || operador === 'nao') {
326
- this.textoSaida += `
327
- cmp rax, 0
328
- sete al
326
+ this.textoSaida += `
327
+ cmp rax, 0
328
+ sete al
329
329
  movzx rax, al`;
330
330
  }
331
331
  else if (operador === '++') {
332
- this.textoSaida += `
333
- inc rax
332
+ this.textoSaida += `
333
+ inc rax
334
334
  mov ${operando}, rax`;
335
335
  }
336
336
  else if (operador === '--') {
337
- this.textoSaida += `
338
- dec rax
337
+ this.textoSaida += `
338
+ dec rax
339
339
  mov ${operando}, rax`;
340
340
  }
341
341
  return 'rax';
@@ -355,8 +355,8 @@ ${labelFim}:`;
355
355
  construto.valores.forEach((valor, index) => {
356
356
  if (this.dicionarioConstrutos[valor.constructor.name]) {
357
357
  const valorTraduzido = this.dicionarioConstrutos[valor.constructor.name](valor);
358
- this.textoSaida += `
359
- mov rax, ${valorTraduzido}
358
+ this.textoSaida += `
359
+ mov rax, ${valorTraduzido}
360
360
  mov [${rotuloVetor} + ${index * 8}], rax`;
361
361
  }
362
362
  });
@@ -376,17 +376,17 @@ ${labelFim}:`;
376
376
  traduzirDeclaracaoEnquanto(declaracao) {
377
377
  const labelInicio = this.gerarLabel();
378
378
  const labelFim = this.gerarLabel();
379
- this.textoSaida += `
379
+ this.textoSaida += `
380
380
  ${labelInicio}:`;
381
381
  const condicao = this.dicionarioConstrutos[declaracao.condicao.constructor.name](declaracao.condicao);
382
- this.textoSaida += `
383
- cmp ${condicao}, 0
382
+ this.textoSaida += `
383
+ cmp ${condicao}, 0
384
384
  je ${labelFim}`;
385
385
  if (this.dicionarioDeclaracoes[declaracao.corpo.constructor.name]) {
386
386
  this.dicionarioDeclaracoes[declaracao.corpo.constructor.name](declaracao.corpo);
387
387
  }
388
- this.textoSaida += `
389
- jmp ${labelInicio}
388
+ this.textoSaida += `
389
+ jmp ${labelInicio}
390
390
  ${labelFim}:`;
391
391
  }
392
392
  traduzirDeclaracaoEscolha(declaracao) {
@@ -397,9 +397,9 @@ ${labelFim}:`;
397
397
  const labelProximo = this.gerarLabel();
398
398
  if (caminho.condicoes && caminho.condicoes[0]) {
399
399
  const valorCaso = this.dicionarioConstrutos[caminho.condicoes[0].constructor.name](caminho.condicoes[0]);
400
- this.textoSaida += `
401
- mov rax, ${valorEscolha}
402
- cmp rax, ${valorCaso}
400
+ this.textoSaida += `
401
+ mov rax, ${valorEscolha}
402
+ cmp rax, ${valorCaso}
403
403
  jne ${labelProximo}`;
404
404
  if (caminho.declaracoes && Array.isArray(caminho.declaracoes)) {
405
405
  caminho.declaracoes.forEach((declaracao) => {
@@ -408,13 +408,13 @@ ${labelFim}:`;
408
408
  }
409
409
  });
410
410
  }
411
- this.textoSaida += `
412
- jmp ${labelFim}
411
+ this.textoSaida += `
412
+ jmp ${labelFim}
413
413
  ${labelProximo}:`;
414
414
  }
415
415
  });
416
416
  }
417
- this.textoSaida += `
417
+ this.textoSaida += `
418
418
  ${labelFim}:`;
419
419
  }
420
420
  traduzirDeclaracaoExpressao(declaracao) {
@@ -425,7 +425,7 @@ ${labelFim}:`;
425
425
  }
426
426
  traduzirDeclaracaoFazer(declaracao) {
427
427
  const labelInicio = this.gerarLabel();
428
- this.textoSaida += `
428
+ this.textoSaida += `
429
429
  ${labelInicio}:`;
430
430
  // Em Delégua, fazer-enquanto tem caminhoFazer que é um Bloco
431
431
  if (declaracao.caminhoFazer && declaracao.caminhoFazer.declaracoes) {
@@ -437,8 +437,8 @@ ${labelInicio}:`;
437
437
  }
438
438
  if (declaracao.condicaoEnquanto) {
439
439
  const condicao = this.dicionarioConstrutos[declaracao.condicaoEnquanto.constructor.name](declaracao.condicaoEnquanto);
440
- this.textoSaida += `
441
- cmp ${condicao}, 0
440
+ this.textoSaida += `
441
+ cmp ${condicao}, 0
442
442
  jne ${labelInicio}`;
443
443
  }
444
444
  }
@@ -453,24 +453,24 @@ ${labelInicio}:`;
453
453
  }
454
454
  }
455
455
  if (this.alvo === 'linux') {
456
- this.textoSaida += `
457
- ; Falhar com mensagem: ${mensagem}
458
- mov eax, 1
459
- mov ebx, 1
456
+ this.textoSaida += `
457
+ ; Falhar com mensagem: ${mensagem}
458
+ mov eax, 1
459
+ mov ebx, 1
460
460
  int 0x80`;
461
461
  }
462
462
  else {
463
- this.textoSaida += `
464
- ; Falhar com mensagem: ${mensagem}
465
- mov eax, 1
463
+ this.textoSaida += `
464
+ ; Falhar com mensagem: ${mensagem}
465
+ mov eax, 1
466
466
  ret`;
467
467
  }
468
468
  }
469
469
  traduzirDeclaracaoFuncao(declaracao) {
470
470
  const nomeFuncao = declaracao.simbolo?.lexema || 'funcao';
471
- this.textoSaida += `
472
- ${nomeFuncao}:
473
- push rbp
471
+ this.textoSaida += `
472
+ ${nomeFuncao}:
473
+ push rbp
474
474
  mov rbp, rsp`;
475
475
  if (declaracao.funcao &&
476
476
  declaracao.funcao.corpo &&
@@ -481,13 +481,13 @@ ${nomeFuncao}:
481
481
  }
482
482
  });
483
483
  }
484
- this.textoSaida += `
485
- pop rbp
484
+ this.textoSaida += `
485
+ pop rbp
486
486
  ret`;
487
487
  }
488
488
  traduzirDeclaracaoImportar(declaracao) {
489
489
  // Importação é tratada em tempo de linkagem
490
- this.textoSaida += `
490
+ this.textoSaida += `
491
491
  ; Importar: ${declaracao.caminho || 'unknown'}`;
492
492
  }
493
493
  traduzirDeclaracaoLeia(declaracao) {
@@ -504,11 +504,11 @@ ${nomeFuncao}:
504
504
  this.bss += ` ${varLabel} resb 256\n`;
505
505
  this.variaveis.set(nomeVar, varLabel);
506
506
  }
507
- this.textoSaida += `
508
- mov eax, 3
509
- mov ebx, 0
510
- mov ecx, ${this.variaveis.get(nomeVar)}
511
- mov edx, 256
507
+ this.textoSaida += `
508
+ mov eax, 3
509
+ mov ebx, 0
510
+ mov ecx, ${this.variaveis.get(nomeVar)}
511
+ mov edx, 256
512
512
  int 0x80`;
513
513
  }
514
514
  traduzirDeclaracaoPara(declaracao) {
@@ -534,12 +534,12 @@ ${nomeFuncao}:
534
534
  }
535
535
  }
536
536
  }
537
- this.textoSaida += `
537
+ this.textoSaida += `
538
538
  ${labelInicio}:`;
539
539
  if (declaracao.condicao) {
540
540
  const condicao = this.dicionarioConstrutos[declaracao.condicao.constructor.name](declaracao.condicao);
541
- this.textoSaida += `
542
- cmp ${condicao}, 0
541
+ this.textoSaida += `
542
+ cmp ${condicao}, 0
543
543
  je ${labelFim}`;
544
544
  }
545
545
  if (this.dicionarioDeclaracoes[declaracao.corpo.constructor.name]) {
@@ -550,8 +550,8 @@ ${labelInicio}:`;
550
550
  this.dicionarioConstrutos[declaracao.incrementar.constructor.name](declaracao.incrementar);
551
551
  }
552
552
  }
553
- this.textoSaida += `
554
- jmp ${labelInicio}
553
+ this.textoSaida += `
554
+ jmp ${labelInicio}
555
555
  ${labelFim}:`;
556
556
  }
557
557
  traduzirDeclaracaoParaCada(declaracao) {
@@ -566,57 +566,57 @@ ${labelFim}:`;
566
566
  if (vetor instanceof construtos_1.Vetor) {
567
567
  tamanhoVetor = vetor.tamanho || 0;
568
568
  }
569
- this.textoSaida += `
570
- xor rcx, rcx
571
- ${rotuloInicio}:
572
- cmp rcx, ${tamanhoVetor}
569
+ this.textoSaida += `
570
+ xor rcx, rcx
571
+ ${rotuloInicio}:
572
+ cmp rcx, ${tamanhoVetor}
573
573
  jge ${rotuloFim}`;
574
574
  if (this.dicionarioDeclaracoes[declaracao.corpo.constructor.name]) {
575
575
  this.dicionarioDeclaracoes[declaracao.corpo.constructor.name](declaracao.corpo);
576
576
  }
577
- this.textoSaida += `
578
- inc rcx
579
- jmp ${rotuloInicio}
577
+ this.textoSaida += `
578
+ inc rcx
579
+ jmp ${rotuloInicio}
580
580
  ${rotuloFim}:`;
581
581
  }
582
582
  traduzirDeclaracaoRetorna(declaracao) {
583
583
  if (declaracao.valor) {
584
584
  const valor = this.dicionarioConstrutos[declaracao.valor.constructor.name](declaracao.valor);
585
- this.textoSaida += `
585
+ this.textoSaida += `
586
586
  mov rax, ${valor}`;
587
587
  }
588
- this.textoSaida += `
589
- pop rbp
588
+ this.textoSaida += `
589
+ pop rbp
590
590
  ret`;
591
591
  }
592
592
  traduzirDeclaracaoSe(declaracao) {
593
593
  const rotuloSenao = this.gerarLabel();
594
594
  const rotuloFim = this.gerarLabel();
595
595
  const condicao = this.dicionarioConstrutos[declaracao.condicao.constructor.name](declaracao.condicao);
596
- this.textoSaida += `
597
- cmp ${condicao}, 0
596
+ this.textoSaida += `
597
+ cmp ${condicao}, 0
598
598
  je ${rotuloSenao}`;
599
599
  if (this.dicionarioDeclaracoes[declaracao.caminhoEntao.constructor.name]) {
600
600
  this.dicionarioDeclaracoes[declaracao.caminhoEntao.constructor.name](declaracao.caminhoEntao);
601
601
  }
602
- this.textoSaida += `
603
- jmp ${rotuloFim}
602
+ this.textoSaida += `
603
+ jmp ${rotuloFim}
604
604
  ${rotuloSenao}:`;
605
605
  if (declaracao.caminhoSenao &&
606
606
  this.dicionarioDeclaracoes[declaracao.caminhoSenao.constructor.name]) {
607
607
  this.dicionarioDeclaracoes[declaracao.caminhoSenao.constructor.name](declaracao.caminhoSenao);
608
608
  }
609
- this.textoSaida += `
609
+ this.textoSaida += `
610
610
  ${rotuloFim}:`;
611
611
  }
612
612
  traduzirDeclaracaoClasse(declaracao) {
613
613
  // Classes em assembly são complexas - implementação básica
614
- this.textoSaida += `
614
+ this.textoSaida += `
615
615
  ; Classe: ${declaracao.simbolo?.lexema || 'unknown'}`;
616
616
  }
617
617
  traduzirDeclaracaoTente(declaracao) {
618
618
  // Try-catch em assembly requer handler complexo
619
- this.textoSaida += `
619
+ this.textoSaida += `
620
620
  ; Tente-pegue`;
621
621
  if (declaracao.caminhoTente && Array.isArray(declaracao.caminhoTente)) {
622
622
  declaracao.caminhoTente.forEach((declaracao) => {
@@ -653,8 +653,8 @@ ${rotuloFim}:`;
653
653
  }
654
654
  else if (this.dicionarioConstrutos[tipoInicializador]) {
655
655
  const valor = this.dicionarioConstrutos[tipoInicializador](declaracao.inicializador);
656
- this.textoSaida += `
657
- mov rax, ${valor}
656
+ this.textoSaida += `
657
+ mov rax, ${valor}
658
658
  mov [${varLabel}], rax`;
659
659
  }
660
660
  }
@@ -674,33 +674,33 @@ ${rotuloFim}:`;
674
674
  return;
675
675
  this.helperPrintIntEmitido = true;
676
676
  this.bss += ` __print_buf resb 24\n`;
677
- this.helpers += `
678
- __delegua_print_int:
679
- push rbx
680
- push rcx
681
- push rdx
682
- push rsi
683
- mov rcx, 10
684
- lea rsi, [__print_buf + 22]
685
- mov byte [rsi], 10
686
- .print_digitloop:
687
- xor rdx, rdx
688
- div rcx
689
- add dl, '0'
690
- dec rsi
691
- mov [rsi], dl
692
- test rax, rax
693
- jnz .print_digitloop
694
- lea rdx, [__print_buf + 23]
695
- sub rdx, rsi
696
- mov ecx, esi
697
- mov ebx, 1
698
- mov eax, 4
699
- int 0x80
700
- pop rsi
701
- pop rdx
702
- pop rcx
703
- pop rbx
677
+ this.helpers += `
678
+ __delegua_print_int:
679
+ push rbx
680
+ push rcx
681
+ push rdx
682
+ push rsi
683
+ mov rcx, 10
684
+ lea rsi, [__print_buf + 22]
685
+ mov byte [rsi], 10
686
+ .print_digitloop:
687
+ xor rdx, rdx
688
+ div rcx
689
+ add dl, '0'
690
+ dec rsi
691
+ mov [rsi], dl
692
+ test rax, rax
693
+ jnz .print_digitloop
694
+ lea rdx, [__print_buf + 23]
695
+ sub rdx, rsi
696
+ mov ecx, esi
697
+ mov ebx, 1
698
+ mov eax, 4
699
+ int 0x80
700
+ pop rsi
701
+ pop rdx
702
+ pop rcx
703
+ pop rbx
704
704
  ret`;
705
705
  }
706
706
  traduzirDeclaracaoEscreva(declaracaoEscreva) {
@@ -709,16 +709,16 @@ __delegua_print_int:
709
709
  const nome_string_literal = this.criaStringLiteral(arg);
710
710
  const tam_string_literal = this.criaTamanhoNaMemoriaReferenteAVar(nome_string_literal);
711
711
  if (this.alvo === 'linux') {
712
- this.textoSaida += `
713
- mov edx, ${tam_string_literal}
714
- mov ecx, ${nome_string_literal}
715
- mov ebx, 1 ; fd stdout
716
- mov eax, 4 ; sys_write
712
+ this.textoSaida += `
713
+ mov edx, ${tam_string_literal}
714
+ mov ecx, ${nome_string_literal}
715
+ mov ebx, 1 ; fd stdout
716
+ mov eax, 4 ; sys_write
717
717
  int 0x80`;
718
718
  }
719
719
  else {
720
- this.textoSaida += `
721
- lea rcx, [rel ${nome_string_literal}]
720
+ this.textoSaida += `
721
+ lea rcx, [rel ${nome_string_literal}]
722
722
  call printf`;
723
723
  }
724
724
  }
@@ -726,8 +726,8 @@ __delegua_print_int:
726
726
  const valor = this.dicionarioConstrutos[arg.constructor.name](arg);
727
727
  if (this.alvo === 'linux') {
728
728
  this.emitirHelperPrintInt();
729
- this.textoSaida += `
730
- mov rax, ${valor}
729
+ this.textoSaida += `
730
+ mov rax, ${valor}
731
731
  call __delegua_print_int`;
732
732
  }
733
733
  else {
@@ -735,24 +735,24 @@ __delegua_print_int:
735
735
  this.data += ` __fmt_int db '%d', 10, 0\n`;
736
736
  this.fmtIntWindowsEmitido = true;
737
737
  }
738
- this.textoSaida += `
739
- mov rdx, ${valor}
740
- lea rcx, [rel __fmt_int]
738
+ this.textoSaida += `
739
+ mov rdx, ${valor}
740
+ lea rcx, [rel __fmt_int]
741
741
  call printf`;
742
742
  }
743
743
  }
744
744
  }
745
745
  saidaSistema() {
746
746
  if (this.alvo === 'linux') {
747
- this.textoSaida += `
748
- mov eax, 1 ; sys_exit
749
- xor ebx, ebx ; status 0
747
+ this.textoSaida += `
748
+ mov eax, 1 ; sys_exit
749
+ xor ebx, ebx ; status 0
750
750
  int 0x80`;
751
751
  }
752
752
  else {
753
753
  // Windows: return from main with 0 in EAX
754
- this.textoSaida += `
755
- xor eax, eax
754
+ this.textoSaida += `
755
+ xor eax, eax
756
756
  ret`;
757
757
  }
758
758
  }
@@ -1,4 +1,4 @@
1
- import { AcessoElementoMatriz, AcessoIndiceVariavel, AcessoIntervaloVariavel, AcessoMetodo, AcessoMetodoOuPropriedade, AcessoPropriedade, Agrupamento, ArgumentoReferenciaFuncao, AtribuicaoPorIndice, AtribuicaoPorIndicesMatriz, Atribuir, Binario, Chamada, ComentarioComoConstruto, Constante, DefinirValor, Dicionario, ExpressaoRegular, FimPara, FormatacaoEscrita, FuncaoConstruto, Isto, Leia, Literal, Logico, ReferenciaFuncao, Separador, Super, TipoDe, Tupla, TuplaN, Unario, Variavel, Vetor } from '../construtos';
1
+ import { AcessoElementoMatriz, AcessoIndiceVariavel, AcessoIntervaloVariavel, AcessoMetodo, AcessoMetodoOuPropriedade, AcessoPropriedade, Agrupamento, ArgumentoReferenciaFuncao, AtribuicaoPorIndice, AtribuicaoPorIndicesMatriz, Atribuir, Binario, Chamada, ComentarioComoConstruto, Constante, DefinirValor, Dicionario, ExpressaoRegular, FimPara, FormatacaoEscrita, FuncaoConstruto, Isto, Leia, Literal, Logico, Morsa, ReferenciaFuncao, Separador, Super, TipoDe, Tupla, TuplaN, Unario, Variavel, Vetor } from '../construtos';
2
2
  import { Bloco, CabecalhoPrograma, Classe, Comentario, Const, ConstMultiplo, Continua, Declaracao, Enquanto, Escolha, Escreva, EscrevaMesmaLinha, Expressao, Falhar, Fazer, FuncaoDeclaracao, InicioAlgoritmo, Para, ParaCada, Retorna, Se, Sustar, TendoComo, Tente, TextoDocumentacao, Var, VarMultiplo } from '../declaracoes';
3
3
  import { CaminhoEscolha, TradutorInterface, VisitanteComumInterface } from '../interfaces';
4
4
  import { ArestaFluxograma, SubgrafoClasse, SubgrafoFuncao, VerticeFluxograma } from './mermaid';
@@ -84,6 +84,7 @@ export declare class TradutorMermaidJs implements TradutorInterface<Declaracao>,
84
84
  visitarExpressaoTipoDe(expressao: TipoDe): Promise<any> | void;
85
85
  visitarExpressaoUnaria(expressao: Unario): Promise<string>;
86
86
  visitarExpressaoVetor(expressao: Vetor): Promise<string>;
87
+ visitarExpressaoMorsa(expressao: Morsa): Promise<any>;
87
88
  /**
88
89
  * Traduz uma declaração de Expressao que contém uma chamada de função,
89
90
  * criando os vértices necessários para conectar ao subgrafo da função.