Merge with master.

This commit is contained in:
Ruben Ayrapetyan
2014-07-10 21:02:48 +04:00
parent c531c78b10
commit 224c509ff3
9 changed files with 44 additions and 28 deletions
+2 -2
View File
@@ -89,7 +89,7 @@ SIZE = size
STRIP = strip STRIP = strip
# General flags # General flags
CFLAGS ?= $(INCLUDES) -std=c99 #-fdiagnostics-color=always CFLAGS ?= $(INCLUDES) -std=c99 -Werror #-fdiagnostics-color=always
CFLAGS += -Wall -Wextra -Wpedantic -Wlogical-op -Winline CFLAGS += -Wall -Wextra -Wpedantic -Wlogical-op -Winline
CFLAGS += -Wformat-nonliteral -Winit-self -Wstack-protector CFLAGS += -Wformat-nonliteral -Winit-self -Wstack-protector
CFLAGS += -Wconversion -Wsign-conversion -Wformat-security CFLAGS += -Wconversion -Wsign-conversion -Wformat-security
@@ -103,7 +103,7 @@ MCU_CFLAGS += -ffunction-sections -fdata-sections -nostdlib -fno-common
LDFLAGS = -nostartfiles -T$(LNK_SCRIPT_STM32F4) LDFLAGS = -nostartfiles -T$(LNK_SCRIPT_STM32F4)
DEBUG_OPTIONS = -g3 -O0 # -fsanitize=address DEBUG_OPTIONS = -g3 -O0 # -fsanitize=address
RELEASE_OPTIONS = -Os -flto -Werror -DJERRY_NDEBUG RELEASE_OPTIONS = -Os -flto -DJERRY_NDEBUG
DEFINES = -DMEM_HEAP_CHUNK_SIZE=256 -DMEM_HEAP_AREA_SIZE=32768 -DMEM_STATS DEFINES = -DMEM_HEAP_CHUNK_SIZE=256 -DMEM_HEAP_AREA_SIZE=32768 -DMEM_STATS
TARGET_HOST = -D__HOST TARGET_HOST = -D__HOST
+2
View File
@@ -13,6 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "globals.h"
static const char* generated_source __unused = "" static const char* generated_source __unused = ""
"while (true) {\n" "while (true) {\n"
"LEDToggle (LED3);\n" "LEDToggle (LED3);\n"
+8 -6
View File
@@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "allocator.h"
#include "jerry-libc.h" #include "jerry-libc.h"
#include "lexer.h" #include "lexer.h"
@@ -115,7 +116,7 @@ get_char (size_t i)
if (buffer == NULL) if (buffer == NULL)
{ {
buffer = (char *) malloc (BUFFER_SIZE); buffer = (char *) malloc (BUFFER_SIZE);
error = fread (buffer, 1, BUFFER_SIZE, file); error = __fread (buffer, 1, BUFFER_SIZE, file);
if (error == 0) if (error == 0)
return '\0'; return '\0';
if (error < BUFFER_SIZE) if (error < BUFFER_SIZE)
@@ -139,7 +140,7 @@ get_char (size_t i)
token_start = buffer_start; token_start = buffer_start;
buffer = buffer_start + token_size; buffer = buffer_start + token_size;
/* Read more characters form input file. */ /* Read more characters form input file. */
error = fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size - token_size, file); error = __fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size - token_size, file);
if (error == 0) if (error == 0)
return '\0'; return '\0';
if (error < BUFFER_SIZE - tail_size - token_size) if (error < BUFFER_SIZE - tail_size - token_size)
@@ -150,7 +151,7 @@ get_char (size_t i)
{ {
__memmove (buffer_start, buffer, tail_size); __memmove (buffer_start, buffer, tail_size);
buffer = buffer_start; buffer = buffer_start;
error = fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size, file); error = __fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size, file);
if (error == 0) if (error == 0)
return '\0'; return '\0';
if (error < BUFFER_SIZE - tail_size) if (error < BUFFER_SIZE - tail_size)
@@ -555,7 +556,7 @@ parse_string (void)
index++; index++;
} }
__memset (index, '\0', length - (index - tok)); __memset (index, '\0', length - (size_t) (index - tok));
token_start = NULL; token_start = NULL;
// Eat up '"' // Eat up '"'
@@ -586,7 +587,7 @@ lexer_set_file (FILE *ex_file)
{ {
JERRY_ASSERT (ex_file); JERRY_ASSERT (ex_file);
file = ex_file; file = ex_file;
lexer_debug_log = fopen ("lexer.log", "w"); lexer_debug_log = __fopen ("lexer.log", "w");
saved_token = empty_token; saved_token = empty_token;
} }
#else #else
@@ -690,7 +691,7 @@ lexer_next_token (void)
return (token) { .type = TOK_NEWLINE, .data.none = NULL }; return (token) { .type = TOK_NEWLINE, .data.none = NULL };
else else
return return
#ifdef JERRY_NDEBUG #ifdef __HOST
lexer_next_token_private (); lexer_next_token_private ();
#else #else
lexer_next_token (); lexer_next_token ();
@@ -807,3 +808,4 @@ lexer_dump_buffer_state (void)
{ {
__printf ("%s\n", buffer); __printf ("%s\n", buffer);
} }
+9 -6
View File
@@ -17,9 +17,11 @@
#include "lexer.h" #include "lexer.h"
#include "parser.h" #include "parser.h"
/* FIXME: */ extern void lexer_dump_buffer_state(void);
extern void lexer_dump_buffer_state();
/* FIXME: Make general fatal function call it from libjsparser's fatal */ /* FIXME: Make general fatal function call it from libjsparser's fatal */
extern void fatal(int);
void void
fatal (int code) fatal (int code)
{ {
@@ -153,7 +155,7 @@ static void
push_scope (int type) push_scope (int type)
{ {
#ifdef __HOST #ifdef __HOST
fprintf (debug_file, "push_scope: 0x%x\n", type); __fprintf (debug_file, "push_scope: 0x%x\n", type);
#endif #endif
current_scopes[scope_index++] = (scope) { .type = type, .was_stmt = false }; current_scopes[scope_index++] = (scope) { .type = type, .was_stmt = false };
} }
@@ -162,7 +164,7 @@ static void
pop_scope (void) pop_scope (void)
{ {
#ifdef __HOST #ifdef __HOST
fprintf (debug_file, "pop_scope: 0x%x\n", current_scopes[scope_index - 1].type); __fprintf (debug_file, "pop_scope: 0x%x\n", current_scopes[scope_index - 1].type);
#endif #endif
scope_index--; scope_index--;
} }
@@ -173,7 +175,7 @@ assert_keyword (keyword kw)
if (tok.type != TOK_KEYWORD || tok.data.kw != kw) if (tok.type != TOK_KEYWORD || tok.data.kw != kw)
{ {
#ifdef __HOST #ifdef __HOST
printf ("assert_keyword: 0x%x\n", kw); __printf ("assert_keyword: 0x%x\n", kw);
#endif #endif
JERRY_UNREACHABLE (); JERRY_UNREACHABLE ();
} }
@@ -191,7 +193,7 @@ current_token_must_be(token_type tt)
if (tok.type != tt) if (tok.type != tt)
{ {
#ifdef __HOST #ifdef __HOST
printf ("current_token_must_be: 0x%x\n", tt); __printf ("current_token_must_be: 0x%x\n", tt);
#endif #endif
fatal (ERR_PARSER); fatal (ERR_PARSER);
} }
@@ -1393,3 +1395,4 @@ parser_init (void)
debug_file = __fopen ("parser.log", "w"); debug_file = __fopen ("parser.log", "w");
#endif #endif
} }
+4 -3
View File
@@ -20,12 +20,13 @@
* Handle failed assertion * Handle failed assertion
*/ */
void __noreturn void __noreturn
jerry_AssertFail( const char *assertion, /**< assertion condition string */ jerry_AssertFail(const char *assertion, /**< assertion condition string */
const char *file, /**< file name */ const char *file, /**< file name */
const uint32_t line) /** line */ const uint32_t line) /** line */
{ {
__printf("Assertion '%s' failed at %s:%u\n", __printf("Assertion '%s' failed at %s:%u\n",
assertion, file, line); assertion, file, line);
__exit( -ERR_GENERAL); __exit( -ERR_GENERAL);
} /* jerry_AssertFail */ } /* jerry_AssertFail */
+3 -3
View File
@@ -404,7 +404,7 @@ pp_keyword (keyword kw)
} }
static void static void
intend () intend (void)
{ {
for (int i = 0; i < intendation; i++) for (int i = 0; i < intendation; i++)
__putchar (' '); __putchar (' ');
@@ -548,7 +548,7 @@ dump_postfix (operand op, const char *operation)
static void static void
pp_assignment_expression (assignment_expression expr) pp_assignment_expression (assignment_expression expr)
{ {
if (expr.var) if (expr.oper != AO_NONE && expr.var)
__printf ("%s", expr.var); __printf ("%s", expr.var);
switch (expr.oper) switch (expr.oper)
@@ -1087,7 +1087,7 @@ pp_statement (statement stmt)
prev_stmt = stmt.type; prev_stmt = stmt.type;
} }
void pp_finish () void pp_finish (void)
{ {
if (prev_stmt == STMT_BLOCK_END) if (prev_stmt == STMT_BLOCK_END)
__putchar ('\n'); __putchar ('\n');
+3 -3
View File
@@ -20,9 +20,9 @@
* Handle failed assertion * Handle failed assertion
*/ */
void __noreturn void __noreturn
jerry_AssertFail( const char *assertion, /**< assertion condition string */ jerry_AssertFail(const char *assertion, /**< assertion condition string */
const char *file, /**< file name */ const char *file, /**< file name */
const uint32_t line) /** line */ const uint32_t line) /** line */
{ {
__exit( -ERR_GENERAL); __exit( -ERR_GENERAL);
} /* jerry_AssertFail */ } /* jerry_AssertFail */
+7 -2
View File
@@ -28,7 +28,12 @@
#include "globals.h" #include "globals.h"
#include "interpreter.h" #include "interpreter.h"
#include "jerry-libc.h" #include "jerry-libc.h"
#include "mem-allocator.h" #include "lexer.h"
#include "parser.h"
#include "pretty-printer.h"
/* FIXME: Make general fatal function call it from libjsparser's fatal */
extern void fatal(int);
void fake_exit (void); void fake_exit (void);
@@ -119,7 +124,7 @@ main (int argc, char **argv)
dump_ast = true; dump_ast = true;
#ifdef __HOST #ifdef __HOST
file = fopen (file_name, "r"); file = __fopen (file_name, "r");
if (file == NULL) if (file == NULL)
{ {
+4 -1
View File
@@ -14,9 +14,12 @@
#!/bin/bash #!/bin/bash
echo "static const char* generated_source = \"\"" > "generated.h" echo "#include \"globals.h\"" > "generated.h"
echo "" >> "generated.h"
echo "static const char* generated_source = \"\"" >> "generated.h"
while read line while read line
do do
echo "\"$line\n\"" >> "generated.h" echo "\"$line\n\"" >> "generated.h"
done < $1 done < $1
echo ";" >> "generated.h" echo ";" >> "generated.h"