12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import * as Models from '../visualUI/ivprog_elements';
- function parseGlobal (global_obj) {
- var new_global = new Models.Variable(
- global_obj.type,
- global_obj.name,
- global_obj.value);
-
- new_global.is_constant = global_obj.is_const;
- new_global.columns = global_obj.columns;
- new_global.dimension = global_obj.dimension;
- new_global.rows = global_obj.rows;
-
- window.program_obj.addGlobal(new_global);
- }
- function parseParameter (parameter_obj) {
- const new_parameter = new Models.Variable(
- parameter_obj.type,
- parameter_obj.name,
- null,
- parameter_obj.dimension,
- parameter_obj.is_const,
- parameter_obj.rows,
- parameter_obj.columns,
- parameter_obj.reference
- );
- return new_parameter;
- }
- function parseFunction (function_obj) {
- console.log(function_obj)
-
- const new_function = new Models.Function(
- function_obj.name,
- function_obj.return_type,
- function_obj.return_dimensions,
- [],
- false,
- false,
- []);
-
- if (!new_function.name) {
- new_function.name = LocalizedStrings.getUI("start");
- new_function.is_main = true;
- }
- if (function_obj.parameters_list) {
- function_obj.parameters_list.forEach(function(el){
- new_function.parameters_list.push(parseParameter(el));
- });
- }
- window.program_obj.addFunction(new_function);
-
- }
- export function parserCodeVisual (code_obj = null) {
- console.log('chegou!', code_obj)
- window.conteudo = code_obj
- // Globals:
- window.program_obj.globals = [];
- code_obj.globals.forEach(parseGlobal);
- // Functions:
- window.program_obj.functions = [];
- code_obj.functions.forEach(parseFunction);
- }
|