|
@@ -1372,6 +1372,15 @@ function getVariable (function_obj, search) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 3. Procurar na lista de parâmetros:
|
|
|
+ if (!variavel)
|
|
|
+ for (var j = 0; j < function_obj.parameters_list.length; j++) {
|
|
|
+ if (function_obj.parameters_list[j].name == search.value) {
|
|
|
+ variavel = function_obj.parameters_list[j];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (search.instance == "expression"
|
|
@@ -1391,27 +1400,68 @@ function getVariable (function_obj, search) {
|
|
|
if (search.instance == "expression"
|
|
|
&& search.type == "var"
|
|
|
&& search.class == "vector") {
|
|
|
- /*
|
|
|
- variable_and_value = 7,
|
|
|
- content = null,
|
|
|
- row = null,
|
|
|
- column = null,
|
|
|
- include_constant = true,
|
|
|
- dimensions = 0
|
|
|
- */
|
|
|
+
|
|
|
+ var obj = new Models.VariableValueMenu(
|
|
|
+ VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
|
|
|
+ variavel,
|
|
|
+ null,
|
|
|
+ getVariable(function_obj, search.line[0]),
|
|
|
+ true
|
|
|
+ );
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (search.instance == "expression"
|
|
|
+ && search.type == "var"
|
|
|
+ && search.class == "matrix") {
|
|
|
var obj = new Models.VariableValueMenu(
|
|
|
VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
|
|
|
variavel,
|
|
|
+ getVariable(function_obj, search.line[0]),
|
|
|
+ getVariable(function_obj, search.column[0]),
|
|
|
+ true
|
|
|
+ );
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (search.instance == "expression"
|
|
|
+ && search.type == "function") {
|
|
|
+ var obj = new Models.VariableValueMenu(
|
|
|
+ VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
|
|
|
+ null,
|
|
|
null,
|
|
|
null,
|
|
|
true
|
|
|
);
|
|
|
-
|
|
|
+ // Procurar a função para referência:
|
|
|
+ for (var i = 0; i < program_obj.functions.length; i++) {
|
|
|
+ if (program_obj.functions[i].name == search.value) {
|
|
|
+ obj.function_called = program_obj.functions[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ obj.parameters_list = [];
|
|
|
+
|
|
|
+ for (var i = 0; i < search.params.length; i++) {
|
|
|
+ obj.parameters_list.push(getVariable(function_obj,search.params[i][0]));
|
|
|
+ }
|
|
|
+ return obj;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function expressionParserToVisual (text, function_obj, input_field) {
|
|
|
+
|
|
|
+ if (text.trim().length == 0) {
|
|
|
+ return [new Models.VariableValueMenu(
|
|
|
+ VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ true
|
|
|
+ )];
|
|
|
+ }
|
|
|
+
|
|
|
var var_not_found = [];
|
|
|
+ var fun_not_found = [];
|
|
|
var parsed;
|
|
|
try {
|
|
|
parsed = ivprogCore.parseExpression(text);
|
|
@@ -1432,7 +1482,7 @@ export function expressionParserToVisual (text, function_obj, input_field) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 2. Procurar a variável nas gloais:
|
|
|
+ // 2. Procurar a variável nas globais:
|
|
|
if (!variavel)
|
|
|
for (var j = 0; j < program_obj.globals.length; j++) {
|
|
|
if (program_obj.globals[j].name == parsed[i].value) {
|
|
@@ -1440,10 +1490,41 @@ export function expressionParserToVisual (text, function_obj, input_field) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 3. Procurar a variável nos parâmetros:
|
|
|
+ if (!variavel)
|
|
|
+ for (var j = 0; j < function_obj.parameters_list.length; j++) {
|
|
|
+ if (function_obj.parameters_list[j].name == parsed[i].value) {
|
|
|
+ variavel = function_obj.parameters_list[j];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (!variavel)
|
|
|
var_not_found.push(parsed[i].value);
|
|
|
}
|
|
|
+
|
|
|
+ var funcao;
|
|
|
+ if (parsed[i].instance == "expression"
|
|
|
+ && parsed[i].type == "function") {
|
|
|
+
|
|
|
+ // Procurar a função para referência:
|
|
|
+ for (var j = 0; j < program_obj.functions.length; j++) {
|
|
|
+ if (program_obj.functions[j].name == parsed[i].value) {
|
|
|
+ funcao = program_obj.functions[j];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!funcao) {
|
|
|
+ fun_not_found.push(parsed[i].value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+ if (fun_not_found.length > 0) {
|
|
|
+ let uniqueWords = [...new Set(fun_not_found)];
|
|
|
+ Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_undeclared_function') + " " + uniqueWords.join(", "));
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
if (var_not_found.length > 0) {
|