: $1","test_case_exception":"Ocorreu uma exceção no caso de teste $0: $1","invalid_type_conversion":"O valor $0 não pode ser convertido para o tipo $1","invalid_read_type":"Erro na linha $0: A entrada \"$1\" não é do tipo $2, que é o tipo da variável
.","invalid_read_type_array":"Erro na linha $0: A entrada \"$1\" não é do tipo $2, que é o tipo aceito pela variável
que é um $4.","inform_valid_identifier":"Informe um nome válido! O nome não pode ser uma palavra reservadas e deve começar com letras ou _ e conter apenas letras, números e _.","inform_valid_global_duplicated":"Já existe uma variável global com o nome
, você precisa de nomes distintos.","inform_valid_variable_duplicated":"Já existe uma variável com o nome
, você precisa de nomes distintos.","inform_valid_function_duplicated":"Já existe uma função com o nome
, você precisa de nomes distintos.","inform_valid_param_duplicated":"Já existe um parâmetro com o nome
, você precisa de nomes distintos.","invalid_character":"O caractere $0 na linha $1 não pode ser utilizado neste contexto.","annonymous_array_literal":"Erro na linha $0: a notação de vetor/matriz só permitida durante a inicialização de uma variável desse tipo. Ex: inteiro vec[3] ← {1,2,3}.","invalid_matrix_literal_line":"A expressão $0 na linha $1 não possui um número de elementos igual a linha anterior. Todas as linhas de uma matriz devem ter a mesma quantidade de elementos.","cannot_infer_matrix_line":"Não é possível inferir o número de linhas da matriz $0 na linha $1. É necessário que ela seja inicializada ou que o valor seja informado de forma explícita.","cannot_infer_matrix_column":"Não é possível inferir o número de colunas da matriz $0 na linha $1. É necessário que ela seja inicializada ou que o valor seja informado de forma explícita.","cannot_infer_vector_size":"Não é possível inferir o número de elementos do vetor $0 na linha $1. É necessário que ele seja inicializado ou que o valor seja informado de forma explícita","matrix_to_vector_literal_attr":"Erro na linha $0: A expressão $1 representa uma matriz e não pode ser atribuída ao vetor $2.","vector_to_matrix_literal_attr":"Erro na linha $0: A expressão $1 representa um vetor e não pode ser atribuído a matriz $2.","invalid_const_ref_full":"A variável $0 fornecida como parâmetro para a função $1 na linha $2 é uma constante e não pode ser usada neste contexto. Use uma variável ou posição de vetor.","invalid_const_ref":"A variável $0 fornecida como parâmetro para a função $1 é uma constante e não pode ser usada neste contexto. Use uma variável ou posição de vetor.","invalid_const_assignment_full":"Erro na linha $0: $1 é uma constante e portanto não pode ter seu valor alterado","invalid_const_assignment":"$0 é uma constante e portanto não pode ter seu valor alterado","array_init_not_literal":"Erro na linha $0: Vetor/Matriz só pode ser inicializado por literal. Ex: real vetor[] <- {1,2,3}","array_exceeds_2d":"Erro na linha $0: O número máximo de dimensões que um arranjo pode ter é 2. Elemento de 3 ou mais dimensões encontrado!","invalid_matrix_id_dimension":"Erro na linha $0: Você deve definir todas as dimensões da matriz quando uma delas é definida por uma variável! Ex: real mat1[var][5], mat2[5][var]","invalid_vector_init":"Erro na linha $0: Não se pode inicializar um vetor que teve seu tamanho declarado utilizando uma variável! Utilize uma atribuição de vetores ou use um laço de repetição.","invalid_matrix_init":"Erro na linha $0: Não se pode inicializar uma matrix que teve ao menos uma das suas dimensões declaradas utilizando uma variável! Utilize uma atribuição de matrizes ou use um laço de repetição.","invalid_vector_assignment_full":"Erro na linha $0: Só se pode atribuir um vetor a outro desde que eles comportem o mesmo número de elementos. $1 comporta $2 e $3 comporta $4!","invalid_vector_assignment":"Só se pode atribuir um vetor a outro desde que eles comportem o mesmo número de elementos. $0 comporta $1 e $2 comporta $3!","invalid_matrix_assignment_full":"Erro na linha $0: Só se pode atribuir uma matriz a outra desde que ambas possuam dimensões de mesmo tamanho. $1 tem $2 linhas e $3 colunas, enquanto $4 possui $5 linhas e $6 colunas!","invalid_matrix_assignment":"Só se pode atribuir uma matriz a outra desde que ambas possuam dimensões de mesmo tamanho. $0 tem $1 linhas e $2 colunas, enquanto $3 possui $4 linhas e $5 colunas!","matrix_to_vector_attr":"Erro na linha $0: $1 representa uma matriz e não pode ser atribuída ao vetor $2.","vector_to_matrix_attr":"Erro na linha $0: $1 representa um vetor e não pode ser atribuído a matriz $2.","invalid_matrix_index_assign_full":"Erro na linha $0: A posição $1 da matriz $2 aceita apenas vetores de tamanho $3, mas $4 tem tamanho $5","invalid_matrix_index_assign":"A linha $0 da matriz $1 aceita apenas vetores de tamanho $2, mas $3 tem tamanho $4","invalid_number_elements_vector":"Esperava-se por $0 elementos na linha $1 mas a expressão $2 possui $3 elementos.","invalid_number_lines_matrix":"Esperava-se por uma matriz com $0 linhas na linha $1 mas a expressão $2 possui $3 linhas","divsion_by_zero_full":"Erro na linha $0: A expressão $1 resulta em uma divisão por 0.","divsion_by_zero":"A expressão $0 resulta em uma divisão por 0.","undefined_tanget_value":"Erro na linha $0: A tangente de $1° não é indefinida.","negative_log_value":"Erro na linha $0: Não se pode calcular o log de um valor negativo.","invalid_string_index":"Erro na linha $0 durante a execução da função $1: $2 é um índice inválido para a cadeia de texto $3. Os valores válidos vão de 0 à $4","negative_sqrt_value":"Erro na linha $0: Não é permitido calcular a raiz quadrada de um número negativo.","exceeded_recursive_calls":"Erro na execução da linha $0: Número de chamadas recursivas execedeu o limite máximo definido!","invalid_for_variable":"Erro na linha $0: A variavel $1 utilizada no comando repita_para deve ser do tipo inteiro.","invalid_for_from":"Erro na linha $0: O valor $1 passado para o parâmetro 'de' do comando repita_para deve ser do tipo inteiro.","invalid_for_to":"Erro na linha $0: O valor $1 passado para o parâmetro 'para' do comando repita_para deve ser do tipo inteiro.","invalid_for_pass":"Erro na linha $0: O valor $1 passado para o parâmetro 'passo' do comando repita_para deve ser do tipo inteiro.","exceed_max_instructions":"Número de instruções excedeu o limite definido. Certifique-se que seu código não possui laços infinitos ou muitas chamadas de funções recursivas."},"en":{"token_missing_one":"Syntax error: Expected $0 but found $1 at line:$2, column:$3","token_missing_two":"Syntax error: Expected $0 or $1 but found $2 at line:$3, column: $4","eos_missing":"A new line or a ‘;’ is missing at line: $0, column: $1","invalid_type":"$0 at line: $1, column: $2 is a invalid type. The valid types are: $3","invalid_array_dimension":"Invalid dimension at line: $0, column: $1. Insert a $2 or a valid identifier of the same type.","invalid_array_size":"The array at line $0 exceeds the maximum size of 2.","extra_lines":"No text is allowed after '}' in 'program { … }'","invalid_main_return":"The function $0 declared at line $2 must return $1.","invalid_var_declaration":"Error at line $0: Variables can only be declared in the main body of a function and at the first lines, before any command.","invalid_break_command":"Error at line $0. The command $1 cannot be used outside a loop command or ‘switch ...case’ structure.","invalid_terminal":"It is not possible to use $0 in the expression at line: $1, column: $2. Try a numeric value, variable or function call.","const_not_init":"Error at line: $0, column: $1. A variable declared as const must be initialized.","id_missing":"Expected an identifier but found $0 at line: $1, column: $2.","invalid_id_format":"$0 at line: $1, column: $2 is not a valid identifier. The symbol '.' is not permitted in this context.","main_missing":"The main function was not found. You need to declare a function of return type void named main.","invalid_global_var":"Critical Error: Invalid call of the function IVProgProcessor.initGlobal outside the BASE context.","not_implemented":"Critial internal error: The system defined function $0 was not found.","function_missing":"The function $0 was not found.","function_missing_full":"The function $0 at line: $1, column: $2 was not found.","invalid_parameters_size_full":"Error at line $0: The number of parameters provided to the function $1 is incorrect. It expected $2 but found $3.","invalid_parameters_size":"The number of parameters provided to the function $0 is incorrect. It expected $1 but found $2.","invalid_ref_full":"The expression $0 provided as a parameter to the function $1 at line $2 is not valid in this context. Use a variable or a position of a vector.","invalid_ref":"The expression $0 provided as a parameter to the function $1 is not valid in this context. Use a variable or a position of a vector.","invalid_parameter_type_full":"The expression $0 provided as a parameter to the function $1 at line $2 is not of the expected type.","invalid_parameter_type":"The expression $0 provided as a parameter to the function $1 is not of the expected type.","unknown_command_full":"Internal error: an unknown command found at line $0.","unknown_command":"Internal error: an unknown command found.","loop_condition_type_full":"Error at line: $0, column $1: the condition $2 of the loop must be of type bool (true or false).","loop_condition_type":"The condition $0 of the loop must be of type bool (true or false).","endless_loop_full":"Possible infinite loop detected in your code. Check line $0.","endless_loop":"Possible infinite loop detected in your code.","for_condition_type_full":"Erro na linha: $0, coluna $1: a condição de parada $2 do comando para(...) deve ser do tipo lógico","for_condition_type":"A condição de parada $0 do comando para(...) deve ser do tipo lógico","if_condition_type_full":"Error at line: $0, column $1: the condition $2 in the if … else command must result in a bool (true or false).","if_condition_type":"The condition $0 in the if … else command must result in a bool (true or false).","invalid_return_type_full":"Error at line $0: The expression doest not result in a type compatible with the function $1. Expected type: $2.","invalid_return_type":"The expression doest not result in a type compatible with the function $0. Expected type: $1.","invalid_void_return_full":"Error at line $0: The function $1 cannot return an empty expression, use an expression that results in a $2","invalid_void_return":"The function $0 cannot return an empty expression, use an expression that results in a $1","unexpected_break_command_full":"Critical error at line $0: a break command was found outside a valid context: loop or switch … case structure.","unexpected_break_command":"Critical error: a break command was found outside a valid context: loop or switch … case structure.","invalid_dimension":"Array (vector or matrix) dimensions must be of type int.","void_in_expression_full":"Error at line: $0, column: $1: The function $2 cannot be used inside an expression since its return type is void.","void_in_expression":"The function $0 cannot be used inside an expression since its return type is void.","invalid_array_access_full":"Identifier $0 at line: $1, column: $2 does not identify a valid vector or matrix.","invalid_array_access":"Identifier $0 does not identify a valid vector or matrix.","invalid_matrix_access_full":"Identifier $0 at line: $1, column: $2 does not identify a valid matrix.","invalid_matrix_access":"Identifier $0 does not identify a valid matrix.","matrix_column_outbounds_full":"Error at line $0: The number of columns $1 is invalid for the matrix $2 which has $3 columns.","matrix_column_outbounds":"The number of columns $0 is invalid for the matrix $1 which has $2 columns.","matrix_line_outbounds_full":"Error at line $0: The number of lines $1 is invalid for matrix $2 which has $3 lines.","matrix_line_outbounds":"The number of lines $0 is invalid for matrix $1 which has $2 lines.","vector_line_outbounds_full":"Error at line $0: The number of elements $1 is invalid for vector $2 which has $3 elements.","vector_line_outbounds":"Error at line $0: The number of elements $1 is invalid for vector $2 which has $3 elements.","vector_not_matrix_full":"Error at line $0: $1 is not a matrix.","vector_not_matrix":"$0 is not a matrix.","invalid_infix_op_full":"Error at line $0: The expression $1 is not valid because the operator $2 cannot be applied to the types $3 and $4.","invalid_infix_op":"The expression $0 is not valid because the operator $1 cannot be applied to the types $2 and $3.","invalid_unary_op_full":"Error at line $0: The expression $1 is not valid because the operator $2 cannot be applied to the type $3.","invalid_unary_op":"The expression $0 is not valid because the operator $1 cannot be applied to the type $2.","unknown_op":"Critical error: Unknown operator $0.","duplicate_function":"The function $0 at line: $1, column: $2 has already been declared.","duplicate_variable":"The variable $0 at line: $1, column: $2 has already been declared.","main_parameters":"The main function cannot have parameters.","symbol_not_found_full":"The variable $0 at line: $1, column: $2 has not been declared.","symbol_not_found":"The variable $0 has not been declared.","array_dimension_not_int_full":"The array (vector or matrix) dimensions at line $0 must be of type int.","array_dimension_not_int":"An array (vector or matrix) dimensions must be of type int.","array_dimension_not_positive_full":"The array (vector or matrix) dimensions at line $0 must be positive.","array_dimension_not_positive":"An array (vector or matrix) dimensions must be positive.","incompatible_types_full":"It expected $0 but the expression $1 at line $2 results in $3.","incompatible_types":"It expected $0 but the expression $1 results in $2.","incompatible_types_array_full":"The expression $0 at line $2 is not compatible with type $1.","incompatible_types_array":"The expression $0 is not compatible with type $1.","invalid_case_type_full":"The case expression $0 at line $1 is not compatible with type $2.","invalid_case_type":"The case expression $0 is not compatible with type $1.","function_no_return":"The function $0 does not have a reacheable return command. Every function must have at least one return command in its main body.","invalid_array_literal_type_full":"Error at line $0: the expression $1 does not result in a compatible type.","invalid_array_literal_type":"The expression $0 does not result in a compatible type.","invalid_array_literal_line_full":"Error at line $0: it expected $1 lines but found $2.","invalid_array_literal_line":"It expected $0 lines but found $1.","invalid_array_literal_column_full":"Error at line $0: it expected $1 column but found $2.","invalid_array_literal_column":"It expected $0 column but found $1.","exceeded_input_request":"The amount of reads requested exceeded the amount of inputs available.","test_case_few_reads":"Teste case $0 failed: there are available inputs remaining.","test_case_failed":"
Test case $0 failed : $1","test_case_exception":"An exception has ocurred during the execution of test case $0: $1","invalid_type_conversion":"The value $0 cannot be converted to type $1.","invalid_read_type":"Error at line $0: The input \"$1\" is not of type $2 which is the type of the variable
$3 .","invalid_read_type_array":"Error at line $0: The input \"$1\" is not of type $2 which is the type accepted by the variable
$3 of type $4.","inform_valid_identifier":"Enter a valid identifier! The identifier cannot be a reserved word and it must begin with a letter or _, followed by numbers, letters and _ only.","inform_valid_global_duplicated":"A global variable named
$0 already exists, you need distinct names for each gloval variable.","inform_valid_variable_duplicated":"A variable named
$0 already exists, you need distinct names for each variable.","inform_valid_function_duplicated":"A function named
$0 already exists, you need distinct names for each function.","inform_valid_param_duplicated":"A parameter named
$0 already exists in function
$1 , you need distinc names for each parameter.","invalid_character":"The character $0 at line $1 cannot be used in this context.","annonymous_array_literal":"Error at line $0: the array notation is only permitted during initialization of an array variable. i. e.: int vec[3] ← {1, 2, 3}.","invalid_matrix_literal_line":"The expression $0 at line $1 does not have the same number of elements as the last line. All lines of a matrix must have the same number of elements.","cannot_infer_matrix_line":"It is not possible to infer the number of lines of matrix $0 at line $1. It must be initialized or have its lines explicitly declared.","cannot_infer_matrix_column":"It is not possible to infer the number of columns of matrix $0 at line $1. It must be initialized or have its columns explicitly declared.","cannot_infer_vector_size":"It is not possible to infer the number of elements of vector $0 at line $1. It must be initialized or have its size explicitly declard.","matrix_to_vector_literal_attr":"Error at line $0: The expression $1 represents a matrix and cannot be assigned to the vector $2.","vector_to_matrix_literal_attr":"Error at line $0: The expression $1 represents a vector and cannot be assigned to the matrix $2.","invalid_const_ref_full":"The variable $0 provided as a parameter to the function $1 at line $2 is a constant and cannot be used in this context. Use a non-constant variable or vector position.","invalid_const_ref":"The variable $0 provided as a parameter to the function $1 is a constant and cannot be used in this context. Use a non-constant variable or vector position.","invalid_const_assignment_full":"Error at line $0: $1 is a constant e therefore cannot have its value changed.","invalid_const_assignment":"$0 is a constant e therefore cannot have its value changed.","array_init_not_literal":"Error at line $0: An array (vector or matrix) can only be initialized by an array literal. i.e : real vector[] <- {1,2,3}","array_exceeds_2d":"Error at line $0: The maximum number of dimensions an array can have is 2. An element of 3 or dimensions was found.","invalid_matrix_id_dimension":"Error at line $0: You must define all dimensions of the matrix when one of them is defined by a variable! i.e: real mat1[var][5], mat2[5][var]","invalid_vector_init":"Error at line $0: You cannot initialize a vector when its size is defined by a variable. Use a vector assignment or loop command.","invalid_matrix_init":"Error at line $0: You cannot initialize a matrix when one of its dimensions is defined by a variable. Use a matrix assignment or loop command.","invalid_vector_assignment_full":"Error at line $0: You can only assign a vector to another when both have the same number of elements. $1 has $2 and $3 has $4 elements!","invalid_vector_assignment":"You can only assign a vector to another when both have the same number of elements. $0 has $1 and $2 has $3 elements!","invalid_matrix_assignment_full":"Error at line $0: You can only assign a matrix to another when both have dimensions of the same size. $1 has $2 lines e $3 columns while $4 has $5 lines and $6 columns!","invalid_matrix_assignment":"You can only assign a matrix to another when both have dimensions of the same size. $0 has $1 lines e $2 columns while $3 has $4 lines and $5 columns!","matrix_to_vector_attr":"Error at line $0: $1 represents a matrix and cannot be assigned to the vector $2.","vector_to_matrix_attr":"Error at line $0: $1 represents a vector and cannot be assigned to the matrix $2.","invalid_matrix_index_assign_full":"Error at line $0: The position $1 of the matrix $2 only accepts vectors of size $3 but $4 has size $5.","invalid_matrix_index_assign":"The position $0 of the matrix $1 only accepts vectors of size $2 but $3 has size $4.","invalid_number_elements_vector":"It expected $0 elements at line $1 but the expression $2 has $3 elements.","invalid_number_lines_matrix":"It expected a matrix with $0 lines at line $1 but the expression $2 has $3 lines.","divsion_by_zero_full":"Error at line $0: The expression $1 resuts in a division by zero.","divsion_by_zero":"The expression $0 resuts in a division by zero.","undefined_tanget_value":"Error at line $0: The tangent of $1° is undefined.","negative_log_value":"Error at line $0: You cannot calculate the logarithm of a negative value.","invalid_string_index":"Error at line $0 during the execution of the function $1: $2 is an invalid index for the text string $3. The valid indexes go from 0 to $4.","negative_sqrt_value":"Error at line $0: It is not allowd to calculate the square root of a negative number.","exceeded_recursive_calls":"Error during the execution of line $0: The number of recursive calls exceeded the allowed number of calls.","invalid_for_variable":"Error at line $0: The variable $1 used in the repeat_for command must be of type int.","invalid_for_from":"Error at line $0: The value $1 passed to the parameter 'from' of the repeat_for command must be of type int.","invalid_for_to":"Error at line $0: The value $1 passed to the parameter 'to' of the repeat_for command must be of type int.","invalid_for_pass":"Error at line $0: The value $1 passed to the parameter 'pass' of the repeat_for command must be of type int.","exceed_max_instructions":"The number of instructions executed by your program exceed the defined limit. Check your code for infinite loops or excessive recursive functions calls."},"es":{"token_missing_one":" ","token_missing_two":" ","eos_missing":" ","invalid_type":" ","invalid_array_dimension":" ","invalid_array_size":" ","extra_lines":" ","invalid_main_return":" ","invalid_var_declaration":" ","invalid_break_command":" ","invalid_terminal":" ","const_not_init":" ","id_missing":" ","invalid_id_format":" ","main_missing":" ","invalid_global_var":" ","not_implemented":" ","function_missing":" ","function_missing_full":" ","invalid_parameters_size_full":" ","invalid_parameters_size":" ","invalid_ref_full":" ","invalid_ref":" ","invalid_parameter_type_full":" ","invalid_parameter_type":" ","unknown_command_full":" ","unknown_command":" ","loop_condition_type_full":" ","loop_condition_type":" ","endless_loop_full":" ","endless_loop":" ","for_condition_type_full":" ","for_condition_type":" ","if_condition_type_full":" ","if_condition_type":" ","invalid_return_type_full":" ","invalid_return_type":" ","invalid_void_return_full":" ","invalid_void_return":" ","unexpected_break_command_full":" ","unexpected_break_command":" ","invalid_dimension":" ","void_in_expression_full":" ","void_in_expression":" ","invalid_array_access_full":" ","invalid_array_access":" ","invalid_matrix_access_full":" ","invalid_matrix_access":" ","matrix_column_outbounds_full":" ","matrix_column_outbounds":" ","matrix_line_outbounds_full":" ","matrix_line_outbounds":" ","vector_line_outbounds_full":" ","vector_line_outbounds":" ","vector_not_matrix_full":" ","vector_not_matrix":" ","invalid_infix_op_full":" ","invalid_infix_op":" ","invalid_unary_op_full":" ","invalid_unary_op":" ","unknown_op":" ","duplicate_function":" ","duplicate_variable":" ","main_parameters":" ","symbol_not_found_full":" ","symbol_not_found":" ","array_dimension_not_int_full":" ","array_dimension_not_int":" ","array_dimension_not_positive_full":" ","array_dimension_not_positive":" ","incompatible_types_full":" ","incompatible_types":" ","incompatible_types_array_full":" ","incompatible_types_array":" ","invalid_case_type_full":" ","invalid_case_type":" ","function_no_return":" ","invalid_array_literal_type_full":" ","invalid_array_literal_type":" ","invalid_array_literal_line_full":" ","invalid_array_literal_line":" ","invalid_array_literal_column_full":" ","invalid_array_literal_column":" ","exceeded_input_request":" ","test_case_few_reads":" ","test_case_failed":" ","test_case_failed_exception":" ","test_case_exception":" ","invalid_type_conversion":" ","invalid_read_type":" ","invalid_read_type_array":" ","inform_valid_identifier":" ","inform_valid_global_duplicated":" ","inform_valid_variable_duplicated":" ","inform_valid_function_duplicated":" ","inform_valid_param_duplicated":" ","invalid_character":" ","annonymous_array_literal":" ","invalid_matrix_literal_line":" ","cannot_infer_matrix_line":" ","cannot_infer_matrix_column":" ","cannot_infer_vector_size":" ","matrix_to_vector_literal_attr":" ","vector_to_matrix_literal_attr":" ","invalid_const_ref_full":" ","invalid_const_ref":" ","invalid_const_assignment_full":" ","invalid_const_assignment":" ","array_init_not_literal":" ","array_exceeds_2d":" ","invalid_matrix_id_dimension":" ","invalid_vector_init":" ","invalid_matrix_init":" ","invalid_vector_assignment_full":" ","invalid_vector_assignment":" ","invalid_matrix_assignment_full":" ","invalid_matrix_assignment":" ","matrix_to_vector_attr":" ","vector_to_matrix_attr":" ","invalid_matrix_index_assign_full":" ","invalid_matrix_index_assign":" ","invalid_number_elements_vector":" ","invalid_number_lines_matrix":" ","divsion_by_zero_full":" ","divsion_by_zero":" ","undefined_tanget_value":" ","negative_log_value":" ","invalid_string_index":" ","negative_sqrt_value":" ","exceeded_recursive_calls":" ","invalid_for_variable":"","invalid_for_from":"","invalid_for_to":"","invalid_for_pass":"","exceed_max_instructions":""}}
/***/ }),
/***/ "./i18n/index.ts":
/*!***********************!*\
!*** ./i18n/index.ts ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
///
const Messages = __webpack_require__(/*! ./message.csv */ "./i18n/message.csv");
const UI = __webpack_require__(/*! ./ui.csv */ "./i18n/ui.csv");
const Errors = __webpack_require__(/*! ./error.csv */ "./i18n/error.csv");
const MessagesObj = Messages;
const UIObj = UI;
const ErrorsObj = Errors;
const i18n_data = {};
for (const key in UIObj) {
const data = {};
data['error'] = ErrorsObj[key];
data['message'] = MessagesObj[key];
data['ui'] = UIObj[key];
i18n_data[key] = data;
}
exports.default = i18n_data;
/***/ }),
/***/ "./i18n/message.csv":
/*!**************************!*\
!*** ./i18n/message.csv ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = {"pt":{"test_case_success":"
Caso de teste $0 : OK
","test_case_duration":"Levou $0ms","test_suite_grade":"A sua solução alcançou $0% da nota.","awaiting_input_message":"O seu programa está em execução e aguardando uma entrada! Digite algo e pressione ENTER...","assessment-empty-expected-tooltip":"A saída gerada foi além do esperado","assessment-empty-generated-tooltip":"O programa não gerou saídas suficientes","testcase_autogen_unused_input":"O caso de teste $0 possui mais entradas do que as leituras feitas no programa.","testcase_autogen_empty":"O caso de teste $0 não gerou qualquer saída.","success_execution":"Programa executado com sucesso!","aborted_execution":"A execução do programa foi interrompida!","unexpected_execution_error":"Erro inesperado durante a execução do programa."},"en":{"test_case_success":"
Test case $0 : OK
","test_case_duration":"Took $0ms","test_suite_grade":"Your solution scored $0% of the grade.","awaiting_input_message":"Your program is running and awaiting for an input. Type something and press ENTER…","assessment-empty-expected-tooltip":"The generated output was beyond the amount expected","assessment-empty-generated-tooltip":"The program did not generated enough outputs","testcase_autogen_unused_input":"The test case $0 has more inputs than output than the number of reads present in the algorithm.","testcase_autogen_empty":"The test case $0 did not generate any output.","success_execution":"Program executed successfully!","aborted_execution":"Program execution was aborted!","unexpected_execution_error":"Unexpected error during program execution."},"es":{"test_case_success":" ","test_case_duration":" ","test_suite_grade":" ","awaiting_input_message":" ","assessment-empty-expected-tooltip":" ","assessment-empty-generated-tooltip":" ","testcase_autogen_unused_input":" ","testcase_autogen_empty":" ","success_execution":"","aborted_execution":"","unexpected_execution_error":""}}
/***/ }),
/***/ "./i18n/ui.csv":
/*!*********************!*\
!*** ./i18n/ui.csv ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = {"pt":{"function":"funcao","btn_clear":"Limpar","btn_function":"Função","btn_arithmetic_plus":"Adição","btn_arithmetic_minus":"Subtração","btn_arithmetic_multiplication":"Multiplicação","btn_arithmetic_division":"Divisão","btn_arithmetic_module":"Módulo","btn_break":"Pare","btn_case":"Caso","start":"inicio","type_void":"vazio","type_integer":"inteiro","logic_operator_and":"E","logic_operator_or":"OU","logic_operator_not":"nao","type_real":"real","program":"programa","type_text":"cadeia","textvar_default_value":"texto","type_boolean":"logico","logic_value_true":"verdadeiro","logic_value_false":"falso","variable":"Variável","command":"Comando","new_parameter":"parametro","new_variable":"variavel","new_global":"global","new_function":"nova_funcao","matrix":"matriz","vector":"vetor","text_comment_start":"Comentário inicial da função...","text_comment_main":"Esta é a função principal...","text_read_var":"Entrada/Leitura de dados","text_write_var":"Saída/Escrita de dados","text_command_read":"leia","text_command_write":"escreva","text_return":"devolva","text_btn_return":"Devolver","text_comment":"Comentário","string_join_or":"ou","matrix_info_string":"matriz de $0","vector_info_string":"vetor de $0","text_attribution":"Atribuição","text_if":"se","text_break":"pare","text_else":"senao","text_for":"repita_para","text_code_while":"repita_enquanto","text_code_do":"repita","text_code_do_until":"ate_que","text_command_do":"repita","text_command_while":"repita enquanto","text_command_do_until":"até que","text_code_switch":"escolha","text_code_case":"caso","text_config_programming":"Programação","text_config_programming_both":"Visual e textual","text_config_programming_textual":"Textual","text_config_programming_visual":"Visual","text_logic_expression":"Lógicos","text_arithmetic_expression":"Aritméticos","text_iftrue":"Se verdadeiro então","text_message_error_activity_file":"Aconteceu um erro ao processar a atividade.
Recarregue a página para tentar novamente.","text_message_error_activity_reload":"Recarregar","text_repeatNtimes":"Repita N vezes","text_receives":"recebe","text_whiletrue":"Enquanto verdadeiro","text_dowhiletrue":"Repita até que verdadeiro","text_switch":"Escolha","text_functioncall":"Chamada de função","text_value":"Valor","text_operator":"Operador","text_parentheses":"Parênteses","text_change":"Alterar","text_teacher_algorithm":"Algoritmo","text_teacher_algorithm_include":"Incluir o algoritmo abaixo no exercício","text_teacher_test_case":"Casos de teste","text_teacher_config":"Configurações","text_teacher_data_types":"Tipos de dados","text_teacher_commands":"Comandos","text_teacher_functions":"Funções","text_teacher_create_functions":"Criar novas funções","text_teacher_create_movement_functions":"Movimentar funções","text_teacher_test_case_input":"Entrada","text_teacher_test_case_output":"Saída","text_teacher_test_case_actions":"Ações","text_teacher_test_case_add":"Adicionar caso de teste","text_header_ivprog_functions":"Funções do iVProg","text_menu_functions_math":"Matemática","text_menu_functions_text":"Texto","text_menu_functions_array":"Arranjo","text_menu_functions_conversion":"Conversão","text_no_variable":"Nenhuma variável declarada","text_no_variable_instruction":"Antes de utilizar uma variável, é necessário criá-la","text_ivprog_description":"Programação Visual interativa na Internet","tooltip_visual":"Programação visual","tooltip_textual":"Programação textual","tooltip_upload":"Upload de código fonte","tooltip_download":"Download do código fonte","tooltip_undo":"Desfazer","tooltip_redo":"Refazer","tooltip_run":"Executar o programa","tooltip_evaluate":"Avaliar o programa","tooltip_help":"Ajuda","tooltip_add_global":"Adicionar variável global","tooltip_hide_function":"Ocultar os elementos da função","var_menu_select_var":"Selecione uma variável","var_menu_select_all":"Selecione","var_menu_select_function":"Selecione uma função","expression_menu_select":"Construir uma expressão lógica","inform_valid_content":"Informe o conteúdo!","inform_valid_expression":"Construa uma expressão lógica!","tooltip_terminal_clear":"Limpa o terminal removendo todos os textos já escritos e os pendentes.","tooltip_terminal_show":"Exibe o terminal caso esteja escondido","tooltip_terminal_hide":"Esconde o terminal caso não esteja escondido","text_ivprog_version":"Versão","text_teacher_filter":"Filtro","text_teacher_filter_active":"Ativado","text_teacher_filter_help":"Ao ativar o filtro, as modificações do iVProg estarão bloqueadas.","text_join_assessment_outputs":" ; ","assessment-detail-time-label":"Duração","assessment-detail-grade-label":"Nota","assessment-detail-input-label":"Entradas","assessment-detail-output-label":"Saídas","assessment-detail-expected-label":"Esperava","assessment-detail-generated-label":"Gerou","assessment-detail-result-label":"Resultado","assessment-detail-title":"Caso de Teste $0","text_teacher_generate_outputs":"Gerar saídas","text_teacher_generate_outputs_algorithm":"Antes de gerar as saídas, elabore um algoritmo!","text_code_for_from":"de","text_code_for_to":"ate","text_code_for_pass":"passo","text_for_from":"de","text_for_to":"até","text_for_pass":"passo","text_relational_expression":"Relacionais","initial_program_code":"programa {\\n\\n\\t\\tfuncao vazio inicio () {\\n\\t\\t\\t// Inicie seu codigo aqui!\\n\\t\\t}\\n}"},"en":{"function":"function","btn_clear":"Clean","btn_function":"Function","btn_arithmetic_plus":"Addition","btn_arithmetic_minus":"Subtraction","btn_arithmetic_multiplication":"Multiplication","btn_arithmetic_division":"Division","btn_arithmetic_module":"Remainder","btn_break":"break","btn_case":"Case","start":"main","type_void":"void","type_integer":"int","logic_operator_and":"AND","logic_operator_or":"OR","logic_operator_not":"not","type_real":"real","program":"program","type_text":"string","textvar_default_value":"text","type_boolean":"bool","logic_value_true":"true","logic_value_false":"false","variable":"Variable","command":"Command","new_parameter":"parameter","new_variable":"variable","new_global":"global","new_function":"new_function","matrix":"matrix","vector":"vector","text_comment_start":"Function initial comment","text_comment_main":"This is the main funcion","text_read_var":"Input/Read data","text_write_var":"Output/Write data","text_command_read":"read","text_command_write":"write","text_return":"return","text_btn_return":"Return","text_comment":"Comment","string_join_or":"or","matrix_info_string":"matrix of $0","vector_info_string":"vector of $0","text_attribution":"Assignment","text_if":"if","text_break":"break","text_else":"else","text_for":"repeat_for","text_code_while":"repeat_while","text_code_do":"repeat","text_code_do_until":"until","text_command_do":"repeat","text_command_while":"repeat while","text_command_do_until":"until","text_code_switch":"switch","text_code_case":"case","text_config_programming":"Programming","text_config_programming_both":"Visual & Textual","text_config_programming_textual":"Textual","text_config_programming_visual":"Visual","text_logic_expression":"Logic","text_arithmetic_expression":"Arithmetics","text_iftrue":"If true then","text_message_error_activity_file":"There was an error processing the activity.
Reload the page to try again.","text_message_error_activity_reload":"Reload","text_repeatNtimes":"Repeat N times","text_receives":"receives","text_whiletrue":"While true","text_dowhiletrue":"Repeat until true","text_switch":"Switch","text_functioncall":"Function call","text_value":"Value","text_operator":"Operator","text_parentheses":"Parentheses","text_change":"Modify","text_teacher_algorithm":"Algorithm","text_teacher_algorithm_include":"Include the algorithm below in the activity","text_teacher_test_case":"Test cases","text_teacher_config":"Configurations","text_teacher_data_types":"Data types","text_teacher_commands":"Commands","text_teacher_functions":"Functions","text_teacher_create_functions":"Create new functions","text_teacher_create_movement_functions":"Move functions","text_teacher_test_case_input":"Input","text_teacher_test_case_output":"Output","text_teacher_test_case_actions":"Actions","text_teacher_test_case_add":"Add test case","text_header_ivprog_functions":"iVProg Functions","text_menu_functions_math":"Math","text_menu_functions_text":"Text","text_menu_functions_array":"Array","text_menu_functions_conversion":"Conversion","text_no_variable":"No variable declared","text_no_variable_instruction":"Before using a variable, you need to create it","text_ivprog_description":"Interactive and Visual Programming on the Internet","tooltip_visual":"Visual programming","tooltip_textual":"Textual programming","tooltip_upload":"Upload source code","tooltip_download":"Download source code","tooltip_undo":"Undo","tooltip_redo":"Redo","tooltip_run":"Run the program","tooltip_evaluate":"Evaluate the program","tooltip_help":"Help","tooltip_add_global":"Add a global variable","tooltip_hide_function":"Hide function elements","var_menu_select_var":"Select a variable","var_menu_select_all":"Select","var_menu_select_function":"Select a function","expression_menu_select":"Construct a logic expression","inform_valid_content":"Provide some data","inform_valid_expression":"Construct a logic expression","tooltip_terminal_clear":"Clears the terminal by removing all wrriten and pending text.","tooltip_terminal_show":"Shows the terminal if it is hidden","tooltip_terminal_hide":"Hides the terminal if it is not on display","text_ivprog_version":"Version","text_teacher_filter":"Filter","text_teacher_filter_active":"Activated","text_teacher_filter_help":"By activating the filter modifications in iVProg will be blocked","text_join_assessment_outputs":" ; ","assessment-detail-time-label":"Duration","assessment-detail-grade-label":"Grade","assessment-detail-input-label":"Inputs","assessment-detail-output-label":"Outputs","assessment-detail-expected-label":"Expected","assessment-detail-generated-label":"Generated","assessment-detail-result-label":"Result","assessment-detail-title":"Test Case $0","text_teacher_generate_outputs":"Generate outputs","text_teacher_generate_outputs_algorithm":"Before generating the outputs you need to create an algorithm","text_code_for_from":"from","text_code_for_to":"to","text_code_for_pass":"pass","text_for_from":"from","text_for_to":"to","text_for_pass":"pass","text_relational_expression":"Relational","initial_program_code":"program {\\n\\n\\t\\tfunction void main () {\\n\\t\\t\\t// Start your code here!\\n\\t\\t}\\n}"},"es":{"function":"funccion","btn_clear":"","btn_function":"","btn_arithmetic_plus":"","btn_arithmetic_minus":"","btn_arithmetic_multiplication":"","btn_arithmetic_division":"","btn_arithmetic_module":"","btn_break":"","btn_case":"","start":"","type_void":"","type_integer":"","logic_operator_and":"","logic_operator_or":"","logic_operator_not":"","type_real":"","program":"","type_text":"","textvar_default_value":"","type_boolean":"","logic_value_true":"","logic_value_false":"","variable":"","command":"","new_parameter":"","new_variable":"","new_global":"","new_function":"","matrix":"","vector":"","text_comment_start":"","text_comment_main":"","text_read_var":"","text_write_var":"","text_command_read":"","text_command_write":"","text_return":"","text_btn_return":"","text_comment":"","string_join_or":"","matrix_info_string":"","vector_info_string":"","text_attribution":"","text_if":"","text_break":"","text_else":"","text_for":"","text_code_while":"","text_code_do":"","text_code_do_until":"","text_command_do":"","text_command_while":"","text_command_do_until":"","text_code_switch":"","text_code_case":"","text_config_programming":"","text_config_programming_both":"","text_config_programming_textual":"","text_config_programming_visual":"","text_logic_expression":"","text_arithmetic_expression":"","text_iftrue":"","text_message_error_activity_file":"","text_message_error_activity_reload":"","text_repeatNtimes":"","text_receives":"","text_whiletrue":"","text_dowhiletrue":"","text_switch":"","text_functioncall":"","text_value":"","text_operator":"","text_parentheses":"","text_change":"","text_teacher_algorithm":"","text_teacher_algorithm_include":"","text_teacher_test_case":"","text_teacher_config":"","text_teacher_data_types":"","text_teacher_commands":"","text_teacher_functions":"","text_teacher_create_functions":"","text_teacher_create_movement_functions":"","text_teacher_test_case_input":"","text_teacher_test_case_output":"","text_teacher_test_case_actions":"","text_teacher_test_case_add":"","text_header_ivprog_functions":"","text_menu_functions_math":"","text_menu_functions_text":"","text_menu_functions_array":"","text_menu_functions_conversion":"","text_no_variable":"","text_no_variable_instruction":"","text_ivprog_description":"","tooltip_visual":"","tooltip_textual":"","tooltip_upload":"","tooltip_download":"","tooltip_undo":"","tooltip_redo":"","tooltip_run":"","tooltip_evaluate":"","tooltip_help":"","tooltip_add_global":"","tooltip_hide_function":"","var_menu_select_var":"","var_menu_select_all":"","var_menu_select_function":"","expression_menu_select":"","inform_valid_content":"","inform_valid_expression":"","tooltip_terminal_clear":"","tooltip_terminal_show":"","tooltip_terminal_hide":"","text_ivprog_version":"","text_teacher_filter":"","text_teacher_filter_active":"","text_teacher_filter_help":"","text_join_assessment_outputs":"","assessment-detail-time-label":"","assessment-detail-grade-label":"","assessment-detail-input-label":"","assessment-detail-output-label":"","assessment-detail-expected-label":"","assessment-detail-generated-label":"","assessment-detail-result-label":"","assessment-detail-title":"","text_teacher_generate_outputs":"","text_teacher_generate_outputs_algorithm":"","text_code_for_from":"","text_code_for_to":"","text_code_for_pass":"","text_for_from":"","text_for_to":"","text_for_pass":"","text_relational_expression":"","initial_program_code":""}}
/***/ }),
/***/ "./js/assessment/ivprogAssessment.js":
/*!*******************************************!*\
!*** ./js/assessment/ivprogAssessment.js ***!
\*******************************************/
/*! exports provided: IVProgAssessment */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IVProgAssessment", function() { return IVProgAssessment; });
/* harmony import */ var line_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
/* harmony import */ var _processor_ivprogProcessor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
/* harmony import */ var _io_domConsole__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../io/domConsole */ "./js/io/domConsole.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _output_matching_output_matching__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./output_matching/output_matching */ "./js/assessment/output_matching/output_matching.js");
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var LocalizedStrings = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_3__["getInstance"]();
var StringTypes = line_i18n__WEBPACK_IMPORTED_MODULE_0__["default"].StringTypes;
var AssessmentConfig = {
max_instruction_count: 350250,
suspend_threshold: 200
};
var IVProgAssessment =
/*#__PURE__*/
function () {
function IVProgAssessment(ast_code, testCases, domConsole) {
_classCallCheck(this, IVProgAssessment);
this.ast_code = ast_code;
this.testCases = testCases;
this.domConsole = domConsole;
this.old_config = JSON.parse(JSON.stringify(_util_config__WEBPACK_IMPORTED_MODULE_5__["Config"]));
_util_config__WEBPACK_IMPORTED_MODULE_5__["Config"].setConfig(AssessmentConfig);
}
_createClass(IVProgAssessment, [{
key: "runTest",
value: function runTest() {
var _this = this;
try {
// loop test cases and show messages through domconsole
var partialTests = this.testCases.map(function (t, name) {
return new _output_matching_output_matching__WEBPACK_IMPORTED_MODULE_4__["OutputMatching"](new _processor_ivprogProcessor__WEBPACK_IMPORTED_MODULE_1__["IVProgProcessor"](_this.ast_code), t.input, t.output, name);
});
var testResult = partialTests.map(function (om) {
return om.eval();
});
return Promise.all(testResult).then(function (results) {
var grade = 0;
for (var i = 0; i < results.length; i += 1) {
var result = results[i];
grade += result.grade;
if (result.grade == 1) {
_this.writeToConsole(_io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].INFO, StringTypes.MESSAGE, 'test_case_success', result.name + 1, result.generateOutput());
} else if (result.status == 1) {
_this.writeToConsole(_io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].ERR, StringTypes.ERROR, 'test_case_failed_exception', result.name + 1, result.error_msg, result.generateOutput());
} else {
_this.writeToConsole(_io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].ERR, StringTypes.ERROR, 'test_case_failed', result.name + 1, result.generateOutput());
}
}
grade /= results.length;
var channel = grade == 1 ? _io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].INFO : _io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].ERR;
_this.writeToConsole(channel, StringTypes.MESSAGE, "test_suite_grade", (grade * 100).toFixed(2));
return grade;
}); // return testResult.then(function (total) {
// const grade = total / this.testCases.length;
// const channel = grade == 1 ? DOMConsole.INFO : DOMConsole.ERR;
// this.writeToConsole(channel, StringTypes.MESSAGE, "test_suite_grade", (grade * 100).toFixed(2));
// return Promise.resolve(grade)
// }).catch(err => {
// this.domConsole.err("Erro inesperado durante o cálculo da nota.");// try and show error messages through domconsole
// this.domConsole.err(err.message);
// return Promise.resolve(0);
// });
} catch (error) {
this.showErrorMessage(_io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].ERR, StringTypes.MESSAGE, "unexpected_execution_error");
this.domConsole.err(error.message);
return Promise.resolve(0);
} finally {
_util_config__WEBPACK_IMPORTED_MODULE_5__["Config"].setConfig(this.old_config);
}
}
}, {
key: "showErrorMessage",
value: function showErrorMessage(errorID) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
this.domConsole.err(LocalizedStrings.getError(errorID, args));
}
}, {
key: "showInfoMessage",
value: function showInfoMessage(msgID) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
this.domConsole.info(LocalizedStrings.getMessage(msgID, args));
}
}, {
key: "writeToConsole",
value: function writeToConsole(channel, msgType, msgID) {
var msg = LocalizedStrings.getString(msgID, msgType);
for (var _len3 = arguments.length, args = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
args[_key3 - 3] = arguments[_key3];
}
msg = LocalizedStrings.processString(msg, args);
switch (channel) {
case _io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].ERR:
{
this.domConsole.err(msg);
break;
}
case _io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].INFO:
{
this.domConsole.info(msg);
break;
}
case _io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"].USER:
{
this.domConsole.write(msg);
break;
}
}
}
}]);
return IVProgAssessment;
}();
/***/ }),
/***/ "./js/assessment/output_matching/assessment_result.js":
/*!************************************************************!*\
!*** ./js/assessment/output_matching/assessment_result.js ***!
\************************************************************/
/*! exports provided: OutputAssessmentResult */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutputAssessmentResult", function() { return OutputAssessmentResult; });
/* harmony import */ var _util_string_diff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../util/string_diff */ "./js/util/string_diff.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var OutputAssessmentResult =
/*#__PURE__*/
function () {
_createClass(OutputAssessmentResult, null, [{
key: "PAGE_TEMPLATE",
get: function get() {
return "\n \n \n
\n
\n \n \n :assessment-result:\n \n ";
}
}, {
key: "DETAIL_TEMPLATE",
get: function get() {
return "
\n \n
\n
\n
:output-label: \n :output-result:\n \n
";
}
}, {
key: "OUPUT_TABLE_TEMPLATE",
get: function get() {
return "
\n
\n \n :expected-label: \n :generated-label: \n :result-label: \n \n :results:\n
\n
";
}
}, {
key: "OUTPUT_TEMPLATE",
get: function get() {
return "
$0 \n $1 \n $2 ";
}
}, {
key: "EMPTY_OUTPUT_TEMPLATE",
get: function get() {
return "";
}
}, {
key: "FAILED_TEMPLATE",
get: function get() {
return "
\u2717 $0
";
}
}, {
key: "INPUT_INFO_TEMPLATE",
get: function get() {
return "
$1 ";
} // Status code - it is not grade related!
// 0 - Succesful execution
// 1 - failed execution
}]);
function OutputAssessmentResult(name, status, inputs, result, store, time) {
var error_msg = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
_classCallCheck(this, OutputAssessmentResult);
this.name = name;
this.status = status;
this.inputs = inputs;
this.results = result;
this.store = store;
this.time = time;
this.error_msg = error_msg;
}
_createClass(OutputAssessmentResult, [{
key: "prepareResults",
value: function prepareResults() {
var _this = this;
var template = OutputAssessmentResult.DETAIL_TEMPLATE;
var grade = (this.grade * 100).toFixed(2);
var time = this.time || "-";
template = template.replace(':test-name:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-title', [this.name + 1]));
template = template.replace(':time-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-time-label'));
template = template.replace(':time:', time);
template = template.replace(':grade-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-grade-label'));
template = template.replace(':grade:', grade);
var input_spans = this.prepareInputList(this.inputs);
template = template.replace(':input-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-input-label'));
template = template.replace(':input-list:', input_spans);
template = template.replace(':output-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-output-label'));
if (this.status == 0) {
var output_rows = this.results.map(function (result) {
if (result.type == "string") {
return _this.formatString(result);
} else if (result.type == "number") {
return _this.formatNumber(result);
} else {
return _this.formatBool(result);
}
}, this);
template = template.replace(':output-result:', this.prepareOutputTable(output_rows));
} else {
var failed_text = OutputAssessmentResult.FAILED_TEMPLATE;
failed_text = failed_text.replace("$0", this.error_msg);
template = template.replace(":output-result:", failed_text);
}
return template;
}
}, {
key: "prepareInputList",
value: function prepareInputList(input_list) {
var list = input_list.map(function (input) {
var template = OutputAssessmentResult.INPUT_INFO_TEMPLATE;
template = template.replace("$1", input.value);
if (input.read) {
template = template.replace("$0", "assessment-input-read");
} else {
template = template.replace("$0", "assessment-input-unread");
}
return template;
}, this);
return list.join(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('text_join_assessment_outputs'));
}
}, {
key: "prepareOutputTable",
value: function prepareOutputTable(output_rows) {
var template = OutputAssessmentResult.OUPUT_TABLE_TEMPLATE;
template = template.replace(':expected-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-expected-label'));
template = template.replace(':generated-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-generated-label'));
template = template.replace(':result-label:', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('assessment-detail-result-label'));
template = template.replace(':results:', output_rows.join(''));
return template;
}
}, {
key: "generateOutput",
value: function generateOutput() {
var assessment_result = this.prepareResults();
var page = OutputAssessmentResult.PAGE_TEMPLATE;
page = page.replace(':assessment-result:', assessment_result);
page = page.replace(/(\r|\n|\t)/gm, '').replace(/> *<');
return page;
}
}, {
key: "formatNumber",
value: function formatNumber(result) {
var result_class = result.grade == 1 ? 'assessment-number-result' : 'assessment-number-result-failed';
var template = this.formatOutput('assessment-number-expected', 'assessment-number-generated', result_class, result);
return template;
}
}, {
key: "formatBool",
value: function formatBool(result) {
var result_class = result.grade == 1 ? 'assessment-bool-result' : 'assessment-bool-result-failed';
var template = this.formatOutput('assessment-bool-expected', 'assessment-bool-generated', result_class, result);
return template;
}
}, {
key: "formatOutput",
value: function formatOutput(expected_class, generated_class, result_class, result) {
var template = OutputAssessmentResult.OUTPUT_TEMPLATE;
template = template.replace(":class-expected:", expected_class);
template = template.replace(":class-generated:", generated_class);
template = template.replace(":class-result:", result_class);
var expected_tmpl = result.expected;
var generated_tmpl = result.generated;
if (expected_tmpl == null) {
expected_tmpl = OutputAssessmentResult.EMPTY_OUTPUT_TEMPLATE.replace('$0', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getMessage('assessment-empty-expected-tooltip'));
} else if (generated_tmpl == null) {
generated_tmpl = OutputAssessmentResult.EMPTY_OUTPUT_TEMPLATE.replace('$0', _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getMessage('assessment-empty-generated-tooltip'));
}
template = template.replace("$0", expected_tmpl);
template = template.replace("$1", generated_tmpl);
var final_result = result.grade == 1 ? "✓" : "✗";
template = template.replace("$2", final_result);
return template;
}
}, {
key: "formatString",
value: function formatString(result) {
var _this2 = this;
var expected_class = 'assessment-string-expected';
var generated_class = 'assessment-string-generated'; //const result_class = 'assessment-string-result';
var template = OutputAssessmentResult.OUTPUT_TEMPLATE;
template = template.replace(":class-expected:", expected_class);
template = template.replace(":class-generated:", generated_class); //template = template.replace(":class-result:", result_class);
var g_string = result.generated || "";
var e_string = result.expected || "";
template = template.replace("$0", result.expected);
template = template.replace("$1", result.generated);
if (result.grade == 1) {
template = template.replace("$2", "✓");
template = template.replace(":class-result:", 'assessment-string-result');
} else {
var diff = Object(_util_string_diff__WEBPACK_IMPORTED_MODULE_0__["default"])(g_string, e_string);
var diff_vec = diff.map(function (part) {
return _this2.getDiffStringStyle(part[1], part[0]);
}, this);
var diff_string = diff_vec.reduce(function (prev, actual) {
return prev + actual;
}, "");
template = template.replace("$2", "
✗ " + diff_string);
template = template.replace(":class-result:", "assessment-string-diff");
}
return template;
}
}, {
key: "getDiffStringStyle",
value: function getDiffStringStyle(text, action) {
var template = "
$1 ";
switch (action) {
case _util_string_diff__WEBPACK_IMPORTED_MODULE_0__["default"].INSERT:
return template.replace("$0", "stringdiff-insert").replace("$1", text);
case _util_string_diff__WEBPACK_IMPORTED_MODULE_0__["default"].DELETE:
return template.replace("$0", "stringdiff-delete").replace("$1", text);
case _util_string_diff__WEBPACK_IMPORTED_MODULE_0__["default"].EQUAL:
return template.replace("$0", "stringdiff-equal").replace("$1", text);
}
}
}, {
key: "grade",
get: function get() {
if (this.results == null) {
return 0;
}
return this.results.reduce(function (prev, val) {
return prev + val.grade;
}, 0) / this.results.length;
}
}]);
return OutputAssessmentResult;
}();
/***/ }),
/***/ "./js/assessment/output_matching/output_matching.js":
/*!**********************************************************!*\
!*** ./js/assessment/output_matching/output_matching.js ***!
\**********************************************************/
/*! exports provided: OutputMatching */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutputMatching", function() { return OutputMatching; });
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(decimal_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _util_input_assessment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../util/input_assessment */ "./js/util/input_assessment.js");
/* harmony import */ var _util_outputTest__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../util/outputTest */ "./js/util/outputTest.js");
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../util/config */ "./js/util/config.js");
/* harmony import */ var _util_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../util/utils */ "./js/util/utils.js");
/* harmony import */ var _assessment_result__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./assessment_result */ "./js/assessment/output_matching/assessment_result.js");
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _output_result__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./output_result */ "./js/assessment/output_matching/output_result.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var LocalizedStrings = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_7__["getInstance"]();
var OutputMatching =
/*#__PURE__*/
function () {
_createClass(OutputMatching, null, [{
key: "NUM_REGEX",
get: function get() {
return /^[+-]?([0-9]+([.][0-9]*)?(e[+-]?[0-9]+)?)$/;
}
}, {
key: "NUM_IN_STRING_REGEX",
get: function get() {
return /[+-]?([0-9]+([.][0-9]*)?(e[+-]?[0-9]+)?)/g;
}
}, {
key: "BOOLEAN_REGEX",
get: function get() {
var str = "^(".concat(LocalizedStrings.getUI("logic_value_true"), "|").concat(LocalizedStrings.getUI("logic_value_false"), ")$");
return new RegExp(str);
}
}, {
key: "BOOLEAN_IN_STRING_REGEX",
get: function get() {
var str = "(".concat(LocalizedStrings.getUI("logic_value_true"), "|").concat(LocalizedStrings.getUI("logic_value_false"), ")");
return new RegExp(str, 'g');
}
}]);
function OutputMatching(program, input_list, expected_output, test_name) {
_classCallCheck(this, OutputMatching);
this.program = program;
this.name = test_name;
this.input_list = input_list;
this.expected_output = expected_output;
}
_createClass(OutputMatching, [{
key: "eval",
value: function _eval() {
var _this = this;
var refThis = this;
var input = new _util_input_assessment__WEBPACK_IMPORTED_MODULE_1__["InputAssessment"](this.input_list);
var gen_output = new _util_outputTest__WEBPACK_IMPORTED_MODULE_2__["OutputTest"]();
this.program.registerInput(input);
this.program.registerOutput(gen_output);
var start_time = Date.now();
return this.program.interpretAST().then(function (sto) {
var final_time = Date.now() - start_time;
if (input.isInputAvailable()) {
return new _assessment_result__WEBPACK_IMPORTED_MODULE_5__["OutputAssessmentResult"](_this.name, 1, input.input_list, null, sto, final_time, refThis.getErrorMessage('test_case_few_reads', _this.name + 1));
}
var result = gen_output.list.map(function (g_out, i) {
if (i >= _this.expected_output.length) {
return new _output_result__WEBPACK_IMPORTED_MODULE_8__["OutputMatchResult"](null, g_out, 0, _this.getPotentialOutputType(g_out));
}
return _this.outputMatch(g_out, _this.expected_output[i]);
}, _this);
if (_this.expected_output.length > gen_output.list.length) {
for (var i = gen_output.list.length; i < _this.expected_output.length; ++i) {
var e_out = _this.expected_output[i];
result.push(new _output_result__WEBPACK_IMPORTED_MODULE_8__["OutputMatchResult"](e_out, null, 0, _this.getPotentialOutputType(e_out)));
}
}
return new _assessment_result__WEBPACK_IMPORTED_MODULE_5__["OutputAssessmentResult"](_this.name, 0, input.input_list, result, sto, final_time);
})["catch"](function (error) {
return new _assessment_result__WEBPACK_IMPORTED_MODULE_5__["OutputAssessmentResult"](_this.name, 1, input.input_list, null, null, null, refThis.getErrorMessage('test_case_exception', _this.name + 1, error.message));
});
}
}, {
key: "getPotentialOutputType",
value: function getPotentialOutputType(output) {
if (OutputMatching.NUM_REGEX.test(output)) {
return "number";
} else if (OutputMatching.BOOLEAN_REGEX.test(output)) {
return "bool";
} else {
return "string";
}
}
}, {
key: "outputMatch",
value: function outputMatch(g_output, e_output) {
if (OutputMatching.NUM_REGEX.test(e_output)) {
if (!OutputMatching.NUM_REGEX.test(g_output)) {
return this.checkStrings(g_output, e_output);
}
var g_num = new decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"](g_output);
var e_num = new decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"](e_output);
return this.checkNumbers(g_num, e_num);
} else if (OutputMatching.BOOLEAN_REGEX.test(e_output)) {
if (!OutputMatching.BOOLEAN_REGEX.test(g_output)) {
return this.checkStrings(g_output, e_output);
}
var g_bool = _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__["toBool"](g_output);
var e_bool = _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__["toBool"](e_output);
return this.checkBoolean(g_bool, e_bool);
} else {
return this.checkStrings(g_output, e_output);
}
}
}, {
key: "checkNumbers",
value: function checkNumbers(g_num, e_num) {
var decimalPlaces = Math.min(e_num.dp(), _util_config__WEBPACK_IMPORTED_MODULE_3__["Config"].decimalPlaces);
g_num = new decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"](g_num.toFixed(decimalPlaces, decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"].ROUND_FLOOR));
e_num = new decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"](e_num.toFixed(decimalPlaces, decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"].ROUND_FLOOR));
var result = g_num.eq(e_num);
var grade = result ? 1 : 0;
return _output_result__WEBPACK_IMPORTED_MODULE_8__["createNumberResult"](e_num.toNumber(), g_num.toNumber(), grade);
}
}, {
key: "checkBoolean",
value: function checkBoolean(g_bool, e_bool) {
var grade = g_bool == e_bool ? 1 : 0;
var g_bool_text = _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__["convertBoolToString"](g_bool);
var e_bool_text = _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__["convertBoolToString"](e_bool);
return _output_result__WEBPACK_IMPORTED_MODULE_8__["createBoolResult"](e_bool_text, g_bool_text, grade);
}
}, {
key: "checkStrings",
value: function checkStrings(g_output, e_ouput) {
var _this2 = this;
var assessmentList = [];
var e_output_clean = e_ouput;
var g_output_clean = g_output;
if (OutputMatching.NUM_IN_STRING_REGEX.test(e_ouput)) {
var expected_numbers = e_ouput.match(OutputMatching.NUM_IN_STRING_REGEX);
var generated_numbers = g_output.match(OutputMatching.NUM_IN_STRING_REGEX) || [];
var result = generated_numbers.map(function (val, i) {
if (i >= expected_numbers.length) {
return _output_result__WEBPACK_IMPORTED_MODULE_8__["createNumberResult"](null, val, 0);
}
var g_val = new decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"](val);
var e_val = new decimal_js__WEBPACK_IMPORTED_MODULE_0__["Decimal"](expected_numbers[i]);
return _this2.checkNumbers(g_val, e_val);
}, this);
if (expected_numbers.length > generated_numbers.length) {
for (var i = generated_numbers.length; i < expected_numbers.length; ++i) {
result.push(_output_result__WEBPACK_IMPORTED_MODULE_8__["createNumberResult"](expected_numbers[i], null, 0));
}
}
e_output_clean = e_output_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
g_output_clean = g_output_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
var numberGrade = result.reduce(function (prev, r) {
return prev + r.grade;
}, 0) / result.length;
assessmentList.push(numberGrade);
}
if (OutputMatching.BOOLEAN_IN_STRING_REGEX.test(e_ouput)) {
var expected_bools = e_ouput.match(OutputMatching.BOOLEAN_IN_STRING_REGEX);
var generated_bools = g_output.match(OutputMatching.BOOLEAN_IN_STRING_REGEX) || [];
var _result = generated_bools.map(function (val, i) {
if (i >= expected_bools.length) {
return _output_result__WEBPACK_IMPORTED_MODULE_8__["createBoolResult"](null, val, 0);
}
var g_bool = _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__["toBool"](val);
var e_bool = _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_6__["toBool"](expected_bools[i]);
return _this2.checkBoolean(g_bool, e_bool);
}, this);
if (expected_bools.length > generated_bools.length) {
for (var _i = generated_bools.length; _i < expected_bools.length; ++_i) {
_result.push(_output_result__WEBPACK_IMPORTED_MODULE_8__["createBoolResult"](expected_bools[_i], null, 0));
}
}
e_output_clean = e_output_clean.replace(OutputMatching.BOOLEAN_IN_STRING_REGEX, '').trim();
g_output_clean = g_output_clean.replace(OutputMatching.BOOLEAN_IN_STRING_REGEX, '').trim();
var boolGrade = _result.reduce(function (prev, r) {
return prev + r.grade;
}, 0) / _result.length;
assessmentList.push(boolGrade);
}
var dist = Object(_util_utils__WEBPACK_IMPORTED_MODULE_4__["levenshteinDistance"])(g_output_clean, e_output_clean);
var gradeDiff = Math.max(0, e_output_clean.length - dist) / e_output_clean.length;
gradeDiff = Number.isNaN(gradeDiff) ? 0 : gradeDiff;
var assessment_size = assessmentList.length + 1;
var gradeAcc = assessmentList.reduce(function (prev, val) {
return prev + val / assessment_size;
}, 0);
var finalGrade = 1 * (gradeDiff / assessment_size + gradeAcc);
return _output_result__WEBPACK_IMPORTED_MODULE_8__["createStringResult"](e_ouput, g_output, finalGrade);
}
}, {
key: "getErrorMessage",
value: function getErrorMessage(errorID) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return LocalizedStrings.getError(errorID, args);
}
}]);
return OutputMatching;
}();
/***/ }),
/***/ "./js/assessment/output_matching/output_result.js":
/*!********************************************************!*\
!*** ./js/assessment/output_matching/output_result.js ***!
\********************************************************/
/*! exports provided: createNumberResult, createBoolResult, createStringResult, OutputMatchResult */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createNumberResult", function() { return createNumberResult; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createBoolResult", function() { return createBoolResult; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createStringResult", function() { return createStringResult; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutputMatchResult", function() { return OutputMatchResult; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function createNumberResult(expected, generated, grade) {
return new OutputMatchResult(expected, generated, grade, "number");
}
function createBoolResult(expected, generated, grade) {
return new OutputMatchResult(expected, generated, grade, "bool");
}
function createStringResult(expected, generated, grade) {
return new OutputMatchResult(expected, generated, grade, "string");
}
var OutputMatchResult = function OutputMatchResult(expected, generated, grade, type) {
_classCallCheck(this, OutputMatchResult);
this.expected = expected;
this.generated = generated;
this.grade = grade;
this.type = type;
};
/***/ }),
/***/ "./js/ast/ast_helpers.js":
/*!*******************************!*\
!*** ./js/ast/ast_helpers.js ***!
\*******************************/
/*! exports provided: recover */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "recover", function() { return recover; });
/* harmony import */ var _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./error/syntaxErrorFactory */ "./js/ast/error/syntaxErrorFactory.js");
function recover(_) {
var start = this._tokenStartCharIndex;
var stop = this._input.index;
var text = this._input.getText(start, stop);
text = this.getErrorDisplay(text);
var line = this._tokenStartLine;
var column = this._tokenStartColumn;
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_0__["SyntaxErrorFactory"].invalid_character(text, line, column);
}
/***/ }),
/***/ "./js/ast/commands/arrayAssign.js":
/*!****************************************!*\
!*** ./js/ast/commands/arrayAssign.js ***!
\****************************************/
/*! exports provided: ArrayIndexAssign */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayIndexAssign", function() { return ArrayIndexAssign; });
/* harmony import */ var _assign__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assign */ "./js/ast/commands/assign.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ArrayIndexAssign =
/*#__PURE__*/
function (_Assign) {
_inherits(ArrayIndexAssign, _Assign);
function ArrayIndexAssign(id, lineExpression, columnExpression, expression) {
var _this;
_classCallCheck(this, ArrayIndexAssign);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ArrayIndexAssign).call(this, id, expression));
_this.line = lineExpression;
_this.column = columnExpression;
return _this;
}
return ArrayIndexAssign;
}(_assign__WEBPACK_IMPORTED_MODULE_0__["Assign"]);
/***/ }),
/***/ "./js/ast/commands/arrayDeclaration.js":
/*!*********************************************!*\
!*** ./js/ast/commands/arrayDeclaration.js ***!
\*********************************************/
/*! exports provided: ArrayDeclaration */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayDeclaration", function() { return ArrayDeclaration; });
/* harmony import */ var _declaration__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./declaration */ "./js/ast/commands/declaration.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ArrayDeclaration =
/*#__PURE__*/
function (_Declaration) {
_inherits(ArrayDeclaration, _Declaration);
function ArrayDeclaration(id, type, lines, columns, initial, isConst) {
var _this;
_classCallCheck(this, ArrayDeclaration);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ArrayDeclaration).call(this, id, type, initial, isConst));
_this.lines = lines;
_this.columns = columns;
return _this;
}
_createClass(ArrayDeclaration, [{
key: "isVector",
get: function get() {
return this.columns == null;
}
}]);
return ArrayDeclaration;
}(_declaration__WEBPACK_IMPORTED_MODULE_0__["Declaration"]);
/***/ }),
/***/ "./js/ast/commands/assign.js":
/*!***********************************!*\
!*** ./js/ast/commands/assign.js ***!
\***********************************/
/*! exports provided: Assign */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Assign", function() { return Assign; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Assign =
/*#__PURE__*/
function (_Command) {
_inherits(Assign, _Command);
function Assign(id, expression) {
var _this;
_classCallCheck(this, Assign);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Assign).call(this));
_this.id = id;
_this.expression = expression;
return _this;
}
return Assign;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/break.js":
/*!**********************************!*\
!*** ./js/ast/commands/break.js ***!
\**********************************/
/*! exports provided: Break */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Break", function() { return Break; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Break =
/*#__PURE__*/
function (_Command) {
_inherits(Break, _Command);
function Break() {
_classCallCheck(this, Break);
return _possibleConstructorReturn(this, _getPrototypeOf(Break).call(this));
}
return Break;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/case.js":
/*!*********************************!*\
!*** ./js/ast/commands/case.js ***!
\*********************************/
/*! exports provided: Case */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Case", function() { return Case; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Case =
/*#__PURE__*/
function (_Command) {
_inherits(Case, _Command);
function Case(expression) {
var _this;
_classCallCheck(this, Case);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Case).call(this));
_this.expression = expression;
_this.commands = [];
return _this;
}
_createClass(Case, [{
key: "setCommands",
value: function setCommands(commands) {
this.commands = commands;
}
}, {
key: "isDefault",
get: function get() {
return this.expression === null;
}
}]);
return Case;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/command.js":
/*!************************************!*\
!*** ./js/ast/commands/command.js ***!
\************************************/
/*! exports provided: Command */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Command =
/*#__PURE__*/
function () {
function Command() {
_classCallCheck(this, Command);
this._sourceInfo = null;
}
_createClass(Command, [{
key: "sourceInfo",
set: function set(sourceInfo) {
this._sourceInfo = sourceInfo;
},
get: function get() {
return this._sourceInfo;
}
}]);
return Command;
}();
/***/ }),
/***/ "./js/ast/commands/commandBlock.js":
/*!*****************************************!*\
!*** ./js/ast/commands/commandBlock.js ***!
\*****************************************/
/*! exports provided: CommandBlock */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CommandBlock", function() { return CommandBlock; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var CommandBlock =
/*#__PURE__*/
function () {
function CommandBlock(variables, commands) {
_classCallCheck(this, CommandBlock);
this.variables = variables;
this.commands = commands;
this._sourceInfo = null;
}
_createClass(CommandBlock, [{
key: "sourceInfo",
set: function set(sourceInfo) {
this._sourceInfo = sourceInfo;
},
get: function get() {
return this._sourceInfo;
}
}]);
return CommandBlock;
}();
/***/ }),
/***/ "./js/ast/commands/declaration.js":
/*!****************************************!*\
!*** ./js/ast/commands/declaration.js ***!
\****************************************/
/*! exports provided: Declaration */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Declaration", function() { return Declaration; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Declaration =
/*#__PURE__*/
function (_Command) {
_inherits(Declaration, _Command);
function Declaration(id, type, initial, isConst) {
var _this;
_classCallCheck(this, Declaration);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Declaration).call(this));
_this.id = id;
_this.type = type;
_this.initial = initial;
_this.isConst = isConst;
return _this;
}
return Declaration;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/for.js":
/*!********************************!*\
!*** ./js/ast/commands/for.js ***!
\********************************/
/*! exports provided: For */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "For", function() { return For; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var For =
/*#__PURE__*/
function (_Command) {
_inherits(For, _Command);
function For(for_id, for_from, for_to, for_pass, commandBlock) {
var _this;
_classCallCheck(this, For);
_this = _possibleConstructorReturn(this, _getPrototypeOf(For).call(this));
_this.for_id = for_id;
_this.for_from = for_from;
_this.for_to = for_to;
_this.for_pass = for_pass;
_this.commandBlock = commandBlock;
return _this;
}
_createClass(For, [{
key: "commands",
get: function get() {
return this.commandBlock.commands;
}
}]);
return For;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/formalParameter.js":
/*!********************************************!*\
!*** ./js/ast/commands/formalParameter.js ***!
\********************************************/
/*! exports provided: FormalParameter */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormalParameter", function() { return FormalParameter; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var FormalParameter =
/*#__PURE__*/
function () {
function FormalParameter(type, id) {
var byRef = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
_classCallCheck(this, FormalParameter);
this.type = type;
this.id = id;
this.byRef = byRef;
this._sourceInfo = null;
}
_createClass(FormalParameter, [{
key: "sourceInfo",
set: function set(sourceInfo) {
this._sourceInfo = sourceInfo;
},
get: function get() {
return this._sourceInfo;
}
}]);
return FormalParameter;
}();
/***/ }),
/***/ "./js/ast/commands/function.js":
/*!*************************************!*\
!*** ./js/ast/commands/function.js ***!
\*************************************/
/*! exports provided: Function */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Function", function() { return Function; });
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Function =
/*#__PURE__*/
function () {
function Function(name, returnType, formalParameters, commandBlock) {
_classCallCheck(this, Function);
this.name = name;
this.returnType = returnType;
this.formalParameters = formalParameters;
this.commandBlock = commandBlock;
this._sourceInfo = null;
}
_createClass(Function, [{
key: "isMain",
get: function get() {
return this.name === null && this.returnType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].VOID);
}
}, {
key: "commands",
get: function get() {
return this.commandBlock.commands;
}
}, {
key: "variablesDeclarations",
get: function get() {
return this.commandBlock.variables;
}
}, {
key: "sourceInfo",
set: function set(sourceInfo) {
this._sourceInfo = sourceInfo;
},
get: function get() {
return this._sourceInfo;
}
}]);
return Function;
}();
/***/ }),
/***/ "./js/ast/commands/ifThenElse.js":
/*!***************************************!*\
!*** ./js/ast/commands/ifThenElse.js ***!
\***************************************/
/*! exports provided: IfThenElse */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IfThenElse", function() { return IfThenElse; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var IfThenElse =
/*#__PURE__*/
function (_Command) {
_inherits(IfThenElse, _Command);
function IfThenElse(condition, ifTrue, ifFalse) {
var _this;
_classCallCheck(this, IfThenElse);
_this = _possibleConstructorReturn(this, _getPrototypeOf(IfThenElse).call(this));
_this.condition = condition;
_this.ifTrue = ifTrue;
_this.ifFalse = ifFalse;
return _this;
}
return IfThenElse;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/index.js":
/*!**********************************!*\
!*** ./js/ast/commands/index.js ***!
\**********************************/
/*! exports provided: Break, Return, Assign, ArrayIndexAssign, Declaration, ArrayDeclaration, While, For, Function, IfThenElse, CommandBlock, RepeatUntil, Switch, Case, SysCall, FormalParameter, FunctionCall */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _break__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./break */ "./js/ast/commands/break.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Break", function() { return _break__WEBPACK_IMPORTED_MODULE_0__["Break"]; });
/* harmony import */ var _return__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./return */ "./js/ast/commands/return.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Return", function() { return _return__WEBPACK_IMPORTED_MODULE_1__["Return"]; });
/* harmony import */ var _assign__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./assign */ "./js/ast/commands/assign.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Assign", function() { return _assign__WEBPACK_IMPORTED_MODULE_2__["Assign"]; });
/* harmony import */ var _arrayAssign__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arrayAssign */ "./js/ast/commands/arrayAssign.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArrayIndexAssign", function() { return _arrayAssign__WEBPACK_IMPORTED_MODULE_3__["ArrayIndexAssign"]; });
/* harmony import */ var _declaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./declaration */ "./js/ast/commands/declaration.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Declaration", function() { return _declaration__WEBPACK_IMPORTED_MODULE_4__["Declaration"]; });
/* harmony import */ var _arrayDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./arrayDeclaration */ "./js/ast/commands/arrayDeclaration.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArrayDeclaration", function() { return _arrayDeclaration__WEBPACK_IMPORTED_MODULE_5__["ArrayDeclaration"]; });
/* harmony import */ var _while__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./while */ "./js/ast/commands/while.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "While", function() { return _while__WEBPACK_IMPORTED_MODULE_6__["While"]; });
/* harmony import */ var _for__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./for */ "./js/ast/commands/for.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "For", function() { return _for__WEBPACK_IMPORTED_MODULE_7__["For"]; });
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./function */ "./js/ast/commands/function.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Function", function() { return _function__WEBPACK_IMPORTED_MODULE_8__["Function"]; });
/* harmony import */ var _ifThenElse__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ifThenElse */ "./js/ast/commands/ifThenElse.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IfThenElse", function() { return _ifThenElse__WEBPACK_IMPORTED_MODULE_9__["IfThenElse"]; });
/* harmony import */ var _commandBlock__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./commandBlock */ "./js/ast/commands/commandBlock.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CommandBlock", function() { return _commandBlock__WEBPACK_IMPORTED_MODULE_10__["CommandBlock"]; });
/* harmony import */ var _repeatUntil__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./repeatUntil */ "./js/ast/commands/repeatUntil.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RepeatUntil", function() { return _repeatUntil__WEBPACK_IMPORTED_MODULE_11__["RepeatUntil"]; });
/* harmony import */ var _switch__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./switch */ "./js/ast/commands/switch.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Switch", function() { return _switch__WEBPACK_IMPORTED_MODULE_12__["Switch"]; });
/* harmony import */ var _case__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./case */ "./js/ast/commands/case.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Case", function() { return _case__WEBPACK_IMPORTED_MODULE_13__["Case"]; });
/* harmony import */ var _sysCall__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sysCall */ "./js/ast/commands/sysCall.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SysCall", function() { return _sysCall__WEBPACK_IMPORTED_MODULE_14__["SysCall"]; });
/* harmony import */ var _formalParameter__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./formalParameter */ "./js/ast/commands/formalParameter.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FormalParameter", function() { return _formalParameter__WEBPACK_IMPORTED_MODULE_15__["FormalParameter"]; });
/* harmony import */ var _expressions_functionCall__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./../expressions/functionCall */ "./js/ast/expressions/functionCall.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FunctionCall", function() { return _expressions_functionCall__WEBPACK_IMPORTED_MODULE_16__["FunctionCall"]; });
//Proxy to expression since they do exatcly the same thing
/***/ }),
/***/ "./js/ast/commands/repeatUntil.js":
/*!****************************************!*\
!*** ./js/ast/commands/repeatUntil.js ***!
\****************************************/
/*! exports provided: RepeatUntil */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepeatUntil", function() { return RepeatUntil; });
/* harmony import */ var _while__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./while */ "./js/ast/commands/while.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var RepeatUntil =
/*#__PURE__*/
function (_While) {
_inherits(RepeatUntil, _While);
function RepeatUntil(condition, commandBlock) {
_classCallCheck(this, RepeatUntil);
return _possibleConstructorReturn(this, _getPrototypeOf(RepeatUntil).call(this, condition, commandBlock));
}
_createClass(RepeatUntil, [{
key: "testFirst",
get: function get() {
return false;
}
}]);
return RepeatUntil;
}(_while__WEBPACK_IMPORTED_MODULE_0__["While"]);
/***/ }),
/***/ "./js/ast/commands/return.js":
/*!***********************************!*\
!*** ./js/ast/commands/return.js ***!
\***********************************/
/*! exports provided: Return */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Return", function() { return Return; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Return =
/*#__PURE__*/
function (_Command) {
_inherits(Return, _Command);
function Return(expression) {
var _this;
_classCallCheck(this, Return);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Return).call(this));
_this.expression = expression;
return _this;
}
return Return;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/switch.js":
/*!***********************************!*\
!*** ./js/ast/commands/switch.js ***!
\***********************************/
/*! exports provided: Switch */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Switch", function() { return Switch; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Switch =
/*#__PURE__*/
function (_Command) {
_inherits(Switch, _Command);
function Switch(expression, cases) {
var _this;
_classCallCheck(this, Switch);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Switch).call(this));
_this.expression = expression;
_this.cases = cases;
return _this;
}
return Switch;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/commands/sysCall.js":
/*!************************************!*\
!*** ./js/ast/commands/sysCall.js ***!
\************************************/
/*! exports provided: SysCall */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SysCall", function() { return SysCall; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* This class represents all the language defined functions.
* The language processor uses the id provided here to properly execute the desired function.
* The function is actually implemented inside the language processor.
* All the functions can be found at: js/processor/definedFunctions.js
*/
var SysCall = function SysCall(langFunc) {
_classCallCheck(this, SysCall);
this.langFunc = langFunc;
};
/***/ }),
/***/ "./js/ast/commands/while.js":
/*!**********************************!*\
!*** ./js/ast/commands/while.js ***!
\**********************************/
/*! exports provided: While */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "While", function() { return While; });
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var While =
/*#__PURE__*/
function (_Command) {
_inherits(While, _Command);
function While(expression, commandBlock) {
var _this;
_classCallCheck(this, While);
_this = _possibleConstructorReturn(this, _getPrototypeOf(While).call(this));
_this.expression = expression;
_this.commandBlock = commandBlock;
return _this;
}
_createClass(While, [{
key: "commands",
get: function get() {
return this.commandBlock.commands;
}
}, {
key: "testFirst",
get: function get() {
return true;
}
}]);
return While;
}(_command__WEBPACK_IMPORTED_MODULE_0__["Command"]);
/***/ }),
/***/ "./js/ast/error/syntaxError.js":
/*!*************************************!*\
!*** ./js/ast/error/syntaxError.js ***!
\*************************************/
/*! exports provided: SyntaxError */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SyntaxError", function() { return SyntaxError; });
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var SyntaxError =
/*#__PURE__*/
function (_Error) {
_inherits(SyntaxError, _Error);
function SyntaxError() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, SyntaxError);
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
msg[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SyntaxError)).call.apply(_getPrototypeOf2, [this].concat(msg)));
if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_this), SyntaxError);
return _this;
}
return SyntaxError;
}(_wrapNativeSuper(Error));
/***/ }),
/***/ "./js/ast/error/syntaxErrorFactory.js":
/*!********************************************!*\
!*** ./js/ast/error/syntaxErrorFactory.js ***!
\********************************************/
/*! exports provided: SyntaxErrorFactory */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SyntaxErrorFactory", function() { return SyntaxErrorFactory; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _syntaxError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./syntaxError */ "./js/ast/error/syntaxError.js");
var LocalizedStrings = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["getInstance"]();
function createError(message_id) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return new _syntaxError__WEBPACK_IMPORTED_MODULE_1__["SyntaxError"](LocalizedStrings.getError(message_id, context));
}
var SyntaxErrorFactory = Object.freeze({
extra_lines: function extra_lines() {
return new _syntaxError__WEBPACK_IMPORTED_MODULE_1__["SyntaxError"](LocalizedStrings.getError("extra_lines"));
},
token_missing_one: function token_missing_one(expected, token) {
var context = [expected, token.text, token.line, token.column];
return createError("token_missing_one", context);
},
token_missing_list: function token_missing_list(expectedList, token) {
var line = expectedList.join(LocalizedStrings.getOR());
return SyntaxErrorFactory.token_missing_one(line, token);
},
id_missing: function id_missing(token) {
var context = [token.text, token.line, token.column];
return createError("id_missing", context);
},
eos_missing: function eos_missing(token) {
var context = [token.line, token.column];
return createError("eos_missing", context);
},
invalid_array_dimension: function invalid_array_dimension(typeName, token) {
var context = [token.line, token.column, typeName];
return createError("invalid_array_dimension", context);
},
invalid_array_size: function invalid_array_size(token) {
var context = [token.line];
return createError("invalid_array_size", context);
},
invalid_main_return: function invalid_main_return(name, typeName, token) {
var context = [name, typeName, token.line];
return createError("invalid_main_return", context);
},
invalid_var_declaration: function invalid_var_declaration(token) {
var context = [token.line];
return createError("invalid_var_declaration", context);
},
invalid_break_command: function invalid_break_command(cmdName, token) {
var context = [token.line, cmdName];
return createError("invalid_break_command", context);
},
invalid_terminal: function invalid_terminal(token) {
var context = [token.text, token.line, token.column];
return createError('invalid_terminal', context);
},
invalid_type: function invalid_type(list, token) {
var line = list.join(LocalizedStrings.getOR());
var context = [token.text, token.line, token.column, line];
return createError("invalid_type", context);
},
const_not_init: function const_not_init(token) {
var context = [token.line, token.column];
return createError("const_not_init", context);
},
invalid_id_format: function invalid_id_format(token) {
var context = [token.text, token.line, token.column];
return createError("invalid_id_format", context);
},
duplicate_function: function duplicate_function(token) {
var context = [token.text, token.line, token.column];
return createError("duplicate_function", context);
},
main_parameters: function main_parameters() {
return createError("main_parameters");
},
duplicate_variable: function duplicate_variable(token) {
var context = [token.text, token.line, token.column];
return createError("duplicate_variable", context);
},
invalid_character: function invalid_character(text, line, _column) {
var context = [text, line];
return createError("invalid_character", context);
},
annonymous_array_literal: function annonymous_array_literal(token) {
var context = [token.line];
return createError("annonymous_array_literal", context);
},
invalid_matrix_literal_line: function invalid_matrix_literal_line(exp, sourceInfo) {
var context = [exp, sourceInfo.line];
return createError("invalid_matrix_literal_line", context);
},
cannot_infer_matrix_line: function cannot_infer_matrix_line(name, sourceInfo) {
var context = [name, sourceInfo.line];
return createError("cannot_infer_matrix_line", context);
},
cannot_infer_matrix_column: function cannot_infer_matrix_column(name, sourceInfo) {
var context = [name, sourceInfo.line];
return createError("cannot_infer_matrix_column", context);
},
cannot_infer_vector_size: function cannot_infer_vector_size(name, sourceInfo) {
var context = [name, sourceInfo.line];
return createError("cannot_infer_vector_size", context);
},
matrix_to_vector_literal_attr: function matrix_to_vector_literal_attr(name, exp, sourceInfo) {
var context = [sourceInfo.line, exp, name];
return createError("matrix_to_vector_literal_attr", context);
},
vector_to_matrix_literal_attr: function vector_to_matrix_literal_attr(name, exp, sourceInfo) {
var context = [sourceInfo.line, exp, name];
return createError("vector_to_matrix_literal_attr", context);
},
array_init_not_literal: function array_init_not_literal(sourceInfo) {
var context = [sourceInfo.line];
return createError("array_init_not_literal", context);
},
array_exceeds_2d: function array_exceeds_2d(sourceInfo) {
var context = [sourceInfo.line];
return createError("array_exceeds_2d", context);
},
invalid_matrix_id_dimension: function invalid_matrix_id_dimension(sourceInfo) {
var context = [sourceInfo.line];
return createError("invalid_matrix_id_dimension", context);
},
invalid_vector_init: function invalid_vector_init(sourceInfo) {
var context = [sourceInfo.line];
return createError("invalid_vector_init", context);
},
invalid_matrix_init: function invalid_matrix_init(sourceInfo) {
var context = [sourceInfo.line];
return createError("invalid_matrix_init", context);
}
});
/***/ }),
/***/ "./js/ast/expressions/arrayAccess.js":
/*!*******************************************!*\
!*** ./js/ast/expressions/arrayAccess.js ***!
\*******************************************/
/*! exports provided: ArrayAccess */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayAccess", function() { return ArrayAccess; });
/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ArrayAccess =
/*#__PURE__*/
function (_Expression) {
_inherits(ArrayAccess, _Expression);
function ArrayAccess(id, line, column) {
var _this;
_classCallCheck(this, ArrayAccess);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ArrayAccess).call(this));
_this.id = id;
_this.line = line;
_this.column = column;
return _this;
}
_createClass(ArrayAccess, [{
key: "toString",
value: function toString() {
var strLine = this.line.toString();
var strColumn = null;
if (this.column) {
strColumn = this.column.toString();
}
var text = null;
if (strColumn) {
text = "".concat(this.id, "[").concat(strLine, "][").concat(strColumn, "]");
} else {
text = "".concat(this.id, "[").concat(strLine, "]");
}
if (this.parenthesis) {
return "(".concat(text, ")");
} else {
return text;
}
}
}]);
return ArrayAccess;
}(_expression__WEBPACK_IMPORTED_MODULE_0__["Expression"]);
/***/ }),
/***/ "./js/ast/expressions/arrayLiteral.js":
/*!********************************************!*\
!*** ./js/ast/expressions/arrayLiteral.js ***!
\********************************************/
/*! exports provided: ArrayLiteral */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayLiteral", function() { return ArrayLiteral; });
/* harmony import */ var _literal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ArrayLiteral =
/*#__PURE__*/
function (_Literal) {
_inherits(ArrayLiteral, _Literal);
function ArrayLiteral(type, value) {
var _this;
_classCallCheck(this, ArrayLiteral);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ArrayLiteral).call(this, type));
_this.value = value;
return _this;
}
_createClass(ArrayLiteral, [{
key: "validateType",
value: function validateType() {
var valid = true; // const subtype = this.subtype;
// if(this.columns !== null) {
// const len = this.lines;
// const len2 = this.columns;
// for (let i = len - 1; i >= 0 && valid; --i) {
// for (let j = len2 - 1; j >= 0 && valid; --j) {
// if(!this.value[i].value[j].type.isCompatilbe(subtype)) {
// valid = false;
// break;
// }
// }
// }
// } else {
// const len = this.lines;
// for (var i = len - 1; i >= 0 && valid; i--) {
// if(!this.value[i].type.isCompatilbe(subtype)) {
// valid = false;
// break;
// }
// }
// }
// Cannot validate type since no information on variables literals are available
return valid;
}
}, {
key: "validateSize",
value: function validateSize() {
var valid = true; // if(this.columns !== null) {
// const equalityTest = this.value.map(v => v.value.length)
// .reduce((old, next) => {
// console.log(next);
// if (old == null) {
// return next;
// } else if (old === next) {
// return old
// } else {
// return -1;
// }
// }, null);
// valid = equalityTest !== -1;
// }
// check is now made inside IVProgParser.parseVectorList(...)
return valid;
}
}, {
key: "toString",
value: function toString() {
var strList = this.value.map(function (arrayLiteral) {
return arrayLiteral.toString();
});
var text = "{" + strList.join(',') + "}";
if (this.parenthesis) {
return "(".concat(text, ")");
} else {
return text;
}
}
}, {
key: "subtype",
get: function get() {
var element = this.value[0];
if (element instanceof ArrayLiteral) {
return element.value[0].type;
} else {
return element.type;
}
}
}, {
key: "lines",
get: function get() {
return this.value.length;
}
}, {
key: "columns",
get: function get() {
var element = this.value[0];
if (!(element instanceof ArrayLiteral)) {
return null;
} else {
return element.value.length;
}
}
}, {
key: "isVector",
get: function get() {
return this.columns === null;
}
}, {
key: "isValid",
get: function get() {
return this.validateSize() && this.validateType();
}
}]);
return ArrayLiteral;
}(_literal__WEBPACK_IMPORTED_MODULE_0__["Literal"]);
/***/ }),
/***/ "./js/ast/expressions/boolLiteral.js":
/*!*******************************************!*\
!*** ./js/ast/expressions/boolLiteral.js ***!
\*******************************************/
/*! exports provided: BoolLiteral */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoolLiteral", function() { return BoolLiteral; });
/* harmony import */ var _literal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var BoolLiteral =
/*#__PURE__*/
function (_Literal) {
_inherits(BoolLiteral, _Literal);
function BoolLiteral(value) {
var _this;
_classCallCheck(this, BoolLiteral);
_this = _possibleConstructorReturn(this, _getPrototypeOf(BoolLiteral).call(this, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN));
_this.value = value;
return _this;
}
_createClass(BoolLiteral, [{
key: "toString",
value: function toString() {
var text = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["convertBoolToString"])(this.value);
if (this.parenthesis) {
return "(".concat(text, ")");
} else {
return text;
}
}
}]);
return BoolLiteral;
}(_literal__WEBPACK_IMPORTED_MODULE_0__["Literal"]);
/***/ }),
/***/ "./js/ast/expressions/expression.js":
/*!******************************************!*\
!*** ./js/ast/expressions/expression.js ***!
\******************************************/
/*! exports provided: Expression */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Expression", function() { return Expression; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Expression =
/*#__PURE__*/
function () {
function Expression() {
_classCallCheck(this, Expression);
this._sourceInfo = null;
this._parenthesis = false;
}
_createClass(Expression, [{
key: "sourceInfo",
set: function set(sourceInfo) {
this._sourceInfo = sourceInfo;
},
get: function get() {
return this._sourceInfo;
}
}, {
key: "parenthesis",
set: function set(flag) {
this._parenthesis = flag;
},
get: function get() {
return this._parenthesis;
}
}]);
return Expression;
}();
/***/ }),
/***/ "./js/ast/expressions/functionCall.js":
/*!********************************************!*\
!*** ./js/ast/expressions/functionCall.js ***!
\********************************************/
/*! exports provided: FunctionCall */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FunctionCall", function() { return FunctionCall; });
/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
/* harmony import */ var _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../processor/definedFunctions */ "./js/processor/definedFunctions.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var FunctionCall =
/*#__PURE__*/
function (_Expression) {
_inherits(FunctionCall, _Expression);
function FunctionCall(id, actualParameters) {
var _this;
_classCallCheck(this, FunctionCall);
_this = _possibleConstructorReturn(this, _getPrototypeOf(FunctionCall).call(this));
_this.id = id;
_this.actualParameters = actualParameters;
return _this;
}
_createClass(FunctionCall, [{
key: "toString",
value: function toString() {
var name = null;
if (this.isMainCall) {
name = _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_1__["LanguageDefinedFunction"].getMainFunctionName();
} else {
name = _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_1__["LanguageDefinedFunction"].getLocalName(this.id);
}
var params = null;
if (this.actualParameters.length == 0) {
params = "()";
} else {
var strParams = this.actualParameters.map(function (v) {
return v.toString();
});
params = "(" + strParams.join(",") + ")";
}
if (this.parenthesis) {
return "(".concat(name + params, ")");
} else {
return name + params;
}
}
}, {
key: "isMainCall",
get: function get() {
return this.id === null;
}
}, {
key: "parametersSize",
get: function get() {
return this.actualParameters.length;
}
}]);
return FunctionCall;
}(_expression__WEBPACK_IMPORTED_MODULE_0__["Expression"]);
/***/ }),
/***/ "./js/ast/expressions/index.js":
/*!*************************************!*\
!*** ./js/ast/expressions/index.js ***!
\*************************************/
/*! exports provided: ArrayAccess, FunctionCall, IntLiteral, RealLiteral, BoolLiteral, StringLiteral, ArrayLiteral, VariableLiteral, InfixApp, UnaryApp */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _arrayAccess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayAccess */ "./js/ast/expressions/arrayAccess.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArrayAccess", function() { return _arrayAccess__WEBPACK_IMPORTED_MODULE_0__["ArrayAccess"]; });
/* harmony import */ var _functionCall__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./functionCall */ "./js/ast/expressions/functionCall.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FunctionCall", function() { return _functionCall__WEBPACK_IMPORTED_MODULE_1__["FunctionCall"]; });
/* harmony import */ var _intLiteral__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./intLiteral */ "./js/ast/expressions/intLiteral.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntLiteral", function() { return _intLiteral__WEBPACK_IMPORTED_MODULE_2__["IntLiteral"]; });
/* harmony import */ var _realLiteral__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./realLiteral */ "./js/ast/expressions/realLiteral.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RealLiteral", function() { return _realLiteral__WEBPACK_IMPORTED_MODULE_3__["RealLiteral"]; });
/* harmony import */ var _boolLiteral__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boolLiteral */ "./js/ast/expressions/boolLiteral.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoolLiteral", function() { return _boolLiteral__WEBPACK_IMPORTED_MODULE_4__["BoolLiteral"]; });
/* harmony import */ var _stringLiteral__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stringLiteral */ "./js/ast/expressions/stringLiteral.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringLiteral", function() { return _stringLiteral__WEBPACK_IMPORTED_MODULE_5__["StringLiteral"]; });
/* harmony import */ var _arrayLiteral__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./arrayLiteral */ "./js/ast/expressions/arrayLiteral.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArrayLiteral", function() { return _arrayLiteral__WEBPACK_IMPORTED_MODULE_6__["ArrayLiteral"]; });
/* harmony import */ var _variableLiteral__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./variableLiteral */ "./js/ast/expressions/variableLiteral.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VariableLiteral", function() { return _variableLiteral__WEBPACK_IMPORTED_MODULE_7__["VariableLiteral"]; });
/* harmony import */ var _infixApp__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./infixApp */ "./js/ast/expressions/infixApp.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InfixApp", function() { return _infixApp__WEBPACK_IMPORTED_MODULE_8__["InfixApp"]; });
/* harmony import */ var _unaryApp__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./unaryApp */ "./js/ast/expressions/unaryApp.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UnaryApp", function() { return _unaryApp__WEBPACK_IMPORTED_MODULE_9__["UnaryApp"]; });
/***/ }),
/***/ "./js/ast/expressions/infixApp.js":
/*!****************************************!*\
!*** ./js/ast/expressions/infixApp.js ***!
\****************************************/
/*! exports provided: InfixApp */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InfixApp", function() { return InfixApp; });
/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var InfixApp =
/*#__PURE__*/
function (_Expression) {
_inherits(InfixApp, _Expression);
function InfixApp(op, left, right) {
var _this;
_classCallCheck(this, InfixApp);
_this = _possibleConstructorReturn(this, _getPrototypeOf(InfixApp).call(this));
_this.op = op;
_this.left = left;
_this.right = right;
return _this;
}
_createClass(InfixApp, [{
key: "toString",
value: function toString() {
var l = this.left.toString();
var op = this.op.value;
var r = this.right.toString();
if (this.parenthesis) {
return "(".concat(l + op + r, ")");
} else {
return l + op + r;
}
}
}]);
return InfixApp;
}(_expression__WEBPACK_IMPORTED_MODULE_0__["Expression"]);
/***/ }),
/***/ "./js/ast/expressions/intLiteral.js":
/*!******************************************!*\
!*** ./js/ast/expressions/intLiteral.js ***!
\******************************************/
/*! exports provided: IntLiteral */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntLiteral", function() { return IntLiteral; });
/* harmony import */ var _literal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var IntLiteral =
/*#__PURE__*/
function (_Literal) {
_inherits(IntLiteral, _Literal);
function IntLiteral(value) {
var _this;
_classCallCheck(this, IntLiteral);
_this = _possibleConstructorReturn(this, _getPrototypeOf(IntLiteral).call(this, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER));
_this.value = value;
return _this;
}
_createClass(IntLiteral, [{
key: "toString",
value: function toString() {
var text = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["convertToString"])(this.value, this.type);
if (this.parenthesis) {
return "(".concat(text, ")");
} else {
return text;
}
}
}]);
return IntLiteral;
}(_literal__WEBPACK_IMPORTED_MODULE_0__["Literal"]);
/***/ }),
/***/ "./js/ast/expressions/literal.js":
/*!***************************************!*\
!*** ./js/ast/expressions/literal.js ***!
\***************************************/
/*! exports provided: Literal */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Literal", function() { return Literal; });
/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Literal =
/*#__PURE__*/
function (_Expression) {
_inherits(Literal, _Expression);
function Literal(type) {
var _this;
_classCallCheck(this, Literal);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Literal).call(this));
_this.type = type;
return _this;
}
return Literal;
}(_expression__WEBPACK_IMPORTED_MODULE_0__["Expression"]);
/***/ }),
/***/ "./js/ast/expressions/realLiteral.js":
/*!*******************************************!*\
!*** ./js/ast/expressions/realLiteral.js ***!
\*******************************************/
/*! exports provided: RealLiteral */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RealLiteral", function() { return RealLiteral; });
/* harmony import */ var _literal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var RealLiteral =
/*#__PURE__*/
function (_Literal) {
_inherits(RealLiteral, _Literal);
function RealLiteral(value) {
var _this;
_classCallCheck(this, RealLiteral);
_this = _possibleConstructorReturn(this, _getPrototypeOf(RealLiteral).call(this, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL));
_this.value = value;
return _this;
}
_createClass(RealLiteral, [{
key: "toString",
value: function toString() {
var text = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["convertToString"])(this.value, this.type);
if (this.parenthesis) {
return "(".concat(text, ")");
} else {
return text;
}
}
}]);
return RealLiteral;
}(_literal__WEBPACK_IMPORTED_MODULE_0__["Literal"]);
/***/ }),
/***/ "./js/ast/expressions/stringLiteral.js":
/*!*********************************************!*\
!*** ./js/ast/expressions/stringLiteral.js ***!
\*********************************************/
/*! exports provided: StringLiteral */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringLiteral", function() { return StringLiteral; });
/* harmony import */ var _literal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var StringLiteral =
/*#__PURE__*/
function (_Literal) {
_inherits(StringLiteral, _Literal);
function StringLiteral(value) {
var _this;
_classCallCheck(this, StringLiteral);
_this = _possibleConstructorReturn(this, _getPrototypeOf(StringLiteral).call(this, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING));
_this.value = value;
return _this;
}
_createClass(StringLiteral, [{
key: "toString",
value: function toString() {
var text = '"' + this.value + '"';
if (this.parenthesis) {
return "(".concat(text, ")");
} else {
return text;
}
}
}]);
return StringLiteral;
}(_literal__WEBPACK_IMPORTED_MODULE_0__["Literal"]);
/***/ }),
/***/ "./js/ast/expressions/unaryApp.js":
/*!****************************************!*\
!*** ./js/ast/expressions/unaryApp.js ***!
\****************************************/
/*! exports provided: UnaryApp */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UnaryApp", function() { return UnaryApp; });
/* harmony import */ var _infixApp__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./infixApp */ "./js/ast/expressions/infixApp.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var UnaryApp =
/*#__PURE__*/
function (_InfixApp) {
_inherits(UnaryApp, _InfixApp);
function UnaryApp(op, left) {
_classCallCheck(this, UnaryApp);
return _possibleConstructorReturn(this, _getPrototypeOf(UnaryApp).call(this, op, left, null));
}
_createClass(UnaryApp, [{
key: "toString",
value: function toString() {
var l = this.left.toString();
var op = this.op.value;
if (this.parenthesis) {
return "(".concat(op + l, ")");
} else {
return op + l;
}
}
}]);
return UnaryApp;
}(_infixApp__WEBPACK_IMPORTED_MODULE_0__["InfixApp"]);
/***/ }),
/***/ "./js/ast/expressions/variableLiteral.js":
/*!***********************************************!*\
!*** ./js/ast/expressions/variableLiteral.js ***!
\***********************************************/
/*! exports provided: VariableLiteral */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VariableLiteral", function() { return VariableLiteral; });
/* harmony import */ var _literal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var VariableLiteral =
/*#__PURE__*/
function (_Literal) {
_inherits(VariableLiteral, _Literal);
function VariableLiteral(id) {
var _this;
_classCallCheck(this, VariableLiteral);
_this = _possibleConstructorReturn(this, _getPrototypeOf(VariableLiteral).call(this, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].UNDEFINED));
_this.id = id;
return _this;
}
_createClass(VariableLiteral, [{
key: "toString",
value: function toString() {
if (this.parenthesis) {
return "(".concat(this.id, ")");
} else {
return this.id;
}
}
}]);
return VariableLiteral;
}(_literal__WEBPACK_IMPORTED_MODULE_0__["Literal"]);
/***/ }),
/***/ "./js/ast/ivprogParser.js":
/*!********************************!*\
!*** ./js/ast/ivprogParser.js ***!
\********************************/
/*! exports provided: IVProgParser */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IVProgParser", function() { return IVProgParser; });
/* harmony import */ var antlr4_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! antlr4/index */ "./node_modules/antlr4/index.js");
/* harmony import */ var antlr4_index__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(antlr4_index__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./expressions */ "./js/ast/expressions/index.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./commands */ "./js/ast/commands/index.js");
/* harmony import */ var _ast_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ast_helpers */ "./js/ast/ast_helpers.js");
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _sourceInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sourceInfo */ "./js/ast/sourceInfo.js");
/* harmony import */ var _operators__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./operators */ "./js/ast/operators.js");
/* harmony import */ var _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./error/syntaxErrorFactory */ "./js/ast/error/syntaxErrorFactory.js");
/* harmony import */ var _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../processor/definedFunctions */ "./js/processor/definedFunctions.js");
/* harmony import */ var _services_languageService__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var IVProgParser =
/*#__PURE__*/
function () {
_createClass(IVProgParser, null, [{
key: "createParser",
value: function createParser(input) {
var lexerClass = _services_languageService__WEBPACK_IMPORTED_MODULE_11__["LanguageService"].getCurrentLexer();
return new IVProgParser(input, lexerClass);
} //
}, {
key: "BASE",
get: function get() {
return 0;
}
}, {
key: "FUNCTION",
get: function get() {
return 1;
}
}, {
key: "COMMAND",
get: function get() {
return 2;
}
}, {
key: "BREAKABLE",
get: function get() {
return 4;
} // END scope consts>
}]);
function IVProgParser(input, lexerClass) {
_classCallCheck(this, IVProgParser);
this.lexerClass = lexerClass;
this.inputStream = new antlr4_index__WEBPACK_IMPORTED_MODULE_0__["InputStream"](input);
this.lexer = new lexerClass(this.inputStream);
this.lexer.recover = _ast_helpers__WEBPACK_IMPORTED_MODULE_3__["recover"].bind(this.lexer);
this.tokenStream = new antlr4_index__WEBPACK_IMPORTED_MODULE_0__["CommonTokenStream"](this.lexer);
this.tokenStream.fill();
this.pos = 1;
this.variableTypes = [this.lexerClass.RK_INTEGER, this.lexerClass.RK_REAL, this.lexerClass.RK_BOOLEAN, this.lexerClass.RK_STRING];
this.functionTypes = this.variableTypes.concat(this.lexerClass.RK_VOID);
this.parsingArrayDimension = 0;
this.scope = [];
this.langFuncs = _services_languageService__WEBPACK_IMPORTED_MODULE_11__["LanguageService"].getCurrentLangFuncs();
this.definedFuncsNameList = [];
this.definedVariablesStack = [];
}
_createClass(IVProgParser, [{
key: "parseTree",
value: function parseTree() {
return this.parseProgram();
}
}, {
key: "getToken",
value: function getToken() {
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.pos;
// if(index === null)
// index = this.pos;
return this.tokenStream.LT(index);
}
}, {
key: "insideScope",
value: function insideScope(scope) {
if (this.scope.length <= 0) {
return IVProgParser.BASE === scope;
} else {
return this.scope[this.scope.length - 1] === scope;
}
}
}, {
key: "pushScope",
value: function pushScope(scope) {
this.scope.push(scope);
}
}, {
key: "pushVariableStack",
value: function pushVariableStack() {
this.definedVariablesStack.push([]);
}
}, {
key: "popScope",
value: function popScope() {
return this.scope.pop();
}
}, {
key: "popVariableStack",
value: function popVariableStack() {
return this.definedVariablesStack.pop();
}
}, {
key: "getCurrentVariableStack",
value: function getCurrentVariableStack() {
return this.definedVariablesStack[this.definedVariablesStack.length - 1];
}
}, {
key: "isEOF",
value: function isEOF() {
this.getToken(this.pos);
return this.tokenStream.fetchedEOF;
}
}, {
key: "parseProgram",
value: function parseProgram() {
this.consumeNewLines();
var token = this.getToken();
var globalVars = [];
var functions = [];
if (this.lexerClass.RK_PROGRAM === token.type) {
this.pos++;
this.consumeNewLines();
this.checkOpenCurly();
this.pos++;
this.pushVariableStack();
for (;;) {
this.consumeNewLines();
var _token = this.getToken();
if (_token.type === this.lexerClass.RK_CONST || this.isVariableType(_token)) {
globalVars = globalVars.concat(this.parseGlobalVariables());
} else if (_token.type === this.lexerClass.RK_FUNCTION) {
this.pushVariableStack();
functions = functions.concat(this.parseFunction());
this.popVariableStack();
} else {
break;
}
}
this.consumeNewLines();
this.checkCloseCurly();
this.pos++;
this.consumeNewLines();
if (!this.isEOF()) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].extra_lines();
}
this.popVariableStack();
return {
global: globalVars,
functions: functions
};
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(this.lexer.literalNames[this.lexerClass.RK_PROGRAM], token);
}
}
}, {
key: "checkOpenCurly",
value: function checkOpenCurly() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var token = this.getToken();
if (this.lexerClass.OPEN_CURLY !== token.type) {
if (!attempt) throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one('{', token);else return false;
}
return true;
}
}, {
key: "checkCloseCurly",
value: function checkCloseCurly() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var token = this.getToken();
if (this.lexerClass.CLOSE_CURLY !== token.type) {
if (!attempt) throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one('}', token);else return false;
}
return true;
}
/* It checks if the current token at position pos is a ']'.
* As a check function it doesn't increment pos.
*
* @params bool:attempt, indicates that the token is optional. Defaults: false
*
* @returns true if the attempt is true and current token is '[',
* false is attempt is true and current token is not '['
**/
}, {
key: "checkOpenBrace",
value: function checkOpenBrace() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var token = this.getToken();
if (this.lexerClass.OPEN_BRACE !== token.type) {
if (!attempt) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one('[', token);
} else {
return false;
}
}
return true;
}
}, {
key: "checkCloseBrace",
value: function checkCloseBrace() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var token = this.getToken();
if (this.lexerClass.CLOSE_BRACE !== token.type) {
if (!attempt) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(']', token);
} else {
return false;
}
}
return true;
}
}, {
key: "checkOpenParenthesis",
value: function checkOpenParenthesis() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var token = this.getToken();
if (this.lexerClass.OPEN_PARENTHESIS !== token.type) {
if (!attempt) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one('(', token);
} else {
return false;
}
}
return true;
}
}, {
key: "checkCloseParenthesis",
value: function checkCloseParenthesis() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var token = this.getToken();
if (this.lexerClass.CLOSE_PARENTHESIS !== token.type) {
if (!attempt) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(')', token);
} else {
return false;
}
}
return true;
}
}, {
key: "checkEOS",
value: function checkEOS() {
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var eosToken = this.getToken();
if (eosToken.type !== this.lexerClass.EOS) {
if (!attempt) throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].eos_missing(eosToken);else return false;
}
return true;
}
}, {
key: "checkFunctionDuplicate",
value: function checkFunctionDuplicate(functionID, funcIDToken) {
var id = functionID === null ? "$main" : functionID;
var index = this.definedFuncsNameList.indexOf(id);
if (index !== -1) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].duplicate_function(funcIDToken);
}
this.definedFuncsNameList.push(id);
}
}, {
key: "checkVariableDuplicate",
value: function checkVariableDuplicate(variableID, sourceInfo) {
var index = this.getCurrentVariableStack().indexOf(variableID);
if (index !== -1) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].duplicate_variable(sourceInfo);
}
this.getCurrentVariableStack().push(variableID);
}
}, {
key: "consumeForSemiColon",
value: function consumeForSemiColon() {
var eosToken = this.getToken();
if (eosToken.type === this.lexerClass.EOS && eosToken.text.match(';')) {
this.pos++;
return;
}
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(';', eosToken);
}
}, {
key: "parseGlobalVariables",
value: function parseGlobalVariables() {
var decl = this.parseMaybeConst();
this.checkEOS();
this.pos++;
return decl;
}
/*
* Checks if the next token is PR_CONST. It's only available
* at global variables declaration level
* @returns Declararion(const, type, id, initVal?)
**/
}, {
key: "parseMaybeConst",
value: function parseMaybeConst() {
var constToken = this.getToken();
if (constToken.type === this.lexerClass.RK_CONST) {
this.pos++;
var typeString = this.parseType();
return this.parseDeclaration(typeString, true);
} else if (this.isVariableType(constToken)) {
var _typeString = this.parseType();
return this.parseDeclaration(_typeString);
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_list([this.lexer.literalNames[this.lexerClass.RK_CONST]].concat(this.getTypeArray()), constToken);
}
}
/*
* Parses a declarion of the form: type --- id --- (= --- EAnd)?
* @returns a list of Declararion(const, type, id, initVal?)
**/
}, {
key: "parseDeclaration",
value: function parseDeclaration(typeString) {
var isConst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var initial = null;
var dim1 = null;
var dim2 = null;
var dimensions = 0;
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(this.getToken());
var idString = this.parseID();
this.checkVariableDuplicate(idString, sourceInfo); // Check for array or vector
// ID[int/IDi?][int/IDj?]
if (this.checkOpenBrace(true)) {
this.pos += 1;
this.consumeNewLines();
dim1 = this.parseArrayDimension();
this.consumeNewLines();
this.checkCloseBrace();
this.pos += 1;
dimensions += 1;
if (this.checkOpenBrace(true)) {
this.pos += 1;
this.consumeNewLines();
dim2 = this.parseArrayDimension();
this.consumeNewLines();
this.checkCloseBrace();
this.pos += 1;
dimensions += 1;
}
return this.parseArrayDeclaration(typeString, isConst, idString, sourceInfo, dimensions, dim1, dim2);
} else {
var equalsToken = this.getToken();
if (isConst && equalsToken.type !== this.lexerClass.EQUAL) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].const_not_init(sourceInfo);
}
if (equalsToken.type === this.lexerClass.EQUAL) {
this.pos++;
initial = this.parseExpressionOR();
}
var declaration = new _commands__WEBPACK_IMPORTED_MODULE_2__["Declaration"](idString, typeString, initial, isConst);
declaration.sourceInfo = sourceInfo;
var commaToken = this.getToken();
if (commaToken.type === this.lexerClass.COMMA) {
this.pos++;
this.consumeNewLines();
return [declaration].concat(this.parseDeclaration(typeString, isConst));
} else {
return [declaration];
}
}
}
}, {
key: "parseArrayDeclaration",
value: function parseArrayDeclaration(typeString, isConst, idString, sourceInfo, dimensions, dim1, dim2) {
var equalsToken = this.getToken();
var n_lines = dim1;
var n_columns = dim2;
var initial = null;
var dim_is_id = false;
if (dim1 instanceof _expressions__WEBPACK_IMPORTED_MODULE_1__["VariableLiteral"] || dim2 instanceof _expressions__WEBPACK_IMPORTED_MODULE_1__["VariableLiteral"]) {
dim_is_id = true;
if (dimensions > 1 && (dim1 == null || dim2 == null)) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_matrix_id_dimension(_sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(equalsToken));
}
}
if (isConst && equalsToken.type !== this.lexerClass.EQUAL) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].const_not_init(sourceInfo);
}
if (equalsToken.type === this.lexerClass.EQUAL) {
if (dim_is_id) {
if (dimensions == 1) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_vector_init(_sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(equalsToken));
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_matrix_init(_sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(equalsToken));
}
}
this.pos += 1;
initial = this.parseArrayLiteral(typeString);
}
if (initial == null && dim1 == null) {
if (dimensions > 1) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].cannot_infer_matrix_line(idString, sourceInfo);
}
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].cannot_infer_vector_size(idString, sourceInfo);
}
if (dimensions > 1) {
if (initial == null && dim2 == null) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].cannot_infer_matrix_column(idString, sourceInfo);
}
}
if (dimensions === 1 && initial != null && !initial.isVector) {
var expString = initial.toString();
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].matrix_to_vector_literal_attr(idString, expString, initial.sourceInfo);
} else if (dimensions > 1 && initial != null && initial.isVector) {
var _expString = initial.toString();
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].vector_to_matrix_literal_attr(idString, _expString, initial.sourceInfo);
}
if (dim1 == null) {
n_lines = new _expressions__WEBPACK_IMPORTED_MODULE_1__["IntLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__["toInt"])(initial.lines));
n_lines.sourceInfo = sourceInfo;
}
if (dimensions > 1) {
if (dim2 == null) {
n_columns = new _expressions__WEBPACK_IMPORTED_MODULE_1__["IntLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__["toInt"])(initial.columns));
n_columns.sourceInfo = sourceInfo;
}
}
var declaration = new _commands__WEBPACK_IMPORTED_MODULE_2__["ArrayDeclaration"](idString, new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__["ArrayType"](typeString, dimensions), n_lines, n_columns, initial, isConst);
declaration.sourceInfo = sourceInfo;
var commaToken = this.getToken();
if (commaToken.type === this.lexerClass.COMMA) {
this.pos++;
this.consumeNewLines();
return [declaration].concat(this.parseDeclaration(typeString, isConst));
} else {
return [declaration];
}
}
}, {
key: "consumeNewLines",
value: function consumeNewLines() {
var token = this.getToken();
while (token.type === this.lexerClass.EOS && token.text.match('[\r\n]+')) {
this.pos++;
token = this.getToken();
}
}
}, {
key: "isVariableType",
value: function isVariableType(token) {
return this.variableTypes.find(function (v) {
return v === token.type;
});
}
/*
* Reads the next token of the stream to check if it is a Integer or an ID.
* @returns Integer | ID
**/
}, {
key: "parseArrayDimension",
value: function parseArrayDimension() {
var dimToken = this.getToken();
if (dimToken.type === this.lexerClass.INTEGER) {
//parse as int literal
this.pos++;
return this.getIntLiteral(dimToken);
} else if (dimToken.type === this.lexerClass.ID) {
//parse as variable
this.pos++;
return this.parseVariable(dimToken);
} else if (dimToken.type === this.lexerClass.CLOSE_BRACE) {
return null;
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_array_dimension(this.lexer.literalNames[this.lexerClass.RK_INTEGER], dimToken);
}
}
/*
* Returns an object {type: 'int', value: value}.
* It checks for binary and hexadecimal integers.
* @returns object with fields type and value
**/
}, {
key: "getIntLiteral",
value: function getIntLiteral(token) {
var text = token.text;
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["IntLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__["toInt"])(text));
exp.sourceInfo = sourceInfo;
return exp;
}
}, {
key: "getRealLiteral",
value: function getRealLiteral(token) {
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["RealLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__["toReal"])(token.text));
exp.sourceInfo = sourceInfo;
return exp;
}
}, {
key: "getStringLiteral",
value: function getStringLiteral(token) {
var text = token.text;
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["StringLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__["toString"])(text));
exp.sourceInfo = sourceInfo;
return exp;
}
}, {
key: "getBoolLiteral",
value: function getBoolLiteral(token) {
var val = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_4__["toBool"])(token.text);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["BoolLiteral"](val);
exp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
return exp;
}
}, {
key: "parseArrayLiteral",
value: function parseArrayLiteral(typeString) {
var openCurly = this.checkOpenCurly(true);
if (!openCurly) {
var invalid_token = this.getToken();
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].array_init_not_literal(_sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(invalid_token));
}
var beginArray = this.getToken();
if (this.parsingArrayDimension >= 2) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].array_exceeds_2d(_sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(beginArray));
}
this.pos += 1;
this.parsingArrayDimension += 1;
this.consumeNewLines();
var data = null;
var maybeCurlyOpen = this.checkOpenCurly(true);
if (maybeCurlyOpen) {
// This is potentially a list of vectors
data = this.parseVectorList(typeString);
} else {
data = this.parseExpressionList();
}
this.consumeNewLines();
this.checkCloseCurly();
var endArray = this.getToken();
this.pos += 1;
this.parsingArrayDimension -= 1;
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfoFromList(beginArray, endArray);
var dataDim = 1;
if (data[0] instanceof _expressions__WEBPACK_IMPORTED_MODULE_1__["ArrayLiteral"]) {
dataDim += 1;
} else if (data.length == 1) {
console.log("Talvez uma variável seja uma melhor opção");
}
var type = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__["ArrayType"](typeString, dataDim);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["ArrayLiteral"](type, data);
exp.sourceInfo = sourceInfo;
return exp;
}
/**
* Returns a list of ArrayLiterals. Helper function for parsing matrices
*/
}, {
key: "parseVectorList",
value: function parseVectorList(typeString) {
var list = [];
var lastSize = null;
for (;;) {
this.checkOpenCurly();
var beginArray = this.getToken();
if (this.parsingArrayDimension >= 2) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].array_exceeds_2d(_sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(beginArray));
}
this.pos += 1;
this.parsingArrayDimension += 1;
this.consumeNewLines();
var data = this.parseExpressionList();
this.consumeNewLines();
this.checkCloseCurly();
var endArray = this.getToken();
this.pos += 1;
this.parsingArrayDimension -= 1;
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfoFromList(beginArray, endArray);
if (lastSize == null) {
lastSize = data.length;
} else if (lastSize !== data.length) {
var expString = this.inputStream.getText(beginArray.start, endArray.stop);
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_matrix_literal_line(expString, sourceInfo);
}
var type = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__["ArrayType"](typeString, 1);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["ArrayLiteral"](type, data);
exp.sourceInfo = sourceInfo;
list.push(exp);
var commaToken = this.getToken();
if (commaToken.type !== this.lexerClass.COMMA) {
break;
}
this.pos += 1;
this.consumeNewLines();
}
if (list.length == 1) {
console.log("Talvez um vetor seja uma melhor opção");
}
return list;
}
/*
* Returns an object {type: 'variable', value: value}.
* @returns object with fields type and value
**/
}, {
key: "parseVariable",
value: function parseVariable(token) {
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["VariableLiteral"](token.text);
exp.sourceInfo = sourceInfo;
return exp;
}
/*
* Returns an object representing a function. It has
* four attributes: returnType, id, formalParams and block.
* The block object has two attributes: declarations and commands
**/
}, {
key: "parseFunction",
value: function parseFunction() {
this.pushScope(IVProgParser.FUNCTION);
var formalParams = [];
var token = this.getToken();
if (token.type !== this.lexerClass.RK_FUNCTION) {
//throw SyntaxError.createError(this.lexer.literalNames[this.lexerClass.PR_FUNCAO], token);
return null;
}
this.pos++;
var funType = this.parseType();
var dimensions = 0;
if (this.checkOpenBrace(true)) {
this.pos++;
this.checkCloseBrace();
this.pos++;
dimensions++;
if (this.checkOpenBrace(true)) {
this.pos++;
this.checkCloseBrace();
this.pos++;
dimensions++;
}
}
var funcIDToken = this.getToken();
var functionID = this.parseID();
this.checkFunctionDuplicate(functionID, funcIDToken);
this.checkOpenParenthesis();
this.pos++;
this.consumeNewLines();
if (!this.checkCloseParenthesis(true)) {
formalParams = this.parseFormalParameters(); // formal parameters
this.consumeNewLines();
this.checkCloseParenthesis();
this.pos++;
} else {
this.pos++;
}
this.consumeNewLines();
var commandsBlock = this.parseCommandBlock();
var returnType = funType;
if (dimensions > 0) {
returnType = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__["ArrayType"](funType, dimensions);
}
var func = new _commands__WEBPACK_IMPORTED_MODULE_2__["Function"](functionID, returnType, formalParams, commandsBlock);
if (functionID === null && !func.isMain) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_main_return(_processor_definedFunctions__WEBPACK_IMPORTED_MODULE_10__["LanguageDefinedFunction"].getMainFunctionName(), this.lexer.literalNames[this.lexerClass.RK_VOID], token.line);
} else if (func.isMain && formalParams.length !== 0) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].main_parameters();
}
this.popScope();
return func;
}
/*
* Parse the formal parameters of a function.
* @returns a list of objects with the following attributes: type, id and dimensions.
**/
}, {
key: "parseFormalParameters",
value: function parseFormalParameters() {
var list = [];
for (;;) {
var dimensions = 0;
var reference = false;
var typeString = this.parseType();
var maybeIDToken = this.getToken();
if (maybeIDToken.type === this.lexerClass.RK_REFERENCE) {
reference = true;
this.pos += 1;
maybeIDToken = this.getToken();
}
var idString = this.parseID();
this.checkVariableDuplicate(idString, maybeIDToken);
if (this.checkOpenBrace(true)) {
this.pos += 1;
dimensions += 1;
this.checkCloseBrace();
this.pos += 1;
if (this.checkOpenBrace(true)) {
this.pos += 1;
dimensions += 1;
this.checkCloseBrace();
this.pos += 1;
}
}
var type = null;
if (dimensions > 0) {
type = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_6__["ArrayType"](typeString, dimensions);
} else {
type = typeString;
}
var parameter = new _commands__WEBPACK_IMPORTED_MODULE_2__["FormalParameter"](type, idString, reference);
parameter.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(maybeIDToken);
list.push(parameter);
var commaToken = this.getToken();
if (commaToken.type !== this.lexerClass.COMMA) break;
this.pos++;
this.consumeNewLines();
}
return list;
}
}, {
key: "parseID",
value: function parseID() {
var token = this.getToken();
if (token.type !== this.lexerClass.ID) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].id_missing(token);
}
this.pos++;
if (this.insideScope(IVProgParser.FUNCTION)) {
if (token.text === _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_10__["LanguageDefinedFunction"].getMainFunctionName()) {
return null;
}
}
return token.text;
}
}, {
key: "parseMaybeLibID",
value: function parseMaybeLibID() {
var token = this.getToken();
if (token.type !== this.lexerClass.ID && token.type !== this.lexerClass.LIB_ID) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].id_missing(token);
}
this.pos++;
return token.text;
}
}, {
key: "parseType",
value: function parseType() {
var token = this.getToken();
if (token.type === this.lexerClass.ID && this.insideScope(IVProgParser.FUNCTION)) {
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__["Types"].VOID;
} else if (token.type === this.lexerClass.RK_VOID && this.insideScope(IVProgParser.FUNCTION)) {
this.pos++;
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__["Types"].VOID;
} else if (this.isVariableType(token)) {
this.pos++;
switch (token.type) {
case this.lexerClass.RK_INTEGER:
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__["Types"].INTEGER;
case this.lexerClass.RK_BOOLEAN:
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__["Types"].BOOLEAN;
case this.lexerClass.RK_REAL:
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__["Types"].REAL;
case this.lexerClass.RK_STRING:
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_5__["Types"].STRING;
default:
break;
}
}
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_type(this.getTypeArray(), token);
}
}, {
key: "parseCommandBlock",
value: function parseCommandBlock() {
var optionalCurly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var variablesDecl = [];
var commands = [];
var hasOpen = false;
if (this.checkOpenCurly(optionalCurly)) {
this.pos++;
hasOpen = true;
}
this.consumeNewLines();
var parsedCommand = false;
for (;;) {
var cmd = this.parseCommand();
if (cmd === null) break;
if (cmd !== -1) {
if (cmd instanceof Array) {
if (parsedCommand) {
var lastToken = this.getToken(this.pos - 1);
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_var_declaration(lastToken);
}
variablesDecl = variablesDecl.concat(cmd);
} else {
parsedCommand = true;
commands.push(cmd);
}
}
}
this.consumeNewLines();
if (hasOpen) {
this.checkCloseCurly();
this.pos++;
this.consumeNewLines();
}
return new _commands__WEBPACK_IMPORTED_MODULE_2__["CommandBlock"](variablesDecl, commands);
}
}, {
key: "parseCommand",
value: function parseCommand() {
var token = this.getToken();
if (this.isVariableType(token)) {
if (!this.insideScope(IVProgParser.FUNCTION)) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_var_declaration(token);
}
this.pushScope(IVProgParser.BASE);
var varType = this.parseType();
this.popScope();
var cmd = this.parseDeclaration(varType);
this.checkEOS();
this.pos++;
return cmd;
} else if (token.type === this.lexerClass.ID) {
return this.parseIDCommand();
} else if (token.type === this.lexerClass.LIB_ID) {
return this.parseIDCommand();
} else if (token.type === this.lexerClass.RK_RETURN) {
return this.parseReturn();
} else if (token.type === this.lexerClass.RK_WHILE || token.type === this.lexerClass.RK_WHILE_ALT) {
return this.parseWhile();
} else if (token.type === this.lexerClass.RK_FOR || token.type === this.lexerClass.RK_FOR_ALT) {
return this.parseFor();
} else if (token.type === this.lexerClass.RK_BREAK) {
if (!this.insideScope(IVProgParser.BREAKABLE)) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_break_command(this.lexer.literalNames[this.lexerClass.RK_BREAK], token);
}
return this.parseBreak();
} else if (token.type === this.lexerClass.RK_SWITCH) {
return this.parseSwitchCase();
} else if (token.type === this.lexerClass.RK_DO) {
return this.parseRepeatUntil();
} else if (token.type === this.lexerClass.RK_IF) {
return this.parseIfThenElse();
} else if (this.checkEOS(true)) {
this.pos++;
return -1;
} else {
return null;
}
}
}, {
key: "parseSwitchCase",
value: function parseSwitchCase() {
this.pushScope(IVProgParser.BREAKABLE);
this.pos++;
this.checkOpenParenthesis();
this.pos++;
this.consumeNewLines();
var exp = this.parseExpressionOR();
this.consumeNewLines();
this.checkCloseParenthesis();
this.pos++;
this.consumeNewLines();
this.checkOpenCurly();
this.pos++;
this.consumeNewLines();
var casesList = this.parseCases();
this.consumeNewLines();
this.checkCloseCurly();
this.pos++;
this.consumeNewLines();
this.popScope();
return new _commands__WEBPACK_IMPORTED_MODULE_2__["Switch"](exp, casesList);
}
}, {
key: "parseRepeatUntil",
value: function parseRepeatUntil() {
this.pos++;
this.consumeNewLines();
this.pushScope(IVProgParser.BREAKABLE);
var commandsBlock = this.parseCommandBlock();
this.consumeNewLines(); //Maybe not...
var whileToken = this.getToken();
if (whileToken.type !== this.lexerClass.RK_DO_UNTIL) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(this.lexer.literalNames[this.lexerClass.RK_DO_UNTIL], whileToken);
}
this.pos++;
this.checkOpenParenthesis();
this.pos++;
this.consumeNewLines();
var condition = this.parseExpressionOR();
this.consumeNewLines();
this.checkCloseParenthesis();
this.pos++;
this.checkEOS();
this.popScope();
return new _commands__WEBPACK_IMPORTED_MODULE_2__["RepeatUntil"](condition, commandsBlock);
}
}, {
key: "parseIfThenElse",
value: function parseIfThenElse() {
if (this.insideScope(IVProgParser.BREAKABLE)) {
this.pushScope(IVProgParser.BREAKABLE);
} else {
this.pushScope(IVProgParser.COMMAND);
}
var token = this.getToken();
this.pos++;
this.checkOpenParenthesis();
this.pos++;
this.consumeNewLines();
var logicalExpression = this.parseExpressionOR();
this.consumeNewLines();
this.checkCloseParenthesis();
this.pos++;
this.consumeNewLines();
var cmdBlocks = this.parseCommandBlock();
var maybeElse = this.getToken();
if (maybeElse.type === this.lexerClass.RK_ELSE) {
this.pos++;
this.consumeNewLines();
var maybeIf = this.getToken();
var elseBlock = null;
if (this.checkOpenCurly(true)) {
elseBlock = this.parseCommandBlock();
} else if (maybeIf.type === this.lexerClass.RK_IF) {
elseBlock = this.parseIfThenElse();
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_list([this.lexer.literalNames[this.lexerClass.RK_IF], '{'], maybeIf);
}
this.popScope();
var _cmd = new _commands__WEBPACK_IMPORTED_MODULE_2__["IfThenElse"](logicalExpression, cmdBlocks, elseBlock);
_cmd.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
return _cmd;
}
this.popScope();
var cmd = new _commands__WEBPACK_IMPORTED_MODULE_2__["IfThenElse"](logicalExpression, cmdBlocks, null);
cmd.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
return cmd;
}
}, {
key: "parseFor",
value: function parseFor() {
this.pushScope(IVProgParser.BREAKABLE);
var for_token = this.getToken();
this.pos += 1; // parse ID
var id_token = this.getToken();
var id = this.parseID();
var for_id = new _expressions__WEBPACK_IMPORTED_MODULE_1__["VariableLiteral"](id);
for_id.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(id_token); // END parse ID
var for_from = this.parseForParameters(this.lexerClass.RK_FOR_FROM);
var for_to = this.parseForParameters(this.lexerClass.RK_FOR_TO);
var maybePass = this.parseForParameters(this.lexerClass.RK_FOR_PASS);
this.consumeNewLines();
var commandsBlock = this.parseCommandBlock();
this.popScope();
var cmd = new _commands__WEBPACK_IMPORTED_MODULE_2__["For"](for_id, for_from, for_to, maybePass, commandsBlock);
cmd.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(for_token);
return cmd;
}
}, {
key: "parseWhile",
value: function parseWhile() {
this.pushScope(IVProgParser.BREAKABLE);
var token = this.getToken();
this.pos++;
this.checkOpenParenthesis();
this.pos++;
this.consumeNewLines();
var logicalExpression = this.parseExpressionOR();
this.consumeNewLines();
this.checkCloseParenthesis();
this.pos++;
this.consumeNewLines();
var cmdBlocks = this.parseCommandBlock();
this.popScope();
var cmd = new _commands__WEBPACK_IMPORTED_MODULE_2__["While"](logicalExpression, cmdBlocks);
cmd.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
return cmd;
}
}, {
key: "parseBreak",
value: function parseBreak() {
this.pos++;
this.checkEOS();
this.pos++;
return new _commands__WEBPACK_IMPORTED_MODULE_2__["Break"]();
}
}, {
key: "parseReturn",
value: function parseReturn() {
this.pos++;
var exp = null;
if (!this.checkEOS(true)) {
exp = this.parseExpressionOR();
this.checkEOS();
}
this.pos++;
return new _commands__WEBPACK_IMPORTED_MODULE_2__["Return"](exp);
}
}, {
key: "parseIDCommand",
value: function parseIDCommand() {
var refToken = this.getToken();
var isID = refToken.type === this.lexerClass.ID;
var id = this.parseMaybeLibID();
if (this.checkOpenBrace(true)) {
this.pos++;
var lineExpression = null;
var columnExpression = null;
this.consumeNewLines();
lineExpression = this.parseExpression();
this.consumeNewLines();
this.checkCloseBrace();
this.pos++;
if (this.checkOpenBrace(true)) {
this.pos++;
this.consumeNewLines();
columnExpression = this.parseExpression();
this.consumeNewLines();
this.checkCloseBrace();
this.pos++;
}
var equalToken = this.getToken();
if (equalToken.type !== this.lexerClass.EQUAL) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one('=', equalToken);
}
this.pos++;
var exp = this.parseExpressionOR();
this.checkEOS();
this.pos++;
var cmd = new _commands__WEBPACK_IMPORTED_MODULE_2__["ArrayIndexAssign"](id, lineExpression, columnExpression, exp);
cmd.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(equalToken);
return cmd;
}
var equalOrParenthesis = this.getToken();
if (isID && equalOrParenthesis.type === this.lexerClass.EQUAL) {
this.pos++;
var _exp = this.parseExpressionOR();
this.checkEOS();
this.pos++;
var _cmd2 = new _commands__WEBPACK_IMPORTED_MODULE_2__["Assign"](id, _exp);
_cmd2.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(equalOrParenthesis);
return _cmd2;
} else if (equalOrParenthesis.type === this.lexerClass.OPEN_PARENTHESIS) {
var funcCall = this.parseFunctionCallCommand(id);
this.checkEOS();
this.pos++;
return funcCall;
} else if (isID) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_list(['=', '('], equalOrParenthesis);
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_id_format(refToken);
}
}
}, {
key: "parseForParameters",
value: function parseForParameters(keyword_code) {
if (keyword_code === this.lexerClass.RK_FOR_PASS) {
if (this.checkOpenCurly(true)) {
return null;
}
}
var from_token = this.getToken();
if (from_token.type !== keyword_code) {
// TODO better error message
var keyword = this.lexer.literalNames[keyword_code];
throw new Error("Error de sintaxe no comando repita_para: esperava-se " + keyword + " mas encontrou " + from_token.text);
}
this.pos += 1;
var int_or_id = this.getToken();
var is_unary_op = false;
var op = null;
if (int_or_id.type === this.lexerClass.SUM_OP) {
is_unary_op = true;
op = int_or_id.text;
this.pos += 1;
int_or_id = this.getToken();
}
var for_from = null;
if (int_or_id.type === this.lexerClass.ID) {
for_from = new _expressions__WEBPACK_IMPORTED_MODULE_1__["VariableLiteral"](this.parseID());
for_from.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(int_or_id);
} else if (int_or_id.type === this.lexerClass.INTEGER) {
this.pos += 1;
for_from = this.getIntLiteral(int_or_id);
}
if (for_from == null) {
// TODO better error message
var _keyword = this.lexer.literalNames[keyword_code];
throw new Error("Error de sintaxe no comando repeita_para: " + int_or_id.text + " não é compativel com o esperado para o paramentro " + _keyword + ". O valor deve ser um inteiro ou variável.");
}
if (is_unary_op) {
for_from = new _expressions__WEBPACK_IMPORTED_MODULE_1__["UnaryApp"](Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])(op), for_from);
}
return for_from;
}
}, {
key: "parseCases",
value: function parseCases() {
var token = this.getToken();
if (token.type !== this.lexerClass.RK_CASE) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(this.lexer.literalNames[this.lexerClass.RK_CASE], token);
}
this.pos++;
var nextToken = this.getToken();
if (nextToken.type === this.lexerClass.RK_DEFAULT) {
this.pos++;
var colonToken = this.getToken();
if (colonToken.type !== this.lexerClass.COLON) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(':', colonToken);
}
this.pos++;
this.consumeNewLines();
var block = this.parseCommandBlock(true);
var defaultCase = new _commands__WEBPACK_IMPORTED_MODULE_2__["Case"](null);
defaultCase.setCommands(block.commands);
return [defaultCase];
} else {
var exp = this.parseExpressionOR();
var _colonToken = this.getToken();
if (_colonToken.type !== this.lexerClass.COLON) {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].token_missing_one(':', _colonToken);
}
this.pos++;
this.consumeNewLines();
var _block = this.parseCommandBlock(true);
var aCase = new _commands__WEBPACK_IMPORTED_MODULE_2__["Case"](exp);
aCase.setCommands(_block.commands);
var caseToken = this.getToken();
if (caseToken.type === this.lexerClass.RK_CASE) {
return [aCase].concat(this.parseCases());
} else {
return [aCase];
}
}
}
/*
* Parses an Expression following the structure:
*
* EOR => EAnd ( 'or' EOR)? #expression and
*
* EOR => ENot ('and' EOR)? #expression or
*
* ENot => 'not'? ER #expression not
*
* ER => E ((>=, <=, ==, >, <) E)? #expression relational
*
* E => factor ((+, -) E)? #expression
*
* factor=> term ((*, /, %) factor)?
*
* term => literal || arrayAccess || FuncCall || ID || '('EAnd')'
**/
}, {
key: "parseExpressionOR",
value: function parseExpressionOR() {
var exp1 = this.parseExpressionAND();
while (this.getToken().type === this.lexerClass.OR_OPERATOR) {
var opToken = this.getToken();
this.pos++;
var or = Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])('or');
this.consumeNewLines();
var exp2 = this.parseExpressionAND();
var finalExp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["InfixApp"](or, exp1, exp2);
finalExp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(opToken);
exp1 = finalExp;
}
return exp1;
}
}, {
key: "parseExpressionAND",
value: function parseExpressionAND() {
var exp1 = this.parseExpressionNot();
while (this.getToken().type === this.lexerClass.AND_OPERATOR) {
var opToken = this.getToken();
this.pos++;
var and = Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])('and');
this.consumeNewLines();
var exp2 = this.parseExpressionNot();
var finalExp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["InfixApp"](and, exp1, exp2);
finalExp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(opToken);
exp1 = finalExp;
}
return exp1;
}
}, {
key: "parseExpressionNot",
value: function parseExpressionNot() {
var maybeNotToken = this.getToken();
if (maybeNotToken.type === this.lexerClass.NOT_OPERATOR) {
var opToken = this.getToken();
this.pos++;
var not = Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])('not');
var exp1 = this.parseExpressionRel();
var finalExp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["UnaryApp"](not, exp1);
finalExp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(opToken);
return finalExp;
} else {
return this.parseExpressionRel();
}
}
}, {
key: "parseExpressionRel",
value: function parseExpressionRel() {
var exp1 = this.parseExpression();
while (this.getToken().type === this.lexerClass.RELATIONAL_OPERATOR) {
var relToken = this.getToken();
this.pos++;
var rel = Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])(relToken.text);
var exp2 = this.parseExpression();
var finalExp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["InfixApp"](rel, exp1, exp2);
finalExp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(relToken);
exp1 = finalExp;
}
return exp1;
}
}, {
key: "parseExpression",
value: function parseExpression() {
var factor = this.parseFactor();
while (this.getToken().type === this.lexerClass.SUM_OP) {
var sumOpToken = this.getToken();
this.pos++;
var op = Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])(sumOpToken.text);
var factor2 = this.parseFactor();
var finalExp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["InfixApp"](op, factor, factor2);
finalExp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(sumOpToken);
factor = finalExp;
}
return factor;
}
}, {
key: "parseFactor",
value: function parseFactor() {
var term = this.parseTerm();
while (this.getToken().type === this.lexerClass.MULTI_OP) {
var multOpToken = this.getToken();
this.pos++;
var op = Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])(multOpToken.text);
var term2 = this.parseTerm();
var finalExp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["InfixApp"](op, term, term2);
finalExp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(multOpToken);
term = finalExp;
}
return term;
}
}, {
key: "parseTerm",
value: function parseTerm() {
var token = this.getToken();
var sourceInfo = null;
var exp = null;
switch (token.type) {
case this.lexerClass.SUM_OP:
this.pos++;
sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(token);
exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["UnaryApp"](Object(_operators__WEBPACK_IMPORTED_MODULE_8__["convertFromString"])(token.text), this.parseTerm());
exp.sourceInfo = sourceInfo;
return exp;
case this.lexerClass.INTEGER:
this.pos++;
return this.getIntLiteral(token);
case this.lexerClass.REAL:
this.pos++;
return this.getRealLiteral(token);
case this.lexerClass.STRING:
this.pos++;
return this.getStringLiteral(token);
case this.lexerClass.RK_TRUE:
case this.lexerClass.RK_FALSE:
this.pos++;
return this.getBoolLiteral(token);
case this.lexerClass.OPEN_CURLY:
// No more annonymous array
// return this.parseArrayLiteral();
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].annonymous_array_literal(token);
case this.lexerClass.ID:
case this.lexerClass.LIB_ID:
return this.parseIDTerm();
case this.lexerClass.OPEN_PARENTHESIS:
return this.parseParenthesisExp();
default:
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_terminal(token);
}
}
}, {
key: "parseIDTerm",
value: function parseIDTerm() {
var tokenA = this.getToken();
var id = this.parseMaybeLibID();
var isID = tokenA.type === this.lexerClass.ID;
if (isID && this.checkOpenBrace(true)) {
var tokenB = null;
this.pos++;
var firstIndex = this.parseExpression();
var secondIndex = null;
this.consumeNewLines();
this.checkCloseBrace();
tokenB = this.getToken();
this.pos++;
if (this.checkOpenBrace(true)) {
this.pos++;
secondIndex = this.parseExpression();
this.consumeNewLines();
this.checkCloseBrace();
tokenB = this.getToken();
this.pos++;
}
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfoFromList(tokenA, tokenB);
var exp = new _expressions__WEBPACK_IMPORTED_MODULE_1__["ArrayAccess"](id, firstIndex, secondIndex);
exp.sourceInfo = sourceInfo;
return exp;
} else if (this.checkOpenParenthesis(true)) {
return this.parseFunctionCallExpression(id);
} else if (isID) {
var _sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfo(tokenA);
var _exp2 = new _expressions__WEBPACK_IMPORTED_MODULE_1__["VariableLiteral"](id);
_exp2.sourceInfo = _sourceInfo;
return _exp2;
} else {
throw _error_syntaxErrorFactory__WEBPACK_IMPORTED_MODULE_9__["SyntaxErrorFactory"].invalid_id_format(tokenA);
}
}
}, {
key: "getFunctionName",
value: function getFunctionName(id) {
var name = _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_10__["LanguageDefinedFunction"].getInternalName(id);
if (name === null) {
if (id === _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_10__["LanguageDefinedFunction"].getMainFunctionName()) {
return null;
}
return id;
} else {
return name;
}
}
}, {
key: "parseFunctionCallExpression",
value: function parseFunctionCallExpression(id) {
var tokenA = this.getToken(this.pos - 1);
var actualParameters = this.parseActualParameters();
var tokenB = this.getToken(this.pos - 1);
var funcName = this.getFunctionName(id);
var sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfoFromList(tokenA, tokenB);
var cmd = new _expressions__WEBPACK_IMPORTED_MODULE_1__["FunctionCall"](funcName, actualParameters);
cmd.sourceInfo = sourceInfo;
return cmd;
}
}, {
key: "parseFunctionCallCommand",
value: function parseFunctionCallCommand(id) {
return this.parseFunctionCallExpression(id);
}
}, {
key: "parseParenthesisExp",
value: function parseParenthesisExp() {
this.checkOpenParenthesis();
var tokenA = this.getToken();
this.pos += 1;
this.consumeNewLines();
var exp = this.parseExpressionOR();
this.consumeNewLines();
this.checkCloseParenthesis();
var tokenB = this.getToken();
this.pos += 1;
exp.sourceInfo = _sourceInfo__WEBPACK_IMPORTED_MODULE_7__["SourceInfo"].createSourceInfoFromList(tokenA, tokenB);
exp.parenthesis = true;
return exp;
}
}, {
key: "parseActualParameters",
value: function parseActualParameters() {
this.checkOpenParenthesis();
this.pos++;
if (this.checkCloseParenthesis(true)) {
this.pos++;
return [];
}
this.consumeNewLines();
var list = this.parseExpressionList();
this.consumeNewLines();
this.checkCloseParenthesis();
this.pos++;
return list;
}
}, {
key: "parseExpressionList",
value: function parseExpressionList() {
var list = [];
for (;;) {
var exp = this.parseExpressionOR();
list.push(exp);
var maybeToken = this.getToken();
if (maybeToken.type !== this.lexerClass.COMMA) {
break;
} else {
this.pos++;
this.consumeNewLines();
}
}
return list;
}
}, {
key: "getTypeArray",
value: function getTypeArray() {
var _this = this;
var types = this.insideScope(IVProgParser.FUNCTION) ? this.functionTypes : this.variableTypes;
return types.map(function (x) {
return _this.lexer.literalNames[x];
});
}
}]);
return IVProgParser;
}();
/***/ }),
/***/ "./js/ast/operators.js":
/*!*****************************!*\
!*** ./js/ast/operators.js ***!
\*****************************/
/*! exports provided: Operators, convertFromString */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Operators", function() { return Operators; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertFromString", function() { return convertFromString; });
var Operators = Object.freeze({
ADD: {
ord: 0,
value: "+"
},
SUB: {
ord: 1,
value: "-"
},
MULT: {
ord: 2,
value: '*'
},
DIV: {
ord: 3,
value: '/'
},
MOD: {
ord: 4,
value: '%'
},
GT: {
ord: 5,
value: '>'
},
GE: {
ord: 6,
value: '>='
},
LT: {
ord: 7,
value: '<'
},
LE: {
ord: 8,
value: '<='
},
EQ: {
ord: 9,
value: '=='
},
NEQ: {
ord: 10,
value: '!='
},
AND: {
ord: 11,
value: 'and'
},
OR: {
ord: 12,
value: 'or'
},
NOT: {
ord: 13,
value: 'not'
}
});
function convertFromString(op) {
switch (op) {
case '+':
return Operators.ADD;
case '-':
return Operators.SUB;
case '*':
return Operators.MULT;
case '/':
return Operators.DIV;
case '%':
return Operators.MOD;
case '>':
return Operators.GT;
case '>=':
return Operators.GE;
case '<':
return Operators.LT;
case '<=':
return Operators.LE;
case '==':
return Operators.EQ;
case '!=':
return Operators.NEQ;
case 'and':
return Operators.AND;
case 'or':
return Operators.OR;
case 'not':
return Operators.NOT;
}
}
/***/ }),
/***/ "./js/ast/sourceInfo.js":
/*!******************************!*\
!*** ./js/ast/sourceInfo.js ***!
\******************************/
/*! exports provided: SourceInfo */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SourceInfo", function() { return SourceInfo; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var SourceInfo =
/*#__PURE__*/
function () {
_createClass(SourceInfo, null, [{
key: "createSourceInfo",
value: function createSourceInfo(token) {
return new SourceInfo(token.line, token.column, token.text, token.text.length);
}
}, {
key: "createSourceInfoFromList",
value: function createSourceInfoFromList(tokenA, tokenB) {
var line = tokenA.line;
var column = tokenA.column; // adapted from https://github.com/UNIVALI-LITE/Portugol-Studio/blob/master/core/src/main/java/br/univali/portugol/nucleo/analise/sintatica/Portugol.g
// No idea why...
var size = tokenB.tokenIndex + 1 - tokenA.tokenIndex;
return new SourceInfo(line, column, "", size);
}
}]);
function SourceInfo(line, column, text, size) {
_classCallCheck(this, SourceInfo);
this.line = line;
this.column = column;
this.text = text;
this.size = size;
}
return SourceInfo;
}();
/***/ }),
/***/ "./js/io/domConsole.js":
/*!*****************************!*\
!*** ./js/io/domConsole.js ***!
\*****************************/
/*! exports provided: DOMConsole */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DOMConsole", function() { return DOMConsole; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _util_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../util/utils */ "./js/util/utils.js");
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../util/config */ "./js/util/config.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var DOMConsole =
/*#__PURE__*/
function () {
_createClass(DOMConsole, null, [{
key: "BASH_TEMPLATE",
get: function get() {
return "\n \n \n Terminal \n \n \n
\n
";
}
}, {
key: "INPUT_CARET_TEMPLATE",
get: function get() {
return "\n ";
}
}, {
key: "USER",
get: function get() {
return 0;
}
}, {
key: "INFO",
get: function get() {
return 1;
}
}, {
key: "ERR",
get: function get() {
return 2;
}
}, {
key: "INPUT",
get: function get() {
return 3;
}
}]);
function DOMConsole(elementID) {
var disableMarginTop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
_classCallCheck(this, DOMConsole);
this.disableMarginTop = disableMarginTop;
this.input = null;
this.cursorInterval = null;
this.idleInterval = null;
this.inputDiv = null;
this.inputCMD = null;
this.inputSpan = null;
this.cursorRef = null;
this.needInput = false;
this.clearBtn = null;
this.hideBtn = null;
this.showBtn = null;
this.termDiv = null;
this.anyKey = false;
var actualID = elementID;
if (elementID[0] === '#') {
actualID = elementID.substring(1);
}
this.parent = document.getElementById(actualID);
this.setup();
this.inputListeners = [];
this.hideInput();
this.pending_writes = [];
this.last_clear = -1;
}
_createClass(DOMConsole, [{
key: "setup",
value: function setup() {
this._setupDom();
this._setupEvents();
}
}, {
key: "_setupEvents",
value: function _setupEvents() {
this.input.addEventListener('keydown', this.registerInput.bind(this));
this.clearBtn.addEventListener('click', this.clearBtnClick.bind(this));
this.hideBtn.addEventListener('click', this.hideBtnClick.bind(this));
this.showBtn.addEventListener('click', this.showBtnClick.bind(this));
}
}, {
key: "registerInput",
value: function registerInput(event) {
if (!this.needInput) {
return;
}
var keyCode = event.which;
if (keyCode === 13 || this.anyKey) {
if (this.idleInterval != null) {
clearInterval(this.idleInterval);
this.idleInterval = null;
}
var text = this.input.value;
text = text.replace('[\n\r]+', '');
this.notifyListeners(text);
this._appendUserInput(text);
this.input.value = '';
this.inputSpan.innerHTML = '';
}
}
}, {
key: "_setupDom",
value: function _setupDom() {
var bashNode = document.createElement('div');
bashNode.classList.add('bash');
bashNode.innerHTML = DOMConsole.BASH_TEMPLATE;
this.termDiv = bashNode.querySelector("#ivprog-term");
this.termDiv.classList.add("ivprog-term-div");
this.inputDiv = document.createElement("div");
this.inputDiv.id = "ivprog-terminal-inputdiv";
this.inputDiv.innerHTML = DOMConsole.INPUT_CARET_TEMPLATE;
this.input = document.createElement("input");
this.input.setAttribute("name", "command");
this.input.setAttribute("value", "");
this.input.setAttribute("type", "text");
this.inputDiv.append(this.input);
this.termDiv.append(this.inputDiv);
bashNode.append(this.termDiv);
this.parent.append(bashNode);
this.inputCMD = this.inputDiv.querySelector("#cmd");
this.cursorRef = this.inputCMD.querySelector("#cursor");
this.inputSpan = this.inputCMD.querySelector('span');
this.clearBtn = bashNode.querySelector('#ivprog-console-clearbtn');
this.hideBtn = bashNode.querySelector('#ivprog-console-hidebtn');
this.showBtn = bashNode.querySelector('#ivprog-console-showbtn');
this._setupCursor(); //Jquery tooltips....
window.$(this.clearBtn).popup({
content: _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI("tooltip_terminal_clear")
});
window.$(this.showBtn).popup({
content: _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI("tooltip_terminal_show")
});
window.$(this.hideBtn).popup({
content: _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI("tooltip_terminal_hide")
});
}
}, {
key: "_setupCursor",
value: function _setupCursor() {
this.inputCMD.addEventListener('click', this.blinkCaretAndFocus.bind(this)); //this.inputCMD.click();
this.input.addEventListener('keyup', this.updateSpanText.bind(this));
this.input.addEventListener('blur', this.stopBlinkCaret.bind(this));
}
}, {
key: "blinkCaretAndFocus",
value: function blinkCaretAndFocus() {
var _this = this;
if (this.cursorInterval != null) {
return;
}
this.input.focus();
this.cursorInterval = window.setInterval(function () {
if (_this.cursorRef.style.visibility === 'visible') {
_this.cursorRef.style.visibility = 'hidden';
} else {
_this.cursorRef.style.visibility = 'visible';
}
}, 500);
}
}, {
key: "updateSpanText",
value: function updateSpanText() {
this.inputSpan.innerHTML = this.input.value;
if (this.idleInterval != null) window.clearInterval(this.idleInterval);
this.scheduleNotify();
}
}, {
key: "stopBlinkCaret",
value: function stopBlinkCaret() {
clearInterval(this.cursorInterval);
this.cursorInterval = null;
this.cursorRef.style.visibility = 'visible';
}
}, {
key: "notifyListeners",
value: function notifyListeners(text) {
this.inputListeners.forEach(function (resolve) {
return resolve(text);
});
this.inputListeners.splice(0, this.inputListeners.length);
this.hideInput();
this.anyKey = false;
}
}, {
key: "write",
value: function write(text) {
this._appendText(text, DOMConsole.USER);
}
}, {
key: "info",
value: function info(text) {
this._appendText(text, DOMConsole.INFO);
}
}, {
key: "err",
value: function err(text) {
this._appendText(text, DOMConsole.ERR);
}
}, {
key: "_appendText",
value: function _appendText(text, type) {
var _this2 = this;
var write_time = Date.now();
var pending_write = setTimeout(function () {
_this2.pending_writes.shift();
if (_this2.last_clear >= write_time) {
return;
}
var divClass = _this2.getClassForType(type);
var textDiv = document.createElement('div');
textDiv.classList.add(divClass);
textDiv.innerHTML = _this2.getOutputText(text);
_this2.termDiv.insertBefore(textDiv, _this2.inputDiv);
_this2.scrollTerm();
}, 5);
this.pending_writes.push(pending_write);
}
}, {
key: "_appendUserInput",
value: function _appendUserInput(text) {
var _this3 = this;
var write_time = Date.now();
var pending_write = setTimeout(function () {
_this3.pending_writes.shift();
if (_this3.last_clear >= write_time) {
return;
}
var divClass = _this3.getClassForType(DOMConsole.INPUT);
var textDiv = document.createElement('div');
textDiv.innerHTML = _this3.getUserInputText(text);
textDiv.classList.add(divClass);
_this3.termDiv.insertBefore(textDiv, _this3.inputDiv);
_this3.scrollTerm();
}, 5);
this.pending_writes.push(pending_write);
}
}, {
key: "getOutputText",
value: function getOutputText(text) {
if (text.trim().length == 0) {
text = " ";
}
return "".concat(text, " ");
}
}, {
key: "getUserInputText",
value: function getUserInputText(text) {
if (text.trim().length == 0) {
text = " ";
}
return "".concat(text, " ");
}
}, {
key: "scrollTerm",
value: function scrollTerm() {
//scrollIt(this.inputDiv.previousSibling,200);
this.termDiv.scrollTop = this.termDiv.scrollHeight;
}
}, {
key: "focus",
value: function focus() {
this.termDiv.style.display = 'block'; // Is in draggable mode?
if (!this.disableMarginTop && this.parent.style.top.length == 0) {
this.parent.style.marginTop = "-160px";
}
if (this.needInput) {
this.showInput();
this.scheduleNotify();
}
if (!Object(_util_utils__WEBPACK_IMPORTED_MODULE_1__["isElementInViewport"])(this.termDiv)) this.termDiv.scrollIntoView(false);
this.scrollTerm();
}
}, {
key: "hide",
value: function hide() {
if (this.needInput) {
clearInterval(this.idleInterval);
this.hideInput();
this.needInput = true;
} // Is in draggable mode?
if (!this.disableMarginTop && this.parent.style.top.length == 0) {
this.parent.style.marginTop = "0";
}
this.termDiv.style.display = 'none';
}
}, {
key: "getClassForType",
value: function getClassForType(type) {
switch (type) {
case DOMConsole.INPUT:
return "ivprog-term-userInput";
case DOMConsole.USER:
return "ivprog-term-userText";
case DOMConsole.INFO:
return "ivprog-term-info";
case DOMConsole.ERR:
return "ivprog-term-error";
}
}
}, {
key: "dispose",
value: function dispose() {
this.input.removeEventListener('keyup', this.updateSpanText.bind(this));
this.input.removeEventListener('blur', this.stopBlinkCaret.bind(this));
this.input.removeEventListener('keydown', this.registerInput.bind(this));
this.inputCMD.removeEventListener('click', this.blinkCaretAndFocus.bind(this));
this.clearBtn.removeEventListener('click', this.clearBtnClick.bind(this));
this.hideBtn.removeEventListener('click', this.hideBtnClick.bind(this));
this.showBtn.removeEventListener('click', this.showBtnClick.bind(this));
this.input = null;
this.inputCMD = null;
this.inputDiv = null;
this.termDiv = null;
this.inputSpan = null;
this.cursorRef = null;
this.clearBtn = null;
this.hideBtn = null;
this.showBtn = null;
var cNode = this.parent.cloneNode(false);
this.parent.parentNode.replaceChild(cNode, this.parent);
if (this.cursorInterval != null) {
clearInterval(this.cursorInterval);
}
if (this.idleInterval != null) {
clearInterval(this.idleInterval);
}
}
}, {
key: "showInput",
value: function showInput() {
this.needInput = true;
this.inputDiv.style.display = 'block';
this.inputCMD.click(); //this.inputCMD.scrollIntoView();
this.scrollTerm();
}
}, {
key: "hideInput",
value: function hideInput() {
this.needInput = false;
this.inputDiv.style.display = ' none';
clearInterval(this.cursorInterval);
this.cursorInterval = null;
}
}, {
key: "requestInput",
value: function requestInput(callback) {
var anyKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.inputListeners.push(callback);
this.anyKey = anyKey;
if (this.idleInterval == null) this.scheduleNotify();
this.showInput();
}
}, {
key: "sendOutput",
value: function sendOutput(text) {
var _this4 = this;
var output = "" + text;
output.split("\n").forEach(function (t) {
t = t.replace(/\t/g, ' ');
t = t.replace(/\s/g, " ");
_this4.write(t);
});
}
}, {
key: "clearPendingWrites",
value: function clearPendingWrites() {
this.last_clear = Date.now();
for (var id in this.pending_writes) {
clearTimeout(id);
}
}
}, {
key: "clear",
value: function clear() {
this.clearPendingWrites();
this.pending_writes = [];
while (this.inputDiv.parentElement.childNodes.length > 1) {
this.inputDiv.parentElement.removeChild(this.inputDiv.parentElement.firstChild);
}
this.input.value = "";
this.inputSpan.innerHTML = '';
}
}, {
key: "clearBtnClick",
value: function clearBtnClick() {
this.clear();
}
}, {
key: "showBtnClick",
value: function showBtnClick() {
this.focus();
}
}, {
key: "hideBtnClick",
value: function hideBtnClick() {
this.hide();
}
}, {
key: "notifyIdle",
value: function notifyIdle() {
this.info(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getMessage('awaiting_input_message'));
this.inputCMD.click();
}
}, {
key: "scheduleNotify",
value: function scheduleNotify() {
this.idleInterval = window.setInterval(this.notifyIdle.bind(this), _util_config__WEBPACK_IMPORTED_MODULE_2__["Config"].idle_input_interval);
}
}, {
key: "cancelPendingInputRequests",
value: function cancelPendingInputRequests() {
this.inputListeners.forEach(function (resolve) {
return resolve('');
});
this.inputListeners.splice(0, this.inputListeners.length);
if (this.idleInterval != null) {
clearInterval(this.idleInterval);
this.idleInterval = null;
}
this.input.value = '';
this.inputSpan.innerHTML = '';
this.hideInput();
this.anyKey = false;
}
}]);
return DOMConsole;
}();
/***/ }),
/***/ "./js/io/input.js":
/*!************************!*\
!*** ./js/io/input.js ***!
\************************/
/*! exports provided: Input */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Input", function() { return Input; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Input =
/*#__PURE__*/
function () {
function Input() {
_classCallCheck(this, Input);
}
_createClass(Input, [{
key: "requestInput",
value: function requestInput(callback) {
throw new Error("Must be implemented");
}
}, {
key: "cancelPendingInputRequests",
value: function cancelPendingInputRequests() {
throw new Error("Must be implemented");
}
}]);
return Input;
}();
/***/ }),
/***/ "./js/io/output.js":
/*!*************************!*\
!*** ./js/io/output.js ***!
\*************************/
/*! exports provided: Output */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Output", function() { return Output; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Output =
/*#__PURE__*/
function () {
function Output() {
_classCallCheck(this, Output);
}
_createClass(Output, [{
key: "sendOutput",
value: function sendOutput(text) {
throw new Error("Must be implemented");
}
}]);
return Output;
}();
/***/ }),
/***/ "./js/main.js":
/*!********************!*\
!*** ./js/main.js ***!
\********************/
/*! exports provided: runner, initVisualUI, addFunctionChangeListener, addGlobalChangeListener, removeFunctionListener, removeGlobalListener, getTestCases, autoEval, prepareActivityToStudentHelper, LocalizedStrings, i18n, getLogs, getLogsAsString, registerClick, registerUserEvent, parseLogs, ActionTypes, CodeEditor, openAssessmentDetail, autoGenerateTestCaseOutput */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocalizedStrings", function() { return LocalizedStrings; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i18n", function() { return i18n; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeEditor", function() { return CodeEditor; });
/* harmony import */ var _runner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./runner */ "./js/runner.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "runner", function() { return _runner__WEBPACK_IMPORTED_MODULE_0__["runner"]; });
/* harmony import */ var _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./visualUI/functions */ "./js/visualUI/functions.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "initVisualUI", function() { return _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__["initVisualUI"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "addFunctionChangeListener", function() { return _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__["addFunctionChangeListener"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "addGlobalChangeListener", function() { return _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__["addGlobalChangeListener"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeFunctionListener", function() { return _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__["removeFunctionListener"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeGlobalListener", function() { return _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__["removeGlobalListener"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getTestCases", function() { return _visualUI_functions__WEBPACK_IMPORTED_MODULE_1__["getTestCases"]; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _services_i18nHelper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./services/i18nHelper */ "./js/services/i18nHelper.js");
/* harmony import */ var _services_userLog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./services/userLog */ "./js/services/userLog.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getLogs", function() { return _services_userLog__WEBPACK_IMPORTED_MODULE_4__["getLogs"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getLogsAsString", function() { return _services_userLog__WEBPACK_IMPORTED_MODULE_4__["getLogsAsString"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "registerClick", function() { return _services_userLog__WEBPACK_IMPORTED_MODULE_4__["registerClick"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "registerUserEvent", function() { return _services_userLog__WEBPACK_IMPORTED_MODULE_4__["registerUserEvent"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parseLogs", function() { return _services_userLog__WEBPACK_IMPORTED_MODULE_4__["parseLogs"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionTypes", function() { return _services_userLog__WEBPACK_IMPORTED_MODULE_4__["ActionTypes"]; });
/* harmony import */ var _util_iassignHelpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util/iassignHelpers */ "./js/util/iassignHelpers.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "autoEval", function() { return _util_iassignHelpers__WEBPACK_IMPORTED_MODULE_5__["autoEval"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareActivityToStudentHelper", function() { return _util_iassignHelpers__WEBPACK_IMPORTED_MODULE_5__["prepareActivityToStudentHelper"]; });
/* harmony import */ var _util_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./util/utils */ "./js/util/utils.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "openAssessmentDetail", function() { return _util_utils__WEBPACK_IMPORTED_MODULE_6__["openAssessmentDetail"]; });
/* harmony import */ var _visualUI_text_editor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./visualUI/text_editor */ "./js/visualUI/text_editor.js");
/* harmony import */ var _util_auto_gen_output__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./util/auto_gen_output */ "./js/util/auto_gen_output.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "autoGenerateTestCaseOutput", function() { return _util_auto_gen_output__WEBPACK_IMPORTED_MODULE_8__["autoGenerateTestCaseOutput"]; });
var CodeEditor = {
initTextEditor: _visualUI_text_editor__WEBPACK_IMPORTED_MODULE_7__["initTextEditor"],
setCode: _visualUI_text_editor__WEBPACK_IMPORTED_MODULE_7__["setCode"],
getCode: _visualUI_text_editor__WEBPACK_IMPORTED_MODULE_7__["getCode"],
updateEditor: _visualUI_text_editor__WEBPACK_IMPORTED_MODULE_7__["updateEditor"],
disable: _visualUI_text_editor__WEBPACK_IMPORTED_MODULE_7__["disable"]
};
var i18n = _services_i18nHelper__WEBPACK_IMPORTED_MODULE_3__["i18nHelper"].i18n;
var LocalizedStrings = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["getInstance"]();
/***/ }),
/***/ "./js/memory/address.ts":
/*!******************************!*\
!*** ./js/memory/address.ts ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Address {
/**
*
* @param {Number} id the address id
* @param {*} value the value stored at this address
*/
constructor(id, value) {
this.id = id;
this.value = value;
}
}
exports.Address = Address;
/***/ }),
/***/ "./js/memory/location.ts":
/*!*******************************!*\
!*** ./js/memory/location.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const address_1 = __webpack_require__(/*! ./address */ "./js/memory/address.ts");
class LocationHolder {
constructor() {
this.data = [];
this.address_id = 0;
}
/**
*
* @param {*} value the value to be allocated
* @returns {Number} - the address id
*/
allocate(value) {
const id = this.address_id;
// console.log("Allocation address "+ id);
const address = new address_1.Address(id, value);
this.data.push(address);
this.address_id += 1;
return id;
}
/**
*
* @param {Number} id
*/
deallocate(id) {
const index = this.findIndex(id);
// console.log("Deallocation address "+ id);
if (index !== -1) {
this.data.splice(index, 1);
return true;
}
return false;
}
/**
*
* @param {Number} id
* @returns {Address} the address identified by id
*/
find(id) {
let beg = 0;
let end = this.data.length;
// console.log("Finding address "+id);
while (beg < end) {
const med = Math.floor((beg + end) / 2);
const address = this.getAddressAt(med);
if (address.id === id) {
return address;
}
else if (id > address.id) {
beg = med;
}
else {
end = med;
}
}
return undefined;
}
getAddressAt(pos) {
return this.data[pos];
}
/**
*
* @param {Number} id address id
* @returns {Number} the index of the address identified by id
*/
findIndex(id) {
let beg = 0;
let end = this.data.length;
while (beg < end) {
const med = Math.floor((beg + end) / 2);
const address = this.getAddressAt(med);
if (address.id === id) {
return med;
}
else if (id > address.id) {
beg = med;
}
else {
end = med;
}
}
return -1;
}
updateAddress(id, value) {
const index = this.findIndex(id);
if (index === -1) {
throw new Error("Invalid address..." + id);
}
this.data[index].value = value;
}
clear() {
for (let i = 0; i < this.data.length; i += 1) {
delete this.data[i];
}
this.data = [];
this.address_id = 0;
}
}
const inner_ref = new LocationHolder();
exports.Location = Object.freeze({
allocate: inner_ref.allocate.bind(inner_ref),
deallocate: inner_ref.deallocate.bind(inner_ref),
find: inner_ref.find.bind(inner_ref),
updateAddress: inner_ref.updateAddress.bind(inner_ref),
clear: inner_ref.clear.bind(inner_ref),
size: () => inner_ref.data.length
});
/***/ }),
/***/ "./js/processor/compatibilityTable.js":
/*!********************************************!*\
!*** ./js/processor/compatibilityTable.js ***!
\********************************************/
/*! exports provided: resultTypeAfterInfixOp, resultTypeAfterUnaryOp */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resultTypeAfterInfixOp", function() { return resultTypeAfterInfixOp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resultTypeAfterUnaryOp", function() { return resultTypeAfterUnaryOp; });
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _ast_operators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../ast/operators */ "./js/ast/operators.js");
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../typeSystem/multiType */ "./js/typeSystem/multiType.ts");
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
function buildInfixAddTable() {
var table = [[], [], [], []];
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING;
return table;
}
function buildInfixMultiDivSubTable() {
var table = [[], [], [], []];
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
return table;
}
function buildInfixEqualityInequalityTable() {
var table = [[], [], [], []];
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
return table;
}
function buildInfixRelationalTable() {
var table = [[], [], [], []];
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].STRING.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
return table;
}
function buildInfixAndOrTable() {
var table = [[], [], [], []];
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
return table;
}
function buildInfixModTable() {
var table = [[], [], [], []];
table[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord][_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER;
return table;
}
function buildUnarySumSubList() {
var list = [];
list[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER;
list[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL;
return list;
}
function buildUnaryNegList() {
var list = [];
list[_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN.ord] = _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
return list;
}
function buildInfixCompatibilityTable() {
var compatibilityMap = new WeakMap();
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].ADD, buildInfixAddTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].SUB, buildInfixMultiDivSubTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].MULT, buildInfixMultiDivSubTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].DIV, buildInfixMultiDivSubTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].EQ, buildInfixEqualityInequalityTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].NEQ, buildInfixEqualityInequalityTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].GE, buildInfixRelationalTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].GT, buildInfixRelationalTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].LE, buildInfixRelationalTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].LT, buildInfixRelationalTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].OR, buildInfixAndOrTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].AND, buildInfixAndOrTable());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].MOD, buildInfixModTable());
return compatibilityMap;
}
function buildUnaryCompatibilityTable() {
var compatibilityMap = new WeakMap();
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].ADD, buildUnarySumSubList());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].SUB, buildUnarySumSubList());
compatibilityMap.set(_ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].NOT, buildUnaryNegList());
return compatibilityMap;
}
var infixMap = buildInfixCompatibilityTable();
var unaryMap = buildUnaryCompatibilityTable();
function resultTypeAfterInfixOp(operator, leftExpressionType, rightExpressionType) {
try {
if (leftExpressionType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"] && rightExpressionType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"]) {
var newMulti = [];
for (var i = 0; i < leftExpressionType.types.length; ++i) {
var typeA = leftExpressionType.types[i];
for (var j = 0; j < rightExpressionType.types.length; ++i) {
var typeB = rightExpressionType.types[j];
newMulti.push(resultTypeAfterInfixOp(operator, typeA, typeB));
}
}
newMulti = newMulti.filter(function (x) {
return !x.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED);
});
if (newMulti.length <= 0) {
if (_util_config__WEBPACK_IMPORTED_MODULE_3__["Config"].enable_type_casting) {
if (leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
if (rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
return new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL]);
}
}
}
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
} else {
return new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"](newMulti);
}
} else if (leftExpressionType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"]) {
if (leftExpressionType.isCompatible(rightExpressionType)) {
return resultTypeAfterInfixOp(operator, rightExpressionType, rightExpressionType);
} else {
if (_util_config__WEBPACK_IMPORTED_MODULE_3__["Config"].enable_type_casting) {
if (leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
if (rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
return rightExpressionType;
}
}
}
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
}
} else if (rightExpressionType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"]) {
if (rightExpressionType.isCompatible(leftExpressionType)) {
return resultTypeAfterInfixOp(operator, leftExpressionType, leftExpressionType);
} else {
if (_util_config__WEBPACK_IMPORTED_MODULE_3__["Config"].enable_type_casting) {
if (leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
if (rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
return leftExpressionType;
}
}
}
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
}
}
var resultType = infixMap.get(operator)[leftExpressionType.ord][rightExpressionType.ord];
if (resultType === null || resultType === undefined) {
if (_util_config__WEBPACK_IMPORTED_MODULE_3__["Config"].enable_type_casting) {
if (leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || leftExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
if (rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER) || rightExpressionType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL)) {
if (operator === _ast_operators__WEBPACK_IMPORTED_MODULE_1__["Operators"].MOD) {
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER;
} else if (operator.ord >= 5 && operator.ord <= 10) {
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN;
}
}
}
}
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
}
return resultType;
} catch (e) {
if (e instanceof TypeError) {
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
} else {
throw e;
}
}
}
function resultTypeAfterUnaryOp(operator, leftExpressionType) {
try {
if (leftExpressionType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_2__["MultiType"]) {
return leftExpressionType;
}
var resultType = unaryMap.get(operator)[leftExpressionType.ord];
if (resultType == null) {
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
}
return resultType;
} catch (e) {
if (e instanceof TypeError) {
return _typeSystem_types__WEBPACK_IMPORTED_MODULE_0__["Types"].UNDEFINED;
} else {
throw e;
}
}
}
/***/ }),
/***/ "./js/processor/context.ts":
/*!*********************************!*\
!*** ./js/processor/context.ts ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = Object.freeze({
BASE: Symbol('context:base'),
BREAKABLE: Symbol('context:breakable'),
FUNCTION: Symbol('context:function')
});
/***/ }),
/***/ "./js/processor/definedFunctions.js":
/*!******************************************!*\
!*** ./js/processor/definedFunctions.js ***!
\******************************************/
/*! exports provided: LanguageDefinedFunction */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LanguageDefinedFunction", function() { return LanguageDefinedFunction; });
/* harmony import */ var _services_languageService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
/* harmony import */ var _lib_io__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/io */ "./js/processor/lib/io.js");
/* harmony import */ var _lib_strings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/strings */ "./js/processor/lib/strings.js");
/* harmony import */ var _lib_arrays__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/arrays */ "./js/processor/lib/arrays.js");
/* harmony import */ var _lib_lang__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/lang */ "./js/processor/lib/lang.js");
/* harmony import */ var _lib_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/math */ "./js/processor/lib/math.js");
function valueToKey(value, object) {
for (var key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
if (object[key] === value) {
return key;
}
}
}
return null;
}
function concatObjects() {
var result = {};
for (var i = 0; i < arguments.length; i++) {
var obj = i < 0 || arguments.length <= i ? undefined : arguments[i];
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
result[key] = obj[key];
}
}
}
return result;
}
var libsObject = {
$mathLib: {
$sin: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createSinFun"])(),
$cos: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createCosFun"])(),
$tan: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createTanFun"])(),
$sqrt: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createSqrtFun"])(),
$pow: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createPowFun"])(),
$log: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createLogFun"])(),
$abs: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createAbsFun"])(),
$negate: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createNegateFun"])(),
$invert: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createInvertFun"])(),
$max: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createMaxFun"])(),
$min: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createMinFun"])(),
$rand: Object(_lib_math__WEBPACK_IMPORTED_MODULE_5__["createRandFun"])()
},
$ioLib: {
$read: Object(_lib_io__WEBPACK_IMPORTED_MODULE_1__["createInputFun"])(),
$write: Object(_lib_io__WEBPACK_IMPORTED_MODULE_1__["createOutputFun"])()
},
$strLib: {
$substring: Object(_lib_strings__WEBPACK_IMPORTED_MODULE_2__["createSubstringFun"])(),
$length: Object(_lib_strings__WEBPACK_IMPORTED_MODULE_2__["createLengthFun"])(),
$uppercase: Object(_lib_strings__WEBPACK_IMPORTED_MODULE_2__["createUppercaseFun"])(),
$lowercase: Object(_lib_strings__WEBPACK_IMPORTED_MODULE_2__["createLowercaseFun"])(),
$charAt: Object(_lib_strings__WEBPACK_IMPORTED_MODULE_2__["createrCharAtFun"])()
},
$arrayLib: {
$numElements: Object(_lib_arrays__WEBPACK_IMPORTED_MODULE_3__["createNumElementsFun"])(),
$matrixLines: Object(_lib_arrays__WEBPACK_IMPORTED_MODULE_3__["createMatrixLinesFun"])(),
$matrixColumns: Object(_lib_arrays__WEBPACK_IMPORTED_MODULE_3__["createMatrixColumnsFun"])()
},
$langLib: {
$isReal: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createIsRealFun"])(),
$isInt: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createIsIntFun"])(),
$isBool: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createIsBoolFun"])(),
$castReal: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createCastRealFun"])(),
$castInt: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createCastIntFun"])(),
$castBool: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createCastBoolFun"])(),
$castString: Object(_lib_lang__WEBPACK_IMPORTED_MODULE_4__["createCastStringFun"])()
}
};
var funcsObject = concatObjects(libsObject.$ioLib, libsObject.$langLib, libsObject.$strLib, libsObject.$arrayLib);
var LanguageDefinedFunction = Object.freeze({
getMainFunctionName: function getMainFunctionName() {
return _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangFuncs().main_function;
},
getInternalName: function getInternalName(localName) {
if (localName.indexOf(".") !== -1) {
var names = localName.split(".");
var lib = valueToKey(names[0], _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangLibs());
var internalName = valueToKey(names[1], _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangFuncs());
if (lib === null || internalName === null) {
return null;
}
return lib + "." + internalName;
}
var funcName = valueToKey(localName, _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangFuncs());
if (funcName !== null) {
if (funcsObject[funcName]) {
return funcName;
}
}
return null;
},
getFunction: function getFunction(internalName) {
if (internalName.indexOf(".") !== -1) {
var names = internalName.split(".");
var libName = names[0];
var funName = names[1];
return libsObject[libName][funName];
}
return funcsObject[internalName];
},
getLocalName: function getLocalName(internalName) {
if (internalName.indexOf(".") !== -1) {
var names = internalName.split(".");
var libName = _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangLibs()[names[0]];
var funName = _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangFuncs()[names[1]];
return "".concat(libName, ".").concat(funName);
} else if (_services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangFuncs()[internalName]) {
return _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLangFuncs()[internalName];
} else {
return internalName;
}
}
});
/***/ }),
/***/ "./js/processor/error/processorErrorFactory.js":
/*!*****************************************************!*\
!*** ./js/processor/error/processorErrorFactory.js ***!
\*****************************************************/
/*! exports provided: ProcessorErrorFactory */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProcessorErrorFactory", function() { return ProcessorErrorFactory; });
/* harmony import */ var _runtimeError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./runtimeError */ "./js/processor/error/runtimeError.js");
/* harmony import */ var _semanticError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./semanticError */ "./js/processor/error/semanticError.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _definedFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../definedFunctions */ "./js/processor/definedFunctions.js");
var LocalizedStrings = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["getInstance"]();
function createRuntimeError(i18n_id) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return new _runtimeError__WEBPACK_IMPORTED_MODULE_0__["RuntimeError"](LocalizedStrings.getError(i18n_id, context));
}
function createSemanticError(i18n_id) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return new _semanticError__WEBPACK_IMPORTED_MODULE_1__["SemanticError"](LocalizedStrings.getError(i18n_id, context));
}
var ProcessorErrorFactory = Object.freeze({
symbol_not_found_full: function symbol_not_found_full(id, sourceInfo) {
if (sourceInfo) {
var context = [id, sourceInfo.line, sourceInfo.column];
return createSemanticError("symbol_not_found_full", context);
} else {
return ProcessorErrorFactory.symbol_not_found(id);
}
},
symbol_not_found: function symbol_not_found(id) {
var context = [id];
return createSemanticError("symbol_not_found", context);
},
function_missing_full: function function_missing_full(id, sourceInfo) {
if (sourceInfo) {
var context = [id, sourceInfo.line, sourceInfo.column];
return createSemanticError("function_missing_full", context);
} else {
return ProcessorErrorFactory.function_missing(id);
}
},
function_missing: function function_missing(id) {
var context = [id];
return createSemanticError("function_missing", context);
},
main_missing: function main_missing() {
return createSemanticError("main_missing");
},
array_dimension_not_int_full: function array_dimension_not_int_full(sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line];
return createSemanticError("array_dimension_not_int_full", context);
} else {
return ProcessorErrorFactory.array_dimension_not_int();
}
},
array_dimension_not_int: function array_dimension_not_int() {
return createSemanticError("array_dimension_not_int");
},
unknown_command_full: function unknown_command_full(sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line];
return createRuntimeError("unknown_command_full", context);
} else {
return ProcessorErrorFactory.unknown_command();
}
},
unknown_command: function unknown_command() {
return createRuntimeError("unknown_command");
},
incompatible_types_full: function incompatible_types_full(left_type, left_dim, right_type, right_dim, exp, source_info) {
if (source_info) {
var context = [LocalizedStrings.translateType(left_type, left_dim), exp, source_info.line, LocalizedStrings.translateType(right_type, right_dim)];
return createSemanticError("incompatible_types_full", context);
} else {
return ProcessorErrorFactory.incompatible_types(left_type, left_dim, right_type, right_dim, exp);
}
},
incompatible_types: function incompatible_types(left_type, left_dim, right_type, right_dim, exp) {
var context = [LocalizedStrings.translateType(left_type, left_dim), exp, LocalizedStrings.translateType(right_type, right_dim)];
return createSemanticError("incompatible_types", context);
},
incompatible_types_array_full: function incompatible_types_array_full(exp, type, dim, sourceInfo) {
if (sourceInfo) {
var context = [exp, LocalizedStrings.translateType(type, dim), sourceInfo.line, sourceInfo.column];
return createSemanticError("incompatible_types_array_full", context);
} else {
return ProcessorErrorFactory.incompatible_types_array(exp, type, dim);
}
},
incompatible_types_array: function incompatible_types_array(exp, type, dim) {
var context = [exp, LocalizedStrings.translateType(type, dim)];
return createSemanticError("incompatible_types_array", context);
},
loop_condition_type_full: function loop_condition_type_full(exp, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, sourceInfo.column, exp];
return createSemanticError("loop_condition_type_full", context);
} else {
return ProcessorErrorFactory.loop_condition_type(exp);
}
},
loop_condition_type: function loop_condition_type(exp) {
var context = [exp];
return createSemanticError("loop_condition_type", context);
},
/**
* @deprecated 01/10/2019
*/
endless_loop_full: function endless_loop_full(sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line];
return createSemanticError("endless_loop_full", context);
} else {
return ProcessorErrorFactory.endless_loop();
}
},
endless_loop: function endless_loop() {
return createSemanticError("endless_loop");
},
if_condition_type_full: function if_condition_type_full(exp, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, sourceInfo.column, exp];
return createSemanticError("if_condition_type_full", context);
} else {
return ProcessorErrorFactory.if_condition_type(exp);
}
},
if_condition_type: function if_condition_type(exp) {
var context = [exp];
return createSemanticError("if_condition_type", context);
},
invalid_global_var: function invalid_global_var() {
return createRuntimeError("invalid_global_var");
},
not_implemented: function not_implemented(id) {
var context = [id];
return createRuntimeError("not_implemented", context);
},
invalid_case_type_full: function invalid_case_type_full(exp, type, dim, sourceInfo) {
if (sourceInfo) {
var context = [exp, LocalizedStrings.translateType(type, dim), sourceInfo.line, sourceInfo.column];
return createSemanticError("invalid_case_type_full", context);
} else {
return ProcessorErrorFactory.invalid_case_type(exp, type, dim);
}
},
invalid_case_type: function invalid_case_type(exp, type, dim) {
var context = [exp, LocalizedStrings.translateType(type, dim)];
return createSemanticError("invalid_case_type", context);
},
void_in_expression_full: function void_in_expression_full(id, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, sourceInfo.column, id];
return createSemanticError("void_in_expression_full", context);
} else {
return ProcessorErrorFactory.void_in_expression(id);
}
},
void_in_expression: function void_in_expression(id) {
var context = [id];
return createSemanticError("void_in_expression", context);
},
invalid_array_access_full: function invalid_array_access_full(id, sourceInfo) {
if (sourceInfo) {
var context = [id, sourceInfo.line, sourceInfo.column];
return createSemanticError("invalid_array_access_full", context);
} else {
return ProcessorErrorFactory.invalid_array_access(id);
}
},
invalid_array_access: function invalid_array_access(id) {
var context = [id];
return createSemanticError("invalid_array_access", context);
},
invalid_matrix_access_full: function invalid_matrix_access_full(id, sourceInfo) {
if (sourceInfo) {
var context = [id, sourceInfo.line, sourceInfo.column];
return createSemanticError("invalid_matrix_access_full", context);
} else {
return ProcessorErrorFactory.invalid_matrix_access(id);
}
},
invalid_matrix_access: function invalid_matrix_access(id) {
var context = [id];
return createSemanticError("invalid_matrix_access", context);
},
matrix_column_outbounds_full: function matrix_column_outbounds_full(id, value, columns, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, value, id, columns];
return createRuntimeError("matrix_column_outbounds_full", context);
} else {
return ProcessorErrorFactory.matrix_column_outbounds(id, value, columns);
}
},
matrix_column_outbounds: function matrix_column_outbounds(id, value, columns) {
var context = [value, id, columns];
return createRuntimeError("matrix_column_outbounds", context);
},
matrix_line_outbounds_full: function matrix_line_outbounds_full(id, value, lines, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, value, id, lines];
return createRuntimeError("matrix_line_outbounds_full", context);
} else {
return ProcessorErrorFactory.matrix_line_outbounds(id, value, lines);
}
},
matrix_line_outbounds: function matrix_line_outbounds(id, value, lines) {
var context = [value, id, lines];
return createRuntimeError("matrix_line_outbounds", context);
},
vector_line_outbounds_full: function vector_line_outbounds_full(id, value, lines, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, value, id, lines];
return createRuntimeError("vector_line_outbounds_full", context);
} else {
return ProcessorErrorFactory.vector_line_outbounds(id, value, lines);
}
},
vector_line_outbounds: function vector_line_outbounds(id, value, lines) {
var context = [value, id, lines];
return createRuntimeError("vector_line_outbounds", context);
},
vector_not_matrix_full: function vector_not_matrix_full(id, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, id];
return createRuntimeError("vector_not_matrix_full", context);
} else {
return ProcessorErrorFactory.vector_not_matrix(id);
}
},
vector_not_matrix: function vector_not_matrix(id) {
var context = [id];
return createRuntimeError("vector_not_matrix", context);
},
function_no_return: function function_no_return(id) {
var context = [id];
return createSemanticError("function_no_return", context);
},
invalid_void_return_full: function invalid_void_return_full(id, type, dim, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, id, LocalizedStrings.translateType(type, dim)];
return createSemanticError("invalid_void_return_full", context);
} else {
return ProcessorErrorFactory.invalid_void_return(id, type, dim);
}
},
invalid_void_return: function invalid_void_return(id, type, dim) {
var context = [id, LocalizedStrings.translateType(type, dim)];
return createSemanticError("invalid_void_return_full", context);
},
invalid_return_type_full: function invalid_return_type_full(id, type, dim, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, id, LocalizedStrings.translateType(type, dim)];
return createSemanticError("invalid_return_type_full", context);
} else {
return ProcessorErrorFactory.invalid_return_type(id, type, dim);
}
},
invalid_return_type: function invalid_return_type(id, type, dim) {
var context = [id, LocalizedStrings.translateType(type, dim)];
return createSemanticError("invalid_return_type", context);
},
invalid_parameters_size_full: function invalid_parameters_size_full(id, expected, actual, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, id, expected, actual];
return createSemanticError("invalid_parameters_size_full", context);
} else {
return ProcessorErrorFactory.invalid_parameters_size(id, expected, actual);
}
},
invalid_parameters_size: function invalid_parameters_size(id, expected, actual) {
var context = [id, expected, actual];
return createSemanticError("invalid_parameters_size", context);
},
invalid_parameter_type_full: function invalid_parameter_type_full(fun_name, exp, sourceInfo) {
if (sourceInfo) {
var context = [exp, _definedFunctions__WEBPACK_IMPORTED_MODULE_3__["LanguageDefinedFunction"].getLocalName(fun_name), sourceInfo.line];
return createSemanticError("invalid_parameter_type_full", context);
} else {
return ProcessorErrorFactory.invalid_parameter_type(fun_name, exp);
}
},
invalid_parameter_type: function invalid_parameter_type(fun_name, exp) {
var context = [exp, _definedFunctions__WEBPACK_IMPORTED_MODULE_3__["LanguageDefinedFunction"].getLocalName(fun_name)];
return createSemanticError("invalid_parameter_type_full", context);
},
invalid_ref_full: function invalid_ref_full(id, exp, sourceInfo) {
if (sourceInfo) {
var context = [exp, id, sourceInfo.line];
return createSemanticError("invalid_ref_full", context);
} else {
return ProcessorErrorFactory.invalid_ref(id, exp);
}
},
invalid_ref: function invalid_ref(id, exp) {
var context = [exp, id];
return createSemanticError("invalid_ref", context);
},
unexpected_break_command_full: function unexpected_break_command_full(sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line];
return createRuntimeError("unexpected_break_command_full", context);
} else {
return ProcessorErrorFactory.unexpected_break_command();
}
},
unexpected_break_command: function unexpected_break_command() {
return createRuntimeError("unexpected_break_command");
},
invalid_array_literal_type_full: function invalid_array_literal_type_full(exp, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, exp];
return createRuntimeError("invalid_array_literal_type_full", context);
} else {
return ProcessorErrorFactory.invalid_array_literal_type(exp);
}
},
invalid_array_literal_type: function invalid_array_literal_type(exp) {
var context = [exp];
return createRuntimeError("invalid_array_literal_type", context);
},
invalid_array_literal_line_full: function invalid_array_literal_line_full(expected, actual, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, expected, actual];
return createRuntimeError("invalid_array_literal_line_full", context);
} else {
return ProcessorErrorFactory.invalid_array_literal_type(expected, actual);
}
},
invalid_array_literal_line: function invalid_array_literal_line(expected, actual) {
var context = [expected, actual];
return createRuntimeError("invalid_array_literal_line", context);
},
invalid_array_literal_column_full: function invalid_array_literal_column_full(expected, actual, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, expected, actual];
return createRuntimeError("invalid_array_literal_column_full", context);
} else {
return ProcessorErrorFactory.invalid_array_literal_column(expected, actual);
}
},
invalid_array_literal_column: function invalid_array_literal_column(expected, actual) {
var context = [expected, actual];
return createRuntimeError("invalid_array_literal_column", context);
},
invalid_unary_op_full: function invalid_unary_op_full(expString, opName, type, dim, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(type, dim)];
return createRuntimeError("invalid_unary_op_full", context);
} else {
return ProcessorErrorFactory.invalid_unary_op(opName, type, dim);
}
},
invalid_unary_op: function invalid_unary_op(expString, opName, type, dim) {
var context = [expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(type, dim)];
return createRuntimeError("invalid_unary_op", context);
},
invalid_infix_op_full: function invalid_infix_op_full(expString, opName, typeLeft, dimLeft, typeRight, dimRight, sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line, expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(typeLeft, dimLeft), LocalizedStrings.translateType(typeRight, dimRight)];
return createRuntimeError("invalid_infix_op_full", context);
} else {
return ProcessorErrorFactory.invalid_infix_op(opName, typeLeft, dimLeft, typeRight, dimRight);
}
},
invalid_infix_op: function invalid_infix_op(expString, opName, typeLeft, dimLeft, typeRight, dimRight) {
var context = [expString, LocalizedStrings.translateOp(opName), LocalizedStrings.translateType(typeLeft, dimLeft), LocalizedStrings.translateType(typeRight, dimRight)];
return createRuntimeError("invalid_infix_op", context);
},
array_dimension_not_positive_full: function array_dimension_not_positive_full(sourceInfo) {
if (sourceInfo) {
var context = [sourceInfo.line];
return createSemanticError("array_dimension_not_positive_full", context);
} else {
return ProcessorErrorFactory.array_dimension_not_positive();
}
},
array_dimension_not_positive: function array_dimension_not_positive() {
return createSemanticError("array_dimension_not_positive");
},
invalid_type_conversion: function invalid_type_conversion(value, type, dim) {
var context = [value, LocalizedStrings.translateType(type, dim)];
return createRuntimeError("invalid_type_conversion", context);
},
invalid_read_type: function invalid_read_type(exp, type, dim, name, source_info) {
var context = [source_info.line, exp, LocalizedStrings.translateType(type, dim), name];
return createRuntimeError("invalid_read_type", context);
},
invalid_read_type_array: function invalid_read_type_array(exp, typePos, dimPos, name, typeArray, dimArray, sourceInfo) {
var context = [sourceInfo.line, exp, LocalizedStrings.translateType(typePos, dimPos), name, LocalizedStrings.translateType(typeArray, dimArray)];
return createRuntimeError("invalid_read_type_array", context);
},
invalid_const_ref_full: function invalid_const_ref_full(fun_name, exp, sourceInfo) {
if (sourceInfo) {
var context = [exp, _definedFunctions__WEBPACK_IMPORTED_MODULE_3__["LanguageDefinedFunction"].getLocalName(fun_name), sourceInfo.line];
return createSemanticError("invalid_const_ref_full", context);
} else {
return ProcessorErrorFactory.invalid_const_ref(fun_name, exp);
}
},
invalid_const_ref: function invalid_const_ref(fun_name, exp) {
var context = [exp, _definedFunctions__WEBPACK_IMPORTED_MODULE_3__["LanguageDefinedFunction"].getLocalName(fun_name)];
return createSemanticError("invalid_const_ref", context);
},
invalid_const_assignment_full: function invalid_const_assignment_full(var_id, source_info) {
if (source_info) {
var context = [source_info.line, var_id];
return createSemanticError("invalid_const_assignment_full", context);
} else {
return ProcessorErrorFactory.invalid_const_assignment(var_id);
}
},
invalid_const_assignment: function invalid_const_assignment(var_id) {
var context = [var_id];
return createSemanticError("invalid_const_assignment", context);
},
invalid_vector_assignment_full: function invalid_vector_assignment_full(left_id, left_size, right_id, right_size, source_info) {
if (source_info) {
var context = [source_info.line, left_id, left_size, right_id, right_size];
return createRuntimeError("invalid_vector_assignment_full", context);
} else {
return ProcessorErrorFactory.invalid_vector_assignment(left_id, left_size, right_id, right_size);
}
},
invalid_vector_assignment: function invalid_vector_assignment(left_id, left_size, right_id, right_size) {
var context = [left_id, left_size, right_id, right_size];
return createRuntimeError("invalid_vector_assignment", context);
},
invalid_matrix_assignment_full: function invalid_matrix_assignment_full(left_id, left_line, left_column, right_id, right_line, right_column, source_info) {
if (source_info) {
var context = [source_info.line, left_id, left_line, left_column, right_id, right_line, right_column];
return createRuntimeError("invalid_matrix_assignment_full", context);
} else {
return ProcessorErrorFactory.invalid_matrix_assignment(left_id, left_line, left_column, right_id, right_line, right_column);
}
},
invalid_matrix_assignment: function invalid_matrix_assignment(left_id, left_line, left_column, right_id, right_line, right_column) {
var context = [left_id, left_line, left_column, right_id, right_line, right_column];
return createRuntimeError("invalid_matrix_assignment", context);
},
matrix_to_vector_attr: function matrix_to_vector_attr(left_id, right_id, source_info) {
// SourceInfo have to be valid...
var context = [source_info.line, right_id, left_id];
return createSemanticError("matrix_to_vector_attr", context);
},
vector_to_matrix_attr: function vector_to_matrix_attr(left_id, right_id, source_info) {
// SourceInfo have to be valid...
var context = [source_info.line, right_id, left_id];
return createSemanticError("vector_to_matrix_attr", context);
},
invalid_matrix_index_assign_full: function invalid_matrix_index_assign_full(mat_id, mat_line, mat_size, exp, exp_size, source_info) {
if (source_info) {
var context = [source_info.line, mat_line, mat_id, mat_size, exp, exp_size];
return createRuntimeError("invalid_matrix_index_assign_full", context);
} else {
return ProcessorErrorFactory.invalid_matrix_index_assign(mat_id, mat_line, mat_size, exp, exp_size);
}
},
invalid_matrix_index_assign: function invalid_matrix_index_assign(mat_id, mat_line, mat_size, exp, exp_size) {
var context = [mat_line, mat_id, mat_size, exp, exp_size];
return createRuntimeError("invalid_matrix_index_assign", context);
},
invalid_number_elements_vector: function invalid_number_elements_vector(expected_num, exp, actual_num, source_info) {
// SourceInfo have to be valid...
var context = [expected_num, source_info.line, exp, actual_num];
return createRuntimeError("invalid_number_elements_vector", context);
},
invalid_number_lines_matrix: function invalid_number_lines_matrix(expected_num, exp, actual_num, source_info) {
// SourceInfo have to be valid...
var context = [expected_num, source_info.line, exp, actual_num];
return createRuntimeError("invalid_number_lines_matrix", context);
},
divsion_by_zero_full: function divsion_by_zero_full(exp, source_info) {
if (source_info) {
var context = [source_info.line, exp];
return createRuntimeError("divsion_by_zero_full", context);
} else {
return ProcessorErrorFactory.divsion_by_zero(exp);
}
},
divsion_by_zero: function divsion_by_zero(exp) {
var context = [exp];
return createRuntimeError("divsion_by_zero", context);
},
undefined_tanget_value: function undefined_tanget_value(value, source_info) {
var context = [source_info.line, value];
return createRuntimeError("undefined_tanget_value", context);
},
negative_log_value: function negative_log_value(source_info) {
return createRuntimeError("negative_log_value", [source_info.line]);
},
invalid_string_index: function invalid_string_index(index, str, source_info) {
var local_fun_name = _definedFunctions__WEBPACK_IMPORTED_MODULE_3__["LanguageDefinedFunction"].getLocalName("$charAt");
var context = [source_info.line, local_fun_name, index, str, str.length - 1];
return createRuntimeError("invalid_string_index", context);
},
negative_sqrt_value: function negative_sqrt_value(source_info) {
return createRuntimeError("negative_sqrt_value", [source_info.line]);
},
/**
* @deprecated 01/10/2019
*/
exceeded_recursive_calls: function exceeded_recursive_calls(source_info) {
var context = [source_info.line];
return createRuntimeError("exceeded_recursive_calls", context);
},
invalid_for_variable: function invalid_for_variable(id, source_info) {
var context = [source_info.line, id];
return createSemanticError("invalid_for_variable", context);
},
invalid_for_from: function invalid_for_from(exp, source_info) {
var context = [source_info.line, exp];
return createSemanticError("invalid_for_from", context);
},
invalid_for_to: function invalid_for_to(exp, source_info) {
var context = [source_info.line, exp];
return createSemanticError("invalid_for_to", context);
},
invalid_for_pass: function invalid_for_pass(exp, source_info) {
var context = [source_info.line, exp];
return createSemanticError("invalid_for_pass", context);
},
exceed_max_instructions: function exceed_max_instructions() {
return createRuntimeError('exceed_max_instructions');
}
});
/***/ }),
/***/ "./js/processor/error/runtimeError.js":
/*!********************************************!*\
!*** ./js/processor/error/runtimeError.js ***!
\********************************************/
/*! exports provided: RuntimeError */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeError", function() { return RuntimeError; });
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var RuntimeError =
/*#__PURE__*/
function (_Error) {
_inherits(RuntimeError, _Error);
function RuntimeError() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, RuntimeError);
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
msg[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(RuntimeError)).call.apply(_getPrototypeOf2, [this].concat(msg)));
if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_this), RuntimeError);
return _this;
}
return RuntimeError;
}(_wrapNativeSuper(Error));
/***/ }),
/***/ "./js/processor/error/semanticError.js":
/*!*********************************************!*\
!*** ./js/processor/error/semanticError.js ***!
\*********************************************/
/*! exports provided: SemanticError */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SemanticError", function() { return SemanticError; });
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var SemanticError =
/*#__PURE__*/
function (_Error) {
_inherits(SemanticError, _Error);
function SemanticError() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, SemanticError);
for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {
msg[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SemanticError)).call.apply(_getPrototypeOf2, [this].concat(msg)));
if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_this), SemanticError);
return _this;
}
return SemanticError;
}(_wrapNativeSuper(Error));
/***/ }),
/***/ "./js/processor/ivprogProcessor.js":
/*!*****************************************!*\
!*** ./js/processor/ivprogProcessor.js ***!
\*****************************************/
/*! exports provided: IVProgProcessor */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IVProgProcessor", function() { return IVProgProcessor; });
/* harmony import */ var _store_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./store/store */ "./js/processor/store/store.ts");
/* harmony import */ var _store_store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_store_store__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modes */ "./js/processor/modes.ts");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_modes__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _context__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./context */ "./js/processor/context.ts");
/* harmony import */ var _context__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_context__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _ast_operators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./../ast/operators */ "./js/ast/operators.js");
/* harmony import */ var _definedFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./definedFunctions */ "./js/processor/definedFunctions.js");
/* harmony import */ var _compatibilityTable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./compatibilityTable */ "./js/processor/compatibilityTable.js");
/* harmony import */ var _ast_commands___WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./../ast/commands/ */ "./js/ast/commands/index.js");
/* harmony import */ var _ast_expressions___WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./../ast/expressions/ */ "./js/ast/expressions/index.js");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
/* harmony import */ var _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
/* harmony import */ var _error_runtimeError__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./error/runtimeError */ "./js/processor/error/runtimeError.js");
/* harmony import */ var _memory_location__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../memory/location */ "./js/memory/location.ts");
/* harmony import */ var _memory_location__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_memory_location__WEBPACK_IMPORTED_MODULE_14__);
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./store/value/store_value */ "./js/processor/store/value/store_value.ts");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value__WEBPACK_IMPORTED_MODULE_15__);
/* harmony import */ var _store_value_store_value_ref__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./store/value/store_value_ref */ "./js/processor/store/value/store_value_ref.ts");
/* harmony import */ var _store_value_store_value_ref__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value_ref__WEBPACK_IMPORTED_MODULE_16__);
/* harmony import */ var _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./store/value/array_store_value */ "./js/processor/store/value/array_store_value.ts");
/* harmony import */ var _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__);
/* harmony import */ var _store_value_array_store_value_ref__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./store/value/array_store_value_ref */ "./js/processor/store/value/array_store_value_ref.ts");
/* harmony import */ var _store_value_array_store_value_ref__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_store_value_array_store_value_ref__WEBPACK_IMPORTED_MODULE_18__);
/* harmony import */ var _store_value_store_value_address__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./store/value/store_value_address */ "./js/processor/store/value/store_value_address.ts");
/* harmony import */ var _store_value_store_value_address__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value_address__WEBPACK_IMPORTED_MODULE_19__);
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../services/localizedStringsService */ "./js/services/localizedStringsService.js");
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var IVProgProcessor =
/*#__PURE__*/
function () {
_createClass(IVProgProcessor, null, [{
key: "MAIN_INTERNAL_ID",
get: function get() {
return "$main";
}
}]);
function IVProgProcessor(ast) {
_classCallCheck(this, IVProgProcessor);
this.ast = ast;
this.globalStore = new _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"]("$global");
this.stores = [this.globalStore];
this.context = [_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BASE];
this.input = null;
this.forceKill = false;
this.output = null;
this.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RUN;
/**
* Stores the sourceInfo of every function call, command or expression
*/
this.function_call_stack = [];
this.instruction_count = 0;
this.function_call_count = 0;
}
_createClass(IVProgProcessor, [{
key: "registerInput",
value: function registerInput(input) {
if (this.input !== null) this.input = null;
this.input = input;
}
}, {
key: "registerOutput",
value: function registerOutput(output) {
if (this.output !== null) this.output = null;
this.output = output;
}
}, {
key: "checkContext",
value: function checkContext(context) {
return this.context[this.context.length - 1] === context;
}
}, {
key: "ignoreSwitchCases",
value: function ignoreSwitchCases(store) {
if (store.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN) {
return true;
} else if (store.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].BREAK) {
return true;
} else {
return false;
}
}
}, {
key: "prepareState",
value: function prepareState() {
if (this.stores !== null) {
for (var i = 0; i < this.stores.length; i++) {
delete this.stores[i];
}
this.stores = null;
}
if (this.globalStore !== null) this.globalStore = null;
this.globalStore = new _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"]("$global");
this.stores = [this.globalStore];
this.context = [_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BASE];
this.instruction_count = 0;
this.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RUN;
}
}, {
key: "interpretAST",
value: function interpretAST() {
var _this = this;
this.prepareState();
_memory_location__WEBPACK_IMPORTED_MODULE_14__["Location"].clear();
return this.initGlobal().then(function (_) {
var mainFunc = _this.findMainFunction();
if (mainFunc === null) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].main_missing());
}
return _this.runFunction(mainFunc, [], _this.globalStore);
});
}
}, {
key: "initGlobal",
value: function initGlobal() {
if (!this.checkContext(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BASE)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_global_var());
}
return this.executeCommands(this.globalStore, this.ast.global);
}
}, {
key: "findMainFunction",
value: function findMainFunction() {
return this.ast.functions.find(function (v) {
return v.isMain;
});
}
}, {
key: "findFunction",
value: function findFunction(name) {
if (name.match(/^\$.+$/)) {
if (name === IVProgProcessor.MAIN_INTERNAL_ID) {
return this.findMainFunction();
}
var fun = _definedFunctions__WEBPACK_IMPORTED_MODULE_5__["LanguageDefinedFunction"].getFunction(name);
if (!fun) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].not_implemented(name);
}
return fun;
} else {
var val = this.ast.functions.find(function (v) {
return v.name === name;
});
if (!val) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].function_missing(name);
}
return val;
}
}
}, {
key: "runFunction",
value: function runFunction(func, actualParameters, store) {
var _this2 = this;
var funcName = func.isMain ? IVProgProcessor.MAIN_INTERNAL_ID : func.name;
var funcStore = new _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"](funcName);
funcStore.extendStore(this.globalStore);
return new Promise(function (resolve, reject) {
var run_lambda = function run_lambda() {
var newFuncStore$ = _this2.associateParameters(func.formalParameters, actualParameters, store, funcStore);
newFuncStore$.then(function (sto) {
_this2.context.push(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].FUNCTION);
_this2.stores.push(sto);
return _this2.executeCommands(sto, func.variablesDeclarations).then(function (stoWithVars) {
return _this2.executeCommands(stoWithVars, func.commands);
}).then(function (finalSto) {
_this2.stores.pop();
_this2.context.pop();
return finalSto;
});
}).then(resolve)["catch"](reject);
};
run_lambda();
});
}
}, {
key: "associateParameters",
value: function associateParameters(formal_params, effective_params, caller_store, callee_store) {
var _this3 = this;
var funcName = callee_store.name === IVProgProcessor.MAIN_INTERNAL_ID ? _definedFunctions__WEBPACK_IMPORTED_MODULE_5__["LanguageDefinedFunction"].getMainFunctionName() : callee_store.name;
if (formal_params.length != effective_params.length) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_parameters_size(funcName, formal_params.length, effective_params.length));
}
var promises$ = effective_params.map(function (actual_param) {
return _this3.evaluateExpression(caller_store, actual_param);
});
return Promise.all(promises$).then(function (values) {
for (var i = 0; i < values.length; i++) {
var sto_value = values[i]; // console.log(callee_store.name);
// console.log(sto_value);
var exp = effective_params[i];
var shouldTypeCast = false;
var formalParameter = formal_params[i];
if (!formalParameter.type.isCompatible(sto_value.type)) {
if (_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting && !formalParameter.byRef && _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(formalParameter.type, sto_value.type)) {
shouldTypeCast = true;
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_parameter_type(funcName, exp.toString()));
}
}
if (formalParameter.byRef && !sto_value.inStore()) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_ref(funcName, exp.toString()));
}
if (formalParameter.byRef) {
(function () {
var realObj = caller_store.getStoreObject(sto_value.id);
var ref = null;
if (sto_value instanceof _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__["ArrayStoreValue"]) {
// it's a vector or matrix...
var _values = sto_value.get();
var array_type = sto_value.type;
var addresses = _values.map(function (v) {
return realObj.getLocAddressOf(v.line, v.column);
});
var columns = sto_value.isVector() ? 0 : sto_value.columns;
ref = new _store_value_array_store_value_ref__WEBPACK_IMPORTED_MODULE_18__["ArrayStoreValueRef"](array_type, _values, addresses, sto_value.lines, columns, realObj.id);
} else {
if (sto_value instanceof _store_value_store_value_address__WEBPACK_IMPORTED_MODULE_19__["StoreValueAddress"]) {
var line = sto_value.line;
var column = sto_value.column;
ref = new _store_value_store_value_ref__WEBPACK_IMPORTED_MODULE_16__["StoreValueRef"](sto_value.type, sto_value.get(), realObj.getLocAddressOf(line, column), realObj.id);
ref.setReferenceDimension(realObj.type.dimensions);
} else {
ref = new _store_value_store_value_ref__WEBPACK_IMPORTED_MODULE_16__["StoreValueRef"](sto_value.type, sto_value.get(), realObj.locAddress, realObj.id);
}
}
callee_store.insertStore(formalParameter.id, ref);
})();
} else {
var realValue = sto_value;
if (shouldTypeCast) {
realValue = _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].doImplicitCasting(formalParameter.type, realValue);
}
callee_store.insertStore(formalParameter.id, realValue);
}
}
return callee_store;
});
}
}, {
key: "executeCommands",
value: function executeCommands(store, cmds) {
var _this4 = this;
// helper to partially apply a function, in this case executeCommand
var partial = function partial(fun, cmd) {
return function (sto) {
return fun(sto, cmd);
};
};
return cmds.reduce(function (lastCommand, next) {
var nextCommand = partial(_this4.executeCommand.bind(_this4), next);
return lastCommand.then(nextCommand);
}, Promise.resolve(store));
}
}, {
key: "executeCommand",
value: function executeCommand(store, cmd) {
var _this5 = this;
this.instruction_count += 1;
return new Promise(function (resolve, reject) {
var command_lambda = function command_lambda() {
if (_this5.instruction_count >= _util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].max_instruction_count) {
return reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].exceed_max_instructions());
} else if (_this5.forceKill) {
return reject("FORCED_KILL!");
} else if (store.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].PAUSE) {
return resolve(_this5.executeCommand(store, cmd));
} else if (store.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN) {
return resolve(store);
} else if (_this5.checkContext(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BREAKABLE) && store.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].BREAK) {
return resolve(store);
} else if (_this5.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].ABORT) {
return reject(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_20__["LocalizedStrings"].getMessage('aborted_execution'));
}
if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Declaration"]) {
return resolve(_this5.executeDeclaration(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["ArrayIndexAssign"]) {
return resolve(_this5.executeArrayIndexAssign(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Assign"]) {
return resolve(_this5.executeAssign(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Break"]) {
return resolve(_this5.executeBreak(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Return"]) {
return resolve(_this5.executeReturn(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["IfThenElse"]) {
return resolve(_this5.executeIfThenElse(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["RepeatUntil"]) {
return resolve(_this5.executeRepeatUntil(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["While"]) {
return resolve(_this5.executeWhile(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["For"]) {
return resolve(_this5.executeFor(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Switch"]) {
return resolve(_this5.executeSwitch(store, cmd));
} else if (cmd instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["FunctionCall"]) {
return resolve(_this5.executeFunctionCall(store, cmd));
} else if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["SysCall"]) {
return resolve(_this5.executeSysCall(store, cmd));
} else {
return reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].unknown_command(cmd.sourceInfo));
}
};
if (_this5.instruction_count % _util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].suspend_threshold == 0) {
//every 100th command should briefly delay its execution in order to allow the browser to process other things
setTimeout(command_lambda, 5);
} else {
command_lambda();
}
});
}
}, {
key: "executeSysCall",
value: function executeSysCall(store, cmd) {
var func = cmd.langFunc.bind(this);
return func(store, cmd);
}
}, {
key: "executeFunctionCall",
value: function executeFunctionCall(store, cmd) {
var _this6 = this;
var func = null;
if (cmd.isMainCall) {
func = this.findMainFunction();
} else {
func = this.findFunction(cmd.id);
} // if(this.function_call_stack.length >= Config.max_call_stack) {
// return Promise.reject(ProcessorErrorFactory.exceeded_recursive_calls(cmd.sourceInfo));
// }
this.function_call_stack.push(cmd.sourceInfo);
return this.runFunction(func, cmd.actualParameters, store).then(function (sto) {
sto.destroy();
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].VOID.isCompatible(func.returnType) && sto.mode !== _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN) {
var funcName = func.name === IVProgProcessor.MAIN_INTERNAL_ID ? _definedFunctions__WEBPACK_IMPORTED_MODULE_5__["LanguageDefinedFunction"].getMainFunctionName() : func.name;
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].function_no_return(funcName));
} else {
_this6.function_call_stack.pop();
return store;
}
});
}
}, {
key: "executeSwitch",
value: function executeSwitch(store, cmd) {
var _this7 = this;
this.context.push(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BREAKABLE);
var caseSequence = cmd.cases.reduce(function (prev, next) {
return prev.then(function (tuple) {
if (_this7.ignoreSwitchCases(tuple[1])) {
return Promise.resolve(tuple);
} else if (tuple[0] || next.isDefault) {
return _this7.executeCommands(tuple[1], next.commands).then(function (nSto) {
return Promise.resolve([true, nSto]);
});
} else {
var equalityInfixApp = new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["InfixApp"](_ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].EQ, cmd.expression, next.expression);
equalityInfixApp.sourceInfo = next.sourceInfo;
return _this7.evaluateExpression(tuple[1], equalityInfixApp).then(function (stoObj) {
return stoObj.get();
}).then(function (isEqual) {
if (isEqual) {
return _this7.executeCommands(tuple[1], next.commands).then(function (nSto) {
return Promise.resolve([true, nSto]);
});
} else {
return Promise.resolve(tuple);
}
});
}
});
}, Promise.resolve([false, store]));
return caseSequence.then(function (tuple) {
_this7.context.pop();
var newStore = tuple[1];
if (newStore.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].BREAK) {
newStore.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RUN;
}
return newStore;
});
}
/**
*
* @param {Store} store
* @param {Commands.For} cmd
*/
}, {
key: "executeFor",
value: function executeFor(store, cmd) {
var _this8 = this;
//BEGIN for -> while rewrite
var initCmd = new _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Assign"](cmd.for_id.id, cmd.for_from);
initCmd.sourceInfo = cmd.sourceInfo;
var is_forward_exp = new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["InfixApp"](_ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].GE, cmd.for_to, cmd.for_from);
return this.evaluateExpression(store, is_forward_exp).then(function (result) {
var is_forward = result.value;
var condition = null;
if (is_forward) {
condition = new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["InfixApp"](_ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].LE, cmd.for_id, cmd.for_to);
} else {
condition = new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["InfixApp"](_ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].GE, cmd.for_id, cmd.for_to);
}
condition.sourceInfo = cmd.sourceInfo;
var pass_value = cmd.for_pass;
if (pass_value == null) {
if (is_forward) {
pass_value = new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["IntLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_10__["toInt"])(1));
} else {
pass_value = new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["IntLiteral"](Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_10__["toInt"])(-1));
}
}
var increment = new _ast_commands___WEBPACK_IMPORTED_MODULE_7__["Assign"](cmd.for_id.id, new _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["InfixApp"](_ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].ADD, cmd.for_id, pass_value));
increment.sourceInfo = cmd.sourceInfo;
var whileBlock = new _ast_commands___WEBPACK_IMPORTED_MODULE_7__["CommandBlock"]([], cmd.commands.concat(increment));
var forAsWhile = new _ast_commands___WEBPACK_IMPORTED_MODULE_7__["While"](condition, whileBlock);
forAsWhile.sourceInfo = cmd.sourceInfo; //END for -> while rewrite
var newCmdList = [initCmd, forAsWhile];
return _this8.executeCommands(store, newCmdList);
})["catch"](function (error) {
return Promise.reject(error);
});
}
}, {
key: "executeRepeatUntil",
value: function executeRepeatUntil(store, cmd) {
var _this9 = this;
try {
this.context.push(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BREAKABLE);
var $newStore = this.executeCommands(store, cmd.commands);
return $newStore.then(function (sto) {
if (sto.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].BREAK) {
_this9.context.pop();
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RUN;
return sto;
}
var $value = _this9.evaluateExpression(sto, cmd.expression);
return $value.then(function (vl) {
if (!vl.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].loop_condition_type_full(cmd.sourceInfo));
}
if (!vl.get()) {
_this9.context.pop();
return _this9.executeCommand(sto, cmd);
} else {
_this9.context.pop();
return sto;
}
});
});
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "executeWhile",
value: function executeWhile(store, cmd) {
var _this10 = this;
try {
this.context.push(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BREAKABLE);
var $value = this.evaluateExpression(store, cmd.expression);
return $value.then(function (vl) {
if (vl.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN)) {
if (vl.get()) {
var $newStore = _this10.executeCommands(store, cmd.commands);
return $newStore.then(function (sto) {
_this10.context.pop();
if (sto.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].BREAK) {
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RUN;
return sto;
}
return _this10.executeCommand(sto, cmd);
});
} else {
_this10.context.pop();
return store;
}
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].loop_condition_type_full(cmd.expression.toString(), cmd.sourceInfo));
}
});
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "executeIfThenElse",
value: function executeIfThenElse(store, cmd) {
var _this11 = this;
try {
var $value = this.evaluateExpression(store, cmd.condition);
return $value.then(function (vl) {
if (vl.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN)) {
if (vl.get()) {
return _this11.executeCommands(store, cmd.ifTrue.commands);
} else if (cmd.ifFalse !== null) {
if (cmd.ifFalse instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["IfThenElse"]) {
return _this11.executeCommand(store, cmd.ifFalse);
} else {
return _this11.executeCommands(store, cmd.ifFalse.commands);
}
} else {
return Promise.resolve(store);
}
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].if_condition_type_full(cmd.condition.toString(), cmd.sourceInfo));
}
});
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "executeReturn",
value: function executeReturn(store, cmd) {
try {
var funcName = store.name === IVProgProcessor.MAIN_INTERNAL_ID ? _definedFunctions__WEBPACK_IMPORTED_MODULE_5__["LanguageDefinedFunction"].getMainFunctionName() : store.name; // console.log(funcName, store.name === IVProgProcessor.MAIN_INTERNAL_ID);
var func = this.findFunction(store.name);
var funcType = func.returnType;
var $value = this.evaluateExpression(store, cmd.expression);
return $value.then(function (value) {
var real_value = value;
if (value === null && funcType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].VOID)) {
store.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN;
return Promise.resolve(store);
}
if (value === null || !funcType.isCompatible(value.type)) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(funcType, value.type)) {
var stringInfo = funcType.stringInfo();
var info = stringInfo[0];
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_return_type_full(funcName, info.type, info.dim, cmd.sourceInfo));
}
real_value = _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].doImplicitCasting(funcType, value);
} else {
store.insertStore('$', real_value);
store.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN;
return Promise.resolve(store);
}
});
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "executeBreak",
value: function executeBreak(store, cmd) {
if (this.checkContext(_context__WEBPACK_IMPORTED_MODULE_2__["Context"].BREAKABLE)) {
store.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].BREAK;
return Promise.resolve(store);
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].unexpected_break_command_full(cmd.sourceInfo));
}
}
}, {
key: "executeAssign",
value: function executeAssign(store, cmd) {
try {
var inStore = store.applyStore(cmd.id);
if (inStore.isConst) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_const_assignment_full(cmd.id, cmd.sourceInfo));
}
var $value = this.evaluateExpression(store, cmd.expression);
return $value.then(function (vl) {
var realValue = vl;
if (!inStore.type.isCompatible(realValue.type)) {
if (_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting && _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(inStore.type, vl.type)) {
realValue = _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].doImplicitCasting(inStore.type, realValue);
} else {
var stringInfo = inStore.type.stringInfo();
var info = stringInfo[0];
var exp_type_string_info = vl.type.stringInfo();
var exp_type_info = exp_type_string_info[0];
var exp = cmd.expression.toString();
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].incompatible_types_full(info.type, info.dim, exp_type_info.type, exp_type_info.dim, exp, cmd.sourceInfo));
}
}
if (inStore instanceof _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__["ArrayStoreValue"]) {
var columns = realValue.columns == null ? 0 : realValue.columns;
if (inStore.lines !== realValue.lines || inStore.columns !== columns) {
var _exp = cmd.expression.toString();
if (inStore.isVector()) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_vector_assignment_full(cmd.id, inStore.lines, _exp, realValue.lines, cmd.sourceInfo));
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_matrix_assignment_full(cmd.id, inStore.lines, inStore.columns, _exp, realValue.lines, realValue.columns, cmd.sourceInfo));
}
}
}
store.updateStore(cmd.id, realValue);
return store;
});
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "executeArrayIndexAssign",
value: function executeArrayIndexAssign(store, cmd) {
var mustBeArray = store.applyStore(cmd.id);
var used_dims = 0;
if (mustBeArray.isConst) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_const_assignment_full(cmd.id, cmd.sourceInfo));
}
if (!(mustBeArray.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9__["ArrayType"])) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_array_access_full(cmd.id, cmd.sourceInfo));
}
var line$ = this.evaluateExpression(store, cmd.line);
var column$ = this.evaluateExpression(store, cmd.column);
var value$ = this.evaluateExpression(store, cmd.expression);
return Promise.all([line$, column$, value$]).then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 3),
line_sv = _ref2[0],
column_sv = _ref2[1],
value = _ref2[2];
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(line_sv.type)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_int_full(cmd.sourceInfo));
}
var line = line_sv.get().toNumber();
used_dims += 1;
var column = undefined;
if (column_sv != null) {
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(column_sv.type)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_int_full(cmd.sourceInfo));
}
column = column_sv.get().toNumber();
used_dims += 1;
}
var actualValue = value;
if (line >= mustBeArray.lines) {
if (mustBeArray.isVector) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].vector_line_outbounds_full(cmd.id, line, mustBeArray.lines, cmd.sourceInfo));
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].matrix_line_outbounds_full(cmd.id, line, mustBeArray.lines, cmd.sourceInfo));
}
} else if (line < 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_positive_full(cmd.sourceInfo));
}
if (column != null && mustBeArray.columns === 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].vector_not_matrix_full(cmd.id, cmd.sourceInfo));
}
if (column != null) {
if (column >= mustBeArray.columns) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].matrix_column_outbounds_full(cmd.id, column, mustBeArray.columns, cmd.sourceInfo));
} else if (column < 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_positive_full(cmd.sourceInfo));
}
}
if (!mustBeArray.type.canAccept(value.type, used_dims)) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(mustBeArray.type.innerType, value.type)) {
var type = mustBeArray.type.innerType;
var stringInfo = type.stringInfo();
var info = stringInfo[0];
var exp_type_string_info = value.type.stringInfo();
var exp_type_info = exp_type_string_info[0];
var exp = cmd.expression.toString();
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].incompatible_types_full(info.type, info.dim, exp_type_info.type, exp_type_info.dim, exp, cmd.sourceInfo));
}
actualValue = _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].doImplicitCasting(mustBeArray.type.innerType, value);
}
var current_value = mustBeArray.getAt(line, column);
if (current_value instanceof _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__["ArrayStoreValue"]) {
if (current_value.lines !== actualValue.lines || current_value.columns !== actualValue.columns) {
var _exp2 = cmd.expression.toString();
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_matrix_index_assign_full(cmd.id, line, current_value.lines, _exp2, actualValue.lines, cmd.sourceInfo));
}
} // mustBeArray.setAt(actualValue, line, column);
// store.updateStore(cmd.id, mustBeArray);
return store.updateStoreArray(cmd.id, actualValue, line, column);
});
}
/**
*
* @param {Store} store
* @param {Commands.Declaration} cmd
*/
}, {
key: "executeDeclaration",
value: function executeDeclaration(store, cmd) {
try {
var $value = Promise.resolve(null);
if (cmd instanceof _ast_commands___WEBPACK_IMPORTED_MODULE_7__["ArrayDeclaration"]) {
return this.executeArrayDeclaration(store, cmd);
} else {
if (cmd.initial !== null) {
$value = this.evaluateExpression(store, cmd.initial);
}
return $value.then(function (vl) {
var realValue = vl;
var temp = null;
if (vl !== null) {
if (!vl.type.isCompatible(cmd.type)) {
if (_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting && _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(cmd.type, vl.type)) {
realValue = _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].doImplicitCasting(cmd.type, realValue);
} else {
var stringInfo = vl.type.stringInfo();
var info = stringInfo[0];
var exp_type_string_info = vl.type.stringInfo();
var exp_type_info = exp_type_string_info[0];
var exp = cmd.expression.toString();
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].incompatible_types_full(info.type, info.dim, exp_type_info.type, exp_type_info.dim, exp, cmd.sourceInfo));
}
}
temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](cmd.type, realValue.get(), null, cmd.isConst);
} else {
temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](cmd.type, null, null, cmd.isConst);
}
store.insertStore(cmd.id, temp);
return store;
});
}
} catch (e) {
return Promise.reject(e);
}
}
/**
*
* @param {Store} store
* @param {Commands.ArrayDeclaration} cmd
*/
}, {
key: "executeArrayDeclaration",
value: function executeArrayDeclaration(store, cmd) {
var _this12 = this;
var $lines = this.evaluateExpression(store, cmd.lines);
var $columns = cmd.columns === null ? null : this.evaluateExpression(store, cmd.columns);
return Promise.all([$lines, $columns]).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
line_sv = _ref4[0],
column_sv = _ref4[1];
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(line_sv.type)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_int_full(cmd.sourceInfo));
}
var line = line_sv.get().toNumber();
if (line < 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_positive_full(cmd.sourceInfo));
}
var column = null;
if (column_sv !== null) {
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(column_sv.type)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_int_full(cmd.sourceInfo));
}
column = column_sv.get().toNumber();
if (column < 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_positive_full(cmd.sourceInfo));
}
}
var $value = Promise.resolve(null);
if (cmd.initial !== null) {
// array can only be initialized by a literal....
$value = _this12.evaluateArrayLiteral(store, cmd.initial, cmd.type, line, column);
}
return $value.then(function (vector_list) {
var temp = null;
if (vector_list !== null) {
temp = new _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__["ArrayStoreValue"](cmd.type, vector_list, line, column, null, cmd.isConst);
} else {
temp = new _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__["ArrayStoreValue"](cmd.type, [], line, column, null, cmd.isConst);
}
store.insertStore(cmd.id, temp);
return store;
});
});
}
}, {
key: "evaluateExpression",
value: function evaluateExpression(store, exp) {
var _this13 = this;
this.instruction_count += 1;
return new Promise(function (resolve, reject) {
var expression_lambda = function expression_lambda() {
if (_this13.mode === _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].ABORT) {
return reject(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_20__["LocalizedStrings"].getMessage('aborted_execution'));
}
if (_this13.instruction_count >= _util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].max_instruction_count) {
return reject(new Error("Número de instruções excedeu o limite definido. Verifique se seu código não possui laços infinitos ou muitas chamadas de funções recursivas."));
}
if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["UnaryApp"]) {
return resolve(_this13.evaluateUnaryApp(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["InfixApp"]) {
return resolve(_this13.evaluateInfixApp(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["ArrayAccess"]) {
return resolve(_this13.evaluateArrayAccess(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["VariableLiteral"]) {
return resolve(_this13.evaluateVariableLiteral(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["IntLiteral"]) {
return resolve(_this13.evaluateLiteral(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["RealLiteral"]) {
return resolve(_this13.evaluateLiteral(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["BoolLiteral"]) {
return resolve(_this13.evaluateLiteral(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["StringLiteral"]) {
return resolve(_this13.evaluateLiteral(store, exp));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["ArrayLiteral"]) {
return reject(new Error("Internal Error: The system should not eval an array literal."));
} else if (exp instanceof _ast_expressions___WEBPACK_IMPORTED_MODULE_8__["FunctionCall"]) {
return resolve(_this13.evaluateFunctionCall(store, exp));
}
return resolve(null);
};
if (_this13.instruction_count % _util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].suspend_threshold == 0) {
//every 100th command should briefly delay its execution in order to allow the browser to process other things
setTimeout(expression_lambda, 5);
} else {
expression_lambda();
}
});
}
}, {
key: "evaluateFunctionCall",
value: function evaluateFunctionCall(store, exp) {
var _this14 = this;
if (exp.isMainCall) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].void_in_expression_full(_definedFunctions__WEBPACK_IMPORTED_MODULE_5__["LanguageDefinedFunction"].getMainFunctionName(), exp.sourceInfo));
}
var func = this.findFunction(exp.id);
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].VOID.isCompatible(func.returnType)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].void_in_expression_full(exp.id, exp.sourceInfo));
}
if (this.function_call_stack.length >= _util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].max_call_stack) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].exceeded_recursive_calls(exp.sourceInfo));
}
this.function_call_stack.push(exp.sourceInfo);
var $newStore = this.runFunction(func, exp.actualParameters, store);
return $newStore.then(function (sto) {
if (sto.mode !== _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN) {
return Promise.reject(new Error("!!!Internal error: the function that was called did not have a return command or did not set the store mode properly -> " + exp.id));
}
var val = sto.applyStore('$');
sto.destroy();
_this14.function_call_stack.pop();
return Promise.resolve(val);
});
}
/**
*
* @param {Store} store
* @param {Expressions.ArrayLiteral} exp
* @param {ArrayType} type
*/
}, {
key: "evaluateArrayLiteral",
value: function evaluateArrayLiteral(store, exp, type, lines, columns) {
if (!exp.isVector) {
if (columns == null) {
return Promise.reject(new Error("This should never happen: Vector cannot be initialized by a matrix"));
}
var $matrix = this.evaluateMatrix(store, exp, type, lines, columns);
return Promise.all($matrix).then(function (vectorList) {
var values = vectorList.reduce(function (prev, next) {
return prev.concat(next);
}, []);
return Promise.resolve(values);
});
} else {
if (columns != null) {
return Promise.reject(new Error("This should never happen: Matrix cannot be initialized by a vector"));
}
return this.evaluateVector(store, exp, type, lines).then(function (list) {
return Promise.resolve(list);
});
}
}
/**
* Evalautes a list of literals and expression composing the vector
* @param {Store} store
* @param {Expressions.ArrayLiteral} exps
* @param {ArrayType} type
* @param {number} n_elements
* @returns {Promise} store object list
*/
}, {
key: "evaluateVector",
value: function evaluateVector(store, exps, type, n_elements) {
var _this15 = this;
var values = exps.value;
if (n_elements !== values.length) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_number_elements_vector(n_elements, exps.toString(), values.length, exps.sourceInfo));
}
var actual_values = Promise.all(values.map(function (exp) {
return _this15.evaluateExpression(store, exp);
}));
return actual_values.then(function (values) {
return values.map(function (v, index) {
if (!type.canAccept(v.type, 1)) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(type.innerType, v.type)) {
// const stringInfo = v.type.stringInfo();
// const info = stringInfo[0];
var exp_str = values[index].toString(); // TODO - fix error message
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_array_literal_type_full(exp_str, values[index].sourceInfo));
}
var new_value = _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].doImplicitCasting(type.innerType, v);
return new_value;
}
return v;
});
});
}
/**
* Evaluates a list of array literals composing the matrix
* @param {Store} store
* @param {Expressions.ArrayLiteral} exps
* @param {ArrayType} type
* @returns {Promise[]}
*/
}, {
key: "evaluateMatrix",
value: function evaluateMatrix(store, exps, type, lines, columns) {
var _this16 = this;
var values = exps.value;
if (values.length !== lines) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_number_lines_matrix(lines, exps.toString(), values.length, exps.sourceInfo));
}
return values.map(function (vector) {
var vec_type = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9__["ArrayType"](type.innerType, 1);
return _this16.evaluateVector(store, vector, vec_type, columns);
});
}
}, {
key: "evaluateLiteral",
value: function evaluateLiteral(_, exp) {
return Promise.resolve(new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](exp.type, exp.value));
}
}, {
key: "evaluateVariableLiteral",
value: function evaluateVariableLiteral(store, exp) {
try {
var val = store.applyStore(exp.id);
return Promise.resolve(val);
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "evaluateArrayAccess",
value: function evaluateArrayAccess(store, exp) {
var mustBeArray = store.getStoreObject(exp.id);
if (!(mustBeArray.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9__["ArrayType"])) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_array_access_full(exp.id, exp.sourceInfo));
}
var $line = this.evaluateExpression(store, exp.line);
var $column = this.evaluateExpression(store, exp.column);
return Promise.all([$line, $column]).then(function (_ref5) {
var _ref6 = _slicedToArray(_ref5, 2),
line_sv = _ref6[0],
column_sv = _ref6[1];
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(line_sv.type)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_int_full(exp.sourceInfo));
}
var line = line_sv.get().toNumber();
var column = null;
if (column_sv !== null) {
if (!_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(column_sv.type)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_int_full(exp.sourceInfo));
}
column = column_sv.get().toNumber();
}
if (line >= mustBeArray.lines) {
if (mustBeArray.isVector) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].vector_line_outbounds_full(exp.id, line, mustBeArray.lines, exp.sourceInfo));
} else {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].matrix_line_outbounds_full(exp.id, line, mustBeArray.lines, exp.sourceInfo));
}
} else if (line < 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_positive_full(exp.sourceInfo));
}
if (column !== null && mustBeArray.columns === 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].vector_not_matrix_full(exp.id, exp.sourceInfo));
}
if (column !== null) {
if (column >= mustBeArray.columns) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].matrix_column_outbounds_full(exp.id, column, mustBeArray.columns, exp.sourceInfo));
} else if (column < 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].array_dimension_not_positive_full(exp.sourceInfo));
}
}
var result = mustBeArray.getAt(line, column);
var type = mustBeArray.type.innerType;
if (Array.isArray(result)) {
var values = result.map(function (v, c) {
return new _store_value_store_value_address__WEBPACK_IMPORTED_MODULE_19__["StoreValueAddress"](type, v, line, c, mustBeArray.id, mustBeArray.readOnly);
});
return Promise.resolve(new _store_value_array_store_value__WEBPACK_IMPORTED_MODULE_17__["ArrayStoreValue"](new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_9__["ArrayType"](type, 1), values, mustBeArray.columns, null, mustBeArray.id, mustBeArray.readOnly));
} else {
return Promise.resolve(new _store_value_store_value_address__WEBPACK_IMPORTED_MODULE_19__["StoreValueAddress"](type, result, line, column, mustBeArray.id, mustBeArray.readOnly));
}
});
}
}, {
key: "evaluateUnaryApp",
value: function evaluateUnaryApp(store, unaryApp) {
var $left = this.evaluateExpression(store, unaryApp.left);
return $left.then(function (left) {
var resultType = Object(_compatibilityTable__WEBPACK_IMPORTED_MODULE_6__["resultTypeAfterUnaryOp"])(unaryApp.op, left.type);
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].UNDEFINED.isCompatible(resultType)) {
var stringInfo = left.type.stringInfo();
var info = stringInfo[0];
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_unary_op_full(unaryApp.op, info.type, info.dim, unaryApp.sourceInfo));
}
switch (unaryApp.op.ord) {
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].ADD.ord:
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get());
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].SUB.ord:
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get().negated());
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].NOT.ord:
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, !left.get());
default:
return Promise.reject(new _error_runtimeError__WEBPACK_IMPORTED_MODULE_13__["RuntimeError"]('!!!Critical Invalid UnaryApp ' + unaryApp.op));
}
});
}
}, {
key: "evaluateInfixApp",
value: function evaluateInfixApp(store, infixApp) {
var $left = this.evaluateExpression(store, infixApp.left);
var $right = this.evaluateExpression(store, infixApp.right);
return Promise.all([$left, $right]).then(function (values) {
var shouldImplicitCast = false;
var left = values[0];
var right = values[1];
var resultType = Object(_compatibilityTable__WEBPACK_IMPORTED_MODULE_6__["resultTypeAfterInfixOp"])(infixApp.op, left.type, right.type);
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].UNDEFINED.isCompatible(resultType)) {
if (_util_config__WEBPACK_IMPORTED_MODULE_11__["Config"].enable_type_casting && _store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].canImplicitTypeCast(left.type, right.type)) {
shouldImplicitCast = true;
} else {
var stringInfoLeft = left.type.stringInfo();
var infoLeft = stringInfoLeft[0];
var stringInfoRight = right.type.stringInfo();
var infoRight = stringInfoRight[0];
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].invalid_infix_op_full(infixApp.op, infoLeft.type, infoLeft.dim, infoRight.type, infoRight.dim, infixApp.sourceInfo));
}
}
var result = null;
switch (infixApp.op.ord) {
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].ADD.ord:
{
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING.isCompatible(left.type)) {
var rightStr = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_10__["convertToString"])(right.get(), right.type);
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get() + rightStr);
} else if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING.isCompatible(right.type)) {
var leftStr = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_10__["convertToString"])(left.get(), left.type);
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, leftStr + right.get());
} else {
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get().plus(right.get()));
}
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].SUB.ord:
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get().minus(right.get()));
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].MULT.ord:
{
result = left.get().times(right.get());
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].DIV.ord:
{
if (right.get() == 0) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_12__["ProcessorErrorFactory"].divsion_by_zero_full(infixApp.toString(), infixApp.sourceInfo));
}
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(resultType)) result = left.get().divToInt(right.get());else result = left.get().div(right.get());
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].MOD.ord:
{
var leftValue = left.get();
var rightValue = right.get();
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER;
leftValue = leftValue.trunc();
rightValue = rightValue.trunc();
}
result = leftValue.modulo(rightValue);
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].GT.ord:
{
var _leftValue = left.get();
var _rightValue = right.get();
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING.isCompatible(left.type)) {
result = _leftValue.length > _rightValue.length;
} else {
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
_leftValue = _leftValue.trunc();
_rightValue = _rightValue.trunc();
}
result = _leftValue.gt(_rightValue);
}
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].GE.ord:
{
var _leftValue2 = left.get();
var _rightValue2 = right.get();
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING.isCompatible(left.type)) {
result = _leftValue2.length >= _rightValue2.length;
} else {
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
_leftValue2 = _leftValue2.trunc();
_rightValue2 = _rightValue2.trunc();
}
result = _leftValue2.gte(_rightValue2);
}
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].LT.ord:
{
var _leftValue3 = left.get();
var _rightValue3 = right.get();
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING.isCompatible(left.type)) {
result = _leftValue3.length < _rightValue3.length;
} else {
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
_leftValue3 = _leftValue3.trunc();
_rightValue3 = _rightValue3.trunc();
}
result = _leftValue3.lt(_rightValue3);
}
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].LE.ord:
{
var _leftValue4 = left.get();
var _rightValue4 = right.get();
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING.isCompatible(left.type)) {
result = _leftValue4.length <= _rightValue4.length;
} else {
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
_leftValue4 = _leftValue4.trunc();
_rightValue4 = _rightValue4.trunc();
}
result = _leftValue4.lte(_rightValue4);
}
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].EQ.ord:
{
var _leftValue5 = left.get();
var _rightValue5 = right.get();
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(left.type) || _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].REAL.isCompatible(left.type)) {
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
_leftValue5 = _leftValue5.trunc();
_rightValue5 = _rightValue5.trunc();
}
result = _leftValue5.eq(_rightValue5);
} else {
result = _leftValue5 === _rightValue5;
}
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].NEQ.ord:
{
var _leftValue6 = left.get();
var _rightValue6 = right.get();
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER.isCompatible(left.type) || _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].REAL.isCompatible(left.type)) {
if (shouldImplicitCast) {
resultType = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
_leftValue6 = _leftValue6.trunc();
_rightValue6 = _rightValue6.trunc();
}
result = !_leftValue6.eq(_rightValue6);
} else {
result = _leftValue6 !== _rightValue6;
}
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, result);
}
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].AND.ord:
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get() && right.get());
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].OR.ord:
return new _store_value_store_value__WEBPACK_IMPORTED_MODULE_15__["StoreValue"](resultType, left.get() || right.get());
default:
return Promise.reject(new _error_runtimeError__WEBPACK_IMPORTED_MODULE_13__["RuntimeError"]('!!!Critical Invalid InfixApp ' + infixApp.op));
}
});
}
}]);
return IVProgProcessor;
}();
/***/ }),
/***/ "./js/processor/lib/arrays.js":
/*!************************************!*\
!*** ./js/processor/lib/arrays.js ***!
\************************************/
/*! exports provided: createNumElementsFun, createMatrixLinesFun, createMatrixColumnsFun */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createNumElementsFun", function() { return createNumElementsFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createMatrixLinesFun", function() { return createMatrixLinesFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createMatrixColumnsFun", function() { return createMatrixColumnsFun; });
/* harmony import */ var _ast_commands__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_array_type__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modes */ "./js/processor/modes.ts");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_modes__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../store/value/store_value */ "./js/processor/store/value/store_value.ts");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value__WEBPACK_IMPORTED_MODULE_5__);
/**
* num_elements
* matrix_lines
* matrix_columns
*/
function createNumElementsFun() {
var numElementsFun = function numElementsFun(sto, _) {
var vector = sto.applyStore("vector");
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_5__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toInt"])(vector.lines));
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_4__["Modes"].RETURN;
sto.insertStore("$", temp);
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](numElementsFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$numElements', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_3__["ArrayType"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].ALL, 1), 'vector', false)], block);
return func;
}
function createMatrixLinesFun() {
var matrixLinesFun = function matrixLinesFun(sto, _) {
var matrix = sto.applyStore("matrix");
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_5__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toInt"])(matrix.lines));
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_4__["Modes"].RETURN;
sto.insertStore("$", temp);
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](matrixLinesFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$matrixLines', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_3__["ArrayType"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].ALL, 2), 'matrix', false)], block);
return func;
}
function createMatrixColumnsFun() {
var matrixColumnsFun = function matrixColumnsFun(sto, _) {
var matrix = sto.applyStore("matrix");
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_5__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toInt"])(matrix.columns));
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_4__["Modes"].RETURN;
sto.insertStore("$", temp);
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](matrixColumnsFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$matrixColumns', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_3__["ArrayType"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].ALL, 2), 'matrix', false)], block);
return func;
}
/***/ }),
/***/ "./js/processor/lib/io.js":
/*!********************************!*\
!*** ./js/processor/lib/io.js ***!
\********************************/
/*! exports provided: createOutputFun, createInputFun */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createOutputFun", function() { return createOutputFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createInputFun", function() { return createInputFun; });
/* harmony import */ var _ast_commands__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modes */ "./js/processor/modes.ts");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_modes__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../store/value/store_value */ "./js/processor/store/value/store_value.ts");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value__WEBPACK_IMPORTED_MODULE_5__);
function createOutputFun() {
var writeFunction = function writeFunction(store, _) {
var val = store.applyStore('p1');
this.output.sendOutput(Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["convertToString"])(val.get(), val.type));
store.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN;
return Promise.resolve(store);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](writeFunction)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$write', _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].VOID, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].ALL, 'p1', false)], block);
return func;
}
function createInputFun() {
var readFunction = function readFunction(store, _) {
var _this = this;
var request = new Promise(function (resolve, _) {
_this.input.requestInput(resolve);
});
return request.then(function (text) {
var typeToConvert = store.applyStore('p1').type;
var type = null;
var result = null;
try {
if (typeToConvert.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER)) {
result = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toInt"])(text).trunc();
type = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].INTEGER;
} else if (typeToConvert.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].REAL)) {
result = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toReal"])(text);
type = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].REAL;
} else if (typeToConvert.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN)) {
result = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toBool"])(text);
type = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].BOOLEAN;
} else if (typeToConvert.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING)) {
result = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toString"])(text);
type = _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].STRING;
} else {
return Promise.reject(new Error("!!!!Critical error: Unknown type in readFunction!!!!"));
}
} catch (_) {
if (_this.mode == _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].ABORT) {
store.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN;
return Promise.resolve(store);
}
var stringInfo = typeToConvert.stringInfo()[0];
var realObject = store.getStoreObject("p1");
if (realObject.getReferenceDimension() > 0) {
var arrayInfo = realObject.type.stringInfo()[0];
var dim = realObject.getReferenceDimension();
var _error = _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_4__["ProcessorErrorFactory"].invalid_read_type_array(text, stringInfo.type, stringInfo.dim, realObject.getRefObj(), arrayInfo.type, dim, _this.function_call_stack.pop());
return Promise.reject(_error);
}
var error = _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_4__["ProcessorErrorFactory"].invalid_read_type(text, stringInfo.type, stringInfo.dim, realObject.getRefObj(), _this.function_call_stack.pop());
return Promise.reject(error);
}
var stoValue = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_5__["StoreValue"](type, result);
store.updateStore('p1', stoValue);
store.mode = _modes__WEBPACK_IMPORTED_MODULE_1__["Modes"].RETURN;
return Promise.resolve(store);
});
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](readFunction)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$read', _typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].VOID, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_3__["Types"].ALL, 'p1', true)], block);
return func;
}
/***/ }),
/***/ "./js/processor/lib/lang.js":
/*!**********************************!*\
!*** ./js/processor/lib/lang.js ***!
\**********************************/
/*! exports provided: createIsRealFun, createIsIntFun, createIsBoolFun, createCastRealFun, createCastIntFun, createCastBoolFun, createCastStringFun */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createIsRealFun", function() { return createIsRealFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createIsIntFun", function() { return createIsIntFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createIsBoolFun", function() { return createIsBoolFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createCastRealFun", function() { return createCastRealFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createCastIntFun", function() { return createCastIntFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createCastBoolFun", function() { return createCastBoolFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createCastStringFun", function() { return createCastStringFun; });
/* harmony import */ var _ast_commands__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../ast/ivprogParser */ "./js/ast/ivprogParser.js");
/* harmony import */ var _ast_expressions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../ast/expressions */ "./js/ast/expressions/index.js");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../modes */ "./js/processor/modes.ts");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_modes__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../typeSystem/multiType */ "./js/typeSystem/multiType.ts");
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_multiType__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../store/value/store_value */ "./js/processor/store/value/store_value.ts");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value__WEBPACK_IMPORTED_MODULE_8__);
/**
*
* is_real
* is_int
* is_bool
* cast_real
* cast_int
* cast_bool
* cast_string
*/
function createIsRealFun() {
var isRealFun = function isRealFun(sto, _) {
var str = sto.applyStore("str");
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__["IVProgParser"].createParser(str.get());
var result = false;
try {
var val = parser.parseTerm();
if (val instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["RealLiteral"]) {
result = true;
}
} catch (error) {// ignore
}
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](isRealFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$isReal', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createIsIntFun() {
var isIntFun = function isIntFun(sto, _) {
var str = sto.applyStore("str");
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__["IVProgParser"].createParser(str.get());
var result = false;
try {
var val = parser.parseTerm();
if (val instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["IntLiteral"]) {
result = true;
}
} catch (_unused) {// ignore
}
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](isIntFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$isInt', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createIsBoolFun() {
var isBoolFun = function isBoolFun(sto, _) {
var str = sto.applyStore("str");
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__["IVProgParser"].createParser(str.get());
var result = false;
try {
var val = parser.parseTerm();
if (val instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["BoolLiteral"]) {
result = true;
}
} catch (error) {// ignore
}
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](isBoolFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$isBool', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createCastRealFun() {
var castRealFun = function castRealFun(sto, _) {
var val = sto.applyStore("val");
var value = val.get();
switch (val.type.ord) {
case _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER.ord:
{
value = value.toNumber();
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toReal"])(value));
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
}
case _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING.ord:
{
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__["IVProgParser"].createParser(value);
try {
var result = parser.parseTerm();
if (result instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["RealLiteral"]) {
var _temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result.value);
sto.insertStore("$", _temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
}
} catch (error) {// ignore
}
}
}
var typeStringInfoArray = _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL.stringInfo();
var typeInfo = typeStringInfoArray[0];
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_7__["ProcessorErrorFactory"].invalid_type_conversion(value, typeInfo.type, typeInfo.dim));
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](castRealFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$castReal', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_6__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING]), 'val', false)], block);
return func;
}
function createCastIntFun() {
var castIntFun = function castIntFun(sto, _) {
var val = sto.applyStore("val");
var value = val.get();
switch (val.type.ord) {
case _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL.ord:
{
value = value.toNumber();
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, Math.floor(value));
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
}
case _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING.ord:
{
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__["IVProgParser"].createParser(value);
try {
var result = parser.parseTerm();
if (result instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["IntLiteral"]) {
var _temp2 = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, result.value);
sto.insertStore("$", _temp2);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
}
} catch (error) {// ignore
}
}
}
var typeStringInfoArray = _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER.stringInfo();
var typeInfo = typeStringInfoArray[0];
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_7__["ProcessorErrorFactory"].invalid_type_conversion(value, typeInfo.type, typeInfo.dim));
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](castIntFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$castInt', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_6__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING]), 'val', false)], block);
return func;
}
function createCastBoolFun() {
var castBoolFun = function castBoolFun(sto, _) {
var str = sto.applyStore("str");
var value = str.get();
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_3__["IVProgParser"].createParser(value);
try {
var val = parser.parseTerm();
if (val instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["BoolLiteral"]) {
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, val.value);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(sto);
}
} catch (error) {// ignore
}
var typeStringInfoArray = _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN.stringInfo();
var typeInfo = typeStringInfoArray[0];
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_7__["ProcessorErrorFactory"].invalid_type_conversion(value, typeInfo.type, typeInfo.dim));
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](castBoolFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$castBool', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createCastStringFun() {
var castStringFun = function castStringFun(store, _) {
var val = store.applyStore('str');
var result = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["convertToString"])(val.get(), val.type);
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_8__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, result);
store.insertStore("$", temp);
store.mode = _modes__WEBPACK_IMPORTED_MODULE_5__["Modes"].RETURN;
return Promise.resolve(store);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](castStringFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$castString', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].ALL, 'str', false)], block);
return func;
}
/***/ }),
/***/ "./js/processor/lib/math.js":
/*!**********************************!*\
!*** ./js/processor/lib/math.js ***!
\**********************************/
/*! exports provided: createSinFun, createCosFun, createTanFun, createSqrtFun, createPowFun, createLogFun, createAbsFun, createNegateFun, createInvertFun, createMaxFun, createMinFun, createRandFun */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createSinFun", function() { return createSinFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createCosFun", function() { return createCosFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createTanFun", function() { return createTanFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createSqrtFun", function() { return createSqrtFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPowFun", function() { return createPowFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLogFun", function() { return createLogFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createAbsFun", function() { return createAbsFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createNegateFun", function() { return createNegateFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createInvertFun", function() { return createInvertFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createMaxFun", function() { return createMaxFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createMinFun", function() { return createMinFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRandFun", function() { return createRandFun; });
/* harmony import */ var _ast_commands__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(decimal_js__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../typeSystem/multiType */ "./js/typeSystem/multiType.ts");
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_array_type__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../modes */ "./js/processor/modes.ts");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_modes__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../store/value/store_value */ "./js/processor/store/value/store_value.ts");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
/**
* sin
* cos
* tan
* sqrt
* pow
* log
* abs
* negate
* invert
* max
* min
*/
function convertToRadians(degrees) {
return degrees.times(decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].acos(-1)).div(180);
}
function createSinFun() {
var sinFun = function sinFun(sto, _) {
var x = sto.applyStore('x');
var angle = x.get().mod(360);
var result = null;
if (angle.eq(90)) {
result = new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](1);
} else if (angle.eq(180)) {
result = new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](0);
} else if (angle.eq(270)) {
result = new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](-1);
} else {
result = decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].sin(convertToRadians(angle));
}
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](sinFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$sin', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createCosFun() {
var cosFun = function cosFun(sto, _) {
var x = sto.applyStore('x');
var angle = x.get().mod(360);
var result = null;
if (angle.eq(90)) {
result = new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](0);
} else if (angle.eq(180)) {
result = new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](-1);
} else if (angle.eq(270)) {
result = new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](0);
}
result = decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].cos(convertToRadians(angle));
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](cosFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$cos', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createTanFun() {
var tanFun = function tanFun(sto, _) {
var x = sto.applyStore('x');
var angle = x.get().mod(360);
if (angle.eq(90) || angle.eq(270)) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_8__["ProcessorErrorFactory"].undefined_tanget_value(x.get().toNumber(), this.function_call_stack.pop()));
}
var result = decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].tan(convertToRadians(angle));
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](tanFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$tan', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createSqrtFun() {
var sqrtFun = function sqrtFun(sto, _) {
var x = sto.applyStore('x');
if (x.get().isNeg()) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_8__["ProcessorErrorFactory"].negative_sqrt_value(this.function_call_stack.pop()));
}
var result = x.get().sqrt();
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](sqrtFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$sqrt', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createPowFun() {
var powFun = function powFun(sto, _) {
var x = sto.applyStore('x');
var y = sto.applyStore('y');
var result = x.get().pow(y.get());
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](powFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$pow', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false), new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'y', false)], block);
return func;
}
function createLogFun() {
var logFun = function logFun(sto, _) {
var x = sto.applyStore('x');
if (x.get().isNegative()) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_8__["ProcessorErrorFactory"].negative_log_value(this.function_call_stack.pop()));
}
var result = decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].log10(x.get());
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](logFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$log', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createAbsFun() {
var absFun = function absFun(sto, _) {
var x = sto.applyStore('x');
var result = x.get().abs();
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](x.type, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](absFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$abs', new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createNegateFun() {
var negateFun = function negateFun(sto, _) {
var x = sto.applyStore('x');
var result = x.get().negated();
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](x.type, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](negateFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$negate', new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createInvertFun() {
var invertFun = function invertFun(sto, _) {
var x = sto.applyStore('x');
var result = Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toReal"])(1).dividedBy(x.get());
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](invertFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$invert', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 'x', false)], block);
return func;
}
function createMaxFun() {
var maxFun = function maxFun(sto, _) {
var x = sto.applyStore('x');
var numbers = x.get().map(function (sto_addrs) {
return sto_addrs.get();
});
var result = decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].max.apply(decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"], _toConsumableArray(numbers));
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](x.type.innerType, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var paramType = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_5__["ArrayType"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 1);
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](maxFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$max', new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](paramType, 'x', false)], block);
return func;
}
function createMinFun() {
var minFun = function minFun(sto, _) {
var x = sto.applyStore('x');
var numbers = x.get().map(function (sto_addrs) {
return sto_addrs.get();
});
var result = decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"].min.apply(decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"], _toConsumableArray(numbers));
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](x.type.innerType, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var paramType = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_5__["ArrayType"](new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), 1);
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](minFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$min', new _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_4__["MultiType"]([_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL]), [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](paramType, 'x', false)], block);
return func;
}
function createRandFun() {
var randFun = function randFun(sto, _) {
var val = Math.random();
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_7__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, new decimal_js__WEBPACK_IMPORTED_MODULE_3__["Decimal"](val));
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_6__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](randFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$rand', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL, [], block);
return func;
}
/***/ }),
/***/ "./js/processor/lib/strings.js":
/*!*************************************!*\
!*** ./js/processor/lib/strings.js ***!
\*************************************/
/*! exports provided: createSubstringFun, createLengthFun, createUppercaseFun, createLowercaseFun, createrCharAtFun */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createSubstringFun", function() { return createSubstringFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLengthFun", function() { return createLengthFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createUppercaseFun", function() { return createUppercaseFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLowercaseFun", function() { return createLowercaseFun; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createrCharAtFun", function() { return createrCharAtFun; });
/* harmony import */ var _ast_commands__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modes */ "./js/processor/modes.ts");
/* harmony import */ var _modes__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_modes__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../store/value/store_value */ "./js/processor/store/value/store_value.ts");
/* harmony import */ var _store_value_store_value__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_store_value_store_value__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
/*
* substring
* length
* uppercase
* lowercase
* charAt
**/
function createSubstringFun() {
var substringFun = function substringFun(sto, _) {
var str = sto.applyStore("str");
var start = sto.applyStore("start");
var end = sto.applyStore("end");
var result = str.get().substring(start.get(), end.get());
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_4__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, result);
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_3__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](substringFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$substring', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false), new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, 'start', false), new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, 'end', false)], block);
return func;
}
function createLengthFun() {
var lengthFun = function lengthFun(sto, _) {
var str = sto.applyStore("str");
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_4__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, Object(_typeSystem_parsers__WEBPACK_IMPORTED_MODULE_2__["toInt"])(str.value.length));
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_3__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](lengthFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$length', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createUppercaseFun() {
var uppercaseFun = function uppercaseFun(sto, _) {
var str = sto.applyStore("str");
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_4__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, str.get().toUpperCase());
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_3__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](uppercaseFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$uppercase', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createLowercaseFun() {
var lowercaseFun = function lowercaseFun(sto, _) {
var str = sto.applyStore("str");
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_4__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, str.get().toLowerCase());
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_3__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](lowercaseFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$lowercase', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false)], block);
return func;
}
function createrCharAtFun() {
var charAtFun = function charAtFun(sto, _) {
var str = sto.applyStore("str");
var idx = sto.applyStore("index");
if (idx.get().toNumber() < 0 || idx.get().toNumber() >= str.get().length) {
return Promise.reject(_error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_5__["ProcessorErrorFactory"].invalid_string_index(idx.get().toNumber(), str.get(), this.function_call_stack.pop()));
}
var temp = new _store_value_store_value__WEBPACK_IMPORTED_MODULE_4__["StoreValue"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, str.get().charAt(idx.get().toNumber()));
sto.insertStore("$", temp);
sto.mode = _modes__WEBPACK_IMPORTED_MODULE_3__["Modes"].RETURN;
return Promise.resolve(sto);
};
var block = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["CommandBlock"]([], [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["SysCall"](charAtFun)]);
var func = new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["Function"]('$charAt', _typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, [new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].STRING, 'str', false), new _ast_commands__WEBPACK_IMPORTED_MODULE_0__["FormalParameter"](_typeSystem_types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER, 'index', false)], block);
return func;
}
/***/ }),
/***/ "./js/processor/modes.ts":
/*!*******************************!*\
!*** ./js/processor/modes.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Modes = Object.freeze({
RETURN: Symbol('mode:return'),
BREAK: Symbol('mode:break'),
PAUSE: Symbol('mode:pause'),
RUN: Symbol('mode:run'),
ABORT: Symbol('mode:abort')
});
/***/ }),
/***/ "./js/processor/semantic/semanticAnalyser.js":
/*!***************************************************!*\
!*** ./js/processor/semantic/semanticAnalyser.js ***!
\***************************************************/
/*! exports provided: SemanticAnalyser */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SemanticAnalyser", function() { return SemanticAnalyser; });
/* harmony import */ var _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
/* harmony import */ var _definedFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../definedFunctions */ "./js/processor/definedFunctions.js");
/* harmony import */ var _services_languageService__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../services/languageService */ "./js/services/languageService.js");
/* harmony import */ var _ast_commands__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../ast/commands */ "./js/ast/commands/index.js");
/* harmony import */ var _ast_expressions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../ast/expressions */ "./js/ast/expressions/index.js");
/* harmony import */ var _ast_expressions_literal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../ast/expressions/literal */ "./js/ast/expressions/literal.js");
/* harmony import */ var _compatibilityTable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../compatibilityTable */ "./js/processor/compatibilityTable.js");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../typeSystem/types */ "./js/typeSystem/types.ts");
/* harmony import */ var _typeSystem_types__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
/* harmony import */ var _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../typeSystem/multiType */ "./js/typeSystem/multiType.ts");
/* harmony import */ var _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../util/config */ "./js/util/config.js");
/* harmony import */ var _store_store__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../store/store */ "./js/processor/store/store.ts");
/* harmony import */ var _store_store__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_store_store__WEBPACK_IMPORTED_MODULE_11__);
/* harmony import */ var _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../ast/ivprogParser */ "./js/ast/ivprogParser.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var SemanticAnalyser =
/*#__PURE__*/
function () {
_createClass(SemanticAnalyser, null, [{
key: "analyseFromSource",
value: function analyseFromSource(stringCode) {
var parser = _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_12__["IVProgParser"].createParser(stringCode);
var semantic = new SemanticAnalyser(parser.parseTree());
return semantic.analyseTree();
}
}]);
function SemanticAnalyser(ast) {
_classCallCheck(this, SemanticAnalyser);
this.ast = ast;
this.lexerClass = _services_languageService__WEBPACK_IMPORTED_MODULE_2__["LanguageService"].getCurrentLexer();
var lexer = new this.lexerClass(null);
this.literalNames = lexer.literalNames;
this.symbolMap = null;
this.currentFunction = null;
}
_createClass(SemanticAnalyser, [{
key: "pushMap",
value: function pushMap() {
if (this.symbolMap === null) {
this.symbolMap = {
map: {},
next: null
};
} else {
var n = {
map: {},
next: this.symbolMap
};
this.symbolMap = n;
}
}
}, {
key: "popMap",
value: function popMap() {
if (this.symbolMap !== null) {
this.symbolMap = this.symbolMap.next;
}
}
}, {
key: "insertSymbol",
value: function insertSymbol(id, typeInfo) {
this.symbolMap.map[id] = typeInfo;
}
}, {
key: "findSymbol",
value: function findSymbol(id, symbol_map) {
if (!symbol_map.map[id]) {
if (symbol_map.next) {
return this.findSymbol(id, symbol_map.next);
}
return null;
} else {
return symbol_map.map[id];
}
}
}, {
key: "getMainFunction",
value: function getMainFunction() {
return this.ast.functions.find(function (v) {
return v.isMain;
});
}
}, {
key: "findFunction",
value: function findFunction(name) {
if (name.match(/^\$.+$/)) {
var fun = _definedFunctions__WEBPACK_IMPORTED_MODULE_1__["LanguageDefinedFunction"].getFunction(name);
if (!fun) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].not_implemented(name);
}
return fun;
} else {
var val = this.ast.functions.find(function (v) {
return v.name === name;
});
if (!val) {
return null;
}
return val;
}
}
}, {
key: "analyseTree",
value: function analyseTree() {
var globalVars = this.ast.global;
this.pushMap();
this.assertDeclarations(globalVars);
var functions = this.ast.functions;
var mainFunc = functions.filter(function (f) {
return f.name === null;
});
if (mainFunc.length <= 0) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].main_missing();
}
for (var i = 0; i < functions.length; i++) {
var fun = functions[i];
this.assertFunction(fun);
}
return this.ast;
}
}, {
key: "assertDeclarations",
value: function assertDeclarations(list) {
for (var i = 0; i < list.length; i++) {
this.assertDeclaration(list[i]);
}
}
}, {
key: "assertDeclaration",
value: function assertDeclaration(declaration) {
if (declaration instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["ArrayDeclaration"]) {
this.assertArrayDeclaration(declaration);
this.insertSymbol(declaration.id, {
id: declaration.id,
lines: declaration.lines,
columns: declaration.columns,
type: declaration.type,
isConst: declaration.isConst
});
} else {
if (declaration.initial === null) {
this.insertSymbol(declaration.id, {
id: declaration.id,
type: declaration.type,
isConst: declaration.isConst
});
return;
}
var resultType = this.evaluateExpressionType(declaration.initial);
if (resultType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__["MultiType"]) {
if (!resultType.isCompatible(declaration.type)) {
var stringInfo = declaration.type.stringInfo();
var info = stringInfo[0];
var result_string_info = resultType.stringInfo();
var result_info = result_string_info[0];
var exp = declaration.initial;
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_full(info.type, info.dim, result_info.type, result_info.dim, exp.toString(), declaration.sourceInfo);
}
this.insertSymbol(declaration.id, {
id: declaration.id,
type: declaration.type,
isConst: declaration.isConst
});
} else if (!declaration.type.isCompatible(resultType) && !_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting || !declaration.type.isCompatible(resultType) && _util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting && !_store_store__WEBPACK_IMPORTED_MODULE_11__["Store"].canImplicitTypeCast(declaration.type, resultType)) {
var _stringInfo = declaration.type.stringInfo();
var _info = _stringInfo[0];
var _result_string_info = resultType.stringInfo();
var _result_info = _result_string_info[0];
var _exp = declaration.initial;
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_full(_info.type, _info.dim, _result_info.type, _result_info.dim, _exp.toString(), declaration.sourceInfo);
} else {
this.insertSymbol(declaration.id, {
id: declaration.id,
type: declaration.type,
isConst: declaration.isConst
});
}
}
}
}, {
key: "assertArrayDeclaration",
value: function assertArrayDeclaration(declaration) {
if (declaration.initial === null) {
var lineType = this.evaluateExpressionType(declaration.lines);
if (!lineType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].array_dimension_not_int_full(declaration.sourceInfo);
}
if (declaration.columns !== null) {
var columnType = this.evaluateExpressionType(declaration.columns);
if (!columnType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].array_dimension_not_int_full(declaration.sourceInfo);
}
}
} else {
this.evaluateArrayLiteral(declaration);
}
this.insertSymbol(declaration.id, {
id: declaration.id,
lines: declaration.lines,
columns: declaration.columns,
type: declaration.type
});
return;
}
}, {
key: "evaluateExpressionType",
value: function evaluateExpressionType(expression) {
// TODO: Throw operator error in case type == UNDEFINED
if (expression instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["UnaryApp"]) {
var op = expression.op;
var resultType = this.evaluateExpressionType(expression.left);
var finalResult = Object(_compatibilityTable__WEBPACK_IMPORTED_MODULE_6__["resultTypeAfterUnaryOp"])(op, resultType);
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].UNDEFINED.isCompatible(finalResult)) {
var stringInfo = resultType.stringInfo();
var info = stringInfo[0];
var expString = expression.toString();
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_unary_op_full(expString, op, info.type, info.dim, expression.sourceInfo);
}
return finalResult;
} else if (expression instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["InfixApp"]) {
var _op = expression.op;
var resultTypeLeft = this.evaluateExpressionType(expression.left);
var resultTypeRight = this.evaluateExpressionType(expression.right);
var _finalResult = Object(_compatibilityTable__WEBPACK_IMPORTED_MODULE_6__["resultTypeAfterInfixOp"])(_op, resultTypeLeft, resultTypeRight);
if (_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].UNDEFINED.isCompatible(_finalResult)) {
var stringInfoLeft = resultTypeLeft.stringInfo();
var infoLeft = stringInfoLeft[0];
var stringInfoRight = resultTypeRight.stringInfo();
var infoRight = stringInfoRight[0];
var _expString = expression.toString();
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_infix_op_full(_expString, _op, infoLeft.type, infoLeft.dim, infoRight.type, infoRight.dim, expression.sourceInfo);
}
return _finalResult;
} else if (expression instanceof _ast_expressions_literal__WEBPACK_IMPORTED_MODULE_5__["Literal"]) {
return this.evaluateLiteralType(expression);
} else if (expression instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["FunctionCall"]) {
if (expression.isMainCall) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].void_in_expression_full(_definedFunctions__WEBPACK_IMPORTED_MODULE_1__["LanguageDefinedFunction"].getMainFunctionName(), expression.sourceInfo);
}
var fun = this.findFunction(expression.id);
if (fun === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].function_missing_full(expression.id, expression.sourceInfo);
}
if (fun.returnType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].VOID)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].void_in_expression_full(expression.id, expression.sourceInfo);
}
this.assertParameters(fun, expression.actualParameters);
return fun.returnType;
} else if (expression instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["ArrayAccess"]) {
var arrayTypeInfo = this.findSymbol(expression.id, this.symbolMap);
if (arrayTypeInfo === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].symbol_not_found_full(expression.id, expression.sourceInfo);
}
if (!(arrayTypeInfo.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"])) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_array_access_full(expression.id, expression.sourceInfo);
}
var lineType = this.evaluateExpressionType(expression.line);
if (!lineType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].array_dimension_not_int_full(expression.sourceInfo);
}
if (expression.column !== null) {
if (arrayTypeInfo.columns === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_matrix_access_full(expression.id, expression.sourceInfo);
}
var columnType = this.evaluateExpressionType(expression.column);
if (!columnType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].array_dimension_not_int_full(expression.sourceInfo);
}
}
var arrType = arrayTypeInfo.type;
if (expression.column !== null) {
// indexing matrix
return arrType.innerType;
} else {
if (arrayTypeInfo.columns === null) {
return arrType.innerType;
}
return new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"](arrType.innerType, 1);
}
}
}
}, {
key: "evaluateLiteralType",
value: function evaluateLiteralType(literal) {
if (literal instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["IntLiteral"]) {
return literal.type;
} else if (literal instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["RealLiteral"]) {
return literal.type;
} else if (literal instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["StringLiteral"]) {
return literal.type;
} else if (literal instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["BoolLiteral"]) {
return literal.type;
} else if (literal instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["VariableLiteral"]) {
var typeInfo = this.findSymbol(literal.id, this.symbolMap);
if (typeInfo === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].symbol_not_found_full(literal.id, literal.sourceInfo);
}
if (typeInfo.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"]) {
return typeInfo.type;
}
return typeInfo.type;
} else {
// console.warn("Evaluating type only for an array literal...");
var last = null;
if (literal.value.length === 1) {
last = this.evaluateExpressionType(literal.value[0]);
} else {
for (var i = 0; i < literal.value.length; i++) {
var e = this.evaluateExpressionType(literal.value[i]);
if (last === null) {
last = e;
} else if (!last.isCompatible(e)) {
var strInfo = last.stringInfo();
var info = strInfo[0];
var strExp = literal.toString();
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_array_full(strExp, info.type, info.dim, literal.sourceInfo);
}
}
}
if (last instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"]) {
return new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"](last.innerType, last.dimensions + 1);
}
return new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"](last, 1);
}
}
}, {
key: "evaluateArrayLiteral",
value: function evaluateArrayLiteral(arrayDeclaration) {
var type = arrayDeclaration.type;
var literal = arrayDeclaration.initial; // console.log(arrayDeclaration);
if (arrayDeclaration.isVector) {
this.evaluateVectorLiteralType(literal, type);
} else {
// TODO matrix type check
for (var i = 0; i < literal.lines; ++i) {
var line_literal = literal.value[i];
this.evaluateVectorLiteralType(line_literal, new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"](type.innerType, 1));
}
}
return true;
}
}, {
key: "assertFunction",
value: function assertFunction(fun) {
var _this = this;
this.pushMap();
this.currentFunction = fun;
fun.formalParameters.forEach(function (formalParam) {
if (formalParam.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"]) {
if (formalParam.type.dimensions > 1) {
_this.insertSymbol(formalParam.id, {
id: formalParam.id,
lines: -1,
columns: -1,
type: formalParam.type
});
} else {
_this.insertSymbol(formalParam.id, {
id: formalParam.id,
lines: -1,
columns: null,
type: formalParam.type
});
}
} else {
_this.insertSymbol(formalParam.id, {
id: formalParam.id,
type: formalParam.type
});
}
});
this.assertDeclarations(fun.variablesDeclarations);
var optional = fun.returnType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].VOID);
var valid = this.assertReturn(fun, optional);
if (!valid) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].function_no_return(fun.name);
}
this.popMap();
}
}, {
key: "assertReturn",
value: function assertReturn(fun, optional) {
var _this2 = this;
return fun.commands.reduce(function (last, next) {
return _this2.checkCommand(fun.returnType, next, optional) || last;
}, optional);
}
}, {
key: "checkCommand",
value: function checkCommand(type, cmd, optional) {
if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["While"]) {
var resultType = this.evaluateExpressionType(cmd.expression);
if (!resultType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].BOOLEAN)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].loop_condition_type_full(cmd.expression.toString(), cmd.sourceInfo);
}
this.checkCommands(type, cmd.commands, optional);
return false;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["For"]) {
var var_type = this.evaluateExpressionType(cmd.for_id);
if (!var_type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_for_variable(cmd.for_id, cmd.sourceInfo);
}
var from_type = this.evaluateExpressionType(cmd.for_from);
if (!from_type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_for_from(cmd.for_from, cmd.sourceInfo);
}
var to_type = this.evaluateExpressionType(cmd.for_to);
if (!to_type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_for_to(cmd.for_to, cmd.sourceInfo);
}
if (cmd.for_pass != null) {
var pass_type = this.evaluateExpressionType(cmd.for_pass);
if (!pass_type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_for_pass(cmd.for_pass, cmd.sourceInfo);
}
}
this.checkCommands(type, cmd.commands, optional);
return false;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["Switch"]) {
var sType = this.evaluateExpressionType(cmd.expression);
var result = optional;
var hasDefault = false;
for (var i = 0; i < cmd.cases.length; i++) {
var aCase = cmd.cases[i];
if (aCase.expression !== null) {
var caseType = this.evaluateExpressionType(aCase.expression);
if (!sType.isCompatible(caseType)) {
var strInfo = sType.stringInfo();
var info = strInfo[0];
var strExp = aCase.expression.toString();
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_case_type_full(strExp, info.type, info.dim, aCase.sourceInfo);
}
} else {
hasDefault = true;
}
result = result && this.checkCommands(type, aCase.commands, result);
}
return result && hasDefault;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["ArrayIndexAssign"]) {
// TODO - rework!!!!!
var used_dims = 0;
var typeInfo = this.findSymbol(cmd.id, this.symbolMap);
if (typeInfo === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].symbol_not_found_full(cmd.id, cmd.sourceInfo);
}
if (typeInfo.isConst) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_const_assignment_full(cmd.id, cmd.sourceInfo);
}
if (!(typeInfo.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"])) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_array_access_full(cmd.id, cmd.sourceInfo);
}
var exp = cmd.expression;
var lineExp = cmd.line;
var lineType = this.evaluateExpressionType(lineExp);
if (!lineType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].array_dimension_not_int_full(cmd.sourceInfo);
}
used_dims += 1;
var columnExp = cmd.column;
if (typeInfo.columns === null && columnExp !== null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_matrix_access_full(cmd.id, cmd.sourceInfo);
} else if (columnExp !== null) {
var columnType = this.evaluateExpressionType(columnExp);
if (!columnType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].array_dimension_not_int_full(cmd.sourceInfo);
}
used_dims += 1;
} // exp a single value exp or an array access
var exp_type = this.evaluateExpressionType(exp);
var access_type = typeInfo.type;
var compatible = false;
if (exp_type instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__["MultiType"]) {
var _type = access_type;
if (access_type.dimensions - used_dims == 0) {
_type = access_type.innerType;
} else {
_type = new _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"](access_type.innerType, Math.max(0, access_type.dimensions - used_dims));
}
compatible = exp_type.isCompatible(_type);
} else {
compatible = access_type.canAccept(exp_type, used_dims);
}
if (!compatible) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_11__["Store"].canImplicitTypeCast(access_type, exp_type)) {
var access_type_string_info = access_type.stringInfo();
var access_type_info = access_type_string_info[0];
var exp_type_string_info = exp_type.stringInfo();
var exp_type_info = exp_type_string_info[0];
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_full(access_type_info.type, access_type_info.dim - used_dims, exp_type_info.type, exp_type_info.dim, exp.toString(), cmd.sourceInfo);
}
}
return optional;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["Assign"]) {
// TODO - rework since there is no literal array assignment
var _typeInfo = this.findSymbol(cmd.id, this.symbolMap);
if (_typeInfo === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].symbol_not_found_full(cmd.id, cmd.sourceInfo);
}
if (_typeInfo.isConst) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_const_assignment_full(cmd.id, cmd.sourceInfo);
}
var _exp2 = cmd.expression;
var _exp_type = this.evaluateExpressionType(_exp2);
if (_exp_type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"]) {
if (!(_typeInfo.type instanceof _typeSystem_array_type__WEBPACK_IMPORTED_MODULE_8__["ArrayType"])) {
// TODO better error message
throw new Error("Cannot assign an array to a non-array variable ");
} // Both are arrays...
// if both don't have same dimensions and type, cannot perform assignment
if (!_exp_type.isCompatible(_typeInfo.type)) {
if (_exp_type.dimensions === _typeInfo.type.dimensions && !_exp_type.innerType.isCompatible(_typeInfo.type.innerType)) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_11__["Store"].canImplicitTypeCast(_typeInfo.type.innerType, _exp_type.innerType)) {
var stringInfo = _typeInfo.type.stringInfo();
var _info2 = stringInfo[0];
var _exp_type_string_info = _exp_type.stringInfo();
var _exp_type_info = _exp_type_string_info[0];
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_full(_info2.type, _info2.dim, _exp_type_info.type, _exp_type_info.dim, _exp2.toString(), cmd.sourceInfo);
}
} else {
switch (_exp_type.dimensions) {
case 1:
{
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].vector_to_matrix_attr(cmd.id, _exp2.toString(), cmd.sourceInfo);
}
case 2:
{
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].matrix_to_vector_attr(cmd.id, _exp2.toString(), cmd.sourceInfo);
}
}
}
}
} else if (!_exp_type.isCompatible(_typeInfo.type)) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_11__["Store"].canImplicitTypeCast(_typeInfo.type, _exp_type)) {
var _stringInfo2 = _typeInfo.type.stringInfo();
var _info3 = _stringInfo2[0];
var _exp_type_string_info2 = _exp_type.stringInfo();
var _exp_type_info2 = _exp_type_string_info2[0];
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_full(_info3.type, _info3.dim, _exp_type_info2.type, _exp_type_info2.dim, _exp2.toString(), cmd.sourceInfo);
}
}
return optional;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["Break"]) {
return optional;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["IfThenElse"]) {
var _resultType = this.evaluateExpressionType(cmd.condition);
if (!_resultType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].BOOLEAN)) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].if_condition_type_full(cmd.condition.toString(), cmd.sourceInfo);
}
if (cmd.ifFalse instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["IfThenElse"]) {
return this.checkCommands(type, cmd.ifTrue.commands, optional) && this.checkCommand(type, cmd.ifFalse, optional);
} else if (cmd.ifFalse != null) {
return this.checkCommands(type, cmd.ifTrue.commands, optional) && this.checkCommands(type, cmd.ifFalse.commands, optional);
} else {
return this.checkCommands(type, cmd.ifTrue.commands, optional);
}
} else if (cmd instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["FunctionCall"]) {
var fun = null;
if (cmd.isMainCall) {
fun = this.getMainFunction();
} else {
fun = this.findFunction(cmd.id);
}
if (fun === null) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].function_missing_full(cmd.id, cmd.sourceInfo);
}
this.assertParameters(fun, cmd.actualParameters);
return optional;
} else if (cmd instanceof _ast_commands__WEBPACK_IMPORTED_MODULE_3__["Return"]) {
var funcName = this.currentFunction.isMain ? _definedFunctions__WEBPACK_IMPORTED_MODULE_1__["LanguageDefinedFunction"].getMainFunctionName() : this.currentFunction.name;
if (cmd.expression === null && !type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].VOID)) {
var _stringInfo3 = type.stringInfo();
var _info4 = _stringInfo3[0];
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_void_return_full(funcName, _info4.type, _info4.dim, cmd.sourceInfo);
} else if (cmd.expression !== null) {
var _resultType2 = this.evaluateExpressionType(cmd.expression);
if (!type.isCompatible(_resultType2)) {
var _stringInfo4 = type.stringInfo();
var _info5 = _stringInfo4[0];
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_return_type_full(funcName, _info5.type, _info5.dim, cmd.sourceInfo);
} else {
return true;
}
} else {
return true;
}
}
}
}, {
key: "checkCommands",
value: function checkCommands(type, cmds, optional) {
var _this3 = this;
return cmds.reduce(function (last, next) {
return _this3.checkCommand(type, next, optional) || last;
}, optional);
}
}, {
key: "assertParameters",
value: function assertParameters(fun, actualParametersList) {
if (fun.formalParameters.length !== actualParametersList.length) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_parameters_size_full(fun.name, actualParametersList.length, fun.formalParameters.length, null);
}
for (var i = 0; i < actualParametersList.length; ++i) {
var param = actualParametersList[i];
var formalParam = fun.formalParameters[i]; // const id = formalParam.id;
if (formalParam.byRef) {
if (param instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["VariableLiteral"]) {
var variable = this.findSymbol(param.id, this.symbolMap);
if (variable.isConst) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_const_ref_full(fun.name, param.toString(), param.sourceInfo);
}
} else if (!(param instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["VariableLiteral"] || param instanceof _ast_expressions__WEBPACK_IMPORTED_MODULE_4__["ArrayAccess"])) {
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_parameter_type_full(fun.name, param.toString(), param.sourceInfo);
}
}
var resultType = this.evaluateExpressionType(param);
if (resultType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__["MultiType"] && formalParam.type instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__["MultiType"]) {
var shared = 0;
for (var j = 0; j < resultType.types.length; ++j) {
var element = resultType.types[j];
if (formalParam.type.types.indexOf(element) !== -1) {
shared += 1;
}
}
if (shared <= 0) {
if (_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting && !formalParam.byRef) {
if (resultType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER) || resultType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].REAL)) {
if (formalParam.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER) || formalParam.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].REAL)) {
continue;
}
}
}
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_parameter_type_full(fun.name, param.toString(), param.sourceInfo);
}
} else if (resultType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__["MultiType"]) {
if (!resultType.isCompatible(formalParam.type)) {
if (_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting && !formalParam.byRef) {
if (resultType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER) || resultType.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].REAL)) {
if (formalParam.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].INTEGER) || formalParam.type.isCompatible(_typeSystem_types__WEBPACK_IMPORTED_MODULE_7__["Types"].REAL)) {
continue;
}
}
}
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_parameter_type_full(fun.name, param.toString(), param.sourceInfo);
}
} else if (!formalParam.type.isCompatible(resultType)) {
if (_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting && !formalParam.byRef) {
if (_store_store__WEBPACK_IMPORTED_MODULE_11__["Store"].canImplicitTypeCast(formalParam.type, resultType)) {
continue;
}
}
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].invalid_parameter_type_full(fun.name, param.toString(), param.sourceInfo);
}
}
}
}, {
key: "evaluateVectorLiteralType",
value: function evaluateVectorLiteralType(literal, type) {
// console.log(literal);
for (var i = 0; i < literal.value.length; i += 1) {
var exp = literal.value[i];
var expType = this.evaluateExpressionType(exp);
var compatible = false;
if (expType instanceof _typeSystem_multiType__WEBPACK_IMPORTED_MODULE_9__["MultiType"]) {
compatible = expType.isCompatible(type.innerType);
} else {
compatible = type.canAccept(expType, 1);
}
if (!compatible) {
if (!_util_config__WEBPACK_IMPORTED_MODULE_10__["Config"].enable_type_casting || !_store_store__WEBPACK_IMPORTED_MODULE_11__["Store"].canImplicitTypeCast(type.innerType, expType)) {
var stringInfo = type.stringInfo();
var info = stringInfo[0];
var result_string_info = expType.stringInfo();
var result_info = result_string_info[0];
throw _error_processorErrorFactory__WEBPACK_IMPORTED_MODULE_0__["ProcessorErrorFactory"].incompatible_types_full(info.type, 0, result_info.type, result_info.dim, exp.toString(), literal.sourceInfo);
}
}
}
return type;
}
}]);
return SemanticAnalyser;
}();
/***/ }),
/***/ "./js/processor/store/store.ts":
/*!*************************************!*\
!*** ./js/processor/store/store.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const modes_1 = __webpack_require__(/*! ../modes */ "./js/processor/modes.ts");
const types_1 = __webpack_require__(/*! ../../typeSystem/types */ "./js/typeSystem/types.ts");
const storeObject_1 = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.ts");
const storeObjectRef_1 = __webpack_require__(/*! ./storeObjectRef */ "./js/processor/store/storeObjectRef.ts");
const array_type_1 = __webpack_require__(/*! ../../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
const array_store_value_1 = __webpack_require__(/*! ./value/array_store_value */ "./js/processor/store/value/array_store_value.ts");
const location_1 = __webpack_require__(/*! ../../memory/location */ "./js/memory/location.ts");
const storeObjectArray_1 = __webpack_require__(/*! ./storeObjectArray */ "./js/processor/store/storeObjectArray.ts");
const store_value_1 = __webpack_require__(/*! ./value/store_value */ "./js/processor/store/value/store_value.ts");
const store_value_address_1 = __webpack_require__(/*! ./value/store_value_address */ "./js/processor/store/value/store_value_address.ts");
const store_value_ref_1 = __webpack_require__(/*! ./value/store_value_ref */ "./js/processor/store/value/store_value_ref.ts");
const array_store_value_ref_1 = __webpack_require__(/*! ./value/array_store_value_ref */ "./js/processor/store/value/array_store_value_ref.ts");
const store_object_array_ref_1 = __webpack_require__(/*! ./store_object_array_ref */ "./js/processor/store/store_object_array_ref.ts");
class Store {
constructor(name) {
this.name = name;
this.store = new Map();
this.mode = modes_1.Modes.RUN;
}
static canImplicitTypeCast(castType, sourceType) {
if (castType.isCompatible(types_1.Types.INTEGER) || castType.isCompatible(types_1.Types.REAL)) {
if (sourceType.isCompatible(types_1.Types.INTEGER) || sourceType.isCompatible(types_1.Types.REAL)) {
return true;
}
}
return false;
}
static doImplicitCasting(castType, stoObj) {
if (!Store.canImplicitTypeCast(castType, stoObj.type)) {
throw new Error("!!!Critical error: attempted to type cast invalid types");
}
if (castType.isCompatible(types_1.Types.INTEGER)) {
return new store_value_1.StoreValue(types_1.Types.INTEGER, stoObj.get().trunc());
}
else {
return new store_value_1.StoreValue(types_1.Types.REAL, stoObj.get());
}
}
extendStore(nextStore) {
this.nextStore = nextStore;
}
applyStore(id) {
if (!this.store.has(id)) {
if (this.nextStore != null) {
return this.nextStore.applyStore(id);
}
else {
throw new Error(`Variable ${id} not found.`);
}
}
const val = this.store.get(id);
let result = null;
if (val.type instanceof array_type_1.ArrayType) {
const array = val;
const array_type = array.type;
let l = 0, c = 0;
const values = array.value.map(v => {
if (array.isVector) {
return new store_value_address_1.StoreValueAddress(array_type.innerType, v, l++, undefined, array.id, array.readOnly);
}
else {
if (c >= array.columns) {
c = 0;
l += 1;
}
return new store_value_address_1.StoreValueAddress(array_type.innerType, v, l, c++, array.id, array.readOnly);
}
});
result = new array_store_value_1.ArrayStoreValue(array_type, values, array.lines, array.columns, val.id, val.readOnly);
}
else {
result = new store_value_1.StoreValue(val.type, val.value, val.id, val.readOnly);
}
return result;
}
updateStore(id, stoValue) {
if (!this.store.has(id)) {
if (this.nextStore != null) {
this.nextStore.updateStore(id, stoValue);
return this;
}
else {
// TODO: better error message
throw new Error(`Variable ${id} not found.`);
}
}
else {
const oldObj = this.store.get(id);
if (oldObj.readOnly) {
// TODO: better error message
throw new Error("Cannot change value of a read only variable: " + id);
}
if (oldObj instanceof storeObjectArray_1.StoreObjectArray) {
const array_value = stoValue;
if (oldObj.isCompatible(array_value)) {
if (oldObj.isVector) {
array_value.get().forEach((val, index) => {
oldObj.setAt(val, index, undefined);
});
}
else {
let line = 0;
let column = 0;
array_value.get().forEach((val) => {
oldObj.setAt(val, line, column);
column += 1;
if (column >= oldObj.columns) {
line += 1;
column = 0;
}
});
}
return this;
}
}
else if (oldObj.isCompatible(stoValue)) {
const loc_address = oldObj.locAddress;
location_1.Location.updateAddress(loc_address, stoValue.get());
return this;
}
const oldType = oldObj.type;
const stoType = stoValue.type;
// TODO: better error message
throw new Error(`${oldType.value} is not compatible with type ${stoType.value} given`);
}
}
/**
* Method used to update regions of an array (vector or matrix). The should only be used when update an specific
* possition since it will only update the required addresses.
* @param {string} id the variable id to be updated
* @param {IStoreValue} sto_value the value to be used in the update process
* @param {number} line the line address of the vector/matrix
* @param {number} column the matrix column, which can be undefined
*/
updateStoreArray(id, sto_value, line, column) {
if (!this.store.has(id)) {
if (this.nextStore != null) {
this.nextStore.updateStoreArray(id, sto_value, line, column);
return this;
}
else {
// TODO: better error message
throw new Error(`Variable ${id} not found.`);
}
}
else {
const oldObj = this.store.get(id);
if (oldObj.readOnly) {
// TODO: better error message
throw new Error("Cannot change value of a read only variable: " + id);
}
if (oldObj instanceof storeObjectArray_1.StoreObjectArray) {
if (sto_value instanceof array_store_value_1.ArrayStoreValue) {
// this must be a vector or matrix line update
const actual_values = sto_value.get();
if (oldObj.isVector && sto_value.isVector()) {
for (let i = 0; i < sto_value.lines; i += 1) {
const val = actual_values[i];
oldObj.setAt(val, i, undefined);
}
}
else if (!oldObj.isVector && column == null && sto_value.isVector()) {
for (let i = 0; i < oldObj.columns; i += 1) {
const val = actual_values[i];
oldObj.setAt(val, line, i);
}
}
else {
// TODO: better error message
throw new Error(`Attempting to assign an invalid value to array ${id}`);
}
}
else {
if (!oldObj.isVector && column == null) {
// TODO: better error message
throw new Error(`Attempting to assign an invalid value to array ${id}`);
}
oldObj.setAt(sto_value, line, column);
}
}
else {
throw new Error("Cannot update a non-array variable using updateStoreArray");
}
// const oldType = oldObj.type;
// const stoType = sto_value.type;
// // TODO: better error message
// throw new Error(`${oldType.value} is not compatible with type ${stoType.value} given`);
return this;
}
}
/**
* Inserts a new variable into the Store. This method should be used when declaring a new variable,
* including the special return variable $.
* @param id variable id
* @param stoValue the value to be used as the initial value of id
*/
insertStore(id, stoValue) {
if (this.store.has(id)) {
// TODO: better error message
throw new Error(`${id} is already defined`);
}
// TODO check for array....
let newObj;
if (stoValue instanceof store_value_ref_1.StoreValueRef) {
newObj = new storeObjectRef_1.StoreObjectRef(stoValue);
}
else if (stoValue instanceof array_store_value_ref_1.ArrayStoreValueRef) {
newObj = new store_object_array_ref_1.StoreObjectArrayRef(stoValue, stoValue.lines, stoValue.columns);
}
else if (stoValue instanceof array_store_value_1.ArrayStoreValue) {
const columns = stoValue.isVector() ? 0 : stoValue.columns;
const addresses = [];
const all_values = stoValue.get();
if (all_values.length > 0) {
for (let i = 0; i < stoValue.get().length; i += 1) {
const val = all_values[i].get();
addresses.push(location_1.Location.allocate(val));
}
}
else {
let total = stoValue.lines;
total = stoValue.isVector() ? total : total * columns;
for (let i = 0; i < total; i += 1) {
addresses.push(location_1.Location.allocate(null));
}
}
newObj = new storeObjectArray_1.StoreObjectArray(stoValue.type, stoValue.lines, columns, addresses, stoValue.isConst);
}
else {
const loc_address = location_1.Location.allocate(stoValue.get());
newObj = new storeObject_1.StoreObject(stoValue.type, loc_address, stoValue.isConst);
}
newObj.setID(id);
this.store.set(id, newObj);
return this;
}
/**
* Helper function similar to applyStore. But it returns the actual object in the store be it ref or not
* applyStore will return the refferenced object if the object in the store is a ref
*/
getStoreObject(id) {
if (!this.store.has(id)) {
if (this.nextStore != null) {
return this.nextStore.getStoreObject(id);
}
else {
throw new Error(`Variable ${id} not found.`);
}
}
return this.store.get(id);
}
destroy() {
this.store.forEach(sto => sto.destroy(), this);
}
}
exports.Store = Store;
/***/ }),
/***/ "./js/processor/store/storeObject.ts":
/*!*******************************************!*\
!*** ./js/processor/store/storeObject.ts ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const location_1 = __webpack_require__(/*! ../../memory/location */ "./js/memory/location.ts");
class StoreObject {
/**
*
* @param {Type} type
* @param {Number} loc_address
* @param {Boolean} readOnly
*/
constructor(type, loc_address, readOnly = false) {
this._loc_address = loc_address;
this._type = type;
this._readOnly = readOnly;
this._id = undefined;
}
setID(id) {
this._id = id;
}
get id() {
return this._id;
}
get inStore() {
return this.id !== null;
}
get type() {
return this._type;
}
/**
* Returns the actual value stored at the loccation address present in this object.
* The returned value is compatible with @prop{StoreObject.type}
*/
get value() {
const address = location_1.Location.find(this._loc_address);
if (address != null) {
return address.value;
}
else {
throw new Error("!!!Critical Error: variable " + this.id + " does not have a valid address. Loc-Address " + this.locAddress);
}
}
get number() {
throw new Error("DOT NOT USE THIS PROPERTY!");
}
get readOnly() {
return this._readOnly;
}
set readOnly(value) {
this._readOnly = value;
}
isCompatible(another) {
return this.type.isCompatible(another.type);
}
destroy() {
return location_1.Location.deallocate(this._loc_address);
}
get locAddress() {
return this._loc_address;
}
}
exports.StoreObject = StoreObject;
/***/ }),
/***/ "./js/processor/store/storeObjectArray.ts":
/*!************************************************!*\
!*** ./js/processor/store/storeObjectArray.ts ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const storeObject_1 = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.ts");
const array_store_value_1 = __webpack_require__(/*! ./value/array_store_value */ "./js/processor/store/value/array_store_value.ts");
const location_1 = __webpack_require__(/*! ../../memory/location */ "./js/memory/location.ts");
class StoreObjectArray extends storeObject_1.StoreObject {
constructor(type, _lines, _columns, loc_addresses, readOnly = false) {
super(type, -1, readOnly);
this._lines = _lines;
this._columns = _columns;
this.loc_addresses = loc_addresses;
}
get lines() {
return this._lines;
}
get columns() {
return this._columns;
}
isCompatible(another) {
if (another instanceof array_store_value_1.ArrayStoreValue) {
const cols = another.columns == null ? 0 : another.columns;
if (this.lines === another.lines && this.columns === cols) {
return super.isCompatible(another);
}
}
return false;
}
get isVector() {
return this.type.dimensions === 1;
}
/**@override
* Returns the list of values stored by this array.
* All returned values are compatible with @prop{StoreObject.type}
*/
get value() {
const values = [];
for (let i = 0; i < this.addresses.length; i += 1) {
const address = location_1.Location.find(this.addresses[i]);
if (address != null) {
values.push(address.value);
}
else {
throw new Error("!!!Critical Error: variable " + this.id + " does not have a valid address. Loc-Address " + this.locAddress);
}
}
return values;
}
destroy() {
let bool = true;
for (let i = 0; i < this.addresses.length; i += 1) {
bool = bool && location_1.Location.deallocate(this.addresses[i]);
}
return bool;
}
/**
* @override
*
* Returns the address that contains a list of all addresses of the values present in the array
*/
get locAddress() {
throw new Error("!!!Internal Error: Cannot invoke locAddress on StoreObjectArray");
}
get addresses() {
return this.loc_addresses;
}
getAt(line, column) {
if (this.isVector) {
if (column != null) {
throw new Error(this.id + " is not a matrix!");
}
column = line;
line = 0;
}
else if (column == null) {
// this is a whole line...
const values = [];
for (let col = 0; col < this.columns; col += 1) {
const index = this.getIndexOf(line, col);
const address = location_1.Location.find(this.addresses[index]);
values.push(address.value);
}
return values;
}
const index = this.getIndexOf(line, column);
const address = location_1.Location.find(this.addresses[index]);
return address.value;
}
setAt(value, line, column) {
let used_dims = 1;
if (column != null) {
used_dims += 1;
}
if (!this.type.canAccept(value.type, used_dims)) {
throw new Error("!!!Internal Error: Attempting to insert an invalid value inside array " + this.id);
}
if (this.isVector) {
if (column != null) {
throw new Error(this.id + " is not a matrix!");
}
column = line;
line = 0;
}
else if (column == null) {
throw new Error("!!!Internal Error: Attempting to insert a line into matrix " + this.id);
}
const pos = this.getIndexOf(line, column);
location_1.Location.updateAddress(this.addresses[pos], value.get());
}
getIndexOf(line, column) {
return line * this.columns + column;
}
getLocAddressOf(line, column) {
if (this.isVector) {
if (column != null) {
throw new Error(this.id + " is not a matrix!");
}
column = line;
line = 0;
}
else if (column == null) {
// this is a whole line...
const values = [];
for (let col = 0; col < this.columns; col += 1) {
const index = this.getIndexOf(line, col);
values.push(this.addresses[index]);
}
return values;
}
const index = this.getIndexOf(line, column);
return this.addresses[index];
}
}
exports.StoreObjectArray = StoreObjectArray;
/***/ }),
/***/ "./js/processor/store/storeObjectRef.ts":
/*!**********************************************!*\
!*** ./js/processor/store/storeObjectRef.ts ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const storeObject_1 = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.ts");
class StoreObjectRef extends storeObject_1.StoreObject {
/**
*
* @param {StoreObject} stoValue
*/
constructor(stoValue) {
super(stoValue.type, stoValue.getRefAddress(), false);
this.refObj = stoValue.id;
this.reference_dimension = stoValue.getReferenceDimension();
}
get isRef() {
return true;
}
getRefObj() {
return this.refObj;
}
getReferenceDimension() {
return this.reference_dimension;
}
destroy() {
return false;
}
}
exports.StoreObjectRef = StoreObjectRef;
/***/ }),
/***/ "./js/processor/store/store_object_array_ref.ts":
/*!******************************************************!*\
!*** ./js/processor/store/store_object_array_ref.ts ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const storeObjectArray_1 = __webpack_require__(/*! ./storeObjectArray */ "./js/processor/store/storeObjectArray.ts");
class StoreObjectArrayRef extends storeObjectArray_1.StoreObjectArray {
constructor(stoValue, lines, columns) {
super(stoValue.type, lines, columns, stoValue.getAddresses(), false);
this.refObj = stoValue.id;
}
get isRef() {
return true;
}
getRefObj() {
return this.refObj;
}
destroy() {
return false;
}
}
exports.StoreObjectArrayRef = StoreObjectArrayRef;
/***/ }),
/***/ "./js/processor/store/value/array_store_value.ts":
/*!*******************************************************!*\
!*** ./js/processor/store/value/array_store_value.ts ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const array_type_1 = __webpack_require__(/*! ../../../typeSystem/array_type */ "./js/typeSystem/array_type.ts");
const store_value_address_1 = __webpack_require__(/*! ./store_value_address */ "./js/processor/store/value/store_value_address.ts");
class ArrayStoreValue {
constructor(type, values, lines, columns, id, isConst = false) {
this.type = type;
this.id = id;
this.isConst = isConst;
this.values = values;
this.lines = lines;
this.columns = columns;
}
get() {
return this.values;
}
/**
* @deprecated
* Potential not necessary since array access is occuring directly in the StoreObject
* @param line
* @param column
*/
getAt(line, column) {
console.log("Column ", column);
if (this.isVector()) {
if (column != null) {
throw new Error(this.id + " is not a matrix!");
}
column = line;
line = 0;
}
else if (column == null) {
const values = [];
for (let col = 0; col < this.columns; col += 1) {
const index = line * this.lines + col;
values.push(this.values[index]);
}
const array_type = this.type;
const vector_type = new array_type_1.ArrayType(array_type.innerType, array_type.dimensions - 1);
return new ArrayStoreValue(vector_type, values, this.columns, 0, this.id, this.isConst);
}
const index = line * this.lines + column;
console.log("Get at: ", index);
return this.values[index];
}
setAt(value, line, column) {
let used_dims = 1;
if (column != null) {
used_dims += 1;
}
let actual_line = line;
let actual_column = column;
if (!this.type.canAccept(value.type, used_dims)) {
throw new Error("!!!Internal Error: Attempting to insert an invalid value inside array " + this.id);
}
if (this.isVector) {
if (column != null) {
throw new Error(this.id + " is not a matrix!");
}
actual_column = actual_line;
actual_line = 0;
}
else if (column == null) {
if (!(value instanceof ArrayStoreValue)) {
throw new Error("Attempting to insert a single value as a line of matrix " + this.id);
}
const actual_values = value.get();
for (let i = 0; i < this.columns; i += 1) {
const pos = actual_line * this.columns + i;
const val = actual_values[i];
this.values[pos] = new store_value_address_1.StoreValueAddress(value.type, val.get(), actual_line, i, this.id, this.isConst);
}
}
const columns = this.columns == null ? 0 : this.columns;
const pos = actual_line * columns + actual_column;
this.values[pos] = new store_value_address_1.StoreValueAddress(value.type, value.get(), line, column, this.id, this.isConst);
}
inStore() {
return this.id != null;
}
isVector() {
return this.type.dimensions == 1;
}
}
exports.ArrayStoreValue = ArrayStoreValue;
/***/ }),
/***/ "./js/processor/store/value/array_store_value_ref.ts":
/*!***********************************************************!*\
!*** ./js/processor/store/value/array_store_value_ref.ts ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ArrayStoreValueRef {
constructor(type, values, addresses, lines, columns, id) {
this.type = type;
this.values = values;
this.addresses = addresses;
this.lines = lines;
this.columns = columns;
this.id = id;
this.isConst = false;
}
get() {
return this.values;
}
getAddresses() {
return this.addresses;
}
inStore() {
return this.id != null;
}
}
exports.ArrayStoreValueRef = ArrayStoreValueRef;
/***/ }),
/***/ "./js/processor/store/value/store_value.ts":
/*!*************************************************!*\
!*** ./js/processor/store/value/store_value.ts ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class StoreValue {
constructor(type, value, id, isConst = false) {
this.type = type;
this.id = id;
this.isConst = isConst;
this.value = value;
}
get() {
return this.value;
}
inStore() {
return this.id != null;
}
}
exports.StoreValue = StoreValue;
/***/ }),
/***/ "./js/processor/store/value/store_value_address.ts":
/*!*********************************************************!*\
!*** ./js/processor/store/value/store_value_address.ts ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const store_value_1 = __webpack_require__(/*! ./store_value */ "./js/processor/store/value/store_value.ts");
class StoreValueAddress extends store_value_1.StoreValue {
constructor(type, value, line, column, id, isConst = false) {
super(type, value, id, isConst);
this.line = line;
this.column = column;
}
}
exports.StoreValueAddress = StoreValueAddress;
/***/ }),
/***/ "./js/processor/store/value/store_value_ref.ts":
/*!*****************************************************!*\
!*** ./js/processor/store/value/store_value_ref.ts ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class StoreValueRef {
constructor(type, value, loc_address, id) {
this.type = type;
this.value = value;
this.loc_address = loc_address;
this.id = id;
this.isConst = false;
this.reference_dimesion = 0;
}
get() {
return this.value;
}
getRefAddress() {
return this.loc_address;
}
inStore() {
return this.id != null;
}
getReferenceDimension() {
return this.reference_dimesion;
}
setReferenceDimension(dimension) {
this.reference_dimesion = dimension;
}
}
exports.StoreValueRef = StoreValueRef;
/***/ }),
/***/ "./js/runner.js":
/*!**********************!*\
!*** ./js/runner.js ***!
\**********************/
/*! exports provided: runner */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runner", function() { return runner; });
/* harmony import */ var _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ast/ivprogParser */ "./js/ast/ivprogParser.js");
/* harmony import */ var _processor_ivprogProcessor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
/* harmony import */ var _io_domConsole__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./io/domConsole */ "./js/io/domConsole.js");
/* harmony import */ var _services_languageService__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./services/languageService */ "./js/services/languageService.js");
/* harmony import */ var _processor_semantic_semanticAnalyser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./processor/semantic/semanticAnalyser */ "./js/processor/semantic/semanticAnalyser.js");
/* harmony import */ var _memory_location__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./memory/location */ "./js/memory/location.ts");
/* harmony import */ var _memory_location__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_memory_location__WEBPACK_IMPORTED_MODULE_5__);
function runner() {
var ivprogLexer = _services_languageService__WEBPACK_IMPORTED_MODULE_3__["LanguageService"].getCurrentLexer(); // const lexer = new ivprogLexer(new InputStream(input));
// const stream = new CommonTokenStream(lexer);
// stream.fill();
// let i = 1;
// let token = null;
// while ((token = stream.LT(i)).type !== ivprogLexer.EOF && token.type !== ivprogLexer.WHITESPACE) {
// console.log(`${token.type}-${token.text}`);
// console.log('\n')
// i++;
// }
// const anaSin = new IVProgParser(input, ivprogLexer);
var editor = new window.JsonEditor('#json-renderer', {});
var domConsole = new _io_domConsole__WEBPACK_IMPORTED_MODULE_2__["DOMConsole"]("#console", true);
domConsole.hide(); // proc.interpretAST().then( sto => {
// console.log(sto.applyStore('a'));
// }).catch(e => console.log(e));
try {
window.$('#btn').click(function () {
var input = window.$('#input').val();
var analiser = new _ast_ivprogParser__WEBPACK_IMPORTED_MODULE_0__["IVProgParser"](input, ivprogLexer);
try {
var data = analiser.parseTree();
var semAna = new _processor_semantic_semanticAnalyser__WEBPACK_IMPORTED_MODULE_4__["SemanticAnalyser"](data);
var proc = new _processor_ivprogProcessor__WEBPACK_IMPORTED_MODULE_1__["IVProgProcessor"](semAna.analyseTree());
proc.registerInput(domConsole);
domConsole.clear();
proc.registerOutput(domConsole);
proc.interpretAST().then(function (sto) {
console.log(sto);
editor.load(sto.store);
console.log(_memory_location__WEBPACK_IMPORTED_MODULE_5__["Location"].size());
})["catch"](function (e) {
alert(e);
console.log(e);
console.log(_memory_location__WEBPACK_IMPORTED_MODULE_5__["Location"].size());
});
} catch (error) {
alert(error);
console.log(error);
console.log(_memory_location__WEBPACK_IMPORTED_MODULE_5__["Location"].size());
}
});
} catch (a) {
console.log(a);
}
}
/***/ }),
/***/ "./js/services/i18nHelper.js":
/*!***********************************!*\
!*** ./js/services/i18nHelper.js ***!
\***********************************/
/*! exports provided: i18nHelper */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i18nHelper", function() { return i18nHelper; });
/* harmony import */ var line_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
/* harmony import */ var _localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./localizedStringsService */ "./js/services/localizedStringsService.js");
var StringTypes = line_i18n__WEBPACK_IMPORTED_MODULE_0__["default"].StringTypes;
var i18nHelper = Object.freeze({
i18n: function i18n(identifier) {
var opts = identifier.split(':');
var type = opts[0].toLowerCase();
var id = opts[1];
if (StringTypes.ERROR === type) {
return _localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getError(id);
} else if (StringTypes.MESSAGE === type) {
return _localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getMessage(id);
} else if (StringTypes.UI === type) {
return _localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI(id);
} else {
console.warn("A string has been passed to the i18n helper function that was not in the form type:id -> " + identifier);
return _localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getString(identifier, type);
}
}
});
/***/ }),
/***/ "./js/services/languageService.js":
/*!****************************************!*\
!*** ./js/services/languageService.js ***!
\****************************************/
/*! exports provided: LanguageService */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LanguageService", function() { return LanguageService; });
/* harmony import */ var _grammar___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../grammar/ */ "./grammar/index.js");
/* harmony import */ var line_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../util/config */ "./js/util/config.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var LanguageServiceExtended =
/*#__PURE__*/
function (_line_i18n$LanguageSe) {
_inherits(LanguageServiceExtended, _line_i18n$LanguageSe);
function LanguageServiceExtended() {
_classCallCheck(this, LanguageServiceExtended);
return _possibleConstructorReturn(this, _getPrototypeOf(LanguageServiceExtended).call(this, typeof iLMparameters === 'undefined' ? _util_config__WEBPACK_IMPORTED_MODULE_2__["Config"].default_lang : iLMparameters.lang));
}
_createClass(LanguageServiceExtended, [{
key: "getDefaultLang",
value: function getDefaultLang() {
return "pt";
}
}, {
key: "getCurrentLexer",
value: function getCurrentLexer() {
var langInfo = _grammar___WEBPACK_IMPORTED_MODULE_0__["default"][this.getLang()];
if (langInfo === null || langInfo === undefined) {
return _grammar___WEBPACK_IMPORTED_MODULE_0__["default"][this.getDefaultLang()].lexer;
} else {
return langInfo.lexer;
}
}
}, {
key: "getCurrentLangFuncs",
value: function getCurrentLangFuncs() {
var langInfo = _grammar___WEBPACK_IMPORTED_MODULE_0__["default"][this.getLang()];
if (langInfo === null || langInfo === undefined) {
return _grammar___WEBPACK_IMPORTED_MODULE_0__["default"][this.getDefaultLang()].langFuncs;
} else {
return langInfo.langFuncs;
}
}
}, {
key: "getCurrentLangLibs",
value: function getCurrentLangLibs() {
var langInfo = _grammar___WEBPACK_IMPORTED_MODULE_0__["default"][this.getLang()];
if (langInfo === null || langInfo === undefined) {
return _grammar___WEBPACK_IMPORTED_MODULE_0__["default"][this.getDefaultLang()].langLibs;
}
return langInfo.langLibs;
}
}]);
return LanguageServiceExtended;
}(line_i18n__WEBPACK_IMPORTED_MODULE_1__["default"].LanguageServiceNoLS);
var LanguageService = new LanguageServiceExtended();
/***/ }),
/***/ "./js/services/localizedStringsService.js":
/*!************************************************!*\
!*** ./js/services/localizedStringsService.js ***!
\************************************************/
/*! exports provided: LocalizedStrings, getInstance */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocalizedStrings", function() { return LocalizedStrings; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getInstance", function() { return getInstance; });
/* harmony import */ var line_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
/* harmony import */ var _languageService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./languageService */ "./js/services/languageService.js");
/* harmony import */ var _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../processor/definedFunctions */ "./js/processor/definedFunctions.js");
/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./../../i18n */ "./i18n/index.ts");
/* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_i18n__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _ast_operators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./../ast/operators */ "./js/ast/operators.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var IVProgLocalizedStrings =
/*#__PURE__*/
function (_line_i18n$LocalizedS) {
_inherits(IVProgLocalizedStrings, _line_i18n$LocalizedS);
function IVProgLocalizedStrings(langService, langsJsons) {
var shouldListenToChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
_classCallCheck(this, IVProgLocalizedStrings);
return _possibleConstructorReturn(this, _getPrototypeOf(IVProgLocalizedStrings).call(this, langService, langsJsons, shouldListenToChange));
}
_createClass(IVProgLocalizedStrings, [{
key: "translateType",
value: function translateType(type, dim) {
var type_string = this.getUI("type_".concat(type));
switch (dim) {
case 0:
return type_string;
default:
if (dim > 1) return this.getUI("matrix_info_string", [type_string]);else return this.getUI("vector_info_string", [type_string]);
}
}
}, {
key: "translateOp",
value: function translateOp(op) {
switch (op.ord) {
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].AND.ord:
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].OR.ord:
case _ast_operators__WEBPACK_IMPORTED_MODULE_4__["Operators"].NOT.ord:
return this.getUI("logic_operator_".concat(op.value));
default:
return op.value;
}
}
}, {
key: "translateInternalFunction",
value: function translateInternalFunction(name) {
var category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (category == null) {
return _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_2__["LanguageDefinedFunction"].getLocalName(name);
} else {
return _processor_definedFunctions__WEBPACK_IMPORTED_MODULE_2__["LanguageDefinedFunction"].getLocalName("".concat(category, ".").concat(name));
}
}
}]);
return IVProgLocalizedStrings;
}(line_i18n__WEBPACK_IMPORTED_MODULE_0__["default"].LocalizedStrings);
var LocalizedStrings = Object.freeze(new IVProgLocalizedStrings(_languageService__WEBPACK_IMPORTED_MODULE_1__["LanguageService"], _i18n__WEBPACK_IMPORTED_MODULE_3___default.a, true));
var _instance = null;
function getInstance() {
if (_instance == null) {
_instance = new IVProgLocalizedStrings(_languageService__WEBPACK_IMPORTED_MODULE_1__["LanguageService"], _i18n__WEBPACK_IMPORTED_MODULE_3___default.a);
}
return _instance;
}
/***/ }),
/***/ "./js/services/userLog.js":
/*!********************************!*\
!*** ./js/services/userLog.js ***!
\********************************/
/*! exports provided: ActionTypes, registerClick, registerUserEvent, registerSystemEvent, getLogs, setRebuildMode, getLogsAsString, parseLogs */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionTypes", function() { return ActionTypes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "registerClick", function() { return registerClick; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "registerUserEvent", function() { return registerUserEvent; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "registerSystemEvent", function() { return registerSystemEvent; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLogs", function() { return getLogs; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setRebuildMode", function() { return setRebuildMode; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLogsAsString", function() { return getLogsAsString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseLogs", function() { return parseLogs; });
var clicks = [];
var inRebuildMode = false;
var ActionTypes = Object.freeze({
// registerUserEvent payload:
// (function_name, insert action)
INSERT_FUNCTION: "INSERT_FUNCTION",
// (function_name, remove action)
REMOVE_FUNCTION: "REMOVE_FUNCTION",
// (var_name,insert action, type, dim)
INSERT_GLOBAL_VAR: "INSERT_GLOBAL_VAR",
// (var name, remove action)
REMOVE_GLOBAL_VAR: "REMOVE_GLOBAL_VAR",
// (old function name, rename action, new function name)
RENAME_FUNCTION: "RENAME_FUNCTION",
// (old var name, rename action. new var name)
RENAME_GLOBAL_VAR: "RENAME_GLOBAL_VAR",
// (var name, set const action)
SET_GLOBAL_CONST: "SET_GLOBAL_CONST",
// (function name, change return action, type, dim)
CHANGE_FUNCTION_RETURN: "CHANGE_FUNCTION_RETURN",
// (var name, change type action, type, dim, rows?, columns?)
CHANGE_GLOBAL_TYPE: "CHANGE_GLOBAL_TYPE",
// (var name, change value action, value)
CHANGE_GLOBAL_VALUE: "CHANGE_GLOBAL_VALUE",
// (function name, insert param action, param varname, type, dim)
INSERT_FUNCTION_PARAM: "INSERT_FUNCTION_PARAM",
// (function name, remove param action, param varname)
REMOVE_FUNCTION_PARAM: "REMOVE_FUNCTION_PARAM",
// (function name, change param type action, type, dim)
CHANGE_PARAM_TYPE: "CHANGE_PARAM_TYPE",
// (function name, rename param action, old param name, new param name)
RENAME_FUNCTION_PARAM: "RENAME_FUNCTION_PARAM",
// (function name, insert var action, var name, type, dim)
INSERT_FUNCTION_VAR: "INSERT_FUCNTION_VAR",
// (function name, remove var action, var name)
REMOVE_FUNCTION_VAR: "REMOVE_FUNCTION_VAR",
// (function name, rename var action, old var name, new var name)
RENAME_FUNCTION_VAR: "RENAME_FUNCTION_VAR",
// (function name, change var type action, var name, type, dim, rows?, columns?)
CHANGE_VAR_TYPE: "CHANGE_VAR_TYPE",
// (function name, change var value action, var name, value)
CHANGE_VAR_VALUE: "CHANGE_VAR_VALUE",
// (function name, insert command action, command, path)
INSERT_COMMAND: "INSERT_COMMAND",
// (function name, remove command action, path)
REMOVE_COMMAND: "REMOVE_COMMAND",
// (function name, change command exp action, path, exp)
CHANGE_COMMAND_EXP: "CHANGE_COMMAND_EXP",
// (function name, change attrib exp action, path, exp)
CHANGE_ATTRIB_EXP: "CHANGE_ATTRIB_EXP",
// (function name, change attrib var action, path, var name, row_exp?, column_exp?)
CHANGE_ATTRIB_VAR: "CHANGE_ATTRIB_VAR",
// (function name, move command action, old path, new path)
MOVE_COMMAND: "MOVE_COMMAND",
// (function name, enter change name action, var name)
ENTER_CHANGE_VAR_NAME: 'ENTER_CHANGE_VAR_NAME',
// (function name, enter change value action, var name)
ENTER_CHANGE_VAR_VALUE: 'ENTER_CHANGE_VAR_VALUE',
// (var name, enter change name action)
ENTER_CHANGE_GLOBAL_NAME: 'ENTER_CHANGE_GLOBAL_NAME',
// (var name, enter change value action)
ENTER_CHANGE_GLOBAL_VALUE: 'ENTER_CHANGE_GLOBAL_VALUE',
// (function name, enter change name action, param name)
ENTER_CHANGE_PARAM_NAME: 'ENTER_CHANGE_PARAM_NAME'
});
function registerClick(x, y, details) {
if (inRebuildMode) {
return;
}
clicks.push([x, y, Date.now(), details]);
}
function registerUserEvent(command, action) {
for (var _len = arguments.length, params = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
params[_key - 2] = arguments[_key];
}
registerEvent('user_event', command, action, params);
}
function registerSystemEvent(command, action) {
for (var _len2 = arguments.length, params = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
params[_key2 - 2] = arguments[_key2];
}
registerEvent('system_event', command, action, params);
}
function registerEvent(tag, command, action, params) {
if (inRebuildMode) {
return;
}
var event = {
context: command,
action: action,
params: params
};
clicks.push([tag, Date.now(), event]);
}
function getLogs() {
return clicks;
}
function setRebuildMode(flag) {
inRebuildMode = flag;
}
function getLogsAsString() {
return JSON.stringify(clicks);
}
function parseLogs(logData) {
clicks = JSON.parse(logData);
}
/***/ }),
/***/ "./js/typeSystem/array_type.ts":
/*!*************************************!*\
!*** ./js/typeSystem/array_type.ts ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ArrayType {
constructor(type, dimensions) {
this.dimensions = dimensions;
this.innerType = type;
}
get isVector() {
return this.dimensions == 1;
}
isCompatible(another) {
if (another instanceof ArrayType) {
if (this.dimensions !== another.dimensions) {
return false;
}
return this.innerType.isCompatible(another.innerType);
}
return false;
}
stringInfo() {
const list = this.innerType.stringInfo();
list.forEach(v => {
v.dim = this.dimensions;
});
return list;
}
get value() {
return undefined;
}
get ord() {
return undefined;
}
canAccept(another, used_dims) {
const free_dims = this.dimensions - used_dims;
if (another instanceof ArrayType) {
return free_dims == another.dimensions && this.innerType.isCompatible(another.innerType);
}
else {
return free_dims == 0 && this.innerType.isCompatible(another);
}
}
}
exports.ArrayType = ArrayType;
/***/ }),
/***/ "./js/typeSystem/multiType.ts":
/*!************************************!*\
!*** ./js/typeSystem/multiType.ts ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class MultiType {
constructor(types) {
this.types = types;
}
get value() {
return undefined;
}
get ord() {
return undefined;
}
stringInfo() {
let list = [];
for (let i = 0; i < this.types.length; i++) {
const t = this.types[i];
list = list.concat(t.stringInfo());
}
return list;
}
isCompatible(another) {
for (let i = 0; i < this.types.length; i++) {
const t = this.types[i];
if (another.isCompatible(t)) {
return true;
}
}
return false;
}
}
exports.MultiType = MultiType;
/***/ }),
/***/ "./js/typeSystem/parsers.js":
/*!**********************************!*\
!*** ./js/typeSystem/parsers.js ***!
\**********************************/
/*! exports provided: toInt, toString, toReal, toBool, convertBoolToString, convertToString */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toInt", function() { return toInt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toString", function() { return toString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toReal", function() { return toReal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toBool", function() { return toBool; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertBoolToString", function() { return convertBoolToString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertToString", function() { return convertToString; });
/* harmony import */ var _services_languageService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./js/typeSystem/types.ts");
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(decimal_js__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
function toInt(str) {
return new decimal_js__WEBPACK_IMPORTED_MODULE_2___default.a(str);
}
function toString(str) {
var value = str.replace(/^"/, '');
value = value.replace(/"$/, '');
value = value.replace(/\\b/g, "\b");
value = value.replace(/\\t/g, "\t");
value = value.replace(/\\n/g, "\n");
value = value.replace(/\\r/g, "\r");
value = value.replace(/\\"/g, "\"");
value = value.replace(/\\'/g, '\'');
value = value.replace(/\\\\/g, "\\");
return value;
}
function toReal(value) {
return new decimal_js__WEBPACK_IMPORTED_MODULE_2___default.a(value);
}
function toBool(str) {
var val = "'" + str + "'";
var lexer = _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLexer();
var instance = new lexer(null);
if (instance.literalNames[lexer.RK_TRUE] === val) {
return true;
} else if (instance.literalNames[lexer.RK_FALSE] === val) {
return false;
} else {
// TODO: better error message
throw new Error(str + "not a valid boolean");
}
}
function convertBoolToString(bool) {
var lexer = _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLexer();
var instance = new lexer(null);
var result = null;
if (bool) {
result = instance.literalNames[lexer.RK_TRUE];
} else {
result = instance.literalNames[lexer.RK_FALSE];
}
return result.replace(/'/g, "");
}
function convertToString(value, type) {
switch (type.ord) {
case _types__WEBPACK_IMPORTED_MODULE_1__["Types"].INTEGER.ord:
return value.toString();
case _types__WEBPACK_IMPORTED_MODULE_1__["Types"].REAL.ord:
{
if (value.dp() <= 0) {
return value.toFixed(1);
} else {
return value.toFixed(_util_config__WEBPACK_IMPORTED_MODULE_3__["Config"].decimalPlaces);
}
}
case _types__WEBPACK_IMPORTED_MODULE_1__["Types"].BOOLEAN.ord:
return convertBoolToString(value);
default:
return value;
}
}
/***/ }),
/***/ "./js/typeSystem/type.ts":
/*!*******************************!*\
!*** ./js/typeSystem/type.ts ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Type {
constructor(value, ord) {
this.value = value;
this.ord = ord;
}
stringInfo() {
return [{ type: this.value, dim: 0 }];
}
isCompatible(another) {
return this.value === another.value && this.ord === another.ord;
}
}
exports.Type = Type;
/***/ }),
/***/ "./js/typeSystem/types.ts":
/*!********************************!*\
!*** ./js/typeSystem/types.ts ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const type_1 = __webpack_require__(/*! ./type */ "./js/typeSystem/type.ts");
const multiType_1 = __webpack_require__(/*! ./multiType */ "./js/typeSystem/multiType.ts");
const maybe_1 = __webpack_require__(/*! ../util/maybe */ "./js/util/maybe.ts");
const INTEGER = new type_1.Type("integer", 0);
const REAL = new type_1.Type("real", 1);
const STRING = new type_1.Type("text", 2);
const BOOLEAN = new type_1.Type("boolean", 3);
const VOID = new type_1.Type("void", 4);
const UNDEFINED = new type_1.Type("undefined", 5);
const ALL = new multiType_1.MultiType([INTEGER, REAL, STRING, BOOLEAN]);
exports.Types = Object.freeze({
INTEGER: INTEGER,
REAL: REAL,
STRING: STRING,
BOOLEAN: BOOLEAN,
VOID: VOID,
UNDEFINED: UNDEFINED,
ALL: ALL
});
function fromOrdToType(ord) {
const typeMap = exports.Types;
for (let t in typeMap) {
if (typeMap[t].ord === ord) {
return maybe_1.Maybe.some(typeMap[t]);
}
}
return maybe_1.Maybe.none();
}
exports.fromOrdToType = fromOrdToType;
/***/ }),
/***/ "./js/util/auto_gen_output.js":
/*!************************************!*\
!*** ./js/util/auto_gen_output.js ***!
\************************************/
/*! exports provided: autoGenerateTestCaseOutput */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autoGenerateTestCaseOutput", function() { return autoGenerateTestCaseOutput; });
/* harmony import */ var _processor_semantic_semanticAnalyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../processor/semantic/semanticAnalyser */ "./js/processor/semantic/semanticAnalyser.js");
/* harmony import */ var _processor_ivprogProcessor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
/* harmony import */ var _inputTest__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./inputTest */ "./js/util/inputTest.js");
/* harmony import */ var _outputTest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./outputTest */ "./js/util/outputTest.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
function autoGenerateTestCaseOutput(program_text, testCases) {
var copyTestCases = testCases.map(function (test) {
return Object.assign({}, test);
});
try {
var program = _processor_semantic_semanticAnalyser__WEBPACK_IMPORTED_MODULE_0__["SemanticAnalyser"].analyseFromSource(program_text);
var resultList = testCases.map(function (test, id) {
var input = new _inputTest__WEBPACK_IMPORTED_MODULE_2__["InputTest"](test.input);
var output = new _outputTest__WEBPACK_IMPORTED_MODULE_3__["OutputTest"]();
var exec = new _processor_ivprogProcessor__WEBPACK_IMPORTED_MODULE_1__["IVProgProcessor"](program);
exec.registerInput(input);
exec.registerOutput(output);
return exec.interpretAST().then(function (_) {
return {
id: id,
program: exec
};
});
});
return Promise.all(resultList).then(function (result_final) {
for (var i = 0; i < result_final.length; ++i) {
var result = result_final[i];
var output = result.program.output.list;
var input = result.program.input;
if (input.index != input.inputList.length) {
window.showAlert(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_4__["LocalizedStrings"].getMessage("testcase_autogen_unused_input", [result.id + 1]));
return Promise.resolve(false);
}
if (output.length == 0) {
window.showAlert(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_4__["LocalizedStrings"].getMessage("testcase_autogen_empty", [result.id + 1]));
}
copyTestCases[result.id].output = output;
}
window.outputGenerated(copyTestCases);
return Promise.resolve(true);
});
} catch (error) {
return Promise.reject(error);
}
}
/***/ }),
/***/ "./js/util/config.js":
/*!***************************!*\
!*** ./js/util/config.js ***!
\***************************/
/*! exports provided: Config */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Config", function() { return Config; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var ConfigObject =
/*#__PURE__*/
function () {
function ConfigObject() {
_classCallCheck(this, ConfigObject);
this.decimalPlaces = 8;
this.intConvertRoundMode = 2;
this.default_lang = 'pt';
this.enable_type_casting = true;
this.idle_input_interval = 5000;
this.suspend_threshold = 100; // this.max_instruction_count = 350250; - automated evaluation limit
this.max_instruction_count = Number.MAX_SAFE_INTEGER;
}
_createClass(ConfigObject, [{
key: "setConfig",
value: function setConfig(opts) {
for (var key in opts) {
if (Object.prototype.hasOwnProperty.call(this, key)) {
this[key] = opts[key];
}
}
}
}]);
return ConfigObject;
}();
var config = new ConfigObject();
var Config = config;
/***/ }),
/***/ "./js/util/editorMode2.js":
/*!********************************!*\
!*** ./js/util/editorMode2.js ***!
\********************************/
/*! exports provided: CodeEditorMode */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeEditorMode", function() { return CodeEditorMode; });
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./js/util/utils.js");
/**
* Source: https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/clike/clike.js
* @author arijn Haverbeke and others
* @author Lucas de Souza
* @param {CodeMirror} CodeMirror
*/
function CodeEditorMode(CodeMirror) {
"use strict";
function Context(indented, column, type, info, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.info = info;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type, info) {
var indent = state.indented;
if (state.context && state.context.type == "statement" && type != "statement") indent = state.context.indented;
return state.context = new Context(indent, col, type, info, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}") state.indented = state.context.indented;
return state.context = state.context.prev;
}
function typeBefore(stream, state, pos) {
if (state.prevToken == "variable" || state.prevToken == "type") return true;
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
}
function isTopScope(context) {
for (;;) {
if (!context || context.type == "top") return true;
if (context.type == "}" && context.prev.info != "namespace") return false;
context = context.prev;
}
}
function contains(words, word) {
if (typeof words === "function") {
return words(word);
} else {
return Object.propertyIsEnumerable.call(words, word);
}
}
function tokenComment(stream, state) {
var maybeEnd = false,
ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = ch == "*";
}
return "comment";
}
CodeMirror.defineMode("ivprog", function (config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
keywords = parserConfig.keywords || {},
switchKeyword = parserConfig.switchKeyword,
caseKeyword = parserConfig.caseKeyword,
defaultKeyword = parserConfig.defaultKeyword,
caseRegex = new RegExp("^\\s*(?:".concat(caseKeyword, " .*?:|").concat(defaultKeyword, ":|\\{\\}?|\\})$")),
////,
types = parserConfig.types || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
defKeywords = parserConfig.defKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserConfig.multiLineStrings,
indentStatements = false,
namespaceSeparator = null,
isPunctuationChar = /[[\]{}(),;:\n]/,
numberStart = /[\d.]/,
number = /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)$/i,
isOperatorChar = /[+\-*%=<>!/&]/,
isIdentifierChar = /[a-zA-Z0-9_]/,
// An optional function that takes a {string} token and returns true if it
// should be treated as a builtin.
isReservedIdentifier = parserConfig.isReservedIdentifier || false;
var curPunc, isDefKeyword;
var tokenString = function tokenString() {
/*SKIP*/
};
function tokenBase(stream, state) {
var ch = stream.next();
if (hooks[ch]) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
}
if (ch == '"') {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (isPunctuationChar.test(ch)) {
curPunc = ch;
return null;
}
if (numberStart.test(ch)) {
stream.backUp(1);
if (stream.match(number)) return "number";
stream.next();
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
while (!stream.match(/^\/[/*]/, false) && stream.eat(isOperatorChar)) {
/* SKIP */
}
return "operator";
}
stream.eatWhile(isIdentifierChar);
if (namespaceSeparator) while (stream.match(namespaceSeparator)) {
stream.eatWhile(isIdentifierChar);
}
var cur = stream.current();
if (contains(keywords, cur)) {
if (contains(blockKeywords, cur)) curPunc = "newstatement";
if (contains(defKeywords, cur)) isDefKeyword = true;
return "keyword";
}
if (contains(types, cur)) return "type";
if (contains(builtin, cur) || isReservedIdentifier && isReservedIdentifier(cur)) {
if (contains(blockKeywords, cur)) curPunc = "newstatement";
return "builtin";
}
if (contains(atoms, cur)) return "atom";
return "variable";
}
tokenString = function tokenString(quote) {
return function (stream, state) {
var escaped = false,
next,
end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {
end = true;
break;
}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || multiLineStrings)) state.tokenize = null;
return "string";
};
};
function maybeEOL(stream, state) {
if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context)) state.typeAtEndOfLine = typeBefore(stream, state, stream.pos);
} // Interface
return {
startState: function startState(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
indented: 0,
startOfLine: true,
prevToken: null
};
},
token: function token(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) {
maybeEOL(stream, state);
return null;
}
curPunc = isDefKeyword = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;
if (curPunc == ";" || curPunc == ":" || curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false)) while (state.context.type == "statement") {
popContext(state);
} else if (curPunc == "{") pushContext(state, stream.column(), "}");else if (curPunc == "[") pushContext(state, stream.column(), "]");else if (curPunc == "(") pushContext(state, stream.column(), ")");else if (curPunc == "}") {
while (ctx.type == "statement") {
ctx = popContext(state);
}
if (ctx.type == "}") ctx = popContext(state);
while (ctx.type == "statement") {
ctx = popContext(state);
}
} else if (curPunc == ctx.type) popContext(state);else if (indentStatements && ((ctx.type == "}" || ctx.type == "top") && curPunc != ";" || ctx.type == "statement" && curPunc == "newstatement")) {
pushContext(state, stream.column(), "statement", stream.current());
}
if (style == "variable" && (state.prevToken == "def" || parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) && isTopScope(state.context) && stream.match(/^\s*\(/, false))) style = "def";
if (hooks.token) {
var result = hooks.token(stream, state, style);
if (result !== undefined) style = result;
}
if (style == "def" && parserConfig.styleDefs === false) style = "variable";
state.startOfLine = false;
state.prevToken = isDefKeyword ? "def" : style || curPunc;
maybeEOL(stream, state);
return style;
},
indent: function indent(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
var ctx = state.context;
var firstChar = textAfter && textAfter.charAt(0);
var closing = firstChar == ctx.type;
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
if (parserConfig.dontIndentStatements) while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info)) {
ctx = ctx.prev;
}
if (hooks.indent) {
var hook = hooks.indent(state, ctx, textAfter, indentUnit);
if (typeof hook == "number") return hook;
}
var switchBlock = ctx.prev && ctx.prev.info == switchKeyword;
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
while (ctx.type != "top" && ctx.type != "}") {
ctx = ctx.prev;
}
return ctx.indented;
}
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
var caseTestRegex = new RegExp("^(?:".concat(caseKeyword, "|").concat(defaultKeyword, ")\b"));
return ctx.indented + (closing ? 0 : indentUnit) + (!closing && switchBlock && !caseTestRegex.test(textAfter) ? indentUnit : 0);
},
electricInput: caseRegex,
blockCommentStart: "/*",
blockCommentEnd: "*/",
blockCommentContinue: " * ",
lineComment: "//",
fold: "brace"
};
});
function words(str) {
var obj = {},
words = str.split(" ");
for (var i = 0; i < words.length; ++i) {
obj[words[i]] = true;
}
return obj;
}
var codeConfig = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["getCodeEditorModeConfig"])();
var ivprogKeywords = codeConfig.keywords.join(" ");
var basicTypes = words(codeConfig.types.join(" "));
function ivprogTypes(identifier) {
return contains(basicTypes, identifier);
}
var ivprogBlockKeywords = codeConfig.blocks.join(" ");
var ivprogDefKeywords = "funcao const";
function def(mimes, mode) {
if (typeof mimes == "string") mimes = [mimes];
var words = [];
function add(obj) {
if (obj) {
for (var prop in obj) {
if (Object.hasOwnProperty.call(obj, prop)) {
words.push(prop);
}
}
}
}
add(mode.keywords);
add(mode.types);
add(mode.builtin);
add(mode.atoms);
if (words.length) {
mode.helperType = mimes[0];
CodeMirror.registerHelper("hintWords", mimes[0], words);
}
for (var i = 0; i < mimes.length; ++i) {
CodeMirror.defineMIME(mimes[i], mode);
}
}
def(["text/x-ivprog"], {
name: "ivprog",
keywords: words(ivprogKeywords),
types: ivprogTypes,
blockKeywords: words(ivprogBlockKeywords),
defKeywords: words(ivprogDefKeywords),
typeFirstDefinitions: true,
atoms: words(codeConfig.atoms.join(" ")),
switchKeyword: codeConfig.switchString,
caseKeyword: codeConfig.case_default[0],
defaultKeyword: codeConfig.case_default[1],
modeProps: {
fold: ["brace"]
}
});
}
/***/ }),
/***/ "./js/util/iassignHelpers.js":
/*!***********************************!*\
!*** ./js/util/iassignHelpers.js ***!
\***********************************/
/*! exports provided: prepareActivityToStudentHelper, autoEval */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prepareActivityToStudentHelper", function() { return prepareActivityToStudentHelper; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autoEval", function() { return autoEval; });
/* harmony import */ var _visualUI_functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../visualUI/functions */ "./js/visualUI/functions.js");
/* harmony import */ var _visualUI_code_generator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../visualUI/code_generator */ "./js/visualUI/code_generator.js");
/* harmony import */ var _assessment_ivprogAssessment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../assessment/ivprogAssessment */ "./js/assessment/ivprogAssessment.js");
/* harmony import */ var _testConsole__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./testConsole */ "./js/util/testConsole.js");
/* harmony import */ var _services_userLog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./../services/userLog */ "./js/services/userLog.js");
/* harmony import */ var _processor_semantic_semanticAnalyser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../processor/semantic/semanticAnalyser */ "./js/processor/semantic/semanticAnalyser.js");
/* harmony import */ var _maybe__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./maybe */ "./js/util/maybe.ts");
/* harmony import */ var _maybe__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_maybe__WEBPACK_IMPORTED_MODULE_6__);
function parseActivityData(data) {
var algorithm_in_ilm = null;
if (data.split('\n::algorithm::')[1]) {
algorithm_in_ilm = data.split('\n::algorithm::')[1].split('\n::logs::')[0];
var logs = data.split('\n::algorithm::')[1].split('\n::logs::')[1];
if (logs != null) {
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_4__["parseLogs"])(logs);
}
}
var content;
try {
content = JSON.parse(data.split('\n::algorithm::')[0]);
content['algorithm_in_ilm'] = algorithm_in_ilm;
} catch (e) {
console.error(e);
return _maybe__WEBPACK_IMPORTED_MODULE_6__["Maybe"].none();
}
return _maybe__WEBPACK_IMPORTED_MODULE_6__["Maybe"].some(content);
}
function prepareActivityToStudentHelper(ilm_cont) {
var maybe_content = parseActivityData(ilm_cont);
return maybe_content.map(function (content) {
var testCases = content.testcases;
Object(_visualUI_functions__WEBPACK_IMPORTED_MODULE_0__["setTestCases"])(testCases);
var prog_type = null;
if (content.settings_programming_type) {
prog_type = content.settings_programming_type[0].value;
} else {
prog_type = "visual";
}
return {
settingsProgrammingType: prog_type,
settingsDataTypes: content.settings_data_types,
settingsCommands: content.settings_commands,
settingsFunctions: content.settings_functions,
algorithmInIlm: content.algorithm_in_ilm,
settingsFilter: content.settings_filter
};
});
}
function compareArray(a, b) {
for (var i = 0; i < a.length; ++i) {
var elementA = a[i];
var elementB = b[i];
if (elementA != elementB) {
return false;
}
}
return true;
}
function compareTestcases(original, student) {
if (original.length != student.length) {
return false;
}
for (var i = 0; i < original.length; ++i) {
var elementO = original[i];
var elementS = student[i];
if (!compareArray(elementO.input, elementS.input)) {
return false;
}
if (!compareArray(elementO.output, elementS.output)) {
return false;
}
}
return true;
}
function autoEval(originalData, callback) {
var code = Object(_visualUI_code_generator__WEBPACK_IMPORTED_MODULE_1__["generate"])();
var original = parseActivityData(originalData).getOrElse(undefined);
if (original == null) {
alert("iAssign did not provide the original activity data!");
return callback(null);
}
if (code == null) {
return callback(-1); // @FeedbackConvention Casos de teste vazios
} else {
if (!compareTestcases(original.testcases, Object(_visualUI_functions__WEBPACK_IMPORTED_MODULE_0__["getTestCases"])())) {
return callback(-2); // @FeedbackConvention Casos de teste alterados pelo aluno
}
var ast_code = _processor_semantic_semanticAnalyser__WEBPACK_IMPORTED_MODULE_5__["SemanticAnalyser"].analyseFromSource(code);
var autoAssessment = new _assessment_ivprogAssessment__WEBPACK_IMPORTED_MODULE_2__["IVProgAssessment"](ast_code, Object(_visualUI_functions__WEBPACK_IMPORTED_MODULE_0__["getTestCases"])(), new _testConsole__WEBPACK_IMPORTED_MODULE_3__["TestConsole"]([]));
autoAssessment.runTest().then(function (grade) {
return callback(grade);
})["catch"](function (err) {
console.log(err);
callback(0);
});
}
}
/***/ }),
/***/ "./js/util/inputTest.js":
/*!******************************!*\
!*** ./js/util/inputTest.js ***!
\******************************/
/*! exports provided: InputTest */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputTest", function() { return InputTest; });
/* harmony import */ var _io_input__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../io/input */ "./js/io/input.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../services/localizedStringsService */ "./js/services/localizedStringsService.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var InputTest =
/*#__PURE__*/
function (_Input) {
_inherits(InputTest, _Input);
function InputTest(inputList) {
var _this;
_classCallCheck(this, InputTest);
_this = _possibleConstructorReturn(this, _getPrototypeOf(InputTest).call(this));
_this.index = 0;
_this.inputList = inputList;
return _this;
}
_createClass(InputTest, [{
key: "requestInput",
value: function requestInput(callback) {
if (this.index < this.inputList.length) {
callback(this.inputList[this.index]);
this.index++;
} else {
throw new Error(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getError("exceeded_input_request"));
}
}
}]);
return InputTest;
}(_io_input__WEBPACK_IMPORTED_MODULE_0__["Input"]);
/***/ }),
/***/ "./js/util/input_assessment.js":
/*!*************************************!*\
!*** ./js/util/input_assessment.js ***!
\*************************************/
/*! exports provided: InputAssessment */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputAssessment", function() { return InputAssessment; });
/* harmony import */ var _io_input__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../io/input */ "./js/io/input.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../services/localizedStringsService */ "./js/services/localizedStringsService.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var InputAssessment =
/*#__PURE__*/
function (_Input) {
_inherits(InputAssessment, _Input);
function InputAssessment(input_list) {
var _this;
_classCallCheck(this, InputAssessment);
_this = _possibleConstructorReturn(this, _getPrototypeOf(InputAssessment).call(this));
_this.index = 0;
_this.input_list = input_list.map(function (val) {
return {
"value": val,
"read": false
};
});
return _this;
}
_createClass(InputAssessment, [{
key: "requestInput",
value: function requestInput(callback) {
if (this.index < this.input_list.length) {
var input = this.input_list[this.index];
input.read = true;
this.index += 1;
callback(input.value);
} else {
throw new Error(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getError("exceeded_input_request"));
}
}
}, {
key: "isInputAvailable",
value: function isInputAvailable() {
return this.index < this.input_list.length;
}
}]);
return InputAssessment;
}(_io_input__WEBPACK_IMPORTED_MODULE_0__["Input"]);
/***/ }),
/***/ "./js/util/maybe.ts":
/*!**************************!*\
!*** ./js/util/maybe.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
*
* Maybe Monad
* @Source: https://codewithstyle.info/advanced-functional-programming-in-typescript-maybe-monad/
* @Modified by: @lucascalion - 28/08/2019
*
**/
class Maybe {
constructor(value) {
this.value = value;
}
static some(value) {
if (!value) {
throw Error("Provided value must not be empty");
}
return new Maybe(value);
}
static none() {
return new Maybe(null);
}
static fromValue(value) {
return value ? Maybe.some(value) : Maybe.none();
}
getOrElse(defaultValue) {
return this.value === null ? defaultValue : this.value;
}
map(f) {
if (this.value === null) {
return Maybe.none();
}
else {
return Maybe.fromValue(f(this.value));
}
}
}
exports.Maybe = Maybe;
/***/ }),
/***/ "./js/util/outputTest.js":
/*!*******************************!*\
!*** ./js/util/outputTest.js ***!
\*******************************/
/*! exports provided: OutputTest */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutputTest", function() { return OutputTest; });
/* harmony import */ var _io_output__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../io/output */ "./js/io/output.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var OutputTest =
/*#__PURE__*/
function (_Output) {
_inherits(OutputTest, _Output);
function OutputTest() {
var _this;
_classCallCheck(this, OutputTest);
_this = _possibleConstructorReturn(this, _getPrototypeOf(OutputTest).call(this));
_this.list = [];
return _this;
}
_createClass(OutputTest, [{
key: "sendOutput",
value: function sendOutput(text) {
var _this2 = this;
var output = '' + text;
output.split("\n").forEach(function (t) {
t = t.replace(/\t/g, ' ');
t = t.replace(/\s/g, " ");
_this2.list.push(t);
}, this);
}
}]);
return OutputTest;
}(_io_output__WEBPACK_IMPORTED_MODULE_0__["Output"]);
/***/ }),
/***/ "./js/util/string_diff.js":
/*!********************************!*\
!*** ./js/util/string_diff.js ***!
\********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/**
* Author: @jhchen - https://github.com/jhchen
* Modified by: @lucascalion - 23/07/2019
* This library modifies the diff-patch-match library by Neil Fraser
* by removing the patch and match functionality and certain advanced
* options in the diff function. The original license is as follows:
*
* ===
*
* Diff Match and Patch
*
* Copyright 2006 Google Inc.
* http://code.google.com/p/google-diff-match-patch/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The data structure representing a diff is an array of tuples:
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
*/
var DIFF_DELETE = -1;
var DIFF_INSERT = 1;
var DIFF_EQUAL = 0;
/**
* Find the differences between two texts. Simplifies the problem by stripping
* any common prefix or suffix off the texts before diffing.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {Int|Object} [cursor_pos] Edit position in text1 or object with more info
* @return {Array} Array of diff tuples.
*/
function diff_main(text1, text2, cursor_pos, _fix_unicode) {
// Check for equality
if (text1 === text2) {
if (text1) {
return [[DIFF_EQUAL, text1]];
}
return [];
}
if (cursor_pos != null) {
var editdiff = find_cursor_edit_diff(text1, text2, cursor_pos);
if (editdiff) {
return editdiff;
}
} // Trim off common prefix (speedup).
var commonlength = diff_commonPrefix(text1, text2);
var commonprefix = text1.substring(0, commonlength);
text1 = text1.substring(commonlength);
text2 = text2.substring(commonlength); // Trim off common suffix (speedup).
commonlength = diff_commonSuffix(text1, text2);
var commonsuffix = text1.substring(text1.length - commonlength);
text1 = text1.substring(0, text1.length - commonlength);
text2 = text2.substring(0, text2.length - commonlength); // Compute the diff on the middle block.
var diffs = diff_compute_(text1, text2); // Restore the prefix and suffix.
if (commonprefix) {
diffs.unshift([DIFF_EQUAL, commonprefix]);
}
if (commonsuffix) {
diffs.push([DIFF_EQUAL, commonsuffix]);
}
diff_cleanupMerge(diffs, _fix_unicode);
return diffs;
}
/**
* Find the differences between two texts. Assumes that the texts do not
* have any common prefix or suffix.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @return {Array} Array of diff tuples.
*/
function diff_compute_(text1, text2) {
var diffs;
if (!text1) {
// Just add some text (speedup).
return [[DIFF_INSERT, text2]];
}
if (!text2) {
// Just delete some text (speedup).
return [[DIFF_DELETE, text1]];
}
var longtext = text1.length > text2.length ? text1 : text2;
var shorttext = text1.length > text2.length ? text2 : text1;
var i = longtext.indexOf(shorttext);
if (i !== -1) {
// Shorter text is inside the longer text (speedup).
diffs = [[DIFF_INSERT, longtext.substring(0, i)], [DIFF_EQUAL, shorttext], [DIFF_INSERT, longtext.substring(i + shorttext.length)]]; // Swap insertions for deletions if diff is reversed.
if (text1.length > text2.length) {
diffs[0][0] = diffs[2][0] = DIFF_DELETE;
}
return diffs;
}
if (shorttext.length === 1) {
// Single character string.
// After the previous speedup, the character can't be an equality.
return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
} // Check to see if the problem can be split in two.
var hm = diff_halfMatch_(text1, text2);
if (hm) {
// A half-match was found, sort out the return data.
var text1_a = hm[0];
var text1_b = hm[1];
var text2_a = hm[2];
var text2_b = hm[3];
var mid_common = hm[4]; // Send both pairs off for separate processing.
var diffs_a = diff_main(text1_a, text2_a);
var diffs_b = diff_main(text1_b, text2_b); // Merge the results.
return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
}
return diff_bisect_(text1, text2);
}
/**
* Find the 'middle snake' of a diff, split the problem in two
* and return the recursively constructed diff.
* See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @return {Array} Array of diff tuples.
* @private
*/
function diff_bisect_(text1, text2) {
// Cache the text lengths to prevent multiple calls.
var text1_length = text1.length;
var text2_length = text2.length;
var max_d = Math.ceil((text1_length + text2_length) / 2);
var v_offset = max_d;
var v_length = 2 * max_d;
var v1 = new Array(v_length);
var v2 = new Array(v_length); // Setting all elements to -1 is faster in Chrome & Firefox than mixing
// integers and undefined.
for (var x = 0; x < v_length; x++) {
v1[x] = -1;
v2[x] = -1;
}
v1[v_offset + 1] = 0;
v2[v_offset + 1] = 0;
var delta = text1_length - text2_length; // If the total number of characters is odd, then the front path will collide
// with the reverse path.
var front = delta % 2 !== 0; // Offsets for start and end of k loop.
// Prevents mapping of space beyond the grid.
var k1start = 0;
var k1end = 0;
var k2start = 0;
var k2end = 0;
for (var d = 0; d < max_d; d++) {
// Walk the front path one step.
for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
var k1_offset = v_offset + k1;
var x1 = void 0;
if (k1 === -d || k1 !== d && v1[k1_offset - 1] < v1[k1_offset + 1]) {
x1 = v1[k1_offset + 1];
} else {
x1 = v1[k1_offset - 1] + 1;
}
var y1 = x1 - k1;
while (x1 < text1_length && y1 < text2_length && text1.charAt(x1) === text2.charAt(y1)) {
x1++;
y1++;
}
v1[k1_offset] = x1;
if (x1 > text1_length) {
// Ran off the right of the graph.
k1end += 2;
} else if (y1 > text2_length) {
// Ran off the bottom of the graph.
k1start += 2;
} else if (front) {
var k2_offset = v_offset + delta - k1;
if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] !== -1) {
// Mirror x2 onto top-left coordinate system.
var x2 = text1_length - v2[k2_offset];
if (x1 >= x2) {
// Overlap detfrontected.
return diff_bisectSplit_(text1, text2, x1, y1);
}
}
}
} // Walk the reverse path one step.
for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
var _k2_offset = v_offset + k2;
var _x = void 0;
if (k2 === -d || k2 !== d && v2[_k2_offset - 1] < v2[_k2_offset + 1]) {
_x = v2[_k2_offset + 1];
} else {
_x = v2[_k2_offset - 1] + 1;
}
var y2 = _x - k2;
while (_x < text1_length && y2 < text2_length && text1.charAt(text1_length - _x - 1) === text2.charAt(text2_length - y2 - 1)) {
_x++;
y2++;
}
v2[_k2_offset] = _x;
if (_x > text1_length) {
// Ran off the left of the graph.
k2end += 2;
} else if (y2 > text2_length) {
// Ran off the top of the graph.
k2start += 2;
} else if (!front) {
var _k1_offset = v_offset + delta - k2;
if (_k1_offset >= 0 && _k1_offset < v_length && v1[_k1_offset] !== -1) {
var _x2 = v1[_k1_offset];
var _y = v_offset + _x2 - _k1_offset; // Mirror x2 onto top-left coordinate system.
_x = text1_length - _x;
if (_x2 >= _x) {
// Overlap detected.
return diff_bisectSplit_(text1, text2, _x2, _y);
}
}
}
}
} // Diff took too long and hit the deadline or
// number of diffs equals number of characters, no commonality at all.
return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
}
/**
* Given the location of the 'middle snake', split the diff in two parts
* and recurse.
* @param {string} text1 Old string to be diffed.
* @param {string} text2 New string to be diffed.
* @param {number} x Index of split point in text1.
* @param {number} y Index of split point in text2.
* @return {Array} Array of diff tuples.
*/
function diff_bisectSplit_(text1, text2, x, y) {
var text1a = text1.substring(0, x);
var text2a = text2.substring(0, y);
var text1b = text1.substring(x);
var text2b = text2.substring(y); // Compute both diffs serially.
var diffs = diff_main(text1a, text2a);
var diffsb = diff_main(text1b, text2b);
return diffs.concat(diffsb);
}
/**
* Determine the common prefix of two strings.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {number} The number of characters common to the start of each
* string.
*/
function diff_commonPrefix(text1, text2) {
// Quick check for common null cases.
if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
return 0;
} // Binary search.
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
var pointermin = 0;
var pointermax = Math.min(text1.length, text2.length);
var pointermid = pointermax;
var pointerstart = 0;
while (pointermin < pointermid) {
if (text1.substring(pointerstart, pointermid) == text2.substring(pointerstart, pointermid)) {
pointermin = pointermid;
pointerstart = pointermin;
} else {
pointermax = pointermid;
}
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
}
if (is_surrogate_pair_start(text1.charCodeAt(pointermid - 1))) {
pointermid--;
}
return pointermid;
}
/**
* Determine the common suffix of two strings.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {number} The number of characters common to the end of each string.
*/
function diff_commonSuffix(text1, text2) {
// Quick check for common null cases.
if (!text1 || !text2 || text1.slice(-1) !== text2.slice(-1)) {
return 0;
} // Binary search.
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
var pointermin = 0;
var pointermax = Math.min(text1.length, text2.length);
var pointermid = pointermax;
var pointerend = 0;
while (pointermin < pointermid) {
if (text1.substring(text1.length - pointermid, text1.length - pointerend) == text2.substring(text2.length - pointermid, text2.length - pointerend)) {
pointermin = pointermid;
pointerend = pointermin;
} else {
pointermax = pointermid;
}
pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
}
if (is_surrogate_pair_end(text1.charCodeAt(text1.length - pointermid))) {
pointermid--;
}
return pointermid;
}
/**
* Do the two texts share a substring which is at least half the length of the
* longer text?
* This speedup can produce non-minimal diffs.
* @param {string} text1 First string.
* @param {string} text2 Second string.
* @return {Array.} Five element Array, containing the prefix of
* text1, the suffix of text1, the prefix of text2, the suffix of
* text2 and the common middle. Or null if there was no match.
*/
function diff_halfMatch_(text1, text2) {
var longtext = text1.length > text2.length ? text1 : text2;
var shorttext = text1.length > text2.length ? text2 : text1;
if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
return null; // Pointless.
}
/**
* Does a substring of shorttext exist within longtext such that the substring
* is at least half the length of longtext?
* Closure, but does not reference any external variables.
* @param {string} longtext Longer string.
* @param {string} shorttext Shorter string.
* @param {number} i Start index of quarter length substring within longtext.
* @return {Array.} Five element Array, containing the prefix of
* longtext, the suffix of longtext, the prefix of shorttext, the suffix
* of shorttext and the common middle. Or null if there was no match.
* @private
*/
function diff_halfMatchI_(longtext, shorttext, i) {
// Start with a 1/4 length substring at position i as a seed.
var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
var j = -1;
var best_common = '';
var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
var prefixLength = diff_commonPrefix(longtext.substring(i), shorttext.substring(j));
var suffixLength = diff_commonSuffix(longtext.substring(0, i), shorttext.substring(0, j));
if (best_common.length < suffixLength + prefixLength) {
best_common = shorttext.substring(j - suffixLength, j) + shorttext.substring(j, j + prefixLength);
best_longtext_a = longtext.substring(0, i - suffixLength);
best_longtext_b = longtext.substring(i + prefixLength);
best_shorttext_a = shorttext.substring(0, j - suffixLength);
best_shorttext_b = shorttext.substring(j + prefixLength);
}
}
if (best_common.length * 2 >= longtext.length) {
return [best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b, best_common];
} else {
return null;
}
} // First check if the second quarter is the seed for a half-match.
var hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4)); // Check again based on the third quarter.
var hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
var hm;
if (!hm1 && !hm2) {
return null;
} else if (!hm2) {
hm = hm1;
} else if (!hm1) {
hm = hm2;
} else {
// Both matched. Select the longest.
hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
} // A half-match was found, sort out the return data.
var text1_a, text1_b, text2_a, text2_b;
if (text1.length > text2.length) {
text1_a = hm[0];
text1_b = hm[1];
text2_a = hm[2];
text2_b = hm[3];
} else {
text2_a = hm[0];
text2_b = hm[1];
text1_a = hm[2];
text1_b = hm[3];
}
var mid_common = hm[4];
return [text1_a, text1_b, text2_a, text2_b, mid_common];
}
/**
* Reorder and merge like edit sections. Merge equalities.
* Any edit section can move as long as it doesn't cross an equality.
* @param {Array} diffs Array of diff tuples.
* @param {boolean} fix_unicode Whether to normalize to a unicode-correct diff
*/
function diff_cleanupMerge(diffs, fix_unicode) {
diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
var pointer = 0;
var count_delete = 0;
var count_insert = 0;
var text_delete = '';
var text_insert = '';
var commonlength;
var previous_equality;
while (pointer < diffs.length) {
if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
diffs.splice(pointer, 1);
continue;
}
switch (diffs[pointer][0]) {
case DIFF_INSERT:
count_insert++;
text_insert += diffs[pointer][1];
pointer++;
break;
case DIFF_DELETE:
count_delete++;
text_delete += diffs[pointer][1];
pointer++;
break;
case DIFF_EQUAL:
previous_equality = pointer - count_insert - count_delete - 1;
if (fix_unicode) {
// prevent splitting of unicode surrogate pairs. when fix_unicode is true,
// we assume that the old and new text in the diff are complete and correct
// unicode-encoded JS strings, but the tuple boundaries may fall between
// surrogate pairs. we fix this by shaving off stray surrogates from the end
// of the previous equality and the beginning of this equality. this may create
// empty equalities or a common prefix or suffix. for example, if AB and AC are
// emojis, `[[0, 'A'], [-1, 'BA'], [0, 'C']]` would turn into deleting 'ABAC' and
// inserting 'AC', and then the common suffix 'AC' will be eliminated. in this
// particular case, both equalities go away, we absorb any previous inequalities,
// and we keep scanning for the next equality before rewriting the tuples.
if (previous_equality >= 0 && ends_with_pair_start(diffs[previous_equality][1])) {
var stray = diffs[previous_equality][1].slice(-1);
diffs[previous_equality][1] = diffs[previous_equality][1].slice(0, -1);
text_delete = stray + text_delete;
text_insert = stray + text_insert;
if (!diffs[previous_equality][1]) {
// emptied out previous equality, so delete it and include previous delete/insert
diffs.splice(previous_equality, 1);
pointer--;
var k = previous_equality - 1;
if (diffs[k] && diffs[k][0] === DIFF_INSERT) {
count_insert++;
text_insert = diffs[k][1] + text_insert;
k--;
}
if (diffs[k] && diffs[k][0] === DIFF_DELETE) {
count_delete++;
text_delete = diffs[k][1] + text_delete;
k--;
}
previous_equality = k;
}
}
if (starts_with_pair_end(diffs[pointer][1])) {
var _stray = diffs[pointer][1].charAt(0);
diffs[pointer][1] = diffs[pointer][1].slice(1);
text_delete += _stray;
text_insert += _stray;
}
}
if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
// for empty equality not at end, wait for next equality
diffs.splice(pointer, 1);
break;
}
if (text_delete.length > 0 || text_insert.length > 0) {
// note that diff_commonPrefix and diff_commonSuffix are unicode-aware
if (text_delete.length > 0 && text_insert.length > 0) {
// Factor out any common prefixes.
commonlength = diff_commonPrefix(text_insert, text_delete);
if (commonlength !== 0) {
if (previous_equality >= 0) {
diffs[previous_equality][1] += text_insert.substring(0, commonlength);
} else {
diffs.splice(0, 0, [DIFF_EQUAL, text_insert.substring(0, commonlength)]);
pointer++;
}
text_insert = text_insert.substring(commonlength);
text_delete = text_delete.substring(commonlength);
} // Factor out any common suffixes.
commonlength = diff_commonSuffix(text_insert, text_delete);
if (commonlength !== 0) {
diffs[pointer][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
text_insert = text_insert.substring(0, text_insert.length - commonlength);
text_delete = text_delete.substring(0, text_delete.length - commonlength);
}
} // Delete the offending records and add the merged ones.
var n = count_insert + count_delete;
if (text_delete.length === 0 && text_insert.length === 0) {
diffs.splice(pointer - n, n);
pointer = pointer - n;
} else if (text_delete.length === 0) {
diffs.splice(pointer - n, n, [DIFF_INSERT, text_insert]);
pointer = pointer - n + 1;
} else if (text_insert.length === 0) {
diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete]);
pointer = pointer - n + 1;
} else {
diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete], [DIFF_INSERT, text_insert]);
pointer = pointer - n + 2;
}
}
if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
// Merge this equality with the previous one.
diffs[pointer - 1][1] += diffs[pointer][1];
diffs.splice(pointer, 1);
} else {
pointer++;
}
count_insert = 0;
count_delete = 0;
text_delete = '';
text_insert = '';
break;
}
}
if (diffs[diffs.length - 1][1] === '') {
diffs.pop(); // Remove the dummy entry at the end.
} // Second pass: look for single edits surrounded on both sides by equalities
// which can be shifted sideways to eliminate an equality.
// e.g: ABA C -> AB AC
var changes = false;
pointer = 1; // Intentionally ignore the first and last element (don't need checking).
while (pointer < diffs.length - 1) {
if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
// This is a single edit surrounded by equalities.
if (diffs[pointer][1].substring(diffs[pointer][1].length - diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
// Shift the edit over the previous equality.
diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);
diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
diffs.splice(pointer - 1, 1);
changes = true;
} else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == diffs[pointer + 1][1]) {
// Shift the edit over the next equality.
diffs[pointer - 1][1] += diffs[pointer + 1][1];
diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];
diffs.splice(pointer + 1, 1);
changes = true;
}
}
pointer++;
} // If shifts were made, the diff needs reordering and another shift sweep.
if (changes) {
diff_cleanupMerge(diffs, fix_unicode);
}
}
function is_surrogate_pair_start(charCode) {
return charCode >= 0xD800 && charCode <= 0xDBFF;
}
function is_surrogate_pair_end(charCode) {
return charCode >= 0xDC00 && charCode <= 0xDFFF;
}
function starts_with_pair_end(str) {
return is_surrogate_pair_end(str.charCodeAt(0));
}
function ends_with_pair_start(str) {
return is_surrogate_pair_start(str.charCodeAt(str.length - 1));
}
function remove_empty_tuples(tuples) {
var ret = [];
for (var i = 0; i < tuples.length; i++) {
if (tuples[i][1].length > 0) {
ret.push(tuples[i]);
}
}
return ret;
}
function make_edit_splice(before, oldMiddle, newMiddle, after) {
if (ends_with_pair_start(before) || starts_with_pair_end(after)) {
return null;
}
return remove_empty_tuples([[DIFF_EQUAL, before], [DIFF_DELETE, oldMiddle], [DIFF_INSERT, newMiddle], [DIFF_EQUAL, after]]);
}
function find_cursor_edit_diff(oldText, newText, cursor_pos) {
// note: this runs after equality check has ruled out exact equality
var oldRange = typeof cursor_pos === 'number' ? {
index: cursor_pos,
length: 0
} : cursor_pos.oldRange;
var newRange = typeof cursor_pos === 'number' ? null : cursor_pos.newRange; // take into account the old and new selection to generate the best diff
// possible for a text edit. for example, a text change from "xxx" to "xx"
// could be a delete or forwards-delete of any one of the x's, or the
// result of selecting two of the x's and typing "x".
var oldLength = oldText.length;
var newLength = newText.length;
if (oldRange.length === 0 && (newRange === null || newRange.length === 0)) {
// see if we have an insert or delete before or after cursor
var oldCursor = oldRange.index;
var oldBefore = oldText.slice(0, oldCursor);
var oldAfter = oldText.slice(oldCursor);
var maybeNewCursor = newRange ? newRange.index : null;
editBefore: {
// is this an insert or delete right before oldCursor?
var newCursor = oldCursor + newLength - oldLength;
if (maybeNewCursor !== null && maybeNewCursor !== newCursor) {
break editBefore;
}
if (newCursor < 0 || newCursor > newLength) {
break editBefore;
}
var newBefore = newText.slice(0, newCursor);
var newAfter = newText.slice(newCursor);
if (newAfter !== oldAfter) {
break editBefore;
}
var prefixLength = Math.min(oldCursor, newCursor);
var oldPrefix = oldBefore.slice(0, prefixLength);
var newPrefix = newBefore.slice(0, prefixLength);
if (oldPrefix !== newPrefix) {
break editBefore;
}
var oldMiddle = oldBefore.slice(prefixLength);
var newMiddle = newBefore.slice(prefixLength);
return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldAfter);
}
editAfter: {
// is this an insert or delete right after oldCursor?
if (maybeNewCursor !== null && maybeNewCursor !== oldCursor) {
break editAfter;
}
var cursor = oldCursor;
var _newBefore = newText.slice(0, cursor);
var _newAfter = newText.slice(cursor);
if (_newBefore !== oldBefore) {
break editAfter;
}
var suffixLength = Math.min(oldLength - cursor, newLength - cursor);
var oldSuffix = oldAfter.slice(oldAfter.length - suffixLength);
var newSuffix = _newAfter.slice(_newAfter.length - suffixLength);
if (oldSuffix !== newSuffix) {
break editAfter;
}
var _oldMiddle = oldAfter.slice(0, oldAfter.length - suffixLength);
var _newMiddle = _newAfter.slice(0, _newAfter.length - suffixLength);
return make_edit_splice(oldBefore, _oldMiddle, _newMiddle, oldSuffix);
}
}
if (oldRange.length > 0 && newRange && newRange.length === 0) {
replaceRange: {
// see if diff could be a splice of the old selection range
var _oldPrefix = oldText.slice(0, oldRange.index);
var _oldSuffix = oldText.slice(oldRange.index + oldRange.length);
var _prefixLength = _oldPrefix.length;
var _suffixLength = _oldSuffix.length;
if (newLength < _prefixLength + _suffixLength) {
break replaceRange;
}
var _newPrefix = newText.slice(0, _prefixLength);
var _newSuffix = newText.slice(newLength - _suffixLength);
if (_oldPrefix !== _newPrefix || _oldSuffix !== _newSuffix) {
break replaceRange;
}
var _oldMiddle2 = oldText.slice(_prefixLength, oldLength - _suffixLength);
var _newMiddle2 = newText.slice(_prefixLength, newLength - _suffixLength);
return make_edit_splice(_oldPrefix, _oldMiddle2, _newMiddle2, _oldSuffix);
}
}
return null;
}
function diff(text1, text2, cursor_pos) {
// only pass fix_unicode=true at the top level, not when diff_main is
// recursively invoked
return diff_main(text1, text2, cursor_pos, true);
}
diff.INSERT = DIFF_INSERT;
diff.DELETE = DIFF_DELETE;
diff.EQUAL = DIFF_EQUAL;
/* harmony default export */ __webpack_exports__["default"] = (diff);
/***/ }),
/***/ "./js/util/testConsole.js":
/*!********************************!*\
!*** ./js/util/testConsole.js ***!
\********************************/
/*! exports provided: TestConsole */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TestConsole", function() { return TestConsole; });
/* harmony import */ var _io_domConsole__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../io/domConsole */ "./js/io/domConsole.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../services/localizedStringsService */ "./js/services/localizedStringsService.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var LocalizedStrings = Object(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["getInstance"])();
var TestConsole =
/*#__PURE__*/
function () {
function TestConsole(inputList) {
_classCallCheck(this, TestConsole);
this.index = 0;
this.inputList = inputList;
this.list = [];
}
_createClass(TestConsole, [{
key: "write",
value: function write(text) {
this._appendText(text, _io_domConsole__WEBPACK_IMPORTED_MODULE_0__["DOMConsole"].USER);
}
}, {
key: "info",
value: function info(text) {
this._appendText(text, _io_domConsole__WEBPACK_IMPORTED_MODULE_0__["DOMConsole"].INFO);
}
}, {
key: "err",
value: function err(text) {
this._appendText(text, _io_domConsole__WEBPACK_IMPORTED_MODULE_0__["DOMConsole"].ERR);
}
}, {
key: "_appendText",
value: function _appendText(text) {
this.list.push(text);
}
}, {
key: "getClassForType",
value: function getClassForType(type) {
switch (type) {
case _io_domConsole__WEBPACK_IMPORTED_MODULE_0__["DOMConsole"].USER:
return "ivprog-term-userText";
case _io_domConsole__WEBPACK_IMPORTED_MODULE_0__["DOMConsole"].INFO:
return "ivprog-term-info";
case _io_domConsole__WEBPACK_IMPORTED_MODULE_0__["DOMConsole"].ERR:
return "ivprog-term-error";
}
}
}, {
key: "requestInput",
value: function requestInput(callback) {
if (this.index < this.inputList.length) {
callback(this.inputList[this.index]);
this.index++;
} else {
throw new Error(LocalizedStrings.getError("exceeded_input_request"));
}
}
}, {
key: "sendOutput",
value: function sendOutput(text) {
var _this = this;
var output = "" + text;
output.split("\n").forEach(function (t) {
t = t.replace(/\t/g, ' ');
_this.write(t);
});
}
}]);
return TestConsole;
}();
/***/ }),
/***/ "./js/util/utils.js":
/*!**************************!*\
!*** ./js/util/utils.js ***!
\**************************/
/*! exports provided: scrollIt, isElementInViewport, isKeyword, isValidIdentifier, getCodeEditorModeConfig, levenshteinDistance, openAssessmentDetail, range */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scrollIt", function() { return scrollIt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isElementInViewport", function() { return isElementInViewport; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isKeyword", function() { return isKeyword; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidIdentifier", function() { return isValidIdentifier; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCodeEditorModeConfig", function() { return getCodeEditorModeConfig; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "levenshteinDistance", function() { return levenshteinDistance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "openAssessmentDetail", function() { return openAssessmentDetail; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "range", function() { return range; });
/* harmony import */ var _services_languageService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../services/languageService */ "./js/services/languageService.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _ast_operators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../ast/operators */ "./js/ast/operators.js");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
/**
* source: https://pawelgrzybek.com/page-scroll-in-vanilla-javascript/
*
*/
function scrollIt(destination) {
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
var easing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'linear';
var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var easings = {
linear: function linear(t) {
return t;
},
easeInQuad: function easeInQuad(t) {
return t * t;
},
easeOutQuad: function easeOutQuad(t) {
return t * (2 - t);
},
easeInOutQuad: function easeInOutQuad(t) {
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
},
easeInCubic: function easeInCubic(t) {
return t * t * t;
},
easeOutCubic: function easeOutCubic(t) {
return --t * t * t + 1;
},
easeInOutCubic: function easeInOutCubic(t) {
return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
},
easeInQuart: function easeInQuart(t) {
return t * t * t * t;
},
easeOutQuart: function easeOutQuart(t) {
return 1 - --t * t * t * t;
},
easeInOutQuart: function easeInOutQuart(t) {
return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
},
easeInQuint: function easeInQuint(t) {
return t * t * t * t * t;
},
easeOutQuint: function easeOutQuint(t) {
return 1 + --t * t * t * t * t;
},
easeInOutQuint: function easeInOutQuint(t) {
return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
}
};
var start = window.pageYOffset;
var startTime = 'now' in window.performance ? performance.now() : new Date().getTime();
var documentHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);
var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;
var destinationOffset = typeof destination === 'number' ? destination : destination.offsetTop;
var destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset);
if ('requestAnimationFrame' in window === false) {
window.scroll(0, destinationOffsetToScroll);
if (callback) {
callback();
}
return;
}
function scroll() {
var now = 'now' in window.performance ? performance.now() : new Date().getTime();
var time = Math.min(1, (now - startTime) / duration);
var timeFunction = easings[easing](time);
window.scroll(0, Math.ceil(timeFunction * (destinationOffsetToScroll - start) + start));
if (window.pageYOffset === destinationOffsetToScroll) {
if (callback) {
callback();
}
return;
}
requestAnimationFrame(scroll);
}
scroll();
}
/**
*
* source: https://stackoverflow.com/a/16270434
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return rect.bottom > 0 && rect.right > 0 && rect.left < (window.innerWidth || document.documentElement.clientWidth) && rect.top < (window.innerHeight || document.documentElement.clientHeight);
}
var cacheMainList = null;
var cacheOp = null;
function fillCache() {
if (cacheMainList == null) {
cacheMainList = [];
var mainList = ["RK_PROGRAM", "RK_REAL", "RK_VOID", "RK_BOOLEAN", "RK_STRING", "RK_INTEGER", "RK_CHARACTER", "RK_SWITCH", "RK_CASE", "RK_DEFAULT", "RK_CONST", "RK_FUNCTION", "RK_RETURN", "RK_FOR", "RK_BREAK", "RK_DO", "RK_WHILE", "RK_IF", "RK_ELSE", "RK_FALSE", "RK_TRUE"];
var lexerClass = _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLexer();
var nullLexer = new lexerClass();
for (var key = 0; key < mainList.length; ++key) {
var word = mainList[key];
var keyword = nullLexer.literalNames[lexerClass[word]];
cacheMainList.push(keyword.substring(1, keyword.length - 1));
}
}
if (cacheOp == null) {
cacheOp = [];
var logicOpList = [_ast_operators__WEBPACK_IMPORTED_MODULE_2__["Operators"].AND.value, _ast_operators__WEBPACK_IMPORTED_MODULE_2__["Operators"].OR.value, _ast_operators__WEBPACK_IMPORTED_MODULE_2__["Operators"].NOT.value];
for (var op = 0; op < logicOpList.length; ++op) {
var lOp = "logic_operator_".concat(logicOpList[op]);
cacheOp.push(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI(lOp));
}
}
}
function isKeyword(text) {
fillCache();
for (var key = 0; key < cacheMainList.length; ++key) {
var keyword = cacheMainList[key];
if (keyword == text) {
return true;
}
} // not in main list, check op
for (var op = 0; op < cacheOp.length; op++) {
var lOp = cacheOp[op];
if (lOp == text) {
return true;
}
}
return false;
}
function isValidIdentifier(identifier_str) {
var validRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier_str);
if (!validRegex) {
return false;
}
return !isKeyword(identifier_str);
}
function getCodeEditorModeConfig() {
var blockList = ["RK_SWITCH", "RK_PROGRAM", "RK_CASE", "RK_DEFAULT", "RK_FOR", "RK_FOR_ALT", "RK_FUNCTION", "RK_DO", "RK_WHILE", "RK_WHILE_ALT", "RK_IF", "RK_ELSE"];
var keywordsList = ["RK_CONST", "RK_RETURN", "RK_BREAK", "RK_FOR_FROM", "RK_FOR_TO", "RK_FOR_PASS", "RK_DO_UNTIL"];
var typeList = ["RK_REAL", "RK_VOID", "RK_BOOLEAN", "RK_STRING", "RK_INTEGER"];
var atomList = ["RK_FALSE", "RK_TRUE"];
var case_default = [];
var blocks = [];
var keywords = [];
var types = [];
var atoms = [];
var switchString = "";
cacheMainList = [];
var lexerClass = _services_languageService__WEBPACK_IMPORTED_MODULE_0__["LanguageService"].getCurrentLexer();
var nullLexer = new lexerClass();
blockList.forEach(function (v) {
var keyword = nullLexer.literalNames[lexerClass[v]];
var value = keyword.substring(1, keyword.length - 1);
cacheMainList.push(value);
keywords.push(value);
blocks.push(value);
if (v == "RK_SWITCH") {
switchString = value;
} else if (v == "RK_CASE" || v == "RK_DEFAULT") {
case_default.push(value);
}
});
keywordsList.forEach(function (v) {
var keyword = nullLexer.literalNames[lexerClass[v]];
var value = keyword.substring(1, keyword.length - 1);
cacheMainList.push(value);
keywords.push(value);
});
typeList.forEach(function (v) {
var keyword = nullLexer.literalNames[lexerClass[v]];
var value = keyword.substring(1, keyword.length - 1);
cacheMainList.push(value);
types.push(value);
});
atomList.forEach(function (v) {
var keyword = nullLexer.literalNames[lexerClass[v]];
var value = keyword.substring(1, keyword.length - 1);
cacheMainList.push(value);
atoms.push(value);
});
cacheOp = [];
var logicOpList = [_ast_operators__WEBPACK_IMPORTED_MODULE_2__["Operators"].AND.value, _ast_operators__WEBPACK_IMPORTED_MODULE_2__["Operators"].OR.value, _ast_operators__WEBPACK_IMPORTED_MODULE_2__["Operators"].NOT.value];
for (var op = 0; op < logicOpList.length; ++op) {
var lOp = "logic_operator_".concat(logicOpList[op]);
var value = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI(lOp);
cacheOp.push(value);
keywords.push(value);
}
return {
case_default: case_default,
atoms: atoms,
keywords: keywords,
switchString: switchString,
types: types,
blocks: blocks
};
}
/**
* Source: https://gist.github.com/andrei-m/982927
* @param {string} a
* @param {string} b
*/
function levenshteinDistance(a, b) {
if (a.length == 0) return b.length;
if (b.length == 0) return a.length;
var matrix = []; // increment along the first column of each row
var i;
for (i = 0; i <= b.length; i++) {
matrix[i] = [i];
} // increment each column in the first row
var j;
for (j = 0; j <= a.length; j++) {
matrix[0][j] = j;
} // Fill in the rest of the matrix
for (i = 1; i <= b.length; i++) {
for (j = 1; j <= a.length; j++) {
if (b.charCodeAt(i - 1) == a.charCodeAt(j - 1)) {
matrix[i][j] = matrix[i - 1][j - 1];
} else {
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // substitution
Math.min(matrix[i][j - 1] + 1, // insertion
matrix[i - 1][j] + 1)); // deletion
}
}
}
return matrix[b.length][a.length];
}
var win = null;
function openAssessmentDetail(event) {
event.preventDefault();
var page_code = event.currentTarget.dataset.page;
if (win != null) {
win.close();
}
win = window.open("", "DetailWindow", "width=550,height=600");
win.document.open();
win.document.write(page_code);
win.document.close();
}
function range(size) {
var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return _toConsumableArray(Array(size).keys()).map(function (i) {
return i + startAt;
});
}
/***/ }),
/***/ "./js/visualUI/algorithm.js":
/*!**********************************!*\
!*** ./js/visualUI/algorithm.js ***!
\**********************************/
/*! exports provided: renderAlgorithm */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderAlgorithm", function() { return renderAlgorithm; });
/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./globals */ "./js/visualUI/globals.js");
/* harmony import */ var _functions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./functions */ "./js/visualUI/functions.js");
window.block_render = false;
function renderAlgorithm() {
if (window.block_render) {
return;
}
if (window.draging) {
return;
}
window.block_render = true;
console.log('rendering algorithm');
$('.all_functions').children().off();
$('.all_functions').empty();
$('.list_globals').children().off();
$('.list_globals').empty();
for (var i = 0; i < window.program_obj.functions.length; i++) {
_functions__WEBPACK_IMPORTED_MODULE_1__["renderFunction"](window.program_obj.functions[i]);
}
for (var i = 0; i < window.program_obj.globals.length; i++) {
_globals__WEBPACK_IMPORTED_MODULE_0__["renderGlobal"](window.program_obj.globals[i]);
}
setTimeout(function () {
window.block_render = false;
}, 100);
console.log('fim do render');
if (settingsFilter && settingsFilter[0]) {
blockAllEditingOptions();
}
}
/***/ }),
/***/ "./js/visualUI/code_generator.js":
/*!***************************************!*\
!*** ./js/visualUI/code_generator.js ***!
\***************************************/
/*! exports provided: generate */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generate", function() { return generate; });
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./js/visualUI/utils.js");
function generate() {
$('.ivprog_visual_panel').find('.error_icon').remove();
var code = _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('program') + ' { ';
code += globalsCode();
code += '\n';
var has_error = false;
for (var i = 0; i < window.program_obj.functions.length; i++) {
var n_code = functionsCode(window.program_obj.functions[i]);
if (n_code == null) {
has_error = true;
}
code += n_code;
code += '\n';
}
code += '\n}';
if (has_error) {
return null;
} else {
return code;
}
}
function functionsCode(function_obj) {
var ret = '\n\t' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('function') + ' ';
var has_error = false;
switch (function_obj.return_type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_integer');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_real');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_text');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_boolean');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].VOID:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_void');
break;
}
ret += ' ';
if (function_obj.return_dimensions == 1) {
ret += '[] ';
} else if (function_obj.return_dimensions == 2) {
ret += '[][] ';
}
ret += function_obj.name + ' ( ';
for (var j = 0; j < function_obj.parameters_list.length; j++) {
ret += parametersCode(function_obj.parameters_list[j]);
if (j + 1 < function_obj.parameters_list.length) {
ret += ', ';
}
}
ret += ' ) {';
for (var j = 0; j < function_obj.variables_list.length; j++) {
ret += variablesCode(function_obj.variables_list[j]);
}
for (var j = 0; j < function_obj.commands.length; j++) {
//try {
ret += commandsCode(function_obj.commands[j]);
/*} catch (err) {
has_error = true;
console.error(err.message);
var todos = $('body').find('.command_container');
for (var i = 0; i < todos.length; i++) {
if ($(todos[i]).data('command') == function_obj.commands[j]) {
$( todos[i] ).prepend( ' ' );
break;
}
}
}*/
}
ret += '\n\t}';
if (has_error) {
return null;
} else {
return ret;
}
}
function commandsCode(command_obj) {
var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
switch (command_obj.type) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"]["break"]:
return breaksCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].comment:
return commentsCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].reader:
return readersCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].writer:
return writersCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].functioncall:
return functioncallsCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].attribution:
return attributionsCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].whiletrue:
return whiletruesCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].dowhiletrue:
return doWhilesCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].iftrue:
return iftruesCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].repeatNtimes:
return repeatNtimesCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"]["switch"]:
return switchsCode(command_obj, indentation);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"]["return"]:
return returnsCode(command_obj, indentation);
}
}
function returnsCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_return');
if (command_obj.variable_value_menu) {
try {
ret += ' ' + elementExpressionCode(command_obj.variable_value_menu); //ret += ' ' + variableValueMenuCode(command_obj.variable_value_menu, true);
} catch (err) {}
}
return ret;
}
function breaksCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_break');
return ret;
}
function switchsCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_switch') + ' ( ';
ret += variableValueMenuCode(command_obj.variable);
ret += ' ) { ';
if (command_obj.cases) {
for (var i = 0; i < command_obj.cases.length; i++) {
ret += switchcasesCode(command_obj.cases[i], indentation + 1);
}
}
ret += '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '} ';
return ret;
}
function switchcasesCode(switchcase, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_case') + ' ';
ret += variableValueMenuCode(switchcase.variable_value_menu);
ret += ' :';
if (switchcase.commands_block) {
for (var i = 0; i < switchcase.commands_block.length; i++) {
ret += commandsCode(switchcase.commands_block[i], indentation + 1);
}
}
return ret;
}
function repeatNtimesCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_for') + ' ';
if (command_obj.var_attribution) {
ret += variableValueMenuCode(command_obj.var_attribution);
ret += " ".concat(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_for_from'), " ");
ret += variableValueMenuCode(command_obj.expression1);
}
if (command_obj.expression2) {
ret += " ".concat(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_for_to'), " ");
ret += variableValueMenuCode(command_obj.expression2);
}
if (command_obj.expression3) {
ret += " ".concat(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_for_pass'), " ");
switch (command_obj.expression3.itens[1]) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].plus:
ret += ' +';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].minus:
ret += ' -';
break;
}
ret += variableValueMenuCode(command_obj.expression3.itens[2]);
}
/*if (command_obj.var_incrementation) {
ret += variableValueMenuCode(command_obj.var_incrementation);
ret += ' <- ';
ret += variableValueMenuCode(command_obj.expression3.itens[0]);
switch (command_obj.expression3.itens[1]) {
case Models.ARITHMETIC_TYPES.plus:
ret += ' + ';
break;
case Models.ARITHMETIC_TYPES.minus:
ret += ' - ';
break;
case Models.ARITHMETIC_TYPES.multiplication:
ret += ' * ';
break;
case Models.ARITHMETIC_TYPES.division:
ret += ' / ';
break;
case Models.ARITHMETIC_TYPES.module:
ret += ' % ';
break;
}
ret += variableValueMenuCode(command_obj.expression3.itens[2]);
}*/
ret += ' { ';
if (command_obj.commands_block) {
for (var i = 0; i < command_obj.commands_block.length; i++) {
ret += commandsCode(command_obj.commands_block[i], indentation + 1);
}
}
ret += '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '}';
return ret;
}
function iftruesCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_if');
if (!command_obj.expression) {
_utils__WEBPACK_IMPORTED_MODULE_3__["renderErrorMessage"](command_obj.expression.dom_object, _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('inform_valid_expression'));
} else {
ret += ' ( ';
ret += elementExpressionCode(command_obj.expression);
ret += ' ) ';
}
/*switch (command_obj.expression.expression.type) {
case Models.EXPRESSION_TYPES.exp_logic:
ret += logicExpressionCode(command_obj.expression.expression);
break;
case Models.EXPRESSION_TYPES.exp_arithmetic:
ret += arithmeticExpressionCode(command_obj.expression.expression);
break;
}*/
ret += ' { ';
if (command_obj.commands_block) {
for (var i = 0; i < command_obj.commands_block.length; i++) {
ret += commandsCode(command_obj.commands_block[i], indentation + 1);
}
}
ret += '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '} ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_else') + ' {';
if (command_obj.commands_else) {
for (var i = 0; i < command_obj.commands_else.length; i++) {
ret += commandsCode(command_obj.commands_else[i], indentation + 1);
}
}
ret += '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '}';
return ret;
}
function doWhilesCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_do') + ' { ';
if (command_obj.commands_block) {
for (var i = 0; i < command_obj.commands_block.length; i++) {
ret += commandsCode(command_obj.commands_block[i], indentation + 1);
}
}
ret += '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '} ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_do_until');
if (!command_obj.expression) {
_utils__WEBPACK_IMPORTED_MODULE_3__["renderErrorMessage"](command_obj.expression.dom_object, _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('inform_valid_expression'));
}
/*switch (command_obj.expression.expression.type) {
case Models.EXPRESSION_TYPES.exp_logic:
ret += logicExpressionCode(command_obj.expression.expression);
break;
case Models.EXPRESSION_TYPES.exp_arithmetic:
ret += arithmeticExpressionCode(command_obj.expression.expression);
break;
}*/
if (command_obj.expression) {
ret += ' ( ';
ret += elementExpressionCode(command_obj.expression);
ret += ' ) ';
}
return ret;
}
function whiletruesCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_code_while');
if (!command_obj.expression) {
_utils__WEBPACK_IMPORTED_MODULE_3__["renderErrorMessage"](command_obj.expression.dom_object, _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('inform_valid_expression'));
}
/*switch (command_obj.expression.expression.type) {
case Models.EXPRESSION_TYPES.exp_logic:
ret += logicExpressionCode(command_obj.expression.expression);
break;
case Models.EXPRESSION_TYPES.exp_arithmetic:
ret += arithmeticExpressionCode(command_obj.expression.expression);
break;
}*/
if (command_obj.expression) {
ret += ' ( ';
ret += elementExpressionCode(command_obj.expression);
ret += ' ) ';
}
ret += ' { ';
if (command_obj.commands_block) {
for (var i = 0; i < command_obj.commands_block.length; i++) {
ret += commandsCode(command_obj.commands_block[i], indentation + 1);
}
}
ret += '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '}';
return ret;
}
function logicExpressionCode(expression) {
var ret = ' ( ';
if (expression.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic) {
ret += logicExpressionCode(expression.first_operand);
} else if (expression.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic) {
ret += arithmeticExpressionCode(expression.first_operand);
} else {
ret += variableValueMenuCode(expression.first_operand);
}
if (expression.operator) {
switch (expression.operator) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].equals_to:
ret += ' == ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].not_equals_to:
ret += ' != ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].and:
ret += ' && ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].or:
ret += ' || ';
break;
}
if (expression.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic) {
ret += logicExpressionCode(expression.second_operand);
} else if (expression.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic) {
ret += arithmeticExpressionCode(expression.second_operand);
} else {
ret += variableValueMenuCode(expression.second_operand);
}
}
ret += ' ) ';
return ret;
}
function arithmeticExpressionCode(expression) {
var ret = ' ( ';
if (expression.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic) {
ret += logicExpressionCode(expression.first_operand);
} else if (expression.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic) {
ret += arithmeticExpressionCode(expression.first_operand);
} else {
ret += variableValueMenuCode(expression.first_operand);
}
switch (expression.operator) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].greater_than:
ret += ' > ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].less_than:
ret += ' < ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].equals_to:
ret += ' == ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].not_equals_to:
ret += ' != ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].greater_than_or_equals_to:
ret += ' >= ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].less_than_or_equals_to:
ret += ' <= ';
break;
}
if (expression.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic) {
ret += logicExpressionCode(expression.second_operand);
} else if (expression.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic) {
ret += arithmeticExpressionCode(expression.second_operand);
} else {
ret += variableValueMenuCode(expression.second_operand);
}
ret += ' ) ';
return ret;
}
function attributionsCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += variableValueMenuCode(command_obj.variable) + ' <- ';
/*for (var i = 0; i < command_obj.expression.length; i++) {
ret += elementExpressionCode(command_obj.expression[i]);
}*/
ret += elementExpressionCode(command_obj.expression);
return ret;
}
function elementExpressionCode(expression_obj) {
var ret = '';
for (var i = 0; i < expression_obj.length; i++) {
if (expression_obj[i].type) {
ret += variableValueMenuCode(expression_obj[i]);
} else if (expression_obj[i].type_op) {
switch (expression_obj[i].item) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].plus:
ret += ' + ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].minus:
ret += ' - ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].multiplication:
ret += ' * ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].division:
ret += ' / ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].module:
ret += ' % ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].equals_to:
ret += ' == ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].not_equals_to:
ret += ' != ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].and:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_operator_and') + ' ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].or:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_operator_or') + ' ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].not:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_operator_not') + ' ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].greater_than:
ret += ' > ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].less_than:
ret += ' < ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].greater_than_or_equals_to:
ret += ' >= ';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].less_than_or_equals_to:
ret += ' <= ';
break;
}
} else {
ret += ' ' + expression_obj[i] + ' ';
}
}
return ret;
}
function functioncallsCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += variableValueMenuCode(command_obj.function_called);
return ret;
}
function readersCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_command_read') + ' ( ';
ret += variableValueMenuCode(command_obj.variable_value_menu);
ret += ' ) ';
return ret;
}
function variableValueMenuCode(variable_obj) {
var is_return = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var ret = '';
try {
if (variable_obj.function_called) {
if (variable_obj.function_called.name) {
ret += variable_obj.function_called.name + ' ( ';
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].translateInternalFunction(variable_obj.function_called.identifier, variable_obj.function_called.category) + ' ( ';
}
if (variable_obj.parameters_list) {
for (var i = 0; i < variable_obj.parameters_list.length; i++) {
ret += variableValueMenuCode(variable_obj.parameters_list[i]);
if (i + 1 < variable_obj.parameters_list.length) {
ret += ', ';
}
}
}
ret += ' )';
} else if (variable_obj.content.type) {
ret += variable_obj.content.name;
if (variable_obj.content.dimensions == 1 && variable_obj.dimensions != 1) {
ret += ' [ ' + variableValueMenuCode(variable_obj.column) + ' ] ';
}
if (variable_obj.content.dimensions == 2 && variable_obj.dimensions != 2) {
ret += ' [ ' + variableValueMenuCode(variable_obj.row) + ' ] ';
ret += ' [ ' + variableValueMenuCode(variable_obj.column) + ' ] ';
}
} else {
if (isNaN(variable_obj.content)) {
ret += '"' + variable_obj.content + '"';
} else {
ret += variable_obj.content;
}
}
} catch (err) {
if (!is_return) {
_utils__WEBPACK_IMPORTED_MODULE_3__["renderErrorMessage"](variable_obj.dom_object, _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('inform_valid_content'));
throw err;
}
}
return ret;
}
function writersCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('text_command_write') + ' ( ';
/*for (var i = 0; i < command_obj.content.length; i++) {
ret += variableValueMenuCode(command_obj.content[i]);
if ((i + 1) < command_obj.content.length) {
ret += ' + ';
}
}*/
ret += elementExpressionCode(command_obj.content);
ret += ' ) ';
return ret;
}
function commentsCode(command_obj, indentation) {
var ret = '\n';
for (var i = 0; i < indentation; i++) {
ret += '\t';
}
ret += '// ';
ret += command_obj.comment_text.content;
return ret;
}
function parametersCode(parameter_obj) {
var ret = '';
switch (parameter_obj.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_integer') + ' ';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_real') + ' ';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_text') + ' ';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_boolean') + ' ';
break;
}
ret += parameter_obj.name + '';
if (parameter_obj.dimensions == 1) {
ret += ' []';
} else if (parameter_obj.dimensions == 2) {
ret += ' [][]';
}
return ret;
}
function variablesCode(variable_obj) {
var ret = '';
var temp = variable_obj;
ret += '\n\t\t';
if (temp.is_constant) {
ret += 'const ';
}
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_integer') + ' ';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_real') + ' ';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_text') + ' ';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_boolean') + ' ';
break;
}
ret += temp.name + ' ';
if (temp.dimensions == 1) {
ret += '[' + temp.columns + '] ';
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
ret += temp.value[j];
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
ret += temp.value[j].toFixed(2);
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
ret += '"' + temp.value[j] + '"';
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
if (temp.value[j]) {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_true');
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_false');
}
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
}
} else if (temp.dimensions == 2) {
ret += '[' + temp.rows + '][' + temp.columns + '] ';
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
ret += temp.value[j][k];
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
ret += temp.value[j][k].toFixed(2);
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
ret += '"' + temp.value[j][k] + '"';
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
if (temp.value[j][k]) {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_true');
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_false');
}
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
}
} else {
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += '<- ' + temp.value;
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += '<- ' + temp.value.toFixed(2);
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += '<- "' + temp.value + '"';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += '<- ';
if (temp.value) {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_true');
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_false');
}
break;
}
}
return ret;
}
function globalsCode() {
var ret = '';
if (window.program_obj.globals) {
for (var i = 0; i < window.program_obj.globals.length; i++) {
var temp = window.program_obj.globals[i];
ret += '\n\t';
if (temp.is_constant) {
ret += 'const ';
}
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_integer');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_real');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_text');
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('type_boolean');
break;
}
ret += ' ' + temp.name + ' ';
if (temp.dimensions == 1) {
ret += '[' + temp.columns + '] ';
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
ret += temp.value[j];
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
ret += temp.value[j].toFixed(2);
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
ret += '"' + temp.value[j] + '"';
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += '<- {';
for (var j = 0; j < temp.value.length; j++) {
if (temp.value[j]) {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_true');
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_false');
}
if (j + 1 < temp.value.length) {
ret += ', ';
}
}
ret += '}';
break;
}
} else if (temp.dimensions == 2) {
ret += '[' + temp.rows + '][' + temp.columns + '] ';
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
ret += temp.value[j][k];
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
ret += temp.value[j][k].toFixed(2);
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
ret += '"' + temp.value[j][k] + '"';
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += '<- {';
for (var j = 0; j < temp.rows; j++) {
ret += '{';
for (var k = 0; k < temp.columns; k++) {
if (temp.value[j][k]) {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_true');
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_false');
}
if (k + 1 < temp.columns) {
ret += ', ';
}
}
ret += '}';
if (j + 1 < temp.rows) {
ret += ', ';
}
}
ret += '}';
break;
}
} else {
switch (temp.type) {
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER:
ret += '<- ' + temp.value;
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL:
ret += '<- ' + temp.value.toFixed(2);
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT:
ret += '<- "' + temp.value + '"';
break;
case _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN:
ret += '<- ';
if (temp.value) {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_true');
;
} else {
ret += _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_value_false');
;
}
break;
}
}
}
}
return ret;
}
/***/ }),
/***/ "./js/visualUI/commands.js":
/*!*********************************!*\
!*** ./js/visualUI/commands.js ***!
\*********************************/
/*! exports provided: removeCommand, createFloatingCommand, renderCommand, genericCreateCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeCommand", function() { return removeCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "genericCreateCommand", function() { return genericCreateCommand; });
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands_comment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./commands/comment */ "./js/visualUI/commands/comment.js");
/* harmony import */ var _commands_reader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./commands/reader */ "./js/visualUI/commands/reader.js");
/* harmony import */ var _commands_writer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./commands/writer */ "./js/visualUI/commands/writer.js");
/* harmony import */ var _commands_attribution__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./commands/attribution */ "./js/visualUI/commands/attribution.js");
/* harmony import */ var _commands_iftrue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./commands/iftrue */ "./js/visualUI/commands/iftrue.js");
/* harmony import */ var _commands_repeatNtimes__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./commands/repeatNtimes */ "./js/visualUI/commands/repeatNtimes.js");
/* harmony import */ var _commands_whiletrue__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./commands/whiletrue */ "./js/visualUI/commands/whiletrue.js");
/* harmony import */ var _commands_dowhiletrue__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./commands/dowhiletrue */ "./js/visualUI/commands/dowhiletrue.js");
/* harmony import */ var _commands_switch__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./commands/switch */ "./js/visualUI/commands/switch.js");
/* harmony import */ var _commands_functioncall__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./commands/functioncall */ "./js/visualUI/commands/functioncall.js");
/* harmony import */ var _commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./commands/variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _commands_break__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./commands/break */ "./js/visualUI/commands/break.js");
/* harmony import */ var _commands_return__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./commands/return */ "./js/visualUI/commands/return.js");
/* harmony import */ var _services_userLog__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./../services/userLog */ "./js/services/userLog.js");
// let has_element_created_draged = false;
// let which_element_is_draged = null;
function removeCommand(command, function_obj, dom_obj) {
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].REMOVE_COMMAND, command.type, '/', 0);
if (function_obj.commands.indexOf(command) > -1) {
function_obj.commands.splice(function_obj.commands.indexOf(command), 1);
return true;
} // Utilize dois parantNode, pois o primeiro é o div de comandos
try {
if (dom_obj.parent().parent().data('command').commands_block.indexOf(command) > -1) {
dom_obj.parent().parent().data('command').commands_block.splice(dom_obj.parent().parent().data('command').commands_block.indexOf(command), 1);
return true;
}
} catch (err) {}
try {
if (dom_obj.parent().parent().data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue) {
if (dom_obj.parent().parent().data('command').commands_else.indexOf(command) > -1) {
dom_obj.parent().parent().data('command').commands_else.splice(dom_obj.parent().parent().data('command').commands_else.indexOf(command), 1);
return true;
}
}
} catch (err) {}
if (dom_obj.parent().data('switchcase')) {
console.log("o que encontrei: ");
console.log(dom_obj.parent().data('switchcase'));
dom_obj.parent().data('switchcase').commands_block.splice(dom_obj.parent().data('switchcase').commands_block.indexOf(command), 1);
return true;
}
return false;
}
window.function_container_active = null;
function createFloatingCommand(function_obj, function_container, command_type, mouse_event) {
var floatingObject;
switch (command_type) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["break"]:
floatingObject = _commands_break__WEBPACK_IMPORTED_MODULE_13__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].comment:
floatingObject = _commands_comment__WEBPACK_IMPORTED_MODULE_2__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].reader:
floatingObject = _commands_reader__WEBPACK_IMPORTED_MODULE_3__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].writer:
floatingObject = _commands_writer__WEBPACK_IMPORTED_MODULE_4__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].attribution:
floatingObject = _commands_attribution__WEBPACK_IMPORTED_MODULE_5__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue:
floatingObject = _commands_iftrue__WEBPACK_IMPORTED_MODULE_6__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes:
floatingObject = _commands_repeatNtimes__WEBPACK_IMPORTED_MODULE_7__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue:
floatingObject = _commands_whiletrue__WEBPACK_IMPORTED_MODULE_8__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue:
floatingObject = _commands_dowhiletrue__WEBPACK_IMPORTED_MODULE_9__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]:
floatingObject = _commands_switch__WEBPACK_IMPORTED_MODULE_10__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].functioncall:
floatingObject = _commands_functioncall__WEBPACK_IMPORTED_MODULE_11__["createFloatingCommand"]();
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["return"]:
floatingObject = _commands_return__WEBPACK_IMPORTED_MODULE_14__["createFloatingCommand"]();
break;
}
floatingObject.draggable().appendTo("body");
$('body').mouseup(function (evt) {
manageCommand(function_obj, function_container, evt, command_type);
$('body').off('mouseup');
$('body').off('mouseover');
});
if (!function_container.hasClass('function_div') || function_container.length < 1) {
window.mouse_event = mouse_event;
function_container = $(mouse_event.originalEvent.srcElement.closest('.function_div'));
}
console.log('function_container', function_container);
function_container_active = function_container;
function_container.find('.commands_list_div').on('mousemove', function (evt) {
addGhostDiv(evt);
});
function_container.find('.commands_list_div').find("*").on('mousemove', function (evt) {
addGhostDiv(evt);
});
function_container.on('mouseout', function (event) {
var el = $(document.elementFromPoint(event.clientX, event.clientY));
if (el.closest('.commands_list_div').length < 1) {
window.ghostDiv.remove();
}
});
floatingObject.css("position", "absolute");
mouse_event.type = "mousedown.draggable";
mouse_event.target = floatingObject[0];
floatingObject.css("left", mouse_event.pageX - window.divx);
floatingObject.css("top", mouse_event.pageY);
floatingObject.trigger(mouse_event);
}
window.divx = 100;
window.ghostDiv = $('');
window.active_container = null;
function addGhostToEmptyBlock(element, evt) {
$('.ghost_div').remove();
var container = element.closest('.command_container');
if (container.hasClass('switch')) {
container = $(evt.target).closest('.case_div');
}
if (!container.hasClass('dowhiletrue') && !container.hasClass('iftrue') && !container.hasClass('repeatNtimes') && !container.hasClass('case_div') && !container.hasClass('whiletrue')) {
addGhostToNotEmptyBlock(element, evt);
return;
}
if (window.active_container != null) {
if (window.active_container.is(container)) {
console.log('é o mesmo, não mudou!');
} else {
if (container.length < 1) {
container = element.closest('.commands_list_div');
if (window.active_container.is(container)) {
console.log('é o mesmo command list');
} else {
console.log('mudou para um command list');
window.active_container = container;
}
} else {
console.log('mudou para um outro container?');
}
}
}
window.active_container = container;
if (container.hasClass('iftrue')) {
var containerIf = container.find('.commands_if').get(0);
var containerElse = container.find('.commands_else').get(0);
var topIfDistance = Math.abs(evt.clientY - containerIf.getBoundingClientRect().top);
var bottomIfDistance = Math.abs(containerIf.getBoundingClientRect().top + containerIf.getBoundingClientRect().height - evt.clientY);
var topElseDistance = Math.abs(evt.clientY - containerElse.getBoundingClientRect().top);
var bottomElseDistance = Math.abs(containerElse.getBoundingClientRect().top + containerElse.getBoundingClientRect().height - evt.clientY);
if (topIfDistance < topElseDistance && topIfDistance < bottomElseDistance) {
$(containerIf).append(window.ghostDiv);
} else {
$(containerElse).append(window.ghostDiv);
}
} else if (container.hasClass('case_div')) {
container.find('.case_commands_block').append(window.ghostDiv);
} else {
container.find('.block_commands').append(window.ghostDiv);
}
}
function addGhostToNotEmptyBlock(element, evt) {
$('.ghost_div').remove();
var container = element.closest('.dowhiletrue, .iftrue, .repeatNtimes, .case_div, .whiletrue'); //console.log("\n\nNOT EMPTY: ", container);
//if (window.active_container != null) {
//}
if (container.length < 1) {
container = element.closest('.commands_list_div');
window.active_container = container;
addGhostToFunctionArea(element, evt);
} else {//console.log('mudou para um outro container?');
}
window.active_container = container; // quem está mais próximo? // Essa regra se aplica somente quando o over está sobre um comando
var allfilhos;
console.log('olha o container: ', container);
if (container.hasClass('iftrue')) {
if ($(evt.target).closest('.data_block_if').length > 0) {
allfilhos = container.find('.commands_if').children('.command_container');
} else if ($(evt.target).closest('.data_block_else').length > 0) {
allfilhos = container.find('.commands_else').children('.command_container');
} else {
var containerIf = container.find('.commands_if').get(0);
var containerElse = container.find('.commands_else').get(0);
var topIfDistance = Math.abs(evt.clientY - containerIf.getBoundingClientRect().top);
var bottomIfDistance = Math.abs(containerIf.getBoundingClientRect().top + containerIf.getBoundingClientRect().height - evt.clientY);
var topElseDistance = Math.abs(evt.clientY - containerElse.getBoundingClientRect().top);
var bottomElseDistance = Math.abs(containerElse.getBoundingClientRect().top + containerElse.getBoundingClientRect().height - evt.clientY);
if (topIfDistance < topElseDistance && topIfDistance < bottomElseDistance) {
allfilhos = $(containerIf).children('.command_container');
} else {
allfilhos = $(containerElse).children('.command_container');
}
}
} else if (container.hasClass('case_div')) {
allfilhos = container.children('.case_commands_block').children('.command_container');
} else if (container.hasClass('commands_list_div')) {
allfilhos = container.children('.command_container');
} else {
allfilhos = container.children('.block_commands').children('.command_container');
}
var topDistances = [];
var bottomDistances = [];
for (var i = 0; i < allfilhos.length; i++) {
var topD = Math.abs(evt.clientY - allfilhos.get(i).getBoundingClientRect().top);
topDistances.push(topD);
var botD = Math.abs(allfilhos.get(i).getBoundingClientRect().top + allfilhos.get(i).getBoundingClientRect().height - evt.clientY);
bottomDistances.push(botD);
}
console.log('topDistances\n', topDistances, '\nbottomDistances\n', bottomDistances);
var menorTop = Math.min.apply(null, topDistances);
var indiceTop = topDistances.indexOf(menorTop);
var menorBot = Math.min.apply(null, bottomDistances);
var indiceBot = bottomDistances.indexOf(menorBot);
if (menorTop < menorBot) {
window.ghostDiv.insertBefore($(allfilhos.get(indiceTop)));
} else {
window.ghostDiv.insertAfter($(allfilhos.get(indiceBot)));
}
console.log('distancias: menorTop ', menorTop, ' menorBot ', menorBot);
}
function addGhostToFunctionArea(undermouse, evt) {
$('.ghost_div').remove();
var allfilhos = undermouse.closest('.commands_list_div').children('.command_container');
var topDistances = [];
var bottomDistances = [];
for (var i = 0; i < allfilhos.length; i++) {
var topD = Math.abs(evt.clientY - allfilhos.get(i).getBoundingClientRect().top);
topDistances.push(topD);
var botD = Math.abs(allfilhos.get(i).getBoundingClientRect().top + allfilhos.get(i).getBoundingClientRect().height - evt.clientY);
bottomDistances.push(botD);
}
var menorTop = Math.min.apply(null, topDistances);
var indiceTop = topDistances.indexOf(menorTop);
var menorBot = Math.min.apply(null, bottomDistances);
var indiceBot = bottomDistances.indexOf(menorBot);
if (menorTop < menorBot) {
window.ghostDiv.insertBefore($(allfilhos.get(indiceTop)));
} else {
window.ghostDiv.insertAfter($(allfilhos.get(indiceBot)));
}
}
function addGhostDiv(evt) {
var undermouse = $(evt.target);
if (undermouse.hasClass('ghost_div')) {
return;
} else if (undermouse.hasClass('commands_list_div')) {
addGhostToFunctionArea(undermouse, evt);
return;
} else if (undermouse.hasClass('block_commands')) {
if (undermouse.find('.command_container').length > 0) {
addGhostToNotEmptyBlock(undermouse, evt);
} else {
addGhostToEmptyBlock(undermouse, evt);
}
} else if (undermouse.hasClass('case_div')) {
if (undermouse.find('.case_commands_block').find('.command_container').length > 0) {
addGhostToNotEmptyBlock(undermouse, evt);
} else {
addGhostToEmptyBlock(undermouse, evt);
}
} else {
addGhostToNotEmptyBlock(undermouse, evt);
}
}
function borderMouseDragCommand(function_obj, function_container, evt) {
function_container.find('.over_command_drag').each(function (index) {
$(this).removeClass('over_command_drag');
});
var prev = null;
function_container.find('.commands_list_div').each(function (index) {
prev = $(this);
if (prev) {
var objLeft = prev.offset().left;
var objTop = prev.offset().top;
var objRight = objLeft + prev.width();
var objBottom = objTop + prev.height();
if (evt.pageX > objLeft && evt.pageX < objRight && evt.pageY > objTop && evt.pageY < objBottom) {
prev.addClass("over_command_drag");
}
}
});
function_container.find('.command_container').each(function (index) {
var obj = $(this);
var objLeft = obj.offset().left;
var objTop = obj.offset().top;
var objRight = objLeft + obj.width();
var objBottom = objTop + obj.height();
if (evt.pageX > objLeft && evt.pageX < objRight && evt.pageY > objTop && evt.pageY < objBottom) {
if (prev) {
prev.removeClass('over_command_drag');
}
obj.addClass("over_command_drag");
return;
}
});
} // before_after_inside: 1 -> before, 2 -> after, 3 -> inside
function renderCommand(command, element_reference, before_after_inside, function_obj) {
var createdElement;
switch (command.type) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].comment:
createdElement = _commands_comment__WEBPACK_IMPORTED_MODULE_2__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["break"]:
createdElement = _commands_break__WEBPACK_IMPORTED_MODULE_13__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].reader:
createdElement = _commands_reader__WEBPACK_IMPORTED_MODULE_3__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].writer:
createdElement = _commands_writer__WEBPACK_IMPORTED_MODULE_4__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].attribution:
createdElement = _commands_attribution__WEBPACK_IMPORTED_MODULE_5__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].functioncall:
createdElement = _commands_functioncall__WEBPACK_IMPORTED_MODULE_11__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue:
createdElement = _commands_iftrue__WEBPACK_IMPORTED_MODULE_6__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes:
createdElement = _commands_repeatNtimes__WEBPACK_IMPORTED_MODULE_7__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue:
createdElement = _commands_whiletrue__WEBPACK_IMPORTED_MODULE_8__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue:
createdElement = _commands_dowhiletrue__WEBPACK_IMPORTED_MODULE_9__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]:
createdElement = _commands_switch__WEBPACK_IMPORTED_MODULE_10__["renderCommand"](command, function_obj);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["return"]:
createdElement = _commands_return__WEBPACK_IMPORTED_MODULE_14__["renderCommand"](command, function_obj);
break;
}
switch (before_after_inside) {
case 1:
createdElement.insertBefore(element_reference);
break;
case 2:
createdElement.insertAfter(element_reference);
break;
case 3:
element_reference.append(createdElement);
break;
}
}
function genericCreateCommand(command_type) {
switch (command_type) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["break"]:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Break"]();
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].comment:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Comment"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].only_value, _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('text_comment'), null, null, false));
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].reader:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Reader"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].only_variable, null, null, null, false));
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].writer:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Writer"]([new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].attribution:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Attribution"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].only_variable, null, null, null, false), []);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].functioncall:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["FunctionCall"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].only_function, null, null, null, false), null);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["IfTrue"]([new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
//(var_attribution, var_incrementation, expression1, expression2, expression3, commands_block)
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["RepeatNTimes"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].only_variable, null, null, null, false), new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].only_variable, null, null, null, false), null, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), null, null);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["WhileTrue"]([new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)], null);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["DoWhileTrue"]([new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)], null);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]:
var sc = [new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["SwitchCase"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true))];
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Switch"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].variable_and_function, null, null, null, true), sc);
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["return"]:
return new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["Return"]([new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_commands_variable_value_menu__WEBPACK_IMPORTED_MODULE_12__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
}
}
function dragTrash(event) {
$('.ghost_div').remove();
var trash = $('
');
$('body').append(trash);
trash.css('position', 'absolute');
trash.css('top', event.clientY);
trash.css('left', event.clientX - 20);
trash.css('font-size', '3em');
trash.css('display', 'none');
function_container_active.find('.commands_list_div').off('mousemove');
function_container_active.find('.commands_list_div').find("*").off('mousemove');
trash.fadeIn(200, function () {
trash.fadeOut(200, function () {
trash.remove();
});
});
}
function findSingleElement(searching, query) {
if (!searching || !query) {
return '';
}
if (searching.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes || searching.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue || searching.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue) {
if (searching.commands_block) {
return '' + searching.commands_block.indexOf(query);
} else {
return '0';
}
} else if (searching.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue) {
if (searching.commands_block == null) {
searching.commands_block = [];
}
if (searching.commands_else == null) {
searching.commands_else = [];
}
console.log('\n\nveja onde: ', searching.commands_block, ' \n\nquery: ', query);
if (searching.commands_block.indexOf(query) >= 0) {
return 'if[' + searching.commands_block.indexOf(query) + ']';
} else {
return 'else[' + searching.commands_else.indexOf(query) + ']';
}
} else if (searching.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]) {
for (var i = 0; i < searching.cases.length; i++) {
if (searching.cases[i].commands_block.indexOf(query) >= 0) {
return 'case[' + searching.cases[i].commands_block.indexOf(query) + ']';
}
}
}
}
function findPathRecursive(starter_index, hierarquia_bottom_up, function_obj) {
var index_command = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
var actual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var full_path = '';
for (var i = 0; i <= hierarquia_bottom_up.length; i++) {
console.log('\n\n:: ', i, ':\n', hierarquia_bottom_up[i]);
full_path += findSingleElement(hierarquia_bottom_up[i], hierarquia_bottom_up[i + 1]) + '-';
}
return full_path;
}
function manageCommand(function_obj, function_container, event, command_type) {
$(".created_element").each(function (index) {
$(this).remove();
});
var el = $(document.elementFromPoint(event.clientX, event.clientY));
if (el.hasClass('ghost_div')) {
if (el.closest('.command_container').length < 1) {
console.log('\n\nvou tentar!!!!');
console.log(el.closest('.commands_list_div'), '\n\n');
el.closest('.commands_list_div').css('height', el.closest('.commands_list_div').css('height') + 30); //$('.ghost_div').remove();
el = el.closest('.commands_list_div');
}
}
console.log('soltou no: ');
console.log(el);
console.log(el.data('fun')); // Primeiro verificar se ele soltou no espaço da função correta:
var hier = el.parentsUntil(".all_functions");
var esta_correto = false;
var esta_na_div_correta = false;
if (el.hasClass("commands_list_div")) {
esta_na_div_correta = true;
}
for (var i = 0; i < hier.length; i++) {
var temp = $(hier[i]);
if (temp.hasClass("commands_list_div")) {
esta_na_div_correta = true;
}
if (temp.data('fun') == function_obj) {
esta_correto = true;
break;
}
}
if (!esta_correto) {
// has_element_created_draged = false;
// which_element_is_draged = null;
dragTrash(event);
return;
} else {
if (!esta_na_div_correta) {
// has_element_created_draged = false;
// which_element_is_draged = null;
dragTrash(event);
return;
}
}
var hierarquia_bottom_up = null; // Agora é descobrir qual o escopo para adicionar o comando:
console.log('ev0'); // Se o elemento clicado possuir o atributo "fun", então, é direto na div dos comandos:
if (typeof el.data('fun') !== 'undefined') {
// Se a lista de comandos estiver vazia, então é o primeiro.
// Portanto, ele deve soltar o elemento obrigatoriamente no objeto vazio
if (el.data('fun').commands == null || el.data('fun').commands.length == 0) {
// pode adicionar
el.data('fun').commands = [];
var new_cmd = genericCreateCommand(command_type);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/', 0);
el.data('fun').commands.push(new_cmd);
renderCommand(new_cmd, $(function_container).find('.commands_list_div'), 3, function_obj);
} else {
// Entra nesse else, caso já existam outros comandos no bloco:
findNearbyCommandToAddInFunctionScope(el, event, $(function_container).find('.commands_list_div'), function_obj, command_type);
}
} else {
console.log("soltou em um comando"); // descobrir em qual comando ele soltou:
var hier_find = el.parentsUntil(".commands_list_div");
hierarquia_bottom_up = [];
if (typeof el.data('command') !== 'undefined') {
hierarquia_bottom_up.push(el.data('command'));
}
for (var i = 0; i < hier_find.length; i++) {
if (typeof $(hier_find[i]).data('command') !== 'undefined') {
hierarquia_bottom_up.push($(hier_find[i]).data('command'));
}
}
console.log("comando em que soltou: ");
console.log(hierarquia_bottom_up[0]);
console.log("hierarquia de baixo para cima na árvore, de onde ele soltou: ");
for (var i = 0; i < hierarquia_bottom_up.length; i++) {
console.log(hierarquia_bottom_up[i]);
} // Se for do tipo break, verificar se está no contexto correto:
// Caso não esteja no contexto, apenas retorna sem dar continuidade:
var is_correct_context = false;
if (command_type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["break"]) {
for (var i = 0; i < hierarquia_bottom_up.length; i++) {
if (hierarquia_bottom_up[i].type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes || hierarquia_bottom_up[i].type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue || hierarquia_bottom_up[i].type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue || hierarquia_bottom_up[i].type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]) {
is_correct_context = true;
break;
}
}
if (!is_correct_context) {
console.error("Context not allowed to insert BREAK COMMAND!");
return;
}
} // se a hierarquia possuir apenas um elemento, então está na raiz dos comandos:
if (hierarquia_bottom_up.length == 1) {
console.log('QQ1');
var sub_elemento = false;
for (var i = 0; i < hier_find.length; i++) {
if (typeof $(hier_find[i]).data('command') !== 'undefined') {
console.log('QQ2');
findBeforeOrAfterCommandToAdd(hier_find[i], event, function_obj, command_type);
sub_elemento = true;
break;
}
}
if (!sub_elemento) {
console.log('QQ3');
findBeforeOrAfterCommandToAdd(el[0], event, function_obj, command_type);
}
} else {
console.log('QQ4'); // caso exista mais de um elemento na hierarquia:
if (typeof $(el).data('command') !== 'undefined') {
console.log('QQ5');
console.log("PPP1");
insertCommandInBlockHierar(el[0], event, function_obj, command_type, hier_find, hierarquia_bottom_up);
} else {
console.log('QQ6');
var sub_elemento = false;
for (var i = 0; i < hier_find.length; i++) {
if (typeof $(hier_find[i]).data('command') !== 'undefined') {
console.log('QQ7');
insertCommandInBlockHierar(hier_find[i], event, function_obj, command_type, hier_find, hierarquia_bottom_up);
sub_elemento = true;
break;
}
}
}
}
} // has_element_created_draged = false;
// which_element_is_draged = null;
if (hierarquia_bottom_up) {
console.log('\n\n:::índices::\n\n');
var i = hierarquia_bottom_up.length - 1;
var starter_index = window.program_obj.functions[window.program_obj.functions.indexOf(function_obj)].commands.indexOf(hierarquia_bottom_up[i]);
var all_str_path = starter_index + '-' + findPathRecursive(starter_index, hierarquia_bottom_up, function_obj);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/', all_str_path);
console.log('\n\nfull path: \n\n', all_str_path);
console.log('fim dos índices');
}
renderAlgorithm();
}
function insertCommandInBlockHierar(el, event, function_obj, command_type, hier_dom, hier_obj) {
var el_jq = $(el);
var command_parent = el_jq.data('command');
if (el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]) {
console.log('QQ17');
if (el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue) {
console.log('QQ18'); // Se não tiver outro comando ainda no bloco, só adiciona:
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
command_parent.commands_block = [];
var recentComand = genericCreateCommand(command_type);
command_parent.commands_block.push(recentComand);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/' + el_jq.data('command').type, 0);
renderCommand(recentComand, el_jq.find('.block_commands'), 3, function_obj);
} else {
// Se já tem algum comando no bloco:
findNearbyCommandToAddInBlockScope(el, event, el, function_obj, command_type, command_parent);
}
} else {
// QUANDO FOR BLOCO DO TIPO IF OU SWITCH/CASE:
addCommandToSwitchCase(event, function_obj, command_type);
}
} else {
console.log('QQ19'); // entra neste bloco, se soltou o comando sobre outro comando dentro de um subbloco:
findBeforeOrAfterCommandToAddInsertBlock(el, event, function_obj, command_type);
}
}
function findNearbyCommandToAddInBlockScope(el, event, node_list_commands, function_obj, command_type, command_parent) {
console.log("\n\n\n::COMANDOS:\n\n", el, event, node_list_commands, function_obj, command_type, command_parent);
var all_sub = $(node_list_commands).find('div.command_container');
var menor_distancia = 999999999;
var elemento_menor_distancia = null;
var antes = true;
var t_bot;
var t_top; // Descobrindo o elemento mais próximo:
for (var i = 0; i < all_sub.length; i++) {
t_top = all_sub[i].getBoundingClientRect().top;
t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
if (t_top - event.clientY < menor_distancia) {
menor_distancia = event.clientY - t_top;
elemento_menor_distancia = all_sub[i];
}
}
var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height; // Está mais próximo da borda de baixo, ou seja.. inserir por último:
if (borda_inferior - event.clientY < menor_distancia) {
var recentComand = genericCreateCommand(command_type);
command_parent.commands_block.push(recentComand); //
renderCommand(recentComand, node_list_commands, 3, function_obj);
} else {
var recentComand = genericCreateCommand(command_type);
var index = command_parent.commands_block.indexOf($(elemento_menor_distancia).data('command'));
if (index > -1) {
command_parent.commands_block.splice(index, 0, recentComand);
}
renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
}
}
function findBeforeOrAfterCommandToAddInsertBlock(el, event, function_obj, command_type) {
var el_jq = $(el);
var command_parent = $(el.parentNode.parentNode).data('command');
var command_target = el_jq.data('command');
var temp_parent = $(el.parentNode.parentNode);
var is_in_else = false;
if (!command_parent) {
command_parent = el_jq.data('command');
temp_parent = el_jq;
var hier = el_jq.parentsUntil(".command_container");
for (var i = 0; i < hier.length; i++) {
var temp = $(hier[i]);
if (typeof temp.data('else') != 'undefined') {
is_in_else = true;
}
if (typeof temp.data('command') != 'undefined') {
command_parent = temp.data('command');
temp_parent = temp;
}
}
}
var hier = el_jq.parentsUntil(".command_container");
for (var i = 0; i < hier.length; i++) {
var temp = $(hier[i]);
if (typeof temp.data('else') != 'undefined') {
is_in_else = true;
}
}
if (command_parent == command_target) {
var hier = el_jq.parentsUntil(".command_container");
for (var i = 0; i < hier.length; i++) {
var temp = $(hier[i]);
if (typeof temp.data('else') !== 'undefined') {
is_in_else = true;
break;
}
}
}
if (command_parent.type != _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue && command_parent.type != _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]) {
var hier = temp_parent.parentsUntil(".all_cases_div");
console.log("vou procurar!!");
for (var i = 0; i < hier.length; i++) {
console.log("estou vasculhando...");
var temp = $(hier[i]);
if (typeof temp.data('switchcase') !== 'undefined') {
console.log("encontrei");
command_parent = temp.data('switchcase');
is_in_else = false;
break;
}
}
}
console.log('debugging:');
console.log('el_jq');
console.log(el_jq);
console.log('command_parent');
console.log(command_parent);
console.log('command_target');
console.log(command_target);
var menor_distancia = 999999999;
var antes = true;
var t_bot;
var t_top;
t_top = el.getBoundingClientRect().top;
t_bot = el.getBoundingClientRect().top + el.getBoundingClientRect().height;
var d_top = event.clientY - t_top; // distancia topo
var d_bot = t_bot - event.clientY; // distancia baixo
// Está mais próximo da borda de baixo, ou seja.. inserir por último:
if (d_top < d_bot) {
var recentComand = genericCreateCommand(command_type);
console.log('MMM1');
if (is_in_else) {
console.log('MMM2');
if (command_parent == command_target) {
console.log('MMM3');
if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
command_parent.commands_else = [];
var recentComand = genericCreateCommand(command_type);
command_parent.commands_else.push(recentComand);
renderCommand(recentComand, el_jq, 3, function_obj);
} else {
// Se já tem algum comando no bloco:
findInBlockCorrectPlace(el_jq, event, function_obj, command_type, true);
}
return;
}
console.log('MMM7');
var index = command_parent.commands_else.indexOf(command_target);
if (index > -1) {
command_parent.commands_else.splice(index, 0, recentComand);
}
renderCommand(recentComand, el, 1, function_obj);
} else {
console.log('MMM4');
if (command_parent == command_target) {
console.log('Nxxxx5');
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
command_parent.commands_block = [];
console.log('SSS4');
var recentComand = genericCreateCommand(command_type);
command_parent.commands_block.push(recentComand);
renderCommand(recentComand, el_jq, 3, function_obj);
} else {
console.log('SSS5');
findInBlockCorrectPlace(el_jq, event, function_obj, command_type);
}
return;
}
console.log('MMM6');
var index = command_parent.commands_block.indexOf(command_target);
if (index > -1) {
command_parent.commands_block.splice(index, 0, recentComand);
}
renderCommand(recentComand, el, 1, function_obj);
}
} else {
console.log('XXX1');
var recentComand = genericCreateCommand(command_type);
if (is_in_else) {
if (command_parent == command_target) {
console.log('MMM3');
if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
command_parent.commands_else = [];
console.log('SSS1');
var recentComand = genericCreateCommand(command_type);
command_parent.commands_else.push(recentComand);
renderCommand(recentComand, el_jq, 3, function_obj);
} else {
// Se já tem algum comando no bloco:
console.log('SSS2');
findInBlockCorrectPlace(el_jq, event, function_obj, command_type, true);
}
return;
}
console.log('XXX2');
var index = command_parent.commands_else.indexOf(command_target);
if (index > -1) {
command_parent.commands_else.splice(index + 1, 0, recentComand);
}
renderCommand(recentComand, el, 2, function_obj);
} else {
if (command_parent == command_target) {
console.log('Nxxxx78');
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
command_parent.commands_block = [];
var recentComand = genericCreateCommand(command_type);
command_parent.commands_block.push(recentComand);
console.log('SSS6');
renderCommand(recentComand, el_jq, 3, function_obj);
} else {
console.log('SSS7');
findInBlockCorrectPlace(el_jq, event, function_obj, command_type);
}
return;
}
console.log('XXX3');
var index = command_parent.commands_block.indexOf(command_target);
if (index > -1) {
command_parent.commands_block.splice(index + 1, 0, recentComand);
}
renderCommand(recentComand, el, 2, function_obj);
}
}
}
function insertCommandInBlock(el, event, function_obj, command_type) {
var el_jq = $(el);
var command_parent = el_jq.data('command');
if (el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue || el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue) {
// Se não tiver outro comando ainda no bloco, só adiciona:
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
command_parent.commands_block = [];
var recentComand = genericCreateCommand(command_type);
command_parent.commands_block.push(recentComand);
renderCommand(recentComand, el_jq.find('.block_commands'), 3, function_obj);
} else {
// Se já tem algum comando no bloco:
findInBlockCorrectPlace(el, event, function_obj, command_type);
}
} else if (el_jq.data('command').type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue) {
console.log('QQ9'); // no if ou no else?
var correct_div = $(document.elementFromPoint(event.pageX, event.pageY));
var is_in_if = true;
if (correct_div.data('if')) {
is_in_if = true;
} else if (correct_div.data('else')) {
is_in_if = false;
} else {
var hier = correct_div.parentsUntil(".command_container");
for (var i = 0; i < hier.length; i++) {
var temp = $(hier[i]);
if (typeof temp.data('if') !== 'undefined') {
is_in_if = true;
break;
}
if (typeof temp.data('else') !== 'undefined') {
is_in_if = false;
break;
}
}
}
if (is_in_if) {
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
command_parent.commands_block = [];
var recentComand = genericCreateCommand(command_type);
command_parent.commands_block.push(recentComand);
renderCommand(recentComand, el_jq.find('.commands_if'), 3, function_obj);
} else {
// Se já tem algum comando no bloco:
findInBlockCorrectPlace(el_jq.find('.commands_if'), event, function_obj, command_type);
}
} else {
if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
command_parent.commands_else = [];
var recentComand = genericCreateCommand(command_type);
command_parent.commands_else.push(recentComand);
renderCommand(recentComand, el_jq.find('.commands_else'), 3, function_obj);
} else {
// Se já tem algum comando no bloco:
findInBlockCorrectPlace(el_jq.find('.commands_else'), event, function_obj, command_type, true);
}
}
} else {
// é do tipo switch
console.log("está tentando inserir em um switch que está na raiz!");
addCommandToSwitchCase(event, function_obj, command_type);
}
}
function addCommandToSwitchCase(event, function_obj, command_type) {
var el = $(document.elementFromPoint(event.clientX, event.clientY));
var which_case = el.data('switchcase');
var case_div = el;
if (!which_case) {
var hier_find = el.parentsUntil(".all_cases_div");
for (var i = 0; i < hier_find.length; i++) {
if (typeof $(hier_find[i]).data('switchcase') !== 'undefined') {
which_case = $(hier_find[i]).data('switchcase');
case_div = $(hier_find[i]);
break;
}
}
}
if (which_case.commands_block == null || which_case.commands_block.length < 1) {
which_case.commands_block = [];
var recentComand = genericCreateCommand(command_type);
which_case.commands_block.push(recentComand);
renderCommand(recentComand, case_div.find('.case_commands_block'), 3, function_obj);
} else {
findInBlockCorrectPlaceInSwitchCase(which_case, case_div, event, function_obj, command_type);
}
}
function findInBlockCorrectPlaceInSwitchCase(which_case, case_div, event, function_obj, command_type) {
var all_sub = case_div.find('div.command_container');
var menor_distancia = 999999999;
var elemento_menor_distancia = null;
var antes = true;
var t_bot;
var t_top; // Descobrindo o elemento mais próximo:
for (var i = 0; i < all_sub.length; i++) {
t_top = all_sub[i].getBoundingClientRect().top;
t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
if (t_top - event.clientY < menor_distancia) {
menor_distancia = event.clientY - t_top;
elemento_menor_distancia = all_sub[i];
}
}
var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height; // Está mais próximo da borda de baixo, ou seja.. inserir por último:
if (borda_inferior - event.clientY < menor_distancia) {
var recentComand = genericCreateCommand(command_type);
which_case.commands_block.push(recentComand);
renderCommand(recentComand, $(case_div.find('.case_commands_block')[0]), 3, function_obj);
} else {
var recentComand = genericCreateCommand(command_type);
var index = which_case.commands_block.indexOf($(elemento_menor_distancia).data('command'));
if (index > -1) {
which_case.commands_block.splice(index, 0, recentComand);
renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
}
}
}
function findInBlockCorrectPlace(el, event, function_obj, command_type) {
var is_in_else = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var el_jq = $(el);
var all_sub = el_jq.find('div.command_container');
var menor_distancia = 999999999;
var elemento_menor_distancia = null;
var antes = true;
var t_bot;
var t_top; // Descobrindo o elemento mais próximo:
for (var i = 0; i < all_sub.length; i++) {
t_top = all_sub[i].getBoundingClientRect().top;
t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
if (t_top - event.clientY < menor_distancia) {
menor_distancia = event.clientY - t_top;
elemento_menor_distancia = all_sub[i];
}
}
var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height;
console.log("menor_distancia: ");
console.log(elemento_menor_distancia); // Está mais próximo da borda de baixo, ou seja.. inserir por último:
if (borda_inferior - event.clientY < menor_distancia) {
console.log('QQ11');
var recentComand = genericCreateCommand(command_type);
var command_parent = el_jq.data('command');
if (is_in_else) {
console.log('QQ15');
command_parent.commands_else.push(recentComand);
console.log('el_jq');
console.log(el_jq);
console.log("$(el_jq.find('.commands_else')[0]):: ");
console.log($(el_jq.find('.commands_else')[0]));
renderCommand(recentComand, el_jq, 3, function_obj);
} else {
console.log('QQ16');
command_parent.commands_block.push(recentComand);
renderCommand(recentComand, $(el_jq.find('.block_commands')[0]), 3, function_obj);
}
} else {
console.log('QQ12');
var recentComand = genericCreateCommand(command_type);
var command_parent = el_jq.data('command');
if (is_in_else) {
var index = command_parent.commands_else.indexOf($(elemento_menor_distancia).data('command'));
if (index > -1) {
command_parent.commands_else.splice(index, 0, recentComand);
renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
}
} else {
var index = command_parent.commands_block.indexOf($(elemento_menor_distancia).data('command'));
if (index > -1) {
command_parent.commands_block.splice(index, 0, recentComand);
renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
}
}
}
}
function findBeforeOrAfterCommandToAdd(el, event, function_obj, command_type) {
switch ($(el).data('command').type) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].iftrue:
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["switch"]:
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes:
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue:
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue:
insertCommandInBlock(el, event, function_obj, command_type);
return;
}
var menor_distancia = 999999999;
var antes = true;
var t_bot;
var t_top;
t_top = el.getBoundingClientRect().top;
t_bot = el.getBoundingClientRect().top + el.getBoundingClientRect().height;
var d_top = event.clientY - t_top; // distancia topo
var d_bot = t_bot - event.clientY; // distancia baixo
// Está mais próximo da borda de baixo, ou seja.. inserir por último:
if (d_top < d_bot) {
var recentComand = genericCreateCommand(command_type);
var index = function_obj.commands.indexOf($(el).data('command'));
if (index > -1) {
function_obj.commands.splice(index, 0, recentComand);
}
renderCommand(recentComand, el, 1, function_obj);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/', index);
} else {
var recentComand = genericCreateCommand(command_type);
var index = function_obj.commands.indexOf($(el).data('command'));
if (index > -1) {
function_obj.commands.splice(index + 1, 0, recentComand);
}
renderCommand(recentComand, el, 2, function_obj);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/', index);
}
}
function findNearbyCommandToAddInFunctionScope(el, event, node_list_commands, function_obj, command_type) {
var all_sub = $(node_list_commands).find('div.command_container');
var menor_distancia = 999999999;
var elemento_menor_distancia = null;
var antes = true;
var t_bot;
var t_top; // Descobrindo o elemento mais próximo:
for (var i = 0; i < all_sub.length; i++) {
t_top = all_sub[i].getBoundingClientRect().top;
t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
if (t_top - event.clientY < menor_distancia) {
menor_distancia = event.clientY - t_top;
elemento_menor_distancia = all_sub[i];
}
}
var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height; // Está mais próximo da borda de baixo, ou seja.. inserir por último:
if (borda_inferior - event.clientY < menor_distancia) {
var recentComand = genericCreateCommand(command_type);
function_obj.commands.push(recentComand); //
renderCommand(recentComand, node_list_commands, 3, function_obj);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/', function_obj.commands.length - 1);
} else {
var recentComand = genericCreateCommand(command_type);
var index = function_obj.commands.indexOf($(elemento_menor_distancia).data('command'));
if (index > -1) {
function_obj.commands.splice(index, 0, recentComand);
}
renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_15__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_15__["ActionTypes"].INSERT_COMMAND, command_type, '/', index);
}
}
/***/ }),
/***/ "./js/visualUI/commands/attribution.js":
/*!*********************************************!*\
!*** ./js/visualUI/commands/attribution.js ***!
\*********************************************/
/*! exports provided: createFloatingCommand, renderCommand, manageExpressionElements, renderMenuOperations */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "manageExpressionElements", function() { return manageExpressionElements; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderMenuOperations", function() { return renderMenuOperations; });
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _generic_expression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./generic_expression */ "./js/visualUI/commands/generic_expression.js");
function createFloatingCommand() {
return $('
x <— 1 + 1
');
}
function renderCommand(command, function_obj) {
var el = $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('text_receives') + ' ' + '
');
el.data('command', command);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, command.variable, el.find('.var_attributed'), function_obj);
if (!command.expression || command.expression.length < 1) {
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true);
command.expression.push(exp);
}
addHandlers(command, function_obj, el);
_generic_expression__WEBPACK_IMPORTED_MODULE_4__["renderExpression"](command, function_obj, el.find('.expression_elements'), command.expression); //renderExpressionElements(command, function_obj, el);
return el;
}
function manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, selectedItem, expression_element) {
var index_to_move = expression_element.itens.indexOf(ref_object);
switch (selectedItem.data('exp')) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp:
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp, [expression_element.itens[index_to_move], _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
expression_element.itens[index_to_move] = exp;
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].op_exp:
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].op_exp, [_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, expression_element.itens[index_to_move]]);
expression_element.itens[index_to_move] = exp;
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].par_exp_par:
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].par_exp_par, [expression_element.itens[index_to_move]]);
expression_element.itens[index_to_move] = exp;
break;
}
renderExpressionElements(command, function_obj, dom_object);
}
function renderExpressionElements(command, function_obj, el) {
var expression_div = el.find('.expression_elements');
var command_container;
if (el.hasClass("command_container") == false) {
var hier = el.parentsUntil(".command_container");
for (var i = 0; i < hier.length; i++) {
if ($(hier[i]).hasClass("command_container")) {
command_container = $(hier[i]);
break;
}
if ($(hier[i]).hasClass("expression_elements")) {
expression_div = $(hier[i]);
break;
}
}
}
if (command_container) {
expression_div = command_container.find('.expression_elements');
}
expression_div.text('');
for (var i = 0; i < command.expression.length; i++) {
var temp = $('
');
temp.data('ref_element', command.expression[i]);
temp.data('ref_index', i);
expression_div.append(temp);
renderElement(command, function_obj, temp, command.expression[i]);
}
}
function renderOperator(command, function_obj, temp_op, expression_element, index_op) {
var context_menu = '
';
switch (expression_element.itens[index_op]) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus:
context_menu += '+';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].minus:
context_menu += '-';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].multiplication:
context_menu += '*';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].division:
context_menu += '/';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].module:
context_menu += '%';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].none:
context_menu += '...';
break;
}
context_menu += '
';
context_menu = $(context_menu);
temp_op.append(context_menu);
context_menu.dropdown({
onChange: function onChange(value, text, $selectedItem) {
expression_element.itens[index_op] = value;
}
});
}
function renderMenuAddExpression(command, function_obj, el, dom_append_menu, expression_append_new_expression) {
if (el.hasClass("command_container") == false) {
var hier = el.parentsUntil(".commands_list_div");
for (var i = 0; i < hier.length; i++) {
if ($(hier[i]).hasClass("command_container")) {
el = $(hier[i]);
break;
}
}
}
if (dom_append_menu.hasClass("expression_elements") == false) {
var hier = el.parentsUntil(".commands_list_div");
for (var i = 0; i < hier.length; i++) {
if ($(hier[i]).hasClass("expression_elements")) {
dom_append_menu = $(hier[i]);
break;
}
}
}
var context_menu = '
';
context_menu = $(context_menu);
dom_append_menu.append(context_menu);
context_menu.dropdown({
onChange: function onChange(value, text, $selectedItem) {
switch (value) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp:
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp, [new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
expression_append_new_expression.push(exp);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].op_exp:
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].op_exp, [_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
expression_append_new_expression.push(exp);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].par_exp_par:
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].par_exp_par, [new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
expression_append_new_expression.push(exp);
break;
}
renderExpressionElements(command, function_obj, el);
}
});
}
function renderElement(command, function_obj, el, expression_element) {
switch (expression_element.type_exp) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp:
var temp_op = $('
');
var temp_exp_1 = $('
');
var temp_exp_2 = $('
');
el.append(temp_exp_1);
el.append(temp_op);
el.append(temp_exp_2);
if (expression_element.itens[0].type) {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_element.itens[0], temp_exp_1, function_obj, 2, expression_element);
} else {
renderElement(command, function_obj, temp_exp_1, expression_element.itens[0]);
}
renderOperator(command, function_obj, temp_op, expression_element, 1);
if (expression_element.itens[2].type) {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_element.itens[2], temp_exp_2, function_obj, 2, expression_element);
} else {
renderElement(command, function_obj, temp_exp_2, expression_element.itens[2]);
}
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].op_exp:
var temp_op = $('
');
var temp_exp = $('
');
el.append(temp_op);
el.append(temp_exp);
renderOperator(command, function_obj, temp_op, expression_element, 0);
if (expression_element.itens[1].type) {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_element.itens[1], temp_exp, function_obj, 2, expression_element);
} else {
renderElement(command, function_obj, temp_exp, expression_element.itens[1]);
}
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].par_exp_par:
var temp_par_1 = $('
(
');
var temp_exp = $('
');
var temp_par_2 = $('
)
');
el.append(temp_par_1);
el.append(temp_exp);
for (var j = 0; j < expression_element.itens.length; j++) {
if (expression_element.itens[j].type) {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_element.itens[j], temp_exp, function_obj, 2, expression_element);
} else {
renderElement(command, function_obj, temp_exp, expression_element.itens[j]);
}
} //renderMenuAddExpression(command, function_obj, el, el, expression_element.itens);
el.append(temp_par_2);
break;
}
}
function renderExpression(command, function_obj, el) {
var expression_div = el.find('.expression_elements');
expression_div.text('');
var menu_add_item = $('');
menu_add_item.data('index_add', 0);
expression_div.append(menu_add_item);
for (var i = 0; i < command.expression.length; i++) {
if (command.expression[i].type) {
var temp = $('
');
temp.data('ref_element', command.expression[i]);
temp.data('ref_index', i);
expression_div.append(temp);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, command.expression[i], temp, function_obj);
} else if (command.expression[i] == "(" || command.expression[i] == ")") {
var temp = $('
' + command.expression[i] + '
');
temp.data('ref_element', command.expression[i]);
temp.data('ref_index', i);
expression_div.append(temp);
} else {
var temp = '
';
switch (command.expression[i]) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus:
temp += '+';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].minus:
temp += '-';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].multiplication:
temp += '*';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].division:
temp += '/';
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].module:
temp += '%';
break;
}
temp += '
';
temp = $(temp);
temp.data('ref_element', command.expression[i]);
temp.data('ref_index', i);
expression_div.append(temp);
}
var menu_add_item_seq = $('');
var index_temp = i + 1;
menu_add_item_seq.data('index_add', index_temp);
expression_div.append(menu_add_item_seq);
}
addMenuItens(command, function_obj, el);
}
function addMenuItens(command, function_obj, expression_div) {
var divs_expression = expression_div.find('.menu_add_item');
for (var i = 0; i < divs_expression.length; i++) {
var temp = $(divs_expression[i]).data('index_add');
var context_menu = '';
context_menu = $(context_menu);
$(divs_expression[i]).append(context_menu);
context_menu.dropdown({
on: 'hover',
onChange: function onChange(value, text, $selectedItem) {
switch ($selectedItem.data('option')) {
case "value":
command.expression.splice($selectedItem.data('index'), 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
renderExpression(command, function_obj, expression_div);
break;
case "operator":
command.expression.splice($selectedItem.data('index'), 0, _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus);
renderExpression(command, function_obj, expression_div);
break;
case "parentheses":
command.expression.splice($selectedItem.data('index'), 0, "(");
command.expression.splice($selectedItem.data('index') + 1, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
command.expression.splice($selectedItem.data('index') + 2, 0, ")");
renderExpression(command, function_obj, expression_div);
break;
}
}
});
}
}
function addHandlers(command, function_obj, attribution_dom) {
attribution_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_3__["removeCommand"](command, function_obj, attribution_dom)) {
attribution_dom.fadeOut(400, function () {
attribution_dom.remove();
});
}
});
attribution_dom.find('.button_refresh_attribution').on('click', function () {
renderExpressionElements(command, function_obj, attribution_dom);
});
}
function renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected) {
/*console.log("recebido o seguinte DOM: ");
console.log(dom_object);
if (dom_object.hasClass('var_attributed')) {
return;
} else {
var hier = dom_object.parentsUntil(".command_container");
for (var i = 0; i < hier.length; i++) {
if ($(hier[i]).hasClass('var_attributed') || $(hier[i]).hasClass('parameters_function_called')) {
return;
}
}
}
dom_object.find('.context_menu_clear').remove();
var menu_operations = '';
menu_operations = $(menu_operations);
dom_object.append(menu_operations);
menu_operations.dropdown({
onChange: function(value, text, $selectedItem) {
switch ($($selectedItem).data('option')) {
case "clear":
$(dom_object).text('');
VariableValueMenu.renderMenu(command, ref_object, dom_object, function_obj);
break;
default:
createExpressionAround(command, ref_object, dom_object, function_obj);
menu_operations.find('.text').text('');
}
}
});*/
}
function createExpressionAround(command, ref_object, dom_object, function_obj) {
$('
( ').insertBefore(dom_object);
$('
) ').insertAfter(dom_object);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), dom_object, function_obj);
}
/***/ }),
/***/ "./js/visualUI/commands/break.js":
/*!***************************************!*\
!*** ./js/visualUI/commands/break.js ***!
\***************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
function createFloatingCommand() {
return $('');
}
function renderCommand(command, function_obj) {
var el = $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_break') + '
');
el.data('command', command);
addHandlers(command, function_obj, el);
return el;
}
function addHandlers(command, function_obj, break_dom) {
break_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_1__["removeCommand"](command, function_obj, break_dom)) {
break_dom.fadeOut(400, function () {
break_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/comment.js":
/*!*****************************************!*\
!*** ./js/visualUI/commands/comment.js ***!
\*****************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
function createFloatingCommand() {
return $('');
}
function renderCommand(command, function_obj) {
var el = $('
');
el.data('command', command);
addHandlers(command, function_obj, el);
renderTextComment(command, function_obj, el);
return el;
}
function renderTextComment(command, function_obj, el) {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_1__["renderMenu"](command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
}
function addHandlers(command, function_obj, comment_dom) {
comment_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_2__["removeCommand"](command, function_obj, comment_dom)) {
comment_dom.fadeOut(400, function () {
comment_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/conditional_expression.js":
/*!********************************************************!*\
!*** ./js/visualUI/commands/conditional_expression.js ***!
\********************************************************/
/*! exports provided: renderExpression */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderExpression", function() { return renderExpression; });
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
function renderExpression(command, expression, function_obj, initial_el_to_render) {
expression.dom_object = initial_el_to_render;
if (expression.expression == null || expression.expression.length < 1) {
renderStartMenu(command, expression, function_obj, initial_el_to_render);
} else {
var main_div = $('
');
switch (expression.expression.type) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_logic:
renderLogicExpression(command, expression, expression.expression, function_obj, main_div, initial_el_to_render);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_arithmetic:
renderArithmeticExpression(command, expression, expression.expression, function_obj, main_div);
break;
}
initial_el_to_render.append(main_div);
var restartMenu = $('
');
initial_el_to_render.append(restartMenu);
restartMenu.on('click', function (e) {
expression.expression = null;
initial_el_to_render.empty();
renderExpression(command, expression, function_obj, initial_el_to_render);
});
}
}
function renderArithmeticOperator(command, all_expression, expression_arithmetic, arithmetic_operator, function_obj, element_to_append) {
var menu_operator = $('
');
menu_operator.dropdown({
values: [{
name: '>',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].greater_than,
selected: arithmetic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].greater_than
}, {
name: '<',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].less_than,
selected: arithmetic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].less_than
}, {
name: '==',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].equals_to,
selected: arithmetic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].equals_to
}, {
name: '!=',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].not_equals_to,
selected: arithmetic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].not_equals_to
}, {
name: '>=',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].greater_than_or_equals_to,
selected: arithmetic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].greater_than_or_equals_to
}, {
name: '<=',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].less_than_or_equals_to,
selected: arithmetic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].less_than_or_equals_to
}],
onChange: function onChange(value, text, $selectedItem) {
expression_arithmetic.operator = value;
}
});
element_to_append.append(menu_operator);
}
function renderLogicOperator(command, all_expression, expression_logic, logic_operator, function_obj, element_to_append, initial_el_to_render) {
var menu_operator = $('
');
menu_operator.dropdown({
values: [{
name: '==',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].equals_to,
selected: logic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].equals_to
}, {
name: '!=',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].not_equals_to,
selected: logic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].not_equals_to
}, {
name: '&&',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].and,
selected: logic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].and
}, {
name: '||',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].or,
selected: logic_operator == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LOGIC_COMPARISON"].or
}],
onChange: function onChange(value, text, $selectedItem) {
if ($selectedItem) {
expression_logic.operator = value;
if (expression_logic.second_operand == null) {
expression_logic.second_operand = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true);
initial_el_to_render.empty();
renderExpression(command, all_expression, function_obj, initial_el_to_render);
}
}
}
});
element_to_append.append(menu_operator);
}
function renderLogicExpression(command, all_expression, expression_logic, function_obj, element_to_append, initial_el_to_render) {
var exp_el_par_1 = $('
');
var exp_el_expr_el_1 = $('
');
var exp_el_expr_operand = $('
');
var exp_el_expr_el_2 = $('
');
var exp_el_par_2 = $('
');
if (expression_logic.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_logic) {
renderLogicExpression(command, all_expression, expression_logic.first_operand, function_obj, exp_el_expr_el_1);
} else if (expression_logic.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_arithmetic) {
renderArithmeticExpression(command, all_expression, expression_logic.first_operand, function_obj, exp_el_expr_el_1);
} else {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_logic.first_operand, exp_el_expr_el_1, function_obj);
}
element_to_append.append(exp_el_par_1);
element_to_append.append(exp_el_expr_el_1);
renderLogicOperator(command, all_expression, expression_logic, expression_logic.operator, function_obj, exp_el_expr_operand, initial_el_to_render);
element_to_append.append(exp_el_expr_operand);
if (expression_logic.second_operand) {
if (expression_logic.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_logic) {
renderLogicExpression(command, all_expression, expression_logic.second_operand, function_obj, exp_el_expr_el_2);
} else if (expression_logic.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_arithmetic) {
renderArithmeticExpression(command, all_expression, expression_logic.second_operand, function_obj, exp_el_expr_el_2);
} else {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_logic.second_operand, exp_el_expr_el_2, function_obj);
}
element_to_append.append(exp_el_expr_el_2);
}
element_to_append.append(exp_el_par_2);
}
function renderArithmeticExpression(command, all_expression, expression_arithmetic, function_obj, element_to_append) {
var exp_el_par_1 = $('
');
var exp_el_expr_el_1 = $('
');
var exp_el_expr_operand = $('
');
var exp_el_expr_el_2 = $('
');
var exp_el_par_2 = $('
');
if (expression_arithmetic.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_logic) {
renderLogicExpression(command, all_expression, expression_arithmetic.first_operand, function_obj, exp_el_expr_el_1);
} else if (expression_arithmetic.first_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_arithmetic) {
renderArithmeticExpression(command, all_expression, expression_arithmetic.first_operand, function_obj, exp_el_expr_el_1);
} else {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_arithmetic.first_operand, exp_el_expr_el_1, function_obj);
}
if (expression_arithmetic.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_logic) {
renderLogicExpression(command, all_expression, expression_arithmetic.second_operand, function_obj, exp_el_expr_el_2);
} else if (expression_arithmetic.second_operand.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_arithmetic) {
renderArithmeticExpression(command, all_expression, expression_arithmetic.second_operand, function_obj, exp_el_expr_el_2);
} else {
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, expression_arithmetic.second_operand, exp_el_expr_el_2, function_obj);
}
renderArithmeticOperator(command, all_expression, expression_arithmetic, expression_arithmetic.operator, function_obj, exp_el_expr_operand);
element_to_append.append(exp_el_par_1);
element_to_append.append(exp_el_expr_el_1);
element_to_append.append(exp_el_expr_operand);
element_to_append.append(exp_el_expr_el_2);
element_to_append.append(exp_el_par_2);
}
function renderStartMenu(command, expression, function_obj, initial_el_to_render) {
var start_menu = '';
start_menu += '';
start_menu = $(start_menu);
start_menu.dropdown({
onChange: function onChange(value, text, $selectedItem) {
switch ($selectedItem.data('exp')) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_logic:
expression.expression = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["LogicExpression"](false, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_TYPES"].exp_arithmetic:
expression.expression = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ArithmeticExpression"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].less_than);
break;
}
initial_el_to_render.html('');
renderExpression(command, expression, function_obj, initial_el_to_render);
},
selectOnKeydown: false
});
initial_el_to_render.append('
');
initial_el_to_render.append(start_menu);
initial_el_to_render.append('
');
}
/***/ }),
/***/ "./js/visualUI/commands/contextualized_menu.js":
/*!*****************************************************!*\
!*** ./js/visualUI/commands/contextualized_menu.js ***!
\*****************************************************/
/*! exports provided: renderMenu */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderMenu", function() { return renderMenu; });
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _switch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./switch */ "./js/visualUI/commands/switch.js");
function renderMenu(command, dom_where_render, function_obj, dom_command) {
var menu_div = '
';
menu_div = $(menu_div);
dom_where_render.append(menu_div);
addHandlers(command, dom_where_render, function_obj, dom_command);
}
function addHandlers(command, dom_where_render, function_obj, dom_command) {
dom_where_render.find('.menu_commands').dropdown({
on: 'hover'
});
dom_where_render.find('.menu_commands a').on('click', function (evt) {
if (command.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].repeatNtimes || command.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].whiletrue || command.type == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].dowhiletrue) {
if (command.commands_block == null || command.commands_block.length == 0) {
command.commands_block = [];
var new_cmd = _commands__WEBPACK_IMPORTED_MODULE_2__["genericCreateCommand"]($(this).data('command'));
command.commands_block.push(new_cmd);
_commands__WEBPACK_IMPORTED_MODULE_2__["renderCommand"](new_cmd, dom_command.find('.block_commands'), 3, function_obj);
} else {
_commands__WEBPACK_IMPORTED_MODULE_2__["createFloatingCommand"](function_obj, dom_command.find('.block_commands'), $(this).data('command'), evt);
}
} else {
switch ($(this).data('command')) {
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"]["break"]:
_commands__WEBPACK_IMPORTED_MODULE_2__["createFloatingCommand"](function_obj, dom_command.find('.block_commands'), $(this).data('command'), evt);
break;
case _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["COMMAND_TYPES"].switchcase:
addCaseToSwitch(command, dom_where_render, function_obj, dom_command);
break;
}
}
});
}
function addCaseToSwitch(command, dom_where_render, function_obj, dom_command) {
if (command.cases == null) {
command.cases = [];
}
var sc = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["SwitchCase"](new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
command.cases.push(sc);
_switch__WEBPACK_IMPORTED_MODULE_4__["renderCase"](sc, command, function_obj, dom_command.find('.all_cases_div'));
}
/***/ }),
/***/ "./js/visualUI/commands/dowhiletrue.js":
/*!*********************************************!*\
!*** ./js/visualUI/commands/dowhiletrue.js ***!
\*********************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _conditional_expression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
/* harmony import */ var _contextualized_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
/* harmony import */ var _generic_expression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./generic_expression */ "./js/visualUI/commands/generic_expression.js");
function createFloatingCommand() {
return $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_command_do') + ' ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_command_do_until') + '(x < 10)
');
}
function renderCommand(command, function_obj) {
var ret = '';
ret += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_command_do') + ' ';
ret += '
';
ret += '
';
ret += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_command_do_until') + ' (
) ';
ret += '
';
var el = $(ret);
el.data('command', command);
el.find('.block_commands').data('command', command);
addHandlers(command, function_obj, el);
_contextualized_menu__WEBPACK_IMPORTED_MODULE_3__["renderMenu"](command, el.find('.context_menu'), function_obj, el); //ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
if (command.expression) {
_generic_expression__WEBPACK_IMPORTED_MODULE_4__["renderExpression"](command, function_obj, el.find('.conditional_expression'), command.expression);
}
if (command.commands_block) {
for (var j = 0; j < command.commands_block.length; j++) {
_commands__WEBPACK_IMPORTED_MODULE_1__["renderCommand"](command.commands_block[j], $(el.find('.block_commands')[0]), 3, function_obj);
}
}
return el;
}
function addHandlers(command, function_obj, dowhiletrue_dom) {
dowhiletrue_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_1__["removeCommand"](command, function_obj, dowhiletrue_dom)) {
dowhiletrue_dom.fadeOut(400, function () {
dowhiletrue_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/functioncall.js":
/*!**********************************************!*\
!*** ./js/visualUI/commands/functioncall.js ***!
\**********************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
function createFloatingCommand() {
return $('
funcao()
');
}
function renderCommand(command, function_obj) {
var el = $('
');
el.data('command', command);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_0__["renderMenu"](command, command.function_called, el.find('.var_value_menu_div'), function_obj);
addHandlers(command, function_obj, el);
return el;
}
function addHandlers(command, function_obj, functioncall_dom) {
functioncall_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_1__["removeCommand"](command, function_obj, functioncall_dom)) {
functioncall_dom.fadeOut(400, function () {
functioncall_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/generic_expression.js":
/*!****************************************************!*\
!*** ./js/visualUI/commands/generic_expression.js ***!
\****************************************************/
/*! exports provided: renderExpression */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderExpression", function() { return renderExpression; });
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _services_userLog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../services/userLog */ "./js/services/userLog.js");
/* harmony import */ var melanke_watchjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! melanke-watchjs */ "./node_modules/melanke-watchjs/src/watch.js");
/* harmony import */ var melanke_watchjs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(melanke_watchjs__WEBPACK_IMPORTED_MODULE_5__);
window.timer = false;
function renderExpression(command, function_obj, div_to_render, expression_array) {
div_to_render.empty();
melanke_watchjs__WEBPACK_IMPORTED_MODULE_5___default.a.unwatch(command, "expression");
melanke_watchjs__WEBPACK_IMPORTED_MODULE_5___default.a.watch(command, "expression", function () {
if (window.timer) return;
var m = div_to_render.find('.single_element_expression').not('.mouse_distance').not('.add_parentheses');
var s = "";
m.each(function (e) {
if ($(this).hasClass('parentheses_in_expression')) {
s += $(this).text() + " ";
} else {
s += $(this).find('.text').text();
s += $(this).find('.var_name').text();
s += $(this).find('.parameters_function_called').text();
s += $(this).find('.value_rendered').text();
s += " ";
}
});
if (s) {
window.timer = true;
} else {
return;
}
Object(_services_userLog__WEBPACK_IMPORTED_MODULE_4__["registerUserEvent"])(function_obj.name, _services_userLog__WEBPACK_IMPORTED_MODULE_4__["ActionTypes"].CHANGE_COMMAND_EXP, command.type, '/', s);
setTimeout(function () {
window.timer = false;
}, 200);
}, 20, true);
if (command.type === _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["COMMAND_TYPES"].attribution) {
melanke_watchjs__WEBPACK_IMPORTED_MODULE_5___default.a.unwatch(command.variable);
melanke_watchjs__WEBPACK_IMPORTED_MODULE_5___default.a.watch(command.variable, function () {
renderExpression(command, function_obj, div_to_render, expression_array);
}, 0);
if (command.variable.content) {
var types_included = [];
if (command.variable.content.type == _types__WEBPACK_IMPORTED_MODULE_0__["Types"].INTEGER || command.variable.content.type == _types__WEBPACK_IMPORTED_MODULE_0__["Types"].REAL) {
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic);
} else if (command.variable.content.type == _types__WEBPACK_IMPORTED_MODULE_0__["Types"].BOOLEAN) {
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional);
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic);
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic);
} else if (command.variable.content.type == _types__WEBPACK_IMPORTED_MODULE_0__["Types"].TEXT) {
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional);
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic);
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic);
} else {
console.log('NÃO RECONHECI! VEJA: ', command.variable.content.type);
}
renderElements(command, function_obj, div_to_render, expression_array, types_included);
} else {
div_to_render.text(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('var_menu_select_var').toLowerCase());
}
} else {
var types_included = [];
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional);
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic);
types_included.push(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic);
renderElements(command, function_obj, div_to_render, expression_array, types_included);
}
div_to_render.children('.mouse_distance').addClass('mouse_distance_hidden');
div_to_render.children('.higher_element').on('mousemove', function (evt) {
if (!window.open_or_close) {
$(this).css('position', 'relative', '!important');
$(this).children('.mouse_distance').css('opacity', '1');
}
});
div_to_render.children('.higher_element').on('mouseout', function (evt) {
if (!window.open_or_close) {
$(this).css('position', 'absolute', '!important');
$(this).children('.mouse_distance').css('opacity', '0');
}
});
var lixeira = $('
');
div_to_render.find('.single_element_expression').on('mousedown', function (evt) {
window.posX = evt.clientX;
window.posY = evt.clientY;
});
Sortable.create(div_to_render[0], {
animation: 100,
ghostClass: 'ghost',
group: {
name: 'shared',
put: false // Do not allow items to be put into this list
},
draggable: '.single_element_expression',
sort: false,
filter: '.not_allowed',
onStart: function onStart() {
$('body').append(lixeira);
lixeira.css('display', 'block');
lixeira.css('top', window.posY + 70, '!important');
lixeira.css('left', window.posX - 20, '!important');
},
onMove: function onMove() {
lixeira.addClass('color_test');
},
onEnd: function onEnd() {
lixeira.remove();
div_to_render.find('.ghost').removeClass('ghost');
}
});
new Sortable(lixeira[0], {
group: 'shared',
animation: 150,
onAdd: function onAdd(evt) {
lixeira.css('display', 'none');
lixeira.find('.single_element_expression').remove();
lixeira.css('background-color', '');
lixeira.remove();
removeElement(evt, expression_array);
renderExpression(command, function_obj, div_to_render, expression_array);
}
});
}
function removeElement(event, expression_array) {
var indice = $(event.item).data('index');
var first = expression_array[0];
console.log('indice: ', indice);
if (expression_array[indice].type) {
// if is alone in expression:
if (expression_array.length == 1) {
//function_obj.commands.splice(function_obj.commands.indexOf(command), 1);
expression_array.splice(0, 1);
} else if (expression_array.length > 1) {
if (indice > 0 && expression_array[indice - 1].type_op) {
if (indice < expression_array.length && expression_array[indice - 2] == '(' && expression_array[indice + 1].type_op) {
expression_array.splice(indice + 1, 1);
}
expression_array.splice(indice, 1);
expression_array.splice(indice - 1, 1);
if (indice - 2 < expression_array.length && expression_array[indice - 2] == '(' && expression_array[indice - 1] == ')') {
expression_array.splice(indice - 1, 1);
expression_array.splice(indice - 2, 1);
if (indice - 3 >= 0 && indice - 3 < expression_array.length && expression_array[indice - 3].type_op) {
expression_array.splice(indice - 3, 1);
}
}
} else if (indice < expression_array.length - 1 && expression_array[indice + 1].type_op) {
expression_array.splice(indice + 1, 1);
expression_array.splice(indice, 1);
} else if (indice < expression_array.length - 1 && indice > 0 && expression_array[indice - 1] == '(' && expression_array[indice + 1] == ')') {
if (indice > 1 && expression_array[indice - 2].type_op) {
expression_array.splice(indice + 1, 1);
expression_array.splice(indice, 1);
expression_array.splice(indice - 1, 1);
expression_array.splice(indice - 2, 1);
} else if (indice < expression_array.length - 2 && expression_array[indice + 2].type_op) {
expression_array.splice(indice + 1, 1);
expression_array.splice(indice, 1);
expression_array.splice(indice - 1, 1);
} else {
expression_array.splice(indice + 1, 1);
expression_array.splice(indice, 1);
expression_array.splice(indice - 1, 1);
}
}
}
} else if (expression_array[indice].type_op) {// iVProg doesn't support operator remove
} else {
var opening = -1;
var closing = -1;
if (expression_array[indice] == '(') {
opening = indice;
for (var i = indice + 1; i < expression_array.length; i++) {
if (expression_array[i] == ')') {
closing = i;
break;
}
}
} else {
closing = indice;
for (var i = indice - 1; i >= 0; i--) {
if (expression_array[i] == '(') {
opening = i;
break;
}
}
}
if (expression_array[opening + 1].type_op) {
expression_array.splice(closing, 1);
expression_array.splice(opening + 1, 1);
expression_array.splice(opening, 1);
} else {
expression_array.splice(closing, 1);
expression_array.splice(opening, 1);
}
} // if expression is empty, add a new var value:
if (expression_array.length == 0) {
expression_array.push(new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
}
if (first != expression_array[0] && expression_array[0].type_op) {
expression_array.splice(0, 1);
}
}
function renderElements(command, function_obj, div_to_render, expression_array, types_included) {
/*if (expression_array.length > 0) {
if (!expression_array[0].type_op) {
renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);
}
}*/
var i = 0;
for (i = 0; i < expression_array.length; i++) {
if (expression_array[i].type == "var_value") {
var div_temp = $('
');
if (i == 0) {
if (expression_array.length > 0 && !expression_array[0].type_op) {//renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);
}
}
_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["renderMenu"](command, expression_array[i], div_temp, function_obj);
div_to_render.append(div_temp);
} else if (expression_array[i] == '(' || expression_array[i] == ')') {
if (expression_array[i] == ')') {
renderFinalAddElements(div_to_render, types_included, expression_array, command, function_obj, i);
renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
} else if (expression_array[i] == '(' && !expression_array[i + 1].type_op) {
renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, i + 1);
} else {
renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
}
} else {
if (i == 0) {
console.log("NEGAÇÃO NO PRIMEIRO ELEMENTO");
} else if (expression_array[i - 1] == '(') {
console.log("NEGAÇÃO APÓS O PARÊNTESES");
}
renderOperatorMenu(command, function_obj, div_to_render, expression_array[i], types_included, i, expression_array);
}
}
renderFinalAddElements(div_to_render, types_included, expression_array, command, function_obj, i, true);
renderAddParenthesis(command, function_obj, div_to_render, expression_array, types_included);
}
window.parentheses_activate = false;
window.open_or_close = null;
function renderAddParenthesis(command, function_obj, div_to_render, expression_array, types_included) {
var addParentheses = $('
');
div_to_render.append(addParentheses);
addParentheses.popup({
content: "Adicionar parênteses",
delay: {
show: 750,
hide: 0
}
});
addParentheses.on('click', function (mouse_event) {
// verificar se já está ativado
if (window.parentheses_activate) {
return;
}
div_to_render.find('.usepointer').off('click');
window.parentheses_activate = true;
window.open_or_close = "open";
div_to_render.find('.dropdown').addClass('disabled');
div_to_render.find('.ghost_element').addClass('temp_class');
div_to_render.find('.ghost_element').removeClass('ghost_element');
var floatingObject = $('
(
');
floatingObject.draggable().appendTo("body");
floatingObject.css("position", "absolute");
mouse_event.type = "mousedown.draggable";
mouse_event.target = floatingObject[0];
floatingObject.css("left", mouse_event.pageX + 10);
floatingObject.css("top", mouse_event.pageY + 10);
floatingObject.trigger(mouse_event);
div_to_render.on('mousemove', function (evt) {
var actual_target = null;
if ($(evt.target).hasClass('single_element_expression')) {
actual_target = $(evt.target);
} else {
actual_target = $(evt.target).closest('.single_element_expression');
}
if ($(evt.target).hasClass('temp_class') || actual_target.length < 1 || actual_target.hasClass('add_parentheses') || actual_target.hasClass('rendered_parentheses') || $(evt.target).hasClass('expression_elements')) {
return;
}
renderGhostParentheses(actual_target, command, function_obj, div_to_render, expression_array);
});
div_to_render.on('mouseleave', function () {
/*window.open_parentheses.remove();
window.close_parentheses.remove();*/
});
var floating;
$('body').on('mouseup', function (evt) {
if (window.open_or_close == "open") {
window.open_or_close = "close";
floatingObject.remove();
var comando_que_esta = $(evt.target).closest('.command_container');
var comando_certo = div_to_render.closest('.command_container');
if (!comando_que_esta.is(comando_certo)) {
window.parentheses_activate = false;
div_to_render.find('.temp_class').addClass('ghost_element');
div_to_render.find('.temp_class').removeClass('temp_class');
div_to_render.off('mousemove');
div_to_render.off('mouseleave');
$('body').off('mouseup');
window.open_parentheses.remove();
window.close_parentheses.remove();
window.inserir_open = -1;
window.inserir_close = -1;
window.open_or_close = null;
renderExpression(command, function_obj, div_to_render, expression_array);
return;
}
window.open_parentheses.addClass('parentheses_fixed');
floating = $('
)
');
floating.draggable().appendTo("body");
floating.css("position", "absolute");
floating.css("left", evt.pageX + 10);
floating.css("top", evt.pageY + 10);
$('body').on('mousemove', function (evts) {
floating.css("left", evts.pageX + 10);
floating.css("top", evts.pageY + 10);
});
} else {
floating.remove();
window.open_parentheses.removeClass('parentheses_fixed');
div_to_render.off('mousemove');
div_to_render.off('mouseleave');
$('body').off('mouseup');
setTimeout(function () {
window.parentheses_activate = false;
}, 50);
var comando_que_esta = $(evt.target).closest('.command_container');
var comando_certo = div_to_render.closest('.command_container');
var is_correct = false;
if (comando_que_esta.is(comando_certo)) {
is_correct = true;
}
if (is_correct) {
expression_array.splice(window.inserir_open, 0, '(');
expression_array.splice(window.inserir_close, 0, ')');
}
window.inserir_open = -1;
window.inserir_close = -1;
window.open_or_close = null;
renderExpression(command, function_obj, div_to_render, expression_array);
}
});
});
}
window.open_parentheses = $('
(
');
window.close_parentheses = $('
)
');
window.inserir_open = -1;
window.inserir_close = -1;
function renderGhostParentheses(actual_target, command, function_obj, div_to_render, expression_array) {
/*window.open_parentheses.remove();
window.close_parentheses.remove();*/
var index_in_array = actual_target.data('index');
if (expression_array[index_in_array] == '(' || expression_array[index_in_array] == ')') {
return;
}
if (window.open_or_close == "close") {
if (index_in_array < window.inserir_open) {
return;
}
} // Tratando a situação quando é na primeira posição:
if (index_in_array == 0) {
if (expression_array[index_in_array].type == "var_value") {
if (window.open_or_close == "open") {
window.open_parentheses.insertBefore(actual_target);
window.inserir_open = index_in_array;
}
/*if (expression_array.length == 1) {
if (window.open_or_close == "close") {
window.close_parentheses.insertAfter(actual_target);
window.inserir_close = index_in_array + 2;
}*/
//} else {
var count_opened = 0;
var count_closed = 0;
for (var i = 0; i < expression_array.length; i++) {
if (expression_array[i] == '(') {
count_opened++;
}
if (expression_array[i] == ')') {
count_closed++;
}
if (count_opened != count_closed) {} else {
if (count_opened > 0) {
if (window.open_or_close == "close") {
window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + i + '"]'));
window.inserir_close = i + 2;
}
break;
} else {
if (expression_array[i].type == "var_value") {
if (window.open_or_close == "close") {
window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + i + '"]'));
window.inserir_close = i + 2;
}
break;
}
}
}
} //}
} else if (expression_array[index_in_array].type_op) {
if (window.open_or_close == "open") {
window.open_parentheses.insertBefore(actual_target);
window.inserir_open = index_in_array;
}
var count_opened = 0;
var count_closed = 0;
for (var i = 1; i < expression_array.length; i++) {
// $('.slide-link[data-slide="0"]')
if (expression_array[i] == '(') {
count_opened++;
}
if (expression_array[i] == ')') {
count_closed++;
}
if (count_opened != count_closed) {} else {
if (count_opened > 0) {
if (expression_array[i].type == "var_value") {
window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + i + '"]'));
window.inserir_close = i + 2;
}
break;
} else {
if (expression_array[i].type == "var_value") {
if (expression_array[i].type == "var_value") {
window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + i + '"]'));
window.inserir_close = i + 2;
}
break;
}
}
}
}
}
return;
} // Tratando quando não é no índice 0:
if (expression_array[index_in_array].type == "var_value") {
if (window.open_or_close == "open") {
window.open_parentheses.insertBefore(actual_target);
window.inserir_open = index_in_array;
}
if (window.open_or_close == "close") {
window.close_parentheses.insertAfter(actual_target);
window.inserir_close = index_in_array + 2;
}
return;
}
if (expression_array[index_in_array].type_op) {
// buscar para a esquerda primeiro:
if (expression_array[index_in_array - 1] == '(') {
if (window.open_or_close == "open") {
window.open_parentheses.insertBefore(actual_target);
window.inserir_open = index_in_array;
}
} else if (expression_array[index_in_array - 1] == ')') {
// buscar a abertura
var count_opened = 0;
var count_closed = 0;
for (var j = index_in_array - 1; j >= 0; j--) {
if (expression_array[j] == '(') {
count_opened++;
}
if (expression_array[j] == ')') {
count_closed++;
}
if (count_opened != count_closed) {} else {
if (count_closed > 0) {
if (window.open_or_close == "open") {
window.open_parentheses.insertBefore(div_to_render.find('.single_element_expression[data-index="' + j + '"]'));
window.inserir_open = j;
}
break;
}
}
}
} else if (expression_array[index_in_array - 1].type == "var_value") {
if (window.open_or_close == "open") {
window.open_parentheses.insertBefore(div_to_render.find('.single_element_expression[data-index="' + (index_in_array - 1) + '"]'));
window.inserir_open = index_in_array - 1;
}
} // buscar para a direita agora:
if (expression_array[index_in_array + 1] == '(') {
// buscar o fechamento:
var count_opened = 0;
var count_closed = 0;
for (var j = index_in_array + 1; j < expression_array.length; j++) {
if (expression_array[j] == '(') {
count_opened++;
}
if (expression_array[j] == ')') {
count_closed++;
}
if (count_opened != count_closed) {} else {
if (count_opened > 0) {
if (window.open_or_close == "close") {
window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + j + '"]'));
window.inserir_close = j + 2;
}
break;
}
}
}
} else if (expression_array[index_in_array + 1].type == "var_value") {
if (window.open_or_close == "close") {
window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + (index_in_array + 1) + '"]'));
window.inserir_close = index_in_array + 3;
}
}
}
}
function renderParenthesis(div_to_render, expression_content, command, function_obj, position, expression_array) {
var ghost_parenthesis = $('
' + expression_content + '
');
div_to_render.append(ghost_parenthesis);
}
function renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, position) {
var menu_final = '
';
menu_final = $(menu_final);
var div_temp = $('
');
div_temp.append(menu_final);
var div_higher = $('
');
div_higher.append(div_temp);
div_to_render.append(div_higher);
menu_final.dropdown('set selected', _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].minus);
div_temp.on('click', function () {
if (!window.open_or_close) {
var sera = position;
if (types_included.indexOf(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic) >= 0) {
console.log('p1');
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ExpressionOperator"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic, _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].minus));
} else if (types_included.indexOf(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic) >= 0) {
console.log('p2');
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ExpressionOperator"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic, _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].equals_to));
} else if (types_included.indexOf(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional) >= 0) {
console.log('p3');
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ExpressionOperator"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional, _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].greater_than));
}
renderExpression(command, function_obj, div_to_render, expression_array);
}
});
}
function renderFinalAddElements(div_to_render, types_included, expression_array, command, function_obj, position) {
var is_last = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
var menu_final = '
';
menu_final = $(menu_final);
var div_temp = $('
');
var div_higher = $('
');
var button = $('
');
div_temp.append(button);
if (!is_last) {
div_higher.append(div_temp);
div_to_render.append(div_higher); //div_temp.append(menu_final);
div_temp.css('opacity', '0', '!important');
} else {
div_temp.removeClass('mouse_distance');
div_temp.css('opacity', '1', '!important'); //div_temp.append(menu_final);
div_to_render.append(div_temp);
}
menu_final.dropdown('set selected', _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].plus);
div_temp.on('click', function () {
var sera = position;
if (expression_array[sera] == ')' && expression_array[sera - 1] == '(') {
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
renderExpression(command, function_obj, div_to_render, expression_array);
return;
}
if (types_included.indexOf(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic) >= 0) {
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ExpressionOperator"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_arithmetic, _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_TYPES"].plus));
expression_array.splice(sera + 1, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
} else if (types_included.indexOf(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic) >= 0) {
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ExpressionOperator"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_logic, _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["LOGIC_COMPARISON"].equals_to));
expression_array.splice(sera + 1, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
} else if (types_included.indexOf(_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional) >= 0) {
expression_array.splice(sera, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ExpressionOperator"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["EXPRESSION_TYPES"].exp_conditional, _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["ARITHMETIC_COMPARISON"].greater_than));
expression_array.splice(sera + 1, 0, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_1__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_3__["VAR_OR_VALUE_TYPES"].all, null, null, null, true));
}
renderExpression(command, function_obj, div_to_render, expression_array);
});
}
function renderOperatorMenu(command, function_obj, div_to_render, expression_element, types_included, position, expression_array) {
var menu_final = '
';
menu_final = $(menu_final);
var div_temp = $('
');
div_temp.append(menu_final);
div_to_render.append(div_temp);
menu_final.dropdown({
onChange: function onChange(value, text, $selectedItem) {
expression_element.item = $selectedItem.data('value');
expression_element.type_op = $selectedItem.data('type');
}
});
menu_final.dropdown('set selected', expression_element.item);
}
function getArithmeticOperators() {
var arithmetic_operators;
arithmetic_operators = '
+
';
arithmetic_operators += '
-
';
arithmetic_operators += '
*
';
arithmetic_operators += '
/
';
arithmetic_operators += '
%
';
return arithmetic_operators;
}
function getLogicOperators() {
var logic_operators;
logic_operators = '
==
';
logic_operators += '
!=
';
logic_operators += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_operator_and') + '
';
logic_operators += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_operator_or') + '
';
logic_operators += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_2__["LocalizedStrings"].getUI('logic_operator_not') + '
';
return logic_operators;
}
function getRelationalOperators() {
var relational_operators;
relational_operators = '
>
';
relational_operators += '
<
';
relational_operators += '
==
';
relational_operators += '
!=
';
relational_operators += '
>=
';
relational_operators += '
<=
';
return relational_operators;
}
/***/ }),
/***/ "./js/visualUI/commands/iftrue.js":
/*!****************************************!*\
!*** ./js/visualUI/commands/iftrue.js ***!
\****************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _conditional_expression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
/* harmony import */ var _generic_expression__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./generic_expression */ "./js/visualUI/commands/generic_expression.js");
function createFloatingCommand() {
return $('
if (x < 1) { }
');
}
function renderCommand(command, function_obj) {
var ret = '';
ret += '
';
ret += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_if') + ' ';
ret += '
(
) ';
ret += '
';
ret += '
';
ret += '
';
ret += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_else') + ' ';
ret += '
';
ret += '
';
ret += '
';
ret += '
';
var el = $(ret);
el.data('command', command);
el.find('.block_commands').data('command', command);
el.find('.data_block_if').data('command', command);
el.find('.data_block_else').data('command', command);
el.find('.commands_if').data('command', command);
addHandlers(command, function_obj, el); //ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
_generic_expression__WEBPACK_IMPORTED_MODULE_3__["renderExpression"](command, function_obj, el.find('.conditional_expression'), command.expression);
if (command.commands_block) {
for (var j = 0; j < command.commands_block.length; j++) {
_commands__WEBPACK_IMPORTED_MODULE_1__["renderCommand"](command.commands_block[j], $(el.find('.commands_if')[0]), 3, function_obj);
}
}
if (command.commands_else) {
for (var j = 0; j < command.commands_else.length; j++) {
_commands__WEBPACK_IMPORTED_MODULE_1__["renderCommand"](command.commands_else[j], $(el.find('.commands_else')[0]), 3, function_obj);
}
}
return el;
}
function addHandlers(command, function_obj, iftrue_dom) {
iftrue_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_1__["removeCommand"](command, function_obj, iftrue_dom)) {
iftrue_dom.fadeOut(400, function () {
iftrue_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/reader.js":
/*!****************************************!*\
!*** ./js/visualUI/commands/reader.js ***!
\****************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
function createFloatingCommand() {
return $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_command_read') + ' var
');
}
function renderCommand(command, function_obj) {
var el = '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_command_read') + ' ( )
';
el = $(el);
el.data('command', command);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_1__["renderMenu"](command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
addHandlers(command, function_obj, el);
return el;
}
function addHandlers(command, function_obj, reader_dom) {
reader_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_2__["removeCommand"](command, function_obj, reader_dom)) {
reader_dom.fadeOut(400, function () {
reader_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/repeatNtimes.js":
/*!**********************************************!*\
!*** ./js/visualUI/commands/repeatNtimes.js ***!
\**********************************************/
/*! exports provided: createFloatingCommand, renderCommand, manageExpressionElements, manageClearExpressionElements */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "manageExpressionElements", function() { return manageExpressionElements; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "manageClearExpressionElements", function() { return manageClearExpressionElements; });
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _conditional_expression__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _contextualized_menu__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
/* harmony import */ var _generic_expression__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./generic_expression */ "./js/visualUI/commands/generic_expression.js");
function createFloatingCommand() {
return $('
repita_para i de 0 ate 10 passo 1
');
}
function renderCommand(command, function_obj) {
var ret = "
\n\t\t
\n\t\t
\n\t\t
".concat(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('text_for'), "\n\t\t \n\t\t
\n\t\t").concat(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI("text_for_to"), " \n\t\t
\n\t\t
'");
ret += '
';
ret += '
';
ret += '
';
ret += '
';
var el = $(ret);
el.data('command', command);
el.find('.block_commands').data('command', command);
addHandlers(command, function_obj, el);
_contextualized_menu__WEBPACK_IMPORTED_MODULE_5__["renderMenu"](command, el.find('.context_menu'), function_obj, el);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.var_attribution, el.find('.variable_attribution'), function_obj); //ConditionalExpressionManagement.renderExpression(command, command.expression2, function_obj, el.find('.conditional_expression'));
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.expression2, el.find('.conditional_expression'), function_obj); //GenericExpressionManagement.renderExpression(command, function_obj, el.find('.conditional_expression'), command.expression2);
//VariableValueMenu.renderMenu(command, command.var_incrementation, el.find('.incrementation_variable'), function_obj);
//angle double right
if (!command.expression1) {
command.expression1 = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, "0", null, null, true);
}
el.find('.text_receives').text(_services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI("text_for_from"));
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.expression1, el.find('.var_value_expression'), function_obj);
if (!command.expression3) {
el.find('.pass_button').html('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI("text_for_pass") + ' ');
el.find('.pass_button').find('button').on('click', function () {
togglePasso(command);
});
/*var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp,
[command.var_attribution,
Models.ARITHMETIC_TYPES.plus,
new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, "1", null, null, true)]);
command.expression3 = exp;
command.var_incrementation = command.var_attribution;*/
} else {
el.find('.pass_button').html('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI("text_for_pass") + ' ');
el.find('.pass_button').find('button').on('click', function () {
togglePasso(command);
});
renderOperator(command, function_obj, el.find('.operator'), command.expression3, 1);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.expression3.itens[2], el.find('.second_operand'), function_obj);
}
if (command.commands_block) {
for (var j = 0; j < command.commands_block.length; j++) {
_commands__WEBPACK_IMPORTED_MODULE_2__["renderCommand"](command.commands_block[j], $(el.find('.block_commands')[0]), 3, function_obj);
}
}
return el;
}
function togglePasso(command) {
if (!command.expression3) {
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp, [command.var_attribution, _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, "1", null, null, true)]);
command.expression3 = exp;
command.var_incrementation = command.var_attribution;
} else {
command.expression3 = null;
}
renderAlgorithm();
}
function manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element) {
if (dom_object.hasClass('variable_attribution')) {
if (!command.expression3) {
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp, [command.var_attribution, _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, "1", null, null, true)]);
command.expression3 = exp;
command.var_incrementation = command.var_attribution;
var cond_exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ArithmeticExpression"](command.var_attribution, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_COMPARISON"].less_than);
command.expression2.expression = cond_exp;
}
dom_object.parent().find('.text_receives').text('de');
command.expression1 = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, "0", null, null, true);
dom_object.parent().find('.var_value_expression').empty();
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.expression1, dom_object.parent().find('.var_value_expression'), function_obj);
renderAlgorithm();
}
if (dom_object.hasClass('incrementation_variable')) {
dom_object.parent().find('.text_inc_receives').text('de');
var exp = new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ExpressionElement"](_ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["EXPRESSION_ELEMENTS"].exp_op_exp, [new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, null, null, null, true), _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus, new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["VAR_OR_VALUE_TYPES"].all, null, null, null, true)]);
command.expression3 = exp;
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.expression3.itens[0], dom_object.parent().find('.first_operand'), function_obj);
renderOperator(command, function_obj, dom_object.parent().find('.operator'), command.expression3, 1);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_4__["renderMenu"](command, command.expression3.itens[2], dom_object.parent().find('.second_operand'), function_obj);
}
}
function manageClearExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element) {
if (dom_object.hasClass('variable_attribution')) {
$(dom_object).parent().find('.text_receives').text('');
command.expression1 = null;
$(dom_object).parent().find('.var_value_expression').empty();
}
if (dom_object.hasClass('incrementation_variable')) {
$(dom_object).parent().find('.text_inc_receives').text('');
command.expression3 = null;
$(dom_object).parent().find('.first_operand').empty();
$(dom_object).parent().find('.operator').empty();
$(dom_object).parent().find('.second_operand').empty();
}
}
function addHandlers(command, function_obj, repeatNtimes_dom) {
repeatNtimes_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_2__["removeCommand"](command, function_obj, repeatNtimes_dom)) {
repeatNtimes_dom.fadeOut(400, function () {
repeatNtimes_dom.remove();
});
}
});
}
function renderOperator(command, function_obj, temp_op, expression_element, index_op) {
var menu_operator = $('
');
menu_operator.dropdown({
values: [{
name: '+',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus,
selected: expression_element.itens[index_op] == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].plus
}, {
name: '-',
value: _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].minus,
selected: expression_element.itens[index_op] == _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["ARITHMETIC_TYPES"].minus
}],
onChange: function onChange(value, text, $selectedItem) {
expression_element.itens[index_op] = value;
}
});
temp_op.append(menu_operator);
}
/***/ }),
/***/ "./js/visualUI/commands/return.js":
/*!****************************************!*\
!*** ./js/visualUI/commands/return.js ***!
\****************************************/
/*! exports provided: createFloatingCommand, renderCommand */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _generic_expression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./generic_expression */ "./js/visualUI/commands/generic_expression.js");
function createFloatingCommand() {
return $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('text_return') + '
');
}
function renderCommand(command, function_obj) {
var el = $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__["LocalizedStrings"].getUI('text_return') + '
');
el.data('command', command);
addHandlers(command, function_obj, el);
if (function_obj.return_type != _types__WEBPACK_IMPORTED_MODULE_0__["Types"].VOID) {
//VariableValueMenu.renderMenu(command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
_generic_expression__WEBPACK_IMPORTED_MODULE_4__["renderExpression"](command, function_obj, el.find('.expression_elements'), command.variable_value_menu);
} else {
el.find('.expression_elements').remove();
command.variable_value_menu = null;
}
return el;
}
function addHandlers(command, function_obj, return_dom) {
return_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_3__["removeCommand"](command, function_obj, return_dom)) {
return_dom.fadeOut(400, function () {
return_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/switch.js":
/*!****************************************!*\
!*** ./js/visualUI/commands/switch.js ***!
\****************************************/
/*! exports provided: createFloatingCommand, renderCommand, renderCase */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFloatingCommand", function() { return createFloatingCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCommand", function() { return renderCommand; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderCase", function() { return renderCase; });
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
/* harmony import */ var _variable_value_menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
/* harmony import */ var _contextualized_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
function createFloatingCommand() {
return $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_code_switch') + ' ( x ) { ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_code_case') + ' 1: ' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_code_case') + ' 2: }
');
}
function renderCommand(command, function_obj) {
var ret = '';
ret += '
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_code_switch') + ' (
)
';
ret += '
';
var el = $(ret);
el.data('command', command);
addHandlers(command, function_obj, el);
_contextualized_menu__WEBPACK_IMPORTED_MODULE_3__["renderMenu"](command, el.find('.context_menu'), function_obj, el);
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, command.variable, el.find('.variable_to_switch'), function_obj);
if (command.cases) {
for (var i = 0; i < command.cases.length; i++) {
renderCase(command.cases[i], command, function_obj, el.find('.all_cases_div'));
}
}
return el;
}
function renderCase(switchcase, command, function_obj, el) {
var casediv = $('
' + _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_0__["LocalizedStrings"].getUI('text_code_case') + '
:
');
_variable_value_menu__WEBPACK_IMPORTED_MODULE_2__["renderMenu"](command, switchcase.variable_value_menu, casediv.find('.variable_case'), function_obj);
casediv.data('switchcase', switchcase);
casediv.find('.case_commands_block').data('switchcase', switchcase);
el.append(casediv);
if (switchcase.commands_block) {
for (var j = 0; j < switchcase.commands_block.length; j++) {
_commands__WEBPACK_IMPORTED_MODULE_1__["renderCommand"](switchcase.commands_block[j], $(casediv.find('.case_commands_block')[0]), 3, function_obj);
}
}
casediv.find('.button_remove_command').on('click', function () {
for (var i = 0; i < command.cases.length; i++) {
if (switchcase == command.cases[i]) {
delete command.cases[i];
command.cases.splice(i, 1);
casediv.remove();
break;
}
}
});
}
function addHandlers(command, function_obj, switch_dom) {
switch_dom.find('.button_remove_command').on('click', function () {
if (_commands__WEBPACK_IMPORTED_MODULE_1__["removeCommand"](command, function_obj, switch_dom)) {
switch_dom.fadeOut(400, function () {
switch_dom.remove();
});
}
});
}
/***/ }),
/***/ "./js/visualUI/commands/variable_value_menu.js":
/*!*****************************************************!*\
!*** ./js/visualUI/commands/variable_value_menu.js ***!
\*****************************************************/
/*! exports provided: VAR_OR_VALUE_TYPES, renderMenu */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VAR_OR_VALUE_TYPES", function() { return VAR_OR_VALUE_TYPES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "renderMenu", function() { return renderMenu; });
/* harmony import */ var _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
/* harmony import */ var _services_localizedStringsService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
/* harmony import */ var _attribution__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./attribution */ "./js/visualUI/commands/attribution.js");
/* harmony import */ var _repeatNtimes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./repeatNtimes */ "./js/visualUI/commands/repeatNtimes.js");
var VAR_OR_VALUE_TYPES = Object.freeze({
only_variable: 1,
only_value: 2,
only_function: 3,
variable_and_function: 4,
variable_and_value_opt: 5,
value_and_function: 6,
all: 7
});
function renderMenu(command, ref_object, dom_object, function_obj) {
var size_field = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
var expression_element = arguments.length > 5 ? arguments[5] : undefined;
// Verificar se o objeto atual trata-se de uma chamada de função e conferir se possui a quantidade correta de parâmetros
// Caso não possua, tem que adicionar as variáveis que servirão de parâmetros:
if (ref_object.function_called) {
if (ref_object.function_called.parameters_list) {
while (ref_object.function_called.parameters_list.length != ref_object.parameters_list.length) {
if (ref_object.parameters_list.length > ref_object.function_called.parameters_list.length) {
ref_object.parameters_list.pop();
} else {
ref_object.parameters_list.push(new _ivprog_elements__WEBPACK_IMPORTED_MODULE_0__["VariableValueMenu"](VAR_OR_VALUE_TYPES.all, null, null, null, true));
}
}
}
}
var menu_var_or_value = '