diff --git a/.gitignore b/.gitignore index bab9c0778..def6aaec1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ nbproject *~ js.files core +**.orig # ctags and ID database tags diff --git a/Makefile.mak b/Makefile.mak index 6bdfbe040..ec77a95d2 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -110,7 +110,7 @@ CFLAGS_CORTEXM4 ?= -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb \ # Common # -CFLAGS_COMMON ?= $(INCLUDES) -std=c99 -fsanitize=address -fdiagnostics-color=always +CFLAGS_COMMON ?= $(INCLUDES) -std=c99 #-fsanitize=address -fdiagnostics-color=always LDFLAGS ?= diff --git a/src/generated.h b/src/generated.h index fae8816bc..68e831091 100644 --- a/src/generated.h +++ b/src/generated.h @@ -15,17 +15,6 @@ #include "globals.h" -static const char* generated_source __unused = "" -"while (true) {\n" -"LEDToggle (LED3);\n" -"LEDToggle (LED6);\n" -"LEDToggle (LED7);\n" -"LEDToggle (LED4);\n" -"LEDToggle (LED10);\n" -"LEDToggle (LED8);\n" -"LEDToggle (LED9);\n" -"LEDToggle (LED5);\n" -"\n" -"wait(500);\n" -"}\n" +static const char* generated_source = "" +"LEDToggle (14);\n" ; diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 821cb9328..dfc9a8b3b 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -13,8 +13,12 @@ * limitations under the License. */ +#include "deserializer.h" +#include "ecma-globals.h" #include "ecma-helpers.h" +#include "globals.h" #include "interpreter.h" +#include "jerry-libc.h" #define INIT_OP_FUNC(name) [ __op__idx_##name ] = opfunc_##name, static const opfunc __opfuncs[LAST_OP] = { @@ -42,15 +46,17 @@ run_int (void) { JERRY_ASSERT( __program != NULL ); - struct __int_data int_data; - int_data.pos = 0; - int_data.this_binding_p = NULL; - int_data.lex_env_p = ecma_create_lexical_environment( NULL, - ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE); + const int start_pos = 0; + ecma_object_t *this_binding_p = NULL; + ecma_object_t *lex_env_p = ecma_create_lexical_environment (NULL, + ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE); FIXME( Strict mode ); - int_data.is_strict = false; + const bool is_strict = false; - ecma_completion_value_t completion = run_int_from_pos( &int_data); + ecma_completion_value_t completion = run_int_from_pos (start_pos, + this_binding_p, + lex_env_p, + is_strict); switch ( (ecma_completion_type_t)completion.type ) { @@ -82,16 +88,43 @@ run_int (void) } ecma_completion_value_t -run_int_from_pos (struct __int_data *int_data) +run_int_from_pos (int start_pos, + ecma_object_t *this_binding_p, + ecma_object_t *lex_env_p, + bool is_strict) { ecma_completion_value_t completion; + const OPCODE *curr = &__program[start_pos]; + JERRY_ASSERT( curr->op_idx == __op__idx_reg_var_decl ); + + const T_IDX min_reg_num = curr->data.reg_var_decl.min; + const T_IDX max_reg_num = curr->data.reg_var_decl.max; + JERRY_ASSERT( max_reg_num >= min_reg_num ); + + const uint32_t regs_num = (uint32_t) (max_reg_num - min_reg_num + 1); + + ecma_value_t regs[ regs_num ]; + + /* memseting with zero initializes each 'register' to empty value */ + __memset (regs, 0, sizeof(regs)); + JERRY_ASSERT( ecma_is_value_empty( regs[0]) ); + + struct __int_data int_data; + int_data.pos = start_pos + 1; + int_data.this_binding_p = this_binding_p; + int_data.lex_env_p = lex_env_p; + int_data.is_strict = is_strict; + int_data.min_reg_num = min_reg_num; + int_data.max_reg_num = max_reg_num; + int_data.regs_p = regs; + while ( true ) { do { - const OPCODE *curr = &__program[int_data->pos]; - completion = __opfuncs[curr->op_idx](*curr, int_data); + const OPCODE *curr = &__program[int_data.pos]; + completion = __opfuncs[curr->op_idx](*curr, &int_data); JERRY_ASSERT( !ecma_is_completion_value_normal( completion) || ecma_is_completion_value_normal_simple_value(completion, @@ -111,6 +144,13 @@ run_int_from_pos (struct __int_data *int_data) continue; } + for ( uint32_t reg_index = 0; + reg_index < regs_num; + reg_index++ ) + { + ecma_free_value( regs[ reg_index ] ); + } + return completion; } } @@ -128,18 +168,19 @@ try_get_string_by_idx(T_IDX idx, /**< literal id */ { TODO( Actual string literal retrievement ); - ssize_t req_length = 2; // TODO - - JERRY_ASSERT( idx < 'z' - 'a' + 1 ); + const ecma_char_t *str_p = deserialize_string_by_id( idx); + JERRY_ASSERT( str_p != NULL ); + + FIXME( strlen for ecma_char_t ); + ssize_t req_length = (ssize_t)__strlen( (const char*)str_p) + 1; if ( buffer_size < req_length ) { return -req_length; } - // TODO - buffer_p[0] = (ecma_char_t) ('a' + idx); - buffer_p[1] = 0; + FIXME( strncpy for ecma_char_t ); + __strncpy( (char*)buffer_p, (const char*)str_p, (size_t)req_length); return req_length; } /* try_get_string_by_idx */ @@ -154,5 +195,8 @@ get_number_by_idx(T_IDX idx) /**< literal id */ { TODO( Actual number literal retrievement ); - return (ecma_number_t)idx; + FIXME( /* conversion of value returned from deserialize_num_by_id to ecma_number_t */ ); + ecma_number_t num = (ecma_number_t) deserialize_num_by_id( idx); + + return num; } /* get_number_by_idx */ diff --git a/src/libcoreint/interpreter.h b/src/libcoreint/interpreter.h index 5825b25eb..253b77565 100644 --- a/src/libcoreint/interpreter.h +++ b/src/libcoreint/interpreter.h @@ -26,11 +26,17 @@ struct __int_data ecma_object_t *this_binding_p; /**< this binding for current context */ ecma_object_t *lex_env_p; /**< current lexical environment */ bool is_strict; /**< is current code execution mode strict? */ + T_IDX min_reg_num; /**< minimum idx used for register identification */ + T_IDX max_reg_num; /**< maximum idx used for register identification */ + ecma_value_t *regs_p; /**< register variables */ }; void init_int (const OPCODE* program_p); bool run_int (void); -ecma_completion_value_t run_int_from_pos (struct __int_data *); +ecma_completion_value_t run_int_from_pos (int start_pos, + ecma_object_t *this_binding_p, + ecma_object_t *lex_env_p, + bool is_strict); ssize_t try_get_string_by_idx( T_IDX idx, ecma_char_t *buffer_p, ssize_t buffer_size); ecma_number_t get_number_by_idx(T_IDX idx); diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index af9357c26..783ab449f 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -25,6 +25,10 @@ #include "mem-heap.h" #include "opcodes.h" +#include "actuators.h" +#include "common-io.h" +#include "sensors.h" + /** * Note: * The note describes exception handling in opcode handlers that perform operations, @@ -183,27 +187,42 @@ get_variable_value(struct __int_data *int_data, /**< interpreter context */ bool do_eval_or_arguments_check) /** run 'strict eval or arguments reference' check See also: do_strict_eval_arguments_check */ { - string_literal_copy var_name; - ecma_reference_t ref; ecma_completion_value_t ret_value; - init_string_literal_copy( var_idx, &var_name); - ref = ecma_op_get_identifier_reference( int_data->lex_env_p, - var_name.str_p, - int_data->is_strict); + if ( var_idx >= int_data->min_reg_num + && var_idx <= int_data->max_reg_num ) + { + ecma_value_t reg_value = int_data->regs_p[ var_idx - int_data->min_reg_num ]; - if ( unlikely( do_eval_or_arguments_check - && do_strict_eval_arguments_check( ref) ) ) + JERRY_ASSERT( !ecma_is_value_empty( reg_value) ); + + ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, + ecma_copy_value( reg_value), + ECMA_TARGET_ID_RESERVED); + } + else + { + string_literal_copy var_name; + ecma_reference_t ref; + + init_string_literal_copy( var_idx, &var_name); + ref = ecma_op_get_identifier_reference( int_data->lex_env_p, + var_name.str_p, + int_data->is_strict); + + if ( unlikely( do_eval_or_arguments_check + && do_strict_eval_arguments_check( ref) ) ) { ret_value = ecma_make_throw_value( ecma_new_standard_error( ECMA_ERROR_SYNTAX)); } - else + else { ret_value = ecma_op_get_value( ref); } - ecma_free_reference( ref); - free_string_literal_copy( &var_name); + ecma_free_reference( ref); + free_string_literal_copy( &var_name); + } return ret_value; } /* get_variable_value */ @@ -219,26 +238,44 @@ set_variable_value(struct __int_data *int_data, /**< interpreter context */ T_IDX var_idx, /**< variable identifier */ ecma_value_t value) /**< value to set */ { - string_literal_copy var_name; - ecma_reference_t ref; ecma_completion_value_t ret_value; - init_string_literal_copy( var_idx, &var_name); - ref = ecma_op_get_identifier_reference( int_data->lex_env_p, - var_name.str_p, - int_data->is_strict); + if ( var_idx >= int_data->min_reg_num + && var_idx <= int_data->max_reg_num ) + { + ecma_value_t reg_value = int_data->regs_p[ var_idx - int_data->min_reg_num ]; - if ( unlikely( do_strict_eval_arguments_check( ref) ) ) + if ( !ecma_is_value_empty( reg_value) ) + { + ecma_free_value( reg_value); + } + + int_data->regs_p[ var_idx - int_data->min_reg_num ] = ecma_copy_value( value); + + ret_value = ecma_make_empty_completion_value(); + } + else + { + string_literal_copy var_name; + ecma_reference_t ref; + + init_string_literal_copy( var_idx, &var_name); + ref = ecma_op_get_identifier_reference( int_data->lex_env_p, + var_name.str_p, + int_data->is_strict); + + if ( unlikely( do_strict_eval_arguments_check( ref) ) ) { ret_value = ecma_make_throw_value( ecma_new_standard_error( ECMA_ERROR_SYNTAX)); } - else + else { ret_value = ecma_op_put_value( ref, value); } - ecma_free_reference( ref); - free_string_literal_copy( &var_name); + ecma_free_reference( ref); + free_string_literal_copy( &var_name); + } return ret_value; } /* set_variable_value */ @@ -376,20 +413,23 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */ op(post_decr) \ op(pre_incr) \ op(pre_decr) \ - op(reg_var_decl) + static char __unused unimplemented_list_end #define DEFINE_UNIMPLEMENTED_OP(op) \ ecma_completion_value_t opfunc_ ## op(OPCODE opdata, struct __int_data *int_data) { \ JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( opdata, int_data); \ } -OP_UNIMPLEMENTED_LIST(DEFINE_UNIMPLEMENTED_OP) +OP_UNIMPLEMENTED_LIST(DEFINE_UNIMPLEMENTED_OP); #undef DEFINE_UNIMPLEMENTED_OP ecma_completion_value_t opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data) -{ +{ + ecma_completion_value_t ret_value; + ret_value = ecma_make_empty_completion_value (); + #ifdef __HOST - __printf ("%d::op_call_1:idx:%d:%d\n", + __printf ("%d::op_call_1:idx:%d:%d\t", int_data->pos, opdata.data.call_1.name_lit_idx, opdata.data.call_1.arg1_lit_idx); @@ -397,8 +437,27 @@ opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data) int_data->pos++; - // FIXME - return ecma_make_empty_completion_value(); + string_literal_copy str_value; + init_string_literal_copy( opdata.data.call_1.name_lit_idx, &str_value); + +#ifdef __HOST + __printf("%s\n", str_value.str_p); +#endif + + if (!__strcmp ((const char*)str_value.str_p, "LEDToggle")) + { + TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value); + JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER ); + ecma_number_t * num_p = (ecma_number_t*)ecma_get_pointer(cond_value.value.value); + uint32_t int_num = (uint32_t)*num_p; + led_blink_once (int_num); + ret_value = ecma_make_empty_completion_value (); + FINALIZE (cond_value); + } + + free_string_literal_copy (&str_value); + + return ret_value; } /** @@ -808,6 +867,18 @@ opfunc_remainder(OPCODE opdata, /**< operation data */ return ret_value; } /* opfunc_remainder */ +/** + * 'Register variable declaration' opcode handler. + * + * The opcode is meta-opcode that is not supposed to be executed. + */ +ecma_completion_value_t +opfunc_reg_var_decl(OPCODE opdata __unused, /**< operation data */ + struct __int_data *int_data __unused) /**< interpreter context */ +{ + JERRY_UNREACHABLE(); +} /* opfunc_reg_var_decl */ + /** * 'Variable declaration' opcode handler. * @@ -819,25 +890,25 @@ opfunc_remainder(OPCODE opdata, /**< operation data */ */ ecma_completion_value_t opfunc_var_decl(OPCODE opdata, /**< operation data */ - struct __int_data *int_data __unused) /**< interpreter context */ + struct __int_data *int_data) /**< interpreter context */ { string_literal_copy variable_name; init_string_literal_copy( opdata.data.var_decl.variable_name, &variable_name); - if ( ecma_is_completion_value_normal_false( ecma_op_has_binding( int_data->lex_env_p, - variable_name.str_p)) ) + if ( ecma_is_completion_value_normal_false( ecma_op_has_binding (int_data->lex_env_p, + variable_name.str_p)) ) { FIXME( Pass configurableBindings that is true if and only if current code is eval code ); - ecma_op_create_mutable_binding( int_data->lex_env_p, - variable_name.str_p, - false); + ecma_op_create_mutable_binding (int_data->lex_env_p, + variable_name.str_p, + false); /* Skipping SetMutableBinding as we have already checked that there were not * any binding with specified name in current lexical environment * and CreateMutableBinding sets the created binding's value to undefined */ - JERRY_ASSERT( ecma_is_completion_value_normal_simple_value( ecma_op_get_binding_value( int_data->lex_env_p, - variable_name.str_p, - true), + JERRY_ASSERT( ecma_is_completion_value_normal_simple_value( ecma_op_get_binding_value (int_data->lex_env_p, + variable_name.str_p, + true), ECMA_SIMPLE_VALUE_UNDEFINED) ); } diff --git a/src/libecmaobjects/ecma-globals.h b/src/libecmaobjects/ecma-globals.h index 61a58f586..39611a2e3 100644 --- a/src/libecmaobjects/ecma-globals.h +++ b/src/libecmaobjects/ecma-globals.h @@ -63,11 +63,11 @@ typedef enum { * Simple ecma-values */ typedef enum { + ECMA_SIMPLE_VALUE_EMPTY, /**< empty value (see also: ECMA-262 v5, 8.9 Completion specification type) */ ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */ ECMA_SIMPLE_VALUE_NULL, /**< null value */ ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */ ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */ - ECMA_SIMPLE_VALUE_EMPTY, /**< empty value (see also: ECMA-262 v5, 8.9 Completion specification type) */ ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< special value for an array's elements that exists, but is stored directly in the array's property list (used for array elements with non-default attribute values) */ diff --git a/src/libecmaobjects/ecma-helpers-value.c b/src/libecmaobjects/ecma-helpers-value.c index bb66c33a9..efa0a1155 100644 --- a/src/libecmaobjects/ecma-helpers-value.c +++ b/src/libecmaobjects/ecma-helpers-value.c @@ -26,6 +26,18 @@ #include "ecma-helpers.h" #include "globals.h" +/** + * Check if the value is empty. + * + * @return true - if the value contains implementation-defined empty simple value, + * false - otherwise. + */ +bool +ecma_is_value_empty( ecma_value_t value) /**< ecma-value */ +{ + return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_EMPTY ); +} /* ecma_is_value_empty */ + /** * Check if the value is undefined. * diff --git a/src/libecmaobjects/ecma-helpers.h b/src/libecmaobjects/ecma-helpers.h index db8e3e0ab..a72e84bec 100644 --- a/src/libecmaobjects/ecma-helpers.h +++ b/src/libecmaobjects/ecma-helpers.h @@ -42,6 +42,7 @@ extern void* ecma_decompress_pointer(uintptr_t compressed_pointer); (field) = ecma_compress_pointer( non_compressed_pointer) & ( ( 1u << ECMA_POINTER_FIELD_WIDTH ) - 1) /* ecma-helpers-value.c */ +extern bool ecma_is_value_empty( ecma_value_t value); extern bool ecma_is_value_undefined( ecma_value_t value); extern bool ecma_is_value_null( ecma_value_t value); extern bool ecma_is_value_boolean( ecma_value_t value); diff --git a/src/libperipherals/actuators.c b/src/libperipherals/actuators.c index 1fa50043a..bd66af889 100644 --- a/src/libperipherals/actuators.c +++ b/src/libperipherals/actuators.c @@ -13,20 +13,85 @@ * limitations under the License. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#ifdef __TARGET_MCU +#include "stm32f4xx.h" +#include "stm32f4xx_gpio.h" +#include "stm32f4xx_rcc.h" +#endif +#pragma GCC diagnostic pop + #include "actuators.h" #include "jerry-libc.h" -void led_toggle(int led_id) +#ifdef __TARGET_MCU + +void +blink_once (uint32_t led) { - __printf("led_toogle: %d", led_id); + uint32_t pin = led; + uint32_t mode = (uint32_t)GPIO_Mode_OUT << (pin * 2); + uint32_t speed = (uint32_t)GPIO_Speed_100MHz << (pin * 2); + uint32_t type = (uint32_t)GPIO_OType_PP << pin; + uint32_t pullup = (uint32_t)GPIO_PuPd_NOPULL << (pin * 2); + + TODO (INITIALIZE ONCE); + // + // Initialise the peripheral clock. + // + RCC->AHB1ENR |= RCC_AHB1Periph_GPIOD; + // + // Initilaise the GPIO port. + // + volatile GPIO_TypeDef* gpio = GPIOD; + + gpio->MODER |= mode; + gpio->OSPEEDR |= speed; + gpio->OTYPER |= type; + gpio->PUPDR |= pullup; + // + // Toggle the selected LED indefinitely. + // + int index; + + int dot = 600000; + int dash = dot * 3; + + while (1) + { + gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); + gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); + gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); + + for (index = 0; index < dash * 7; index++); + } +} +#endif + +void led_toggle(uint32_t led_id) +{ + __printf("led_toggle: %d\n", led_id); } -void led_on(int led_id) +void led_on(uint32_t led_id) { - __printf("led_on: %d", led_id); + __printf("led_on: %d\n", led_id); } -void led_off(int led_id) +void led_off(uint32_t led_id) { - __printf("led_off: %d", led_id); + __printf("led_off: %d\n", led_id); +} + +void led_blink_once(uint32_t led_id) +{ +#ifdef __HOST + __printf("led_blink_once: %d\n", led_id); +#endif + +#ifdef __TARGET_MCU + blink_once(led_id); +#endif } diff --git a/src/libperipherals/actuators.h b/src/libperipherals/actuators.h index 40114e69f..5700e00d6 100644 --- a/src/libperipherals/actuators.h +++ b/src/libperipherals/actuators.h @@ -16,15 +16,19 @@ #ifndef ACTUATORS_H #define ACTUATORS_H +#include "globals.h" + // STM32 F4 #define LED_GREEN 12 #define LED_ORANGE 13 #define LED_RED 14 #define LED_BLUE 15 -void led_toggle(int); -void led_on(int); -void led_off(int); +void led_toggle(uint32_t); +void led_on(uint32_t); +void led_off(uint32_t); +void led_blink_once(uint32_t); +void blink_once (uint32_t); #endif /* ACTUATORS_H */ diff --git a/src/libruntime/target/linux/deserializer.c b/src/libruntime/target/linux/deserializer.c index fb09c43b4..eaa50a2ce 100644 --- a/src/libruntime/target/linux/deserializer.c +++ b/src/libruntime/target/linux/deserializer.c @@ -22,11 +22,18 @@ uint8_t num_size = 0; const ecma_char_t * deserialize_string_by_id (uint8_t id) { - uint8_t size = *bytecode_data, *data = bytecode_data, offset; + uint8_t size, *data, offset; + + if (bytecode_data == NULL) + return NULL; + + size = *bytecode_data; if (id >= size) return NULL; + data = bytecode_data; + data += id + 1; offset = *data; diff --git a/src/main.c b/src/main.c index ea8ae9e4d..4fc3c6b52 100644 --- a/src/main.c +++ b/src/main.c @@ -27,9 +27,9 @@ #define LED_ORANGE 13 #define LED_RED 14 #define LED_BLUE 15 +#include "generated.h" #endif -#include "generated.h" #include "globals.h" #include "interpreter.h" #include "jerry-libc.h" @@ -164,7 +164,7 @@ void fake_exit(void); void fake_exit (void) { - uint32_t pin = LED_RED; + uint32_t pin = LED_ORANGE; uint32_t mode = (uint32_t)GPIO_Mode_OUT << (pin * 2); uint32_t speed = (uint32_t)GPIO_Speed_100MHz << (pin * 2); uint32_t type = (uint32_t)GPIO_OType_PP << pin; @@ -185,7 +185,7 @@ fake_exit (void) // // Toggle the selected LED indefinitely. // - int index; + volatile int index; // SOS @@ -213,6 +213,9 @@ fake_exit (void) int main(void) { + + //fake_exit(); + const char *source_p = generated_source; const size_t source_size = sizeof(generated_source); diff --git a/tests/unit/test_addition_opcode_number_operands.c b/tests/unit/test_addition_opcode_number_operands.c index 1c840fde1..683432222 100644 --- a/tests/unit/test_addition_opcode_number_operands.c +++ b/tests/unit/test_addition_opcode_number_operands.c @@ -26,6 +26,7 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { + getop_reg_var_decl( 255, 255), getop_var_decl( 0), getop_var_decl( 1), getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), diff --git a/tests/unit/test_assignment_opcode.c b/tests/unit/test_assignment_opcode.c index 8b4ef8292..d138cf377 100644 --- a/tests/unit/test_assignment_opcode.c +++ b/tests/unit/test_assignment_opcode.c @@ -26,17 +26,18 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { - /* 0: */ getop_var_decl( 0), - /* 1: */ getop_var_decl( 1), - /* 2: */ getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1), - /* 3: */ getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0), - /* 4: */ getop_is_true_jmp( 1, 6), - /* 5: */ getop_jmp_down( 5), - /* 6: */ getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), - /* 7: */ getop_assignment( 1, OPCODE_ARG_TYPE_NUMBER, 2), - /* 8: */ getop_is_false_jmp( 1, 10), - /* 9: */ getop_exitval( 0), - /* 10: */ getop_exitval( 1) + /* 0: */ getop_reg_var_decl( 255, 255), + /* 1: */ getop_var_decl( 0), + /* 2: */ getop_var_decl( 1), + /* 3: */ getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1), + /* 4: */ getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0), + /* 5: */ getop_is_true_jmp( 1, 7), + /* 6: */ getop_jmp_down( 5), + /* 7: */ getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), + /* 8: */ getop_assignment( 1, OPCODE_ARG_TYPE_NUMBER, 2), + /* 9: */ getop_is_false_jmp( 1, 11), + /* 10: */ getop_exitval( 0), + /* 11: */ getop_exitval( 1) }; mem_init(); diff --git a/tests/unit/test_division_opcode.c b/tests/unit/test_division_opcode.c index e14084bbc..5c1c121ac 100644 --- a/tests/unit/test_division_opcode.c +++ b/tests/unit/test_division_opcode.c @@ -26,6 +26,7 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { + getop_reg_var_decl( 255, 255), getop_var_decl( 0), getop_var_decl( 1), getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), diff --git a/tests/unit/test_multiplication_opcode.c b/tests/unit/test_multiplication_opcode.c index 1bbd2bb29..aba7f5660 100644 --- a/tests/unit/test_multiplication_opcode.c +++ b/tests/unit/test_multiplication_opcode.c @@ -26,6 +26,7 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { + getop_reg_var_decl( 255, 255), getop_var_decl( 0), getop_var_decl( 1), getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), diff --git a/tests/unit/test_remainder_opcode.c b/tests/unit/test_remainder_opcode.c index a4b7328ce..7e4882a5d 100644 --- a/tests/unit/test_remainder_opcode.c +++ b/tests/unit/test_remainder_opcode.c @@ -26,6 +26,7 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { + getop_reg_var_decl( 255, 255), getop_var_decl( 0), getop_var_decl( 1), getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), diff --git a/tests/unit/test_substraction_opcode.c b/tests/unit/test_substraction_opcode.c index f8c8d64ab..392f1bfb5 100644 --- a/tests/unit/test_substraction_opcode.c +++ b/tests/unit/test_substraction_opcode.c @@ -26,6 +26,7 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { + getop_reg_var_decl( 255, 255), getop_var_decl( 0), getop_var_decl( 1), getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253), diff --git a/tests/unit/test_var_decl_opcode_in_decl_lex_env.c b/tests/unit/test_var_decl_opcode_in_decl_lex_env.c index d6164c131..a10ab2939 100644 --- a/tests/unit/test_var_decl_opcode_in_decl_lex_env.c +++ b/tests/unit/test_var_decl_opcode_in_decl_lex_env.c @@ -26,10 +26,11 @@ main( int __unused argc, char __unused **argv) { const OPCODE test_program[] = { - getop_var_decl( 0), - getop_is_true_jmp( 0, 3), - getop_exitval( 0), - getop_exitval( 1) + /* 0: */ getop_reg_var_decl( 255, 255), + /* 1: */ getop_var_decl( 0), + /* 2: */ getop_is_true_jmp( 0, 4), + /* 3: */ getop_exitval( 0), + /* 4: */ getop_exitval( 1) }; mem_init();