From e3e01672495ca5db666199e5eb4f6bd998d56763 Mon Sep 17 00:00:00 2001 From: "e.gavrin" Date: Fri, 4 Jul 2014 17:11:06 +0400 Subject: [PATCH] remove output from lexer, fixes --- Makefile | 18 +++++++++++++----- docs/compact_profile.txt | 1 + src/globals.h | 28 +++++++++++++++++----------- src/libcoreint/interpreter.c | 36 ++++++++++++++++++------------------ src/libcoreint/opcodes.h | 12 ++++++++---- src/libjsparser/lexer.c | 2 +- src/main.c | 2 +- 7 files changed, 59 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index f8f5da426..6e9b9c1ec 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,15 @@ SOURCES = \ $(wildcard ./src/libecmaobjects/*.c) \ $(wildcard ./src/liballocator/*.c) \ $(wildcard ./src/libcoreint/*.c) ) + +HEADERS = \ + $(sort \ + $(wildcard ./src/*.h) \ + $(wildcard ./src/libperipherals/*.h) \ + $(wildcard ./src/libjsparser/*.h) \ + $(wildcard ./src/libecmaobjects/*.h) \ + $(wildcard ./src/liballocator/*.h) \ + $(wildcard ./src/libcoreint/*.h) ) INCLUDES = \ -I src \ @@ -66,7 +75,7 @@ RELEASE_OPTIONS = -Os -Werror DEFINES = -DMEM_HEAP_CHUNK_SIZE=256 -DMEM_HEAP_AREA_SIZE=32768 -.PHONY: all debug release clean install test +.PHONY: all debug release clean check install all: debug @@ -86,12 +95,11 @@ clean: rm -f $(TARGET).map rm -f $(TARGET).hex rm -f $(TARGET).lst + rm -f jerry.error js.files check: - cppcheck ./src/ --enable=all --std=c99 -v + cppcheck $(HEADERS) $(SOURCES) --enable=all --std=c99 + ./tools/jerry_test.sh install: st-flash write $(TARGET).bin 0x08000000 - -test: - ./tools/jerry_test.sh diff --git a/docs/compact_profile.txt b/docs/compact_profile.txt index 17d0996b4..e1b02a781 100644 --- a/docs/compact_profile.txt +++ b/docs/compact_profile.txt @@ -5,6 +5,7 @@ when the body is not a string literal. - Limit Unicode support - Cut Number from 64bit to 32bit/16/8bit +- Limit recursion level - Do not allow addition, deletion or assignment to the properties of built-in objects. This limitation is needed to support a more efficient implementation based diff --git a/src/globals.h b/src/globals.h index 5f73690d0..40ee240dc 100644 --- a/src/globals.h +++ b/src/globals.h @@ -59,7 +59,7 @@ typedef signed int int32_t; /** * Variable that must not be referenced. - * + * * May be used for static assertion checks. */ extern uint32_t jerry_UnreferencedExpression; @@ -87,14 +87,14 @@ extern uint32_t jerry_UnreferencedExpression; /** * Aligns @value to @alignment. - * + * * Returns maximum positive value, that divides @alignment and is less than or equal to @value */ #define JERRY_ALIGNDOWN( value, alignment) ( (alignment) * ( (value) / (alignment) ) ) /** * Aligns @value to @alignment. - * + * * Returns minimum positive value, that divides @alignment and is more than or equal to @value */ #define JERRY_ALIGNUP( value, alignment) ( (alignment) * ( ((value) + (alignment) - 1) / (alignment) ) ) @@ -108,19 +108,23 @@ extern uint32_t jerry_UnreferencedExpression; /** * Bit-fields */ -inline uint32_t jerry_ExtractBitField(uint32_t value, uint32_t lsb, uint32_t width); -inline uint32_t jerry_SetBitFieldValue(uint32_t value, uint32_t bitFieldValue, uint32_t lsb, uint32_t width); +inline uint32_t jerry_ExtractBitField(uint32_t value, uint32_t lsb, + uint32_t width); +inline uint32_t jerry_SetBitFieldValue(uint32_t value, uint32_t bitFieldValue, + uint32_t lsb, uint32_t width); /** * Extract a bit-field from the integer. - * + * * @return bit-field's value */ inline uint32_t -jerry_ExtractBitField(uint32_t container, /**< container to extract bit-field from */ +jerry_ExtractBitField(uint32_t + container, /**< container to extract bit-field from */ uint32_t lsb, /**< least significant bit of the value * to be extracted */ - uint32_t width) /**< width of the bit-field to be extracted */ { + uint32_t width) /**< width of the bit-field to be extracted */ +{ JERRY_ASSERT(lsb < JERRY_BITSINBYTE * sizeof (uint32_t)); JERRY_ASSERT((lsb + width) <= JERRY_BITSINBYTE * sizeof (uint32_t)); @@ -132,15 +136,17 @@ jerry_ExtractBitField(uint32_t container, /**< container to extract bit-field fr /** * Extract a bit-field from the integer. - * + * * @return bit-field's value */ inline uint32_t -jerry_SetBitFieldValue(uint32_t container, /**< container to insert bit-field to */ +jerry_SetBitFieldValue(uint32_t + container, /**< container to insert bit-field to */ uint32_t newBitFieldValue, /**< value of bit-field to insert */ uint32_t lsb, /**< least significant bit of the value * to be extracted */ - uint32_t width) /**< width of the bit-field to be extracted */ { + uint32_t width) /**< width of the bit-field to be extracted */ +{ JERRY_ASSERT(lsb < JERRY_BITSINBYTE * sizeof (uint32_t)); JERRY_ASSERT((lsb + width) <= JERRY_BITSINBYTE * sizeof (uint32_t)); JERRY_ASSERT(newBitFieldValue <= (1u << width)); diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 2c2a090f7..aaff75bb2 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -32,28 +32,28 @@ gen_bytecode (FILE *src_file) assert (st); while (st->type != STMT_EOF) { - pp_statement (st); + //pp_statement (st); st = parser_parse_statement (); assert (st); } - pp_finish (); + //pp_finish (); - FILE *file = fopen (FILE_NAME, "w+b"); - - OPCODE op0; - - save_op_loop_inf (file, op0, 1); - save_op_call_1 (file, op0, 0, LED_GREEN); - save_op_call_1 (file, op0, 0, LED_BLUE); - save_op_call_1 (file, op0, 0, LED_ORANGE); - save_op_call_1 (file, op0, 0, LED_RED); - save_op_call_1 (file, op0, 0, LED_GREEN); - save_op_call_1 (file, op0, 0, LED_BLUE); - save_op_call_1 (file, op0, 0, LED_ORANGE); - save_op_call_1 (file, op0, 0, LED_RED); - save_op_jmp (file, op0, 0); - - fclose (file); +// FILE *file = fopen (FILE_NAME, "w+b"); +// +// OPCODE op0; +// +// save_op_loop_inf (file, op0, 1); +// save_op_call_1 (file, op0, 0, LED_GREEN); +// save_op_call_1 (file, op0, 0, LED_BLUE); +// save_op_call_1 (file, op0, 0, LED_ORANGE); +// save_op_call_1 (file, op0, 0, LED_RED); +// save_op_call_1 (file, op0, 0, LED_GREEN); +// save_op_call_1 (file, op0, 0, LED_BLUE); +// save_op_call_1 (file, op0, 0, LED_ORANGE); +// save_op_call_1 (file, op0, 0, LED_RED); +// save_op_jmp (file, op0, 0); +// +// fclose (file); } void diff --git a/src/libcoreint/opcodes.h b/src/libcoreint/opcodes.h index 7fef326a7..21a0c9b5f 100644 --- a/src/libcoreint/opcodes.h +++ b/src/libcoreint/opcodes.h @@ -39,9 +39,12 @@ OP_DEF (jmp) OP_DEF (decl) { }; -OP_DEF (named_func_decl) { }; +OP_DEF (decl_func_named) +{ + OP_TYPE_IDX name_literal_idx; +}; -OP_DEF (anon_func_decl) { }; +OP_DEF (decl_func_anon) { }; OP_DEF (decl_var_global) { }; @@ -108,10 +111,11 @@ union __opdata OP (nop); } data; -OPCODE { +OPCODE{ opfunc opfunc_ptr; union __opdata data; -} __packed; +} +__packed; void save_op_jmp (FILE *, OPCODE, int); void save_op_call_1 (FILE *, OPCODE, int, int); diff --git a/src/libjsparser/lexer.c b/src/libjsparser/lexer.c index 2f7dd4df5..c4029e21f 100644 --- a/src/libjsparser/lexer.c +++ b/src/libjsparser/lexer.c @@ -793,5 +793,5 @@ lexer_save_token (token tok) void lexer_dump_buffer_state () { - printf ("%s\n", buffer); + //printf ("%s\n", buffer); } \ No newline at end of file diff --git a/src/main.c b/src/main.c index 0c0ba42e0..9bb7b5cf6 100644 --- a/src/main.c +++ b/src/main.c @@ -73,7 +73,7 @@ main (int argc, char **argv) //gen_bytecode (generated_source); gen_bytecode (file); - run_int (); + //run_int (); #ifdef __TARGET_MCU fake_exit ();