ivprog-visual-1.0.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Definição das classes utilizadas para armazenar o algoritmo
  2. // Não adicionar elementos ao tipoDados, pois existem componentes que dependem do seu tamanho e isso afetará seu funcionamento
  3. var tiposDados = Object.freeze({void:"void", integer:"integer", real:"real", text:"text", boolean:"boolean", vector:"vector"});
  4. var Variavel = function(tipo, nome, valor, dimensoes = 0, eh_constante = false) {
  5. this.tipo = tipo;
  6. this.nome = nome;
  7. this.valor = valor;
  8. this.dimensoes = dimensoes;
  9. this.eh_constante = eh_constante;
  10. };
  11. var Funcao = function(nome, tipo_retorno = tiposDados.void, dimensoes_retorno = 0, lista_parametros = null, eh_principal = false, esta_oculta = false) {
  12. this.nome = nome;
  13. this.tipo_retorno = tipo_retorno;
  14. this.dimensoes_retorno = dimensoes_retorno;
  15. this.lista_parametros = lista_parametros;
  16. this.eh_principal = eh_principal;
  17. this.esta_oculta = esta_oculta;
  18. };
  19. var Comando = function(tipo) {
  20. this.tipo = tipo;
  21. };
  22. var Expressao = function(conteudo) {
  23. this.conteudo = conteudo;
  24. };
  25. var Programa = function () {
  26. this.funcoes = new Array();
  27. };
  28. function adicionarFuncao(funcao) {
  29. programa.funcoes.push(funcao);
  30. }
  31. //var tex = i18n('text');
  32. // Adicionando a função principal automaticamente
  33. var programa = new Programa();
  34. var funcaoPrincipal = new Funcao(i18n("start"), tiposDados.void, 0, new Array(), true);
  35. //funcaoPrincipal.lista_parametros.push(new Variavel(tiposDados.text, "args"));
  36. adicionarFuncao(funcaoPrincipal);
  37. var funcaoSomar = new Funcao("somar", tiposDados.integer, 0, new Array(), false);
  38. funcaoSomar.lista_parametros.push(new Variavel(tiposDados.integer, "a"));
  39. funcaoSomar.lista_parametros.push(new Variavel(tiposDados.integer, "b"));
  40. adicionarFuncao(funcaoSomar);