Merge with master.
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
static const char* generated_source __unused = ""
|
||||
"while (true) {\n"
|
||||
"LEDToggle (LED3);\n"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "allocator.h"
|
||||
#include "jerry-libc.h"
|
||||
#include "lexer.h"
|
||||
|
||||
@@ -115,7 +116,7 @@ get_char (size_t i)
|
||||
if (buffer == NULL)
|
||||
{
|
||||
buffer = (char *) malloc (BUFFER_SIZE);
|
||||
error = fread (buffer, 1, BUFFER_SIZE, file);
|
||||
error = __fread (buffer, 1, BUFFER_SIZE, file);
|
||||
if (error == 0)
|
||||
return '\0';
|
||||
if (error < BUFFER_SIZE)
|
||||
@@ -139,7 +140,7 @@ get_char (size_t i)
|
||||
token_start = buffer_start;
|
||||
buffer = buffer_start + token_size;
|
||||
/* 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)
|
||||
return '\0';
|
||||
if (error < BUFFER_SIZE - tail_size - token_size)
|
||||
@@ -150,7 +151,7 @@ get_char (size_t i)
|
||||
{
|
||||
__memmove (buffer_start, buffer, tail_size);
|
||||
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)
|
||||
return '\0';
|
||||
if (error < BUFFER_SIZE - tail_size)
|
||||
@@ -555,7 +556,7 @@ parse_string (void)
|
||||
index++;
|
||||
}
|
||||
|
||||
__memset (index, '\0', length - (index - tok));
|
||||
__memset (index, '\0', length - (size_t) (index - tok));
|
||||
|
||||
token_start = NULL;
|
||||
// Eat up '"'
|
||||
@@ -586,7 +587,7 @@ lexer_set_file (FILE *ex_file)
|
||||
{
|
||||
JERRY_ASSERT (ex_file);
|
||||
file = ex_file;
|
||||
lexer_debug_log = fopen ("lexer.log", "w");
|
||||
lexer_debug_log = __fopen ("lexer.log", "w");
|
||||
saved_token = empty_token;
|
||||
}
|
||||
#else
|
||||
@@ -690,7 +691,7 @@ lexer_next_token (void)
|
||||
return (token) { .type = TOK_NEWLINE, .data.none = NULL };
|
||||
else
|
||||
return
|
||||
#ifdef JERRY_NDEBUG
|
||||
#ifdef __HOST
|
||||
lexer_next_token_private ();
|
||||
#else
|
||||
lexer_next_token ();
|
||||
@@ -806,4 +807,5 @@ void
|
||||
lexer_dump_buffer_state (void)
|
||||
{
|
||||
__printf ("%s\n", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
#include "lexer.h"
|
||||
#include "parser.h"
|
||||
|
||||
/* FIXME: */
|
||||
extern void lexer_dump_buffer_state();
|
||||
extern void lexer_dump_buffer_state(void);
|
||||
|
||||
/* FIXME: Make general fatal function call it from libjsparser's fatal */
|
||||
extern void fatal(int);
|
||||
|
||||
void
|
||||
fatal (int code)
|
||||
{
|
||||
@@ -153,7 +155,7 @@ static void
|
||||
push_scope (int type)
|
||||
{
|
||||
#ifdef __HOST
|
||||
fprintf (debug_file, "push_scope: 0x%x\n", type);
|
||||
__fprintf (debug_file, "push_scope: 0x%x\n", type);
|
||||
#endif
|
||||
current_scopes[scope_index++] = (scope) { .type = type, .was_stmt = false };
|
||||
}
|
||||
@@ -162,7 +164,7 @@ static void
|
||||
pop_scope (void)
|
||||
{
|
||||
#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
|
||||
scope_index--;
|
||||
}
|
||||
@@ -173,7 +175,7 @@ assert_keyword (keyword kw)
|
||||
if (tok.type != TOK_KEYWORD || tok.data.kw != kw)
|
||||
{
|
||||
#ifdef __HOST
|
||||
printf ("assert_keyword: 0x%x\n", kw);
|
||||
__printf ("assert_keyword: 0x%x\n", kw);
|
||||
#endif
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
@@ -191,7 +193,7 @@ current_token_must_be(token_type tt)
|
||||
if (tok.type != tt)
|
||||
{
|
||||
#ifdef __HOST
|
||||
printf ("current_token_must_be: 0x%x\n", tt);
|
||||
__printf ("current_token_must_be: 0x%x\n", tt);
|
||||
#endif
|
||||
fatal (ERR_PARSER);
|
||||
}
|
||||
@@ -1393,3 +1395,4 @@ parser_init (void)
|
||||
debug_file = __fopen ("parser.log", "w");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_AssertFail( const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
jerry_AssertFail(const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
{
|
||||
__printf("Assertion '%s' failed at %s:%u\n",
|
||||
assertion, file, line);
|
||||
|
||||
__exit( -ERR_GENERAL);
|
||||
} /* jerry_AssertFail */
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ pp_keyword (keyword kw)
|
||||
}
|
||||
|
||||
static void
|
||||
intend ()
|
||||
intend (void)
|
||||
{
|
||||
for (int i = 0; i < intendation; i++)
|
||||
__putchar (' ');
|
||||
@@ -548,7 +548,7 @@ dump_postfix (operand op, const char *operation)
|
||||
static void
|
||||
pp_assignment_expression (assignment_expression expr)
|
||||
{
|
||||
if (expr.var)
|
||||
if (expr.oper != AO_NONE && expr.var)
|
||||
__printf ("%s", expr.var);
|
||||
|
||||
switch (expr.oper)
|
||||
@@ -1087,7 +1087,7 @@ pp_statement (statement stmt)
|
||||
prev_stmt = stmt.type;
|
||||
}
|
||||
|
||||
void pp_finish ()
|
||||
void pp_finish (void)
|
||||
{
|
||||
if (prev_stmt == STMT_BLOCK_END)
|
||||
__putchar ('\n');
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_AssertFail( const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
jerry_AssertFail(const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
{
|
||||
__exit( -ERR_GENERAL);
|
||||
} /* jerry_AssertFail */
|
||||
|
||||
+7
-2
@@ -28,7 +28,12 @@
|
||||
#include "globals.h"
|
||||
#include "interpreter.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);
|
||||
|
||||
@@ -119,7 +124,7 @@ main (int argc, char **argv)
|
||||
dump_ast = true;
|
||||
|
||||
#ifdef __HOST
|
||||
file = fopen (file_name, "r");
|
||||
file = __fopen (file_name, "r");
|
||||
|
||||
if (file == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user