Remove inclusion of std headers to our headers; move fatal from src/error.h to src/libjsparser/parser.c.

This commit is contained in:
Ruben Ayrapetyan
2014-07-10 17:10:50 +04:00
parent c132f6aa3c
commit 76e579d4e1
17 changed files with 263 additions and 476 deletions
-33
View File
@@ -1,33 +0,0 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ERROR_H
#define ERROR_H
#include "mappings.h"
void fatal (int);
#define ERR_IO (-1)
#define ERR_BUFFER_SIZE (-2)
#define ERR_SEVERAL_FILES (-3)
#define ERR_NO_FILES (-4)
#define ERR_NON_CHAR (-5)
#define ERR_UNCLOSED (-6)
#define ERR_INT_LITERAL (-7)
#define ERR_STRING (-8)
#define ERR_PARSER (-9)
#endif /* ERROR_H */
+20 -4
View File
@@ -16,15 +16,12 @@
#ifndef JERRY_GLOBALS_H #ifndef JERRY_GLOBALS_H
#define JERRY_GLOBALS_H #define JERRY_GLOBALS_H
#include <stddef.h>
#include <stdbool.h>
/** /**
* Types * Types
*/ */
typedef unsigned long mword_t; typedef unsigned long mword_t;
typedef mword_t uintptr_t; typedef mword_t uintptr_t;
//typedef mword_t size_t; typedef mword_t size_t;
typedef signed long ssize_t; typedef signed long ssize_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
@@ -32,6 +29,10 @@ typedef unsigned int uint32_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
typedef signed int int32_t; typedef signed int int32_t;
typedef enum {
false, true
} bool;
/** /**
* Attributes * Attributes
*/ */
@@ -42,9 +43,24 @@ typedef signed int int32_t;
/** /**
* Constants * Constants
*/ */
#define NULL ((void*)0)
#define JERRY_BITSINBYTE 8 #define JERRY_BITSINBYTE 8
/**
* Errors
*/
#define ERR_IO (-1)
#define ERR_BUFFER_SIZE (-2)
#define ERR_SEVERAL_FILES (-3)
#define ERR_NO_FILES (-4)
#define ERR_NON_CHAR (-5)
#define ERR_UNCLOSED (-6)
#define ERR_INT_LITERAL (-7)
#define ERR_STRING (-8)
#define ERR_PARSER (-9)
#define ERR_GENERAL (-255)
/** /**
* Asserts * Asserts
* *
-6
View File
@@ -16,12 +16,6 @@
#ifndef INTERPRETER_H #ifndef INTERPRETER_H
#define INTERPRETER_H #define INTERPRETER_H
#ifdef JERRY_NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include "opcodes.h" #include "opcodes.h"
#include "ecma-globals.h" #include "ecma-globals.h"
+4 -4
View File
@@ -14,8 +14,8 @@
*/ */
#include "ecma-operations.h" #include "ecma-operations.h"
#include "error.h"
#include "interpreter.h" #include "interpreter.h"
#include "jerry-libc.h"
#include "opcodes.h" #include "opcodes.h"
void void
@@ -90,7 +90,7 @@ void
opfunc_loop_inf (OPCODE opdata, struct __int_data *int_data) opfunc_loop_inf (OPCODE opdata, struct __int_data *int_data)
{ {
#ifdef __HOST #ifdef __HOST
printf ("%d::loop_inf:idx:%d\n", __printf ("%d::loop_inf:idx:%d\n",
int_data->pos, int_data->pos,
opdata.data.loop_inf.loop_root); opdata.data.loop_inf.loop_root);
#endif #endif
@@ -102,7 +102,7 @@ void
opfunc_call_1 (OPCODE opdata, struct __int_data *int_data) opfunc_call_1 (OPCODE opdata, struct __int_data *int_data)
{ {
#ifdef __HOST #ifdef __HOST
printf ("%d::op_call_1:idx:%d:%d\n", __printf ("%d::op_call_1:idx:%d:%d\n",
int_data->pos, int_data->pos,
opdata.data.call_1.name_lit_idx, opdata.data.call_1.name_lit_idx,
opdata.data.call_1.arg1_lit_idx); opdata.data.call_1.arg1_lit_idx);
@@ -115,7 +115,7 @@ void
opfunc_jmp (OPCODE opdata, struct __int_data *int_data) opfunc_jmp (OPCODE opdata, struct __int_data *int_data)
{ {
#ifdef __HOST #ifdef __HOST
printf ("%d::op_jmp:idx:%d\n", __printf ("%d::op_jmp:idx:%d\n",
int_data->pos, int_data->pos,
opdata.data.jmp.opcode_idx); opdata.data.jmp.opcode_idx);
#endif #endif
-4
View File
@@ -16,10 +16,6 @@
#ifndef OPCODES_H #ifndef OPCODES_H
#define OPCODES_H #define OPCODES_H
#ifdef JERRY_NDEBUG
#include <stdio.h>
#endif
#include "globals.h" #include "globals.h"
#define OPCODE struct __opcode #define OPCODE struct __opcode
+30 -28
View File
@@ -13,13 +13,15 @@
* limitations under the License. * limitations under the License.
*/ */
#include "error.h" #include "jerry-libc.h"
#include "lexer.h" #include "lexer.h"
#include "mappings.h"
static token saved_token; static token saved_token;
static token empty_token = { .type = TOK_EMPTY, .data.none = NULL }; static token empty_token = { .type = TOK_EMPTY, .data.none = NULL };
/* FIXME: Make general fatal function call it from libjsparser's fatal */
extern void fatal(int);
typedef struct typedef struct
{ {
const char *str; const char *str;
@@ -117,7 +119,7 @@ get_char (size_t i)
if (error == 0) if (error == 0)
return '\0'; return '\0';
if (error < BUFFER_SIZE) if (error < BUFFER_SIZE)
memset (buffer + error, '\0', BUFFER_SIZE - error); __memset (buffer + error, '\0', BUFFER_SIZE - error);
buffer_start = buffer; buffer_start = buffer;
} }
@@ -141,7 +143,7 @@ get_char (size_t i)
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)
memset (buffer + tail_size + error, '\0', __memset (buffer + tail_size + error, '\0',
BUFFER_SIZE - tail_size - token_size - error); BUFFER_SIZE - tail_size - token_size - error);
} }
else else
@@ -152,7 +154,7 @@ get_char (size_t i)
if (error == 0) if (error == 0)
return '\0'; return '\0';
if (error < BUFFER_SIZE - tail_size) if (error < BUFFER_SIZE - tail_size)
memset (buffer + tail_size + error, '\0', BUFFER_SIZE - tail_size - error); __memset (buffer + tail_size + error, '\0', BUFFER_SIZE - tail_size - error);
} }
} }
@@ -182,7 +184,7 @@ decode_keyword (void)
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
if (!strncmp (keyword_tokens[i].str, token_start, strlen (keyword_tokens[i].str))) if (!__strncmp (keyword_tokens[i].str, token_start, __strlen (keyword_tokens[i].str)))
return keyword_tokens[i].tok; return keyword_tokens[i].tok;
} }
@@ -196,7 +198,7 @@ convert_seen_name_to_token (void)
for (i = 0; i < seen_names_num; i++) for (i = 0; i < seen_names_num; i++)
{ {
if (!strncmp (seen_names[i].str, token_start, strlen (seen_names[i].str))) if (!__strncmp (seen_names[i].str, token_start, __strlen (seen_names[i].str)))
return seen_names[i].tok; return seen_names[i].tok;
} }
@@ -233,7 +235,7 @@ current_token (void)
JERRY_ASSERT (token_start <= buffer); JERRY_ASSERT (token_start <= buffer);
size_t length = (size_t) (buffer - token_start); size_t length = (size_t) (buffer - token_start);
char *res = (char *) malloc (length + 1); char *res = (char *) malloc (length + 1);
strncpy (res, token_start, length); __strncpy (res, token_start, length);
res[length] = '\0'; res[length] = '\0';
token_start = NULL; token_start = NULL;
return res; return res;
@@ -278,11 +280,11 @@ static token
parse_name (void) parse_name (void)
{ {
char c = LA (0); char c = LA (0);
bool every_char_islower = islower (c); bool every_char_islower = __islower (c);
const char *string = NULL; const char *string = NULL;
token known_token = empty_token; token known_token = empty_token;
JERRY_ASSERT (isalpha (c) || c == '$' || c == '_'); JERRY_ASSERT (__isalpha (c) || c == '$' || c == '_');
new_token (); new_token ();
consume_char (); consume_char ();
@@ -291,9 +293,9 @@ parse_name (void)
c = LA (0); c = LA (0);
if (c == '\0') if (c == '\0')
c = c; c = c;
if (!isalpha (c) && !isdigit (c) && c != '$' && c != '_') if (!__isalpha (c) && !__isdigit (c) && c != '$' && c != '_')
break; break;
if (every_char_islower && (!islower (c))) if (every_char_islower && (!__islower (c)))
every_char_islower = false; every_char_islower = false;
consume_char (); consume_char ();
} }
@@ -366,7 +368,7 @@ parse_number (void)
size_t tok_length = 0, i; size_t tok_length = 0, i;
int res = 0; int res = 0;
JERRY_ASSERT (isdigit (c) || c == '.'); JERRY_ASSERT (__isdigit (c) || c == '.');
if (c == '0') if (c == '0')
if (LA (1) == 'x' || LA (1) == 'X') if (LA (1) == 'x' || LA (1) == 'X')
@@ -374,7 +376,7 @@ parse_number (void)
if (c == '.') if (c == '.')
{ {
JERRY_ASSERT (!isalpha (LA (1))); JERRY_ASSERT (!__isalpha (LA (1)));
is_fp = true; is_fp = true;
} }
@@ -387,12 +389,12 @@ parse_number (void)
while (true) while (true)
{ {
c = LA (0); c = LA (0);
if (!isxdigit (c)) if (!__isxdigit (c))
break; break;
consume_char (); consume_char ();
} }
if (isalpha (c) || c == '_' || c == '$') if (__isalpha (c) || c == '_' || c == '$')
fatal (ERR_INT_LITERAL); fatal (ERR_INT_LITERAL);
tok_length = (size_t) (buffer - token_start); tok_length = (size_t) (buffer - token_start);
@@ -422,7 +424,7 @@ parse_number (void)
if (c == '.') if (c == '.')
{ {
if (isalpha (LA (1)) || LA (1) == '_' || LA (1) == '$') if (__isalpha (LA (1)) || LA (1) == '_' || LA (1) == '$')
fatal (ERR_INT_LITERAL); fatal (ERR_INT_LITERAL);
is_fp = true; is_fp = true;
consume_char (); consume_char ();
@@ -433,17 +435,17 @@ parse_number (void)
{ {
if (LA (1) == '-' || LA (1) == '+') if (LA (1) == '-' || LA (1) == '+')
consume_char (); consume_char ();
if (!isdigit (LA (1))) if (!__isdigit (LA (1)))
fatal (ERR_INT_LITERAL); fatal (ERR_INT_LITERAL);
is_exp = true; is_exp = true;
consume_char (); consume_char ();
continue; continue;
} }
if (isalpha (c) || c == '_' || c == '$') if (__isalpha (c) || c == '_' || c == '$')
fatal (ERR_INT_LITERAL); fatal (ERR_INT_LITERAL);
if (!isdigit (c)) if (!__isdigit (c))
break; break;
consume_char (); consume_char ();
@@ -451,7 +453,7 @@ parse_number (void)
if (is_fp || is_exp) if (is_fp || is_exp)
{ {
float res = strtof (token_start, NULL); float res = __strtof (token_start, NULL);
token_start = NULL; token_start = NULL;
return (token) { .type = TOK_FLOAT, .data.fp_num = res }; return (token) { .type = TOK_FLOAT, .data.fp_num = res };
} }
@@ -512,7 +514,7 @@ parse_string (void)
if (c == '\\') if (c == '\\')
{ {
/* Only single escape character is allowed. */ /* Only single escape character is allowed. */
if (LA (1) == 'x' || LA (1) == 'u' || isdigit (LA (1))) if (LA (1) == 'x' || LA (1) == 'u' || __isdigit (LA (1)))
fatal (ERR_STRING); fatal (ERR_STRING);
if ((LA (1) == '\'' && !is_double_quoted) if ((LA (1) == '\'' && !is_double_quoted)
|| (LA (1) == '"' && is_double_quoted) || (LA (1) == '"' && is_double_quoted)
@@ -553,7 +555,7 @@ parse_string (void)
index++; index++;
} }
memset (index, '\0', length - (size_t) (index - tok)); __memset (index, '\0', length - (index - tok));
token_start = NULL; token_start = NULL;
// Eat up '"' // Eat up '"'
@@ -571,7 +573,7 @@ grobble_whitespaces (void)
{ {
char c = LA (0); char c = LA (0);
while ((isspace (c) && c != '\n') || c == '\0') while ((__isspace (c) && c != '\n') || c == '\0')
{ {
consume_char (); consume_char ();
c = LA (0); c = LA (0);
@@ -653,10 +655,10 @@ lexer_next_token (void)
JERRY_ASSERT (token_start == NULL); JERRY_ASSERT (token_start == NULL);
if (isalpha (c) || c == '$' || c == '_') if (__isalpha (c) || c == '$' || c == '_')
return parse_name (); return parse_name ();
if (isdigit (c) || (c == '.' && isdigit (LA (1)))) if (__isdigit (c) || (c == '.' && __isdigit (LA (1))))
return parse_number (); return parse_number ();
if (c == '\n') if (c == '\n')
@@ -671,7 +673,7 @@ lexer_next_token (void)
if (c == '\'' || c == '"') if (c == '\'' || c == '"')
return parse_string (); return parse_string ();
if (isspace (c)) if (__isspace (c))
{ {
grobble_whitespaces (); grobble_whitespaces ();
return return
@@ -803,5 +805,5 @@ lexer_save_token (token tok)
void void
lexer_dump_buffer_state (void) lexer_dump_buffer_state (void)
{ {
printf ("%s\n", buffer); __printf ("%s\n", buffer);
} }
+1 -1
View File
@@ -16,7 +16,7 @@
#ifndef LEXER_H #ifndef LEXER_H
#define LEXER_H #define LEXER_H
#include "mappings.h" #include "globals.h"
/* Keywords. */ /* Keywords. */
typedef enum typedef enum
-139
View File
@@ -1,139 +0,0 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MAPPINGS_H
#define MAPPINGS_H
#ifndef __HOST
#include "jerry-libc.h"
#include "allocator.h"
#include <stdarg.h>
static inline void *
memset (void *s, int n1, size_t n2)
{
return __memset (s, n1, n2);
}
static inline int
memcmp (const void *s1, const void *s2, size_t n)
{
return __memcmp (s1, s2, n);
}
static inline void *
memcpy (void *s1, const void *s2, size_t n)
{
return __memcpy (s1, s2, n);
}
static inline int
printf (const char *s, ...)
{
va_list args;
va_start (args, s);
int ret = __printf (s, args);
va_end (args);
return ret;
}
static inline int
putchar (int c)
{
return __putchar (c);
}
static inline void
exit (int status)
{
__exit (status);
}
static inline int
strcmp (const char *s1, const char *s2)
{
return __strcmp (s1, s2);
}
static inline int
strncmp (const char *s1, const char *s2, size_t n)
{
return __strncmp (s1, s2, n);
}
static inline char *
strncpy (char *s1, const char *s2, size_t n)
{
return __strncpy (s1, s2, n);
}
static inline float
strtof (const char *s1, char **s2)
{
return __strtof (s1, s2);
}
static inline size_t
strlen (const char *s)
{
return __strlen (s);
}
static inline int
isspace (int s)
{
return __isspace (s);
}
static inline int
isupper (int s)
{
return __isupper (s);
}
static inline int
islower (int s)
{
return __islower (s);
}
static inline int
isalpha (int s)
{
return __isalpha (s);
}
static inline int
isdigit (int s)
{
return __isdigit (s);
}
static inline int
isxdigit (int s)
{
return __isxdigit (s);
}
#else
#undef NULL
#include "../globals.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#endif
#endif // MAPPINGS_H
+7 -7
View File
@@ -13,20 +13,20 @@
* limitations under the License. * limitations under the License.
*/ */
#include "parser.h" #include "jerry-libc.h"
#include "error.h"
#include "lexer.h" #include "lexer.h"
#include "error.h" #include "parser.h"
extern void lexer_dump_buffer_state (void);
/* FIXME: */
extern void lexer_dump_buffer_state();
/* FIXME: Make general fatal function call it from libjsparser's fatal */
void void
fatal (int code) fatal (int code)
{ {
printf ("FATAL: %d\n", code); __printf ("FATAL: %d\n", code);
lexer_dump_buffer_state (); lexer_dump_buffer_state ();
JERRY_UNREACHABLE (); JERRY_UNREACHABLE ();
exit (code); __exit( -code);
} }
bool bool
+1 -1
View File
@@ -16,7 +16,7 @@
#ifndef PARSER_H #ifndef PARSER_H
#define PARSER_H #define PARSER_H
#include "mappings.h" #include "globals.h"
struct source_element_list; struct source_element_list;
struct statement_list; struct statement_list;
+4 -5
View File
@@ -13,21 +13,20 @@
* limitations under the License. * limitations under the License.
*/ */
#include <stdio.h>
#include "actuators.h" #include "actuators.h"
#include "jerry-libc.h"
void led_toggle(int led_id) void led_toggle(int led_id)
{ {
printf("led_toogle: %d", led_id); __printf("led_toogle: %d", led_id);
} }
void led_on(int led_id) void led_on(int led_id)
{ {
printf("led_on: %d", led_id); __printf("led_on: %d", led_id);
} }
void led_off(int led_id) void led_off(int led_id)
{ {
printf("led_off: %d", led_id); __printf("led_off: %d", led_id);
} }
+1 -40
View File
@@ -14,16 +14,11 @@
*/ */
/** /**
* Jerry libc implementation * Jerry libc's common functions implementation
*/ */
#include "jerry-libc.h" #include "jerry-libc.h"
#include <stdarg.h>
extern int vprintf (__const char *__restrict __format, __builtin_va_list __arg);
extern void __noreturn exit(int status);
/** /**
* memset * memset
* *
@@ -89,40 +84,6 @@ __memcpy(void *s1, /**< destination */
return s1; return s1;
} /* __memcpy */ } /* __memcpy */
/**
* printf
*
* @return number of characters printed
*/
int
__printf(const char *format, /**< format string */
...) /**< parameters' values */
{
va_list args;
va_start( args, format);
int ret = vprintf( format, args);
va_end( args);
return ret;
} /* __printf */
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int
__putchar (int c)
{
return __printf ("%c", c);
}
/** exit - cause normal process termination */
void __noreturn
__exit (int status)
{
exit( status);
}
/** Compare two strings. return an integer less than, equal to, or greater than zero /** Compare two strings. return an integer less than, equal to, or greater than zero
if s1 is found, respectively, to be less than, to match, or be greater than s2. */ if s1 is found, respectively, to be less than, to match, or be greater than s2. */
int int
+7
View File
@@ -21,6 +21,8 @@
#include "globals.h" #include "globals.h"
typedef void FILE;
extern void *__memset (void *s, int c, size_t n); extern void *__memset (void *s, int c, size_t n);
extern int __memcmp (const void *s1, const void *s2, size_t n); extern int __memcmp (const void *s1, const void *s2, size_t n);
extern void *__memcpy (void *s1, const void *s2, size_t n); extern void *__memcpy (void *s1, const void *s2, size_t n);
@@ -41,6 +43,11 @@ extern int __isalpha (int);
extern int __isdigit (int); extern int __isdigit (int);
extern int __isxdigit (int); extern int __isxdigit (int);
extern FILE* __fopen(const char *path, const char *mode);
extern int __fclose(FILE *fp);
extern size_t __fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
extern size_t __fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
#define DBL_MANT_DIG ( 52) #define DBL_MANT_DIG ( 52)
#define DBL_DIG ( 10) #define DBL_DIG ( 10)
#define DBL_MIN_EXP (-324) #define DBL_MIN_EXP (-324)
+1 -1
View File
@@ -27,5 +27,5 @@ jerry_AssertFail( const char *assertion, /**< assertion condition string */
__printf("Assertion '%s' failed at %s:%u\n", __printf("Assertion '%s' failed at %s:%u\n",
assertion, file, line); assertion, file, line);
__exit( 1); __exit( -ERR_GENERAL);
} /* jerry_AssertFail */ } /* jerry_AssertFail */
+180 -180
View File
@@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerry-libc.h"
#include "pretty-printer.h" #include "pretty-printer.h"
#include "error.h"
static int intendation; static int intendation;
static bool was_function_expression; static bool was_function_expression;
@@ -35,11 +35,11 @@ pp_token (token tok)
switch (tok.type) switch (tok.type)
{ {
case TOK_NAME: case TOK_NAME:
printf ("IDENTIFIER (%s)\n", tok.data.name); __printf ("IDENTIFIER (%s)\n", tok.data.name);
break; break;
case TOK_STRING: case TOK_STRING:
printf ("STRING (%s)\n", tok.data.str); __printf ("STRING (%s)\n", tok.data.str);
break; break;
case TOK_KEYWORD: case TOK_KEYWORD:
@@ -47,227 +47,227 @@ pp_token (token tok)
break; break;
case TOK_INT: case TOK_INT:
printf ("INTEGER (%d)\n", tok.data.num); __printf ("INTEGER (%d)\n", tok.data.num);
break; break;
case TOK_FLOAT: case TOK_FLOAT:
printf ("FLOAT (%f)\n", tok.data.fp_num); __printf ("FLOAT (%f)\n", tok.data.fp_num);
break; break;
case TOK_NULL: case TOK_NULL:
printf ("NULL (null)\n"); __printf ("NULL (null)\n");
break; break;
case TOK_BOOL: case TOK_BOOL:
if (tok.data.is_true) if (tok.data.is_true)
printf ("BOOL (true)\n"); __printf ("BOOL (true)\n");
else else
printf ("BOOL (false)\n"); __printf ("BOOL (false)\n");
break; break;
case TOK_OPEN_BRACE: case TOK_OPEN_BRACE:
printf ("PUNC ({)\n"); __printf ("PUNC ({)\n");
break; break;
case TOK_CLOSE_BRACE: case TOK_CLOSE_BRACE:
printf ("PUNC (})\n"); __printf ("PUNC (})\n");
break; break;
case TOK_OPEN_PAREN: case TOK_OPEN_PAREN:
printf ("PUNC (()\n"); __printf ("PUNC (()\n");
break; break;
case TOK_CLOSE_PAREN: case TOK_CLOSE_PAREN:
printf ("PUNC ())\n"); __printf ("PUNC ())\n");
break; break;
case TOK_OPEN_SQUARE: case TOK_OPEN_SQUARE:
printf ("PUNC ([)\n"); __printf ("PUNC ([)\n");
break; break;
case TOK_CLOSE_SQUARE: case TOK_CLOSE_SQUARE:
printf ("PUNC (])\n"); __printf ("PUNC (])\n");
break; break;
case TOK_DOT: case TOK_DOT:
printf ("PUNC (.)\n"); __printf ("PUNC (.)\n");
break; break;
case TOK_SEMICOLON: case TOK_SEMICOLON:
printf ("PUNC (;)\n"); __printf ("PUNC (;)\n");
break; break;
case TOK_COMMA: case TOK_COMMA:
printf ("PUNC (,)\n"); __printf ("PUNC (,)\n");
break; break;
case TOK_LESS: case TOK_LESS:
printf ("PUNC (<)\n"); __printf ("PUNC (<)\n");
break; break;
case TOK_GREATER: case TOK_GREATER:
printf ("PUNC (>)\n"); __printf ("PUNC (>)\n");
break; break;
case TOK_LESS_EQ: case TOK_LESS_EQ:
printf ("PUNC (<=)\n"); __printf ("PUNC (<=)\n");
break; break;
case TOK_GREATER_EQ: case TOK_GREATER_EQ:
printf ("PUNC (>=)\n"); __printf ("PUNC (>=)\n");
break; break;
case TOK_DOUBLE_EQ: case TOK_DOUBLE_EQ:
printf ("PUNC (==)\n"); __printf ("PUNC (==)\n");
break; break;
case TOK_NOT_EQ: case TOK_NOT_EQ:
printf ("PUNC (!=)\n"); __printf ("PUNC (!=)\n");
break; break;
case TOK_TRIPLE_EQ: case TOK_TRIPLE_EQ:
printf ("PUNC (===)\n"); __printf ("PUNC (===)\n");
break; break;
case TOK_NOT_DOUBLE_EQ: case TOK_NOT_DOUBLE_EQ:
printf ("PUNC (!==)\n"); __printf ("PUNC (!==)\n");
break; break;
case TOK_PLUS: case TOK_PLUS:
printf ("PUNC (+)\n"); __printf ("PUNC (+)\n");
break; break;
case TOK_MINUS: case TOK_MINUS:
printf ("PUNC (-)\n"); __printf ("PUNC (-)\n");
break; break;
case TOK_MULT: case TOK_MULT:
printf ("PUNC (*)\n"); __printf ("PUNC (*)\n");
break; break;
case TOK_MOD: case TOK_MOD:
printf ("PUNC (%%)\n"); __printf ("PUNC (%%)\n");
break; break;
case TOK_DOUBLE_PLUS: case TOK_DOUBLE_PLUS:
printf ("PUNC (++)\n"); __printf ("PUNC (++)\n");
break; break;
case TOK_DOUBLE_MINUS: case TOK_DOUBLE_MINUS:
printf ("PUNC (--)\n"); __printf ("PUNC (--)\n");
break; break;
case TOK_LSHIFT: case TOK_LSHIFT:
printf ("PUNC (<<)\n"); __printf ("PUNC (<<)\n");
break; break;
case TOK_RSHIFT: case TOK_RSHIFT:
printf ("PUNC (>>)\n"); __printf ("PUNC (>>)\n");
break; break;
case TOK_RSHIFT_EX: case TOK_RSHIFT_EX:
printf ("PUNC (>>>)\n"); __printf ("PUNC (>>>)\n");
break; break;
case TOK_AND: case TOK_AND:
printf ("PUNC (&)\n"); __printf ("PUNC (&)\n");
break; break;
case TOK_OR: case TOK_OR:
printf ("PUNC (|)\n"); __printf ("PUNC (|)\n");
break; break;
case TOK_XOR: case TOK_XOR:
printf ("PUNC (^)\n"); __printf ("PUNC (^)\n");
break; break;
case TOK_NOT: case TOK_NOT:
printf ("PUNC (!)\n"); __printf ("PUNC (!)\n");
break; break;
case TOK_COMPL: case TOK_COMPL:
printf ("PUNC (~)\n"); __printf ("PUNC (~)\n");
break; break;
case TOK_DOUBLE_AND: case TOK_DOUBLE_AND:
printf ("PUNC (&&)\n"); __printf ("PUNC (&&)\n");
break; break;
case TOK_DOUBLE_OR: case TOK_DOUBLE_OR:
printf ("PUNC (||)\n"); __printf ("PUNC (||)\n");
break; break;
case TOK_QUERY: case TOK_QUERY:
printf ("PUNC (?)\n"); __printf ("PUNC (?)\n");
break; break;
case TOK_COLON: case TOK_COLON:
printf ("PUNC (:)\n"); __printf ("PUNC (:)\n");
break; break;
case TOK_EQ: case TOK_EQ:
printf ("PUNC (=)\n"); __printf ("PUNC (=)\n");
break; break;
case TOK_PLUS_EQ: case TOK_PLUS_EQ:
printf ("PUNC (+=)\n"); __printf ("PUNC (+=)\n");
break; break;
case TOK_MINUS_EQ: case TOK_MINUS_EQ:
printf ("PUNC (-=)\n"); __printf ("PUNC (-=)\n");
break; break;
case TOK_MULT_EQ: case TOK_MULT_EQ:
printf ("PUNC (*=)\n"); __printf ("PUNC (*=)\n");
break; break;
case TOK_MOD_EQ: case TOK_MOD_EQ:
printf ("PUNC (%%=)\n"); __printf ("PUNC (%%=)\n");
break; break;
case TOK_LSHIFT_EQ: case TOK_LSHIFT_EQ:
printf ("PUNC (<<=)\n"); __printf ("PUNC (<<=)\n");
break; break;
case TOK_RSHIFT_EQ: case TOK_RSHIFT_EQ:
printf ("PUNC (>>=)\n"); __printf ("PUNC (>>=)\n");
break; break;
case TOK_RSHIFT_EX_EQ: case TOK_RSHIFT_EX_EQ:
printf ("PUNC (>>>=)\n"); __printf ("PUNC (>>>=)\n");
break; break;
case TOK_AND_EQ: case TOK_AND_EQ:
printf ("PUNC (&=)\n"); __printf ("PUNC (&=)\n");
break; break;
case TOK_OR_EQ: case TOK_OR_EQ:
printf ("PUNC (|=)\n"); __printf ("PUNC (|=)\n");
break; break;
case TOK_XOR_EQ: case TOK_XOR_EQ:
printf ("PUNC (^=)\n"); __printf ("PUNC (^=)\n");
break; break;
case TOK_DIV: case TOK_DIV:
printf ("PUNC (/)\n"); __printf ("PUNC (/)\n");
break; break;
case TOK_DIV_EQ: case TOK_DIV_EQ:
printf ("PUNC (/=)\n"); __printf ("PUNC (/=)\n");
break; break;
case TOK_NEWLINE: case TOK_NEWLINE:
printf ("NEWLINE\n"); __printf ("NEWLINE\n");
break; break;
default: default:
@@ -286,115 +286,115 @@ pp_keyword (keyword kw)
break; break;
case KW_RESERVED: case KW_RESERVED:
printf ("KEYWORD RESERVED\n"); __printf ("KEYWORD RESERVED\n");
break; break;
case KW_BREAK: case KW_BREAK:
printf ("KEYWORD (break)\n"); __printf ("KEYWORD (break)\n");
break; break;
case KW_CASE: case KW_CASE:
printf ("KEYWORD (case)\n"); __printf ("KEYWORD (case)\n");
break; break;
case KW_CATCH: case KW_CATCH:
printf ("KEYWORD (catch)\n"); __printf ("KEYWORD (catch)\n");
break; break;
case KW_CONTINUE: case KW_CONTINUE:
printf ("KEYWORD (continue)\n"); __printf ("KEYWORD (continue)\n");
break; break;
case KW_DEBUGGER: case KW_DEBUGGER:
printf ("KEYWORD (debugger)\n"); __printf ("KEYWORD (debugger)\n");
break; break;
case KW_DEFAULT: case KW_DEFAULT:
printf ("KEYWORD (default)\n"); __printf ("KEYWORD (default)\n");
break; break;
case KW_DELETE: case KW_DELETE:
printf ("KEYWORD (delete)\n"); __printf ("KEYWORD (delete)\n");
break; break;
case KW_DO: case KW_DO:
printf ("KEYWORD (do)\n"); __printf ("KEYWORD (do)\n");
break; break;
case KW_ELSE: case KW_ELSE:
printf ("KEYWORD (else)\n"); __printf ("KEYWORD (else)\n");
break; break;
case KW_FINALLY: case KW_FINALLY:
printf ("KEYWORD (finally)\n"); __printf ("KEYWORD (finally)\n");
break; break;
case KW_FOR: case KW_FOR:
printf ("KEYWORD (for)\n"); __printf ("KEYWORD (for)\n");
break; break;
case KW_FUNCTION: case KW_FUNCTION:
printf ("KEYWORD (function)\n"); __printf ("KEYWORD (function)\n");
break; break;
case KW_IF: case KW_IF:
printf ("KEYWORD (if)\n"); __printf ("KEYWORD (if)\n");
break; break;
case KW_IN: case KW_IN:
printf ("KEYWORD (in)\n"); __printf ("KEYWORD (in)\n");
break; break;
case KW_INSTANCEOF: case KW_INSTANCEOF:
printf ("KEYWORD (instanceof)\n"); __printf ("KEYWORD (instanceof)\n");
break; break;
case KW_NEW: case KW_NEW:
printf ("KEYWORD (new)\n"); __printf ("KEYWORD (new)\n");
break; break;
case KW_RETURN: case KW_RETURN:
printf ("KEYWORD (return)\n"); __printf ("KEYWORD (return)\n");
break; break;
case KW_SWITCH: case KW_SWITCH:
printf ("KEYWORD (switch)\n"); __printf ("KEYWORD (switch)\n");
break; break;
case KW_THIS: case KW_THIS:
printf ("KEYWORD (this)\n"); __printf ("KEYWORD (this)\n");
break; break;
case KW_THROW: case KW_THROW:
printf ("KEYWORD (throw)\n"); __printf ("KEYWORD (throw)\n");
break; break;
case KW_TRY: case KW_TRY:
printf ("KEYWORD (try)\n"); __printf ("KEYWORD (try)\n");
break; break;
case KW_TYPEOF: case KW_TYPEOF:
printf ("KEYWORD (typeof)\n"); __printf ("KEYWORD (typeof)\n");
break; break;
case KW_VAR: case KW_VAR:
printf ("KEYWORD (var)\n"); __printf ("KEYWORD (var)\n");
break; break;
case KW_VOID: case KW_VOID:
printf ("KEYWORD (void)\n"); __printf ("KEYWORD (void)\n");
break; break;
case KW_WHILE: case KW_WHILE:
printf ("KEYWORD (while)\n"); __printf ("KEYWORD (while)\n");
break; break;
case KW_WITH: case KW_WITH:
printf ("KEYWORD (with)\n"); __printf ("KEYWORD (with)\n");
break; break;
default: default:
@@ -404,10 +404,10 @@ pp_keyword (keyword kw)
} }
static void static void
intend (void) intend ()
{ {
for (int i = 0; i < intendation; i++) for (int i = 0; i < intendation; i++)
putchar (' '); __putchar (' ');
} }
static void static void
@@ -420,20 +420,20 @@ pp_formal_parameter_list (formal_parameter_list param_list)
if (param_list.names[i] == NULL) if (param_list.names[i] == NULL)
break; break;
if (i != 0) if (i != 0)
printf (", "); __printf (", ");
printf ("%s", param_list.names[i]); __printf ("%s", param_list.names[i]);
} }
} }
static void static void
pp_function_declaration (function_declaration func_decl) pp_function_declaration (function_declaration func_decl)
{ {
printf ("function "); __printf ("function ");
if (func_decl.name) if (func_decl.name)
printf ("%s ", func_decl.name); __printf ("%s ", func_decl.name);
putchar ('('); __putchar ('(');
pp_formal_parameter_list (func_decl.params); pp_formal_parameter_list (func_decl.params);
printf (") "); __printf (") ");
was_function_expression = true; was_function_expression = true;
} }
@@ -443,19 +443,19 @@ pp_literal (literal lit)
switch (lit.type) switch (lit.type)
{ {
case LIT_NULL: case LIT_NULL:
printf ("null"); __printf ("null");
break; break;
case LIT_BOOL: case LIT_BOOL:
printf ("%s", lit.data.is_true ? "true" : "false"); __printf ("%s", lit.data.is_true ? "true" : "false");
break; break;
case LIT_INT: case LIT_INT:
printf ("%d", lit.data.num); __printf ("%d", lit.data.num);
break; break;
case LIT_STR: case LIT_STR:
printf ("\"%s\"", lit.data.str); __printf ("\"%s\"", lit.data.str);
break; break;
default: default:
@@ -470,7 +470,7 @@ pp_operand (operand op)
if (op.is_literal) if (op.is_literal)
pp_literal (op.data.lit); pp_literal (op.data.lit);
else else
printf ("%s", op.data.name); __printf ("%s", op.data.name);
} }
static void static void
@@ -483,7 +483,7 @@ pp_operand_list (operand_list list)
if (is_operand_empty (list.ops[i])) if (is_operand_empty (list.ops[i]))
break; break;
if (i != 0) if (i != 0)
printf (", "); __printf (", ");
pp_operand (list.ops[i]); pp_operand (list.ops[i]);
} }
} }
@@ -493,7 +493,7 @@ pp_property (property prop)
{ {
JERRY_ASSERT (!is_property_empty (prop)); JERRY_ASSERT (!is_property_empty (prop));
pp_operand (prop.name); pp_operand (prop.name);
printf (" : "); __printf (" : ");
pp_operand (prop.value); pp_operand (prop.value);
} }
@@ -507,7 +507,7 @@ pp_property_list (property_list prop_list)
if (is_property_empty (prop_list.props[i])) if (is_property_empty (prop_list.props[i]))
break; break;
if (i != 0) if (i != 0)
printf (", "); __printf (", ");
pp_property (prop_list.props[i]); pp_property (prop_list.props[i]);
} }
} }
@@ -516,40 +516,40 @@ static void
pp_call_expression (call_expression expr) pp_call_expression (call_expression expr)
{ {
JERRY_ASSERT (expr.name); JERRY_ASSERT (expr.name);
printf ("%s (", expr.name); __printf ("%s (", expr.name);
pp_operand_list (expr.args); pp_operand_list (expr.args);
printf (")\n"); __printf (")\n");
} }
static void static void
dump_two_operands (operand_pair pair, const char *operation) dump_two_operands (operand_pair pair, const char *operation)
{ {
pp_operand (pair.op1); pp_operand (pair.op1);
printf ("%s", operation); __printf ("%s", operation);
pp_operand (pair.op2); pp_operand (pair.op2);
putchar ('\n'); __putchar ('\n');
} }
static void static void
dump_unary (operand op, const char *operation) dump_unary (operand op, const char *operation)
{ {
printf ("%s", operation); __printf ("%s", operation);
pp_operand (op); pp_operand (op);
putchar ('\n'); __putchar ('\n');
} }
static void static void
dump_postfix (operand op, const char *operation) dump_postfix (operand op, const char *operation)
{ {
pp_operand (op); pp_operand (op);
printf ("%s\n", operation); __printf ("%s\n", operation);
} }
static void static void
pp_assignment_expression (assignment_expression expr) pp_assignment_expression (assignment_expression expr)
{ {
if (expr.oper != AO_NONE && expr.var) if (expr.var)
printf ("%s", expr.var); __printf ("%s", expr.var);
switch (expr.oper) switch (expr.oper)
{ {
@@ -557,51 +557,51 @@ pp_assignment_expression (assignment_expression expr)
break; break;
case AO_EQ: case AO_EQ:
printf (" = "); __printf (" = ");
break; break;
case AO_MULT_EQ: case AO_MULT_EQ:
printf (" *= "); __printf (" *= ");
break; break;
case AO_DIV_EQ: case AO_DIV_EQ:
printf (" ?= "); __printf (" ?= ");
break; break;
case AO_MOD_EQ: case AO_MOD_EQ:
printf (" %%= "); __printf (" %%= ");
break; break;
case AO_PLUS_EQ: case AO_PLUS_EQ:
printf (" += "); __printf (" += ");
break; break;
case AO_MINUS_EQ: case AO_MINUS_EQ:
printf (" -= "); __printf (" -= ");
break; break;
case AO_LSHIFT_EQ: case AO_LSHIFT_EQ:
printf (" <<= "); __printf (" <<= ");
break; break;
case AO_RSHIFT_EQ: case AO_RSHIFT_EQ:
printf (" >>= "); __printf (" >>= ");
break; break;
case AO_RSHIFT_EX_EQ: case AO_RSHIFT_EX_EQ:
printf (" >>>= "); __printf (" >>>= ");
break; break;
case AO_AND_EQ: case AO_AND_EQ:
printf (" &= "); __printf (" &= ");
break; break;
case AO_XOR_EQ: case AO_XOR_EQ:
printf (" ^= "); __printf (" ^= ");
break; break;
case AO_OR_EQ: case AO_OR_EQ:
printf (" |= "); __printf (" |= ");
break; break;
default: default:
@@ -767,30 +767,30 @@ pp_assignment_expression (assignment_expression expr)
return; return;
case ET_NEW: case ET_NEW:
printf ("new "); __printf ("new ");
pp_operand (expr.data.ops.op1); pp_operand (expr.data.ops.op1);
JERRY_ASSERT (is_operand_empty (expr.data.ops.op2)); JERRY_ASSERT (is_operand_empty (expr.data.ops.op2));
putchar ('\n'); __putchar ('\n');
return; return;
case ET_INDEX: case ET_INDEX:
pp_operand (expr.data.ops.op1); pp_operand (expr.data.ops.op1);
putchar ('.'); __putchar ('.');
pp_operand (expr.data.ops.op2); pp_operand (expr.data.ops.op2);
putchar ('\n'); __putchar ('\n');
return; return;
case ET_PROP_REF: case ET_PROP_REF:
pp_operand (expr.data.ops.op1); pp_operand (expr.data.ops.op1);
putchar ('['); __putchar ('[');
pp_operand (expr.data.ops.op2); pp_operand (expr.data.ops.op2);
printf ("]\n"); __printf ("]\n");
return; return;
case ET_OBJECT: case ET_OBJECT:
putchar ('{'); __putchar ('{');
pp_property_list (expr.data.obj_lit); pp_property_list (expr.data.obj_lit);
printf ("}\n"); __printf ("}\n");
return; return;
case ET_FUNCTION: case ET_FUNCTION:
@@ -798,20 +798,20 @@ pp_assignment_expression (assignment_expression expr)
return; return;
case ET_ARRAY: case ET_ARRAY:
putchar ('['); __putchar ('[');
pp_operand_list (expr.data.arr_lit); pp_operand_list (expr.data.arr_lit);
printf ("]\n"); __printf ("]\n");
return; return;
case ET_SUBEXPRESSION: case ET_SUBEXPRESSION:
putchar ('('); __putchar ('(');
return; return;
case ET_LITERAL: case ET_LITERAL:
case ET_IDENTIFIER: case ET_IDENTIFIER:
pp_operand (expr.data.ops.op1); pp_operand (expr.data.ops.op1);
JERRY_ASSERT (is_operand_empty (expr.data.ops.op2)); JERRY_ASSERT (is_operand_empty (expr.data.ops.op2));
putchar ('\n'); __putchar ('\n');
return; return;
default: default:
@@ -829,13 +829,13 @@ pp_expression (expression_list expr_list)
if (is_expression_empty (expr_list.exprs[i])) if (is_expression_empty (expr_list.exprs[i]))
break; break;
if (i != 0) if (i != 0)
printf (", "); __printf (", ");
pp_assignment_expression (expr_list.exprs[i]); pp_assignment_expression (expr_list.exprs[i]);
} }
if (was_subexpression && !was_function_expression) if (was_subexpression && !was_function_expression)
{ {
putchar (')'); __putchar (')');
was_subexpression = false; was_subexpression = false;
} }
} }
@@ -843,10 +843,10 @@ pp_expression (expression_list expr_list)
static void static void
pp_variable_declaration (variable_declaration var_decl) pp_variable_declaration (variable_declaration var_decl)
{ {
printf ("%s", var_decl.name); __printf ("%s", var_decl.name);
if (!is_expression_empty (var_decl.assign_expr)) if (!is_expression_empty (var_decl.assign_expr))
{ {
printf (" = "); __printf (" = ");
pp_assignment_expression (var_decl.assign_expr); pp_assignment_expression (var_decl.assign_expr);
} }
} }
@@ -856,14 +856,14 @@ pp_variable_declaration_list (variable_declaration_list decl_list)
{ {
int i; int i;
printf ("var "); __printf ("var ");
for (i = 0; i < MAX_DECLS; i++) for (i = 0; i < MAX_DECLS; i++)
{ {
if (is_variable_declaration_empty (decl_list.decls[i])) if (is_variable_declaration_empty (decl_list.decls[i]))
break; break;
if (i != 0) if (i != 0)
printf (", "); __printf (", ");
pp_variable_declaration (decl_list.decls[i]); pp_variable_declaration (decl_list.decls[i]);
} }
} }
@@ -873,7 +873,7 @@ pp_for_in_statement_initializer_part (for_in_statement_initializer_part init)
{ {
if (init.is_decl) if (init.is_decl)
{ {
printf ("var "); __printf ("var ");
pp_variable_declaration (init.data.decl); pp_variable_declaration (init.data.decl);
} }
else if (!is_expression_empty (init.data.left_hand_expr)) else if (!is_expression_empty (init.data.left_hand_expr))
@@ -883,11 +883,11 @@ pp_for_in_statement_initializer_part (for_in_statement_initializer_part init)
static void static void
pp_for_in_statement (for_in_statement for_in_stmt) pp_for_in_statement (for_in_statement for_in_stmt)
{ {
printf ("for ("); __printf ("for (");
pp_for_in_statement_initializer_part (for_in_stmt.init); pp_for_in_statement_initializer_part (for_in_stmt.init);
printf (" in "); __printf (" in ");
pp_expression (for_in_stmt.list_expr); pp_expression (for_in_stmt.list_expr);
printf (") "); __printf (") ");
} }
static void static void
@@ -902,15 +902,15 @@ pp_for_statement_initialiser_part (for_statement_initialiser_part init)
static void static void
pp_for_statement (for_statement for_stmt) pp_for_statement (for_statement for_stmt)
{ {
printf ("for ("); __printf ("for (");
pp_for_statement_initialiser_part (for_stmt.init); pp_for_statement_initialiser_part (for_stmt.init);
printf ("; "); __printf ("; ");
if (is_expression_empty (for_stmt.limit)) if (is_expression_empty (for_stmt.limit))
pp_assignment_expression (for_stmt.limit); pp_assignment_expression (for_stmt.limit);
printf ("; "); __printf ("; ");
if (is_expression_empty (for_stmt.incr)) if (is_expression_empty (for_stmt.incr))
pp_assignment_expression (for_stmt.incr); pp_assignment_expression (for_stmt.incr);
printf (") "); __printf (") ");
} }
static void static void
@@ -932,25 +932,25 @@ pp_statement (statement stmt)
{ {
if (stmt.type == STMT_EMPTY) if (stmt.type == STMT_EMPTY)
{ {
printf (";\n"); __printf (";\n");
prev_stmt = stmt.type; prev_stmt = stmt.type;
return; return;
} }
else else
putchar ('\n'); __putchar ('\n');
} }
switch (stmt.type) switch (stmt.type)
{ {
case STMT_BLOCK_START: case STMT_BLOCK_START:
printf ("{\n"); __printf ("{\n");
intendation += 2; intendation += 2;
break; break;
case STMT_BLOCK_END: case STMT_BLOCK_END:
intendation -= 2; intendation -= 2;
intend (); intend ();
printf ("}"); __printf ("}");
break; break;
case STMT_VARIABLE: case STMT_VARIABLE:
@@ -959,38 +959,38 @@ pp_statement (statement stmt)
break; break;
case STMT_EMPTY: case STMT_EMPTY:
printf (";\n"); __printf (";\n");
break; break;
case STMT_IF: case STMT_IF:
intend (); intend ();
printf ("if ("); __printf ("if (");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (") "); __printf (") ");
break; break;
case STMT_ELSE: case STMT_ELSE:
intend (); intend ();
printf ("else "); __printf ("else ");
break; break;
case STMT_ELSE_IF: case STMT_ELSE_IF:
intend (); intend ();
printf ("else if("); __printf ("else if(");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (") "); __printf (") ");
break; break;
case STMT_DO: case STMT_DO:
intend (); intend ();
printf ("do "); __printf ("do ");
break; break;
case STMT_WHILE: case STMT_WHILE:
intend (); intend ();
printf ("while ("); __printf ("while (");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (") "); __printf (") ");
break; break;
case STMT_FOR_OR_FOR_IN: case STMT_FOR_OR_FOR_IN:
@@ -1000,70 +1000,70 @@ pp_statement (statement stmt)
case STMT_CONTINUE: case STMT_CONTINUE:
intend (); intend ();
printf ("continue\n"); __printf ("continue\n");
break; break;
case STMT_BREAK: case STMT_BREAK:
intend (); intend ();
printf ("break\n"); __printf ("break\n");
break; break;
case STMT_RETURN: case STMT_RETURN:
intend (); intend ();
printf ("return "); __printf ("return ");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
if (!was_function_expression) if (!was_function_expression)
printf (";\n"); __printf (";\n");
break; break;
case STMT_WITH: case STMT_WITH:
intend (); intend ();
printf ("with ("); __printf ("with (");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (") "); __printf (") ");
break; break;
case STMT_LABELLED: case STMT_LABELLED:
intend (); intend ();
printf ("%s:\n", stmt.data.name); __printf ("%s:\n", stmt.data.name);
break; break;
case STMT_SWITCH: case STMT_SWITCH:
intend (); intend ();
printf ("switch ("); __printf ("switch (");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (") "); __printf (") ");
break; break;
case STMT_CASE: case STMT_CASE:
intend (); intend ();
printf ("case "); __printf ("case ");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (":\n"); __printf (":\n");
break; break;
case STMT_THROW: case STMT_THROW:
intend (); intend ();
printf ("throw "); __printf ("throw ");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (";\n"); __printf (";\n");
break; break;
case STMT_TRY: case STMT_TRY:
intend (); intend ();
printf ("try "); __printf ("try ");
break; break;
case STMT_CATCH: case STMT_CATCH:
intend (); intend ();
printf ("catch ("); __printf ("catch (");
pp_expression (stmt.data.expr); pp_expression (stmt.data.expr);
printf (") "); __printf (") ");
break; break;
case STMT_FINALLY: case STMT_FINALLY:
intend (); intend ();
printf ("finally "); __printf ("finally ");
break; break;
case STMT_EXPRESSION: case STMT_EXPRESSION:
@@ -1072,7 +1072,7 @@ pp_statement (statement stmt)
break; break;
case STMT_SUBEXPRESSION_END: case STMT_SUBEXPRESSION_END:
putchar (')'); __putchar (')');
break; break;
case STMT_FUNCTION: case STMT_FUNCTION:
@@ -1087,8 +1087,8 @@ pp_statement (statement stmt)
prev_stmt = stmt.type; prev_stmt = stmt.type;
} }
void pp_finish (void) void pp_finish ()
{ {
if (prev_stmt == STMT_BLOCK_END) if (prev_stmt == STMT_BLOCK_END)
putchar ('\n'); __putchar ('\n');
} }
+1 -5
View File
@@ -24,9 +24,5 @@ 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);
* TODO: Blink with LEDs.
* Save call stack?
*/
while( true );
} /* jerry_AssertFail */ } /* jerry_AssertFail */
+6 -18
View File
@@ -13,12 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
#ifdef __HOST
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#ifdef __TARGET_MCU #ifdef __TARGET_MCU
#include "stm32f4xx.h" #include "stm32f4xx.h"
#include "stm32f4xx_gpio.h" #include "stm32f4xx_gpio.h"
@@ -30,17 +24,11 @@
#define LED_BLUE 15 #define LED_BLUE 15
#endif #endif
#include "error.h"
#include "mem-allocator.h"
#include "interpreter.h"
#include "generated.h" #include "generated.h"
#include "globals.h"
#include "lexer.h" #include "interpreter.h"
#include "parser.h" #include "jerry-libc.h"
#include "pretty-printer.h" #include "mem-allocator.h"
void fake_exit (void); void fake_exit (void);
@@ -111,9 +99,9 @@ main (int argc, char **argv)
if (argc > 0) if (argc > 0)
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
if (!strcmp ("-t", argv[i])) if (!__strcmp ("-t", argv[i]))
dump_tokens = true; dump_tokens = true;
else if (!strcmp ("-a", argv[i])) else if (!__strcmp ("-a", argv[i]))
dump_ast = true; dump_ast = true;
else if (file_name == NULL) else if (file_name == NULL)
file_name = argv[i]; file_name = argv[i];