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
+9 -7
View File
@@ -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);
}
}
+9 -6
View File
@@ -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
}