';
if (function_obj.comentario_funcao) {
appender += renderComment(function_obj.comentario_funcao, sequence, true, -1);
}
appender += '
'+i18n('function')+' ';
if (function_obj.eh_principal) {
appender += '
' + i18n('void') + ' '+function_obj.nome+'
'
+ '(
';
} else {
appender += renderFunctionReturn(function_obj, sequence);
appender += '
'+function_obj.nome+'
'
+ '(
';
}
appender += renderFunctionParameters(function_obj, sequence);
appender += '
) {
'
+ (function_obj.esta_oculta ? '
' : '
')
+ '
'
+ renderVariables(function_obj, sequence)
+ '
'
+ '
';
if (programa.funcoes[sequence].comandos) {
for (l = 0; l < programa.funcoes[sequence].comandos.length; l++) {
appender += renderElementCommandGeneric(programa.funcoes[sequence].comandos[l], sequence, l, -1, l);
}
}
appender += '
';
appender += '
}
'
+ '
'
+ '
';
$('.all_functions').append(appender);
}
function renderElementCommandGeneric(command, sequence, l, parent, fullpath) {
if (command.tipo == tiposComandos.comment) {
return renderComment(command, sequence, false, l, parent, fullpath);
}
if (command.tipo == tiposComandos.reader) {
return renderReader(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.writer) {
return renderWriter(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.attribution) {
return renderAttribution(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.iftrue) {
return renderIfTrue(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.repeatNtimes) {
return renderRepeatNtimes(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.whiletrue) {
return renderWhiletrue(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.dowhiletrue) {
return renderDowhiletrue(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.switch) {
return renderSwitch(command, sequence, l, parent, fullpath);
}
if (command.tipo == tiposComandos.functioncall) {
return renderFunctioncall(command, sequence, l, parent, fullpath);
}
}
function renderFunctioncall(functioncall_obj, function_index, functioncall_index, data_parent, fullpath) {
var ret = '';
ret += '
funcao() ';
ret += '
';
return ret;
}
function renderSwitch(switch_obj, function_index, repeat_index, data_parent, fullpath) {
var ret = '';
ret += '
escolha (x) {
caso 1:
caso 2:
}';
ret += '
';
return ret;
}
function renderDowhiletrue(dowhiletrue_obj, function_index, repeat_index, data_parent, fullpath) {
var ret = '';
ret += '
faça { ';
ret += '
';
if ((dowhiletrue_obj.commands_block == null)
|| (dowhiletrue_obj.commands_block.length == 0)) {
} else {
for (i = 0; i < dowhiletrue_obj.commands_block.length; i ++) {
ret += renderElementCommandGeneric(dowhiletrue_obj.commands_block[i], function_index, i, repeat_index, (fullpath + ',' + i));
}
}
ret += '
';
ret += '
} enquanto (x < 10); ';
ret += '
';
return ret;
}
function renderWhiletrue(whiletrue_obj, function_index, repeat_index, data_parent, fullpath) {
var ret = '';
ret += '
enquanto (x < 10) { ';
ret += '
';
if ((whiletrue_obj.commands_block == null)
|| (whiletrue_obj.commands_block.length == 0)) {
} else {
for (i = 0; i < whiletrue_obj.commands_block.length; i ++) {
ret += renderElementCommandGeneric(whiletrue_obj.commands_block[i], function_index, i, repeat_index, (fullpath + ',' + i));
}
}
ret += '
';
ret += '
}';
ret += '
';
return ret;
}
function renderRepeatNtimes(repeat_obj, function_index, repeat_index, data_parent, fullpath) {
var ret = '';
ret += '
para (x = 0; x < 10; x ++) { ';
ret += '
';
if ((repeat_obj.commands_block == null)
|| (repeat_obj.commands_block.length == 0)) {
} else {
for (i = 0; i < repeat_obj.commands_block.length; i ++) {
ret += renderElementCommandGeneric(repeat_obj.commands_block[i], function_index, i, repeat_index, (fullpath + ',' + i));
}
}
ret += '
';
ret += '
}';
ret += '
';
return ret;
}
function renderIfTrue(writer_obj, function_index, iftrue_index, data_parent, fullpath) {
var ret = '';
ret += '
if (x < 1) { ';
ret += '
';
if ((writer_obj.commands_block == null)
|| (writer_obj.commands_block.length == 0)) {
} else {
for (i = 0; i < writer_obj.commands_block.length; i ++) {
ret += renderElementCommandGeneric(writer_obj.commands_block[i], function_index, i, iftrue_index, (fullpath + ',' + i));
}
}
ret += '
';
ret += '
} else { ';
ret += '
';
if ((writer_obj.commands_else == null)
|| (writer_obj.commands_else.length == 0)) {
} else {
for (i = 0; i < writer_obj.commands_else.length; i ++) {
ret += renderElementCommandGeneric(writer_obj.commands_else[i], function_index, i, iftrue_index, (fullpath + ',' + i));
}
}
ret += '
';
ret += '
}';
ret += '
';
return ret;
}
function renderAttribution(writer_obj, function_index, attr_index, data_parent, fullpath) {
var ret = '';
ret += '
x = 1 + 1';
ret += '
';
return ret;
}
function renderWriter(writer_obj, function_index, reader_index, data_parent, fullpath) {
var ret = '';
ret += '
'+i18n('write')+' x';
ret += '
';
return ret;
}
function renderReader(reader_obj, function_index, reader_index, data_parent, fullpath) {
var ret = '';
ret += '
'+i18n('read')+' ';
ret += '';
ret += '
';
return ret;
}
function renderComment(comment_obj, function_index, is_function_comment, comment_index, data_parent, fullpath) {
var ret = '';
ret += '';
return ret;
}
// Essa função imprime os parâmetros e cria os elementos para a sua manipulação
function renderFunctionParameters(function_obj, sequence) {
var ret = "";
if (function_obj.lista_parametros != null) {
for (var j = 0; j < function_obj.lista_parametros.length; j++) {
var par_temp = function_obj.lista_parametros[j];
ret += '
'+par_temp.nome+' ';
ret += '
';
if (par_temp.dimensoes > 0) {
ret += '
'+ i18n(tiposDados.vector)+':'+i18n(par_temp.tipo);
ret += '
';
} else {
ret += '
'+i18n(par_temp.tipo)+'
';
}
ret += '
'
+ '
';
ret += '
';
}
}
return ret;
}
// Essa função imprime as variáveis e os recursos para sua manipulação
function renderVariables(function_obj, sequence) {
var ret = "";
if (function_obj.variaveis != null) {
for (var j = 0; j < function_obj.variaveis.length; j++) {
var par_temp = function_obj.variaveis[j];
ret += '
'+par_temp.nome+' ';
ret += '
';
if (par_temp.dimensoes > 0) {
ret += '
'+ i18n(tiposDados.vector)+':'+i18n(par_temp.tipo);
for (i = 0; i < par_temp.dimensoes; i ++) {
ret += ' [ ] ';
}
ret += '
';
} else {
ret += '
'+i18n(par_temp.tipo)+'
';
}
ret += '
'
+ '
= ';
if (par_temp.dimensoes == 0) {
if (par_temp.tipo == tiposDados.real) {
ret += '
'+par_temp.valor.toFixed(1)+'
';
} else {
if (par_temp.tipo == tiposDados.boolean) {
ret += '
'+par_temp.valor+'
';
} else {
ret += '
'+par_temp.valor+'
';
}
}
} else {
ret += '
';
if (par_temp.dimensoes == 1) {
ret += '';
if (par_temp.tipo == tiposDados.real) {
for (var k = 0; k < par_temp.colunas; k++) {
ret += ''+par_temp.valor[k].toFixed(1)+''+' | ';
}
} else {
for (var k = 0; k < par_temp.colunas; k++) {
if (par_temp.tipo == tiposDados.boolean) {
ret += ''+par_temp.valor[k]+''+' | ';
} else {
ret += ''+par_temp.valor[k]+''+' | ';
}
}
}
ret += '
';
ret += '
';
ret += '
'
+ '
';
}
if (par_temp.dimensoes == 2) {
if (par_temp.tipo == tiposDados.real) {
for (var l = 0; l < par_temp.linhas; l++) {
ret += '
';
for (var k = 0; k < par_temp.colunas; k++) {
ret += ''+par_temp.valor[l][k].toFixed(1)+''+' | ';
}
ret += '
';
}
} else {
for (var l = 0; l < par_temp.linhas; l++) {
ret += '
';
for (var k = 0; k < par_temp.colunas; k++) {
if (par_temp.tipo == tiposDados.boolean) {
ret += ''+par_temp.valor[l][k]+''+' | ';
} else {
ret += ''+par_temp.valor[l][k]+''+' | ';
}
}
ret += '
';
}
}
if (par_temp.linhas == 0) {
ret += '
|
';
}
ret += '
'
+ ' |
';
ret += '';
ret += '
'
+ '
';
}
}
ret += '
';
}
}
return ret;
}
// Essa função imprime o tipo de retorno da função e cria o menu do tipo 'select' para alteração
function renderFunctionReturn(function_obj, sequence) {
var ret = '
';
if (function_obj.dimensoes_retorno > 0) {
ret += '
'+ i18n(tiposDados.vector)+':'+i18n(function_obj.tipo_retorno);
ret += '
';
} else {
ret += '
'+i18n(function_obj.tipo_retorno)+'
';
}
ret += '
'
+ '
';
return ret;
}
$.fn.textWidth = function(text, font) {
if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('
').hide().appendTo(document.body);
$.fn.textWidth.fakeEl.text(text || this.val() || this.text() || this.attr('placeholder')).css('font', font || this.css('font'));
return $.fn.textWidth.fakeEl.width();
};