Merge branch 'geppetto'
This commit is contained in:
+86
-86
@@ -36,114 +36,114 @@ OPCODE;
|
|||||||
typedef ecma_completion_value_t (*opfunc)(OPCODE, struct __int_data *);
|
typedef ecma_completion_value_t (*opfunc)(OPCODE, struct __int_data *);
|
||||||
|
|
||||||
#define OP_CALLS_AND_ARGS(op) \
|
#define OP_CALLS_AND_ARGS(op) \
|
||||||
op(call_0) \
|
op (call_0) \
|
||||||
op(call_1) \
|
op (call_1) \
|
||||||
op(call_n) \
|
op (call_n) \
|
||||||
op(construct_0) \
|
op (construct_0) \
|
||||||
op(construct_1) \
|
op (construct_1) \
|
||||||
op(construct_n) \
|
op (construct_n) \
|
||||||
op(func_decl_0) \
|
op (func_decl_0) \
|
||||||
op(func_decl_1) \
|
op (func_decl_1) \
|
||||||
op(func_decl_2) \
|
op (func_decl_2) \
|
||||||
op(func_decl_n) \
|
op (func_decl_n) \
|
||||||
op(func_expr_0) \
|
op (func_expr_0) \
|
||||||
op(func_expr_1) \
|
op (func_expr_1) \
|
||||||
op(func_expr_n) \
|
op (func_expr_n) \
|
||||||
op(varg_1_end) \
|
op (varg_1_end) \
|
||||||
op(varg_2_end) \
|
op (varg_2_end) \
|
||||||
op(varg_3) \
|
op (varg_3) \
|
||||||
op(varg_3_end) \
|
op (varg_3_end) \
|
||||||
op(exitval) \
|
op (exitval) \
|
||||||
op(retval) \
|
op (retval) \
|
||||||
op(ret)
|
op (ret)
|
||||||
|
|
||||||
#define OP_INITS(op) \
|
#define OP_INITS(op) \
|
||||||
op(array_0) \
|
op (array_0) \
|
||||||
op(array_1) \
|
op (array_1) \
|
||||||
op(array_2) \
|
op (array_2) \
|
||||||
op(array_n) \
|
op (array_n) \
|
||||||
op(prop) \
|
op (prop) \
|
||||||
op(prop_access) \
|
op (prop_access) \
|
||||||
op(prop_get_decl) \
|
op (prop_get_decl) \
|
||||||
op(prop_set_decl) \
|
op (prop_set_decl) \
|
||||||
op(obj_0) \
|
op (obj_0) \
|
||||||
op(obj_1) \
|
op (obj_1) \
|
||||||
op(obj_2) \
|
op (obj_2) \
|
||||||
op(obj_n) \
|
op (obj_n) \
|
||||||
op(this) \
|
op (this) \
|
||||||
op(delete) \
|
op (delete) \
|
||||||
op(typeof) \
|
op (typeof) \
|
||||||
op(with) \
|
op (with) \
|
||||||
op(end_with)
|
op (end_with)
|
||||||
|
|
||||||
#define OP_ASSIGNMENTS(op) \
|
#define OP_ASSIGNMENTS(op) \
|
||||||
op(assignment)
|
op (assignment)
|
||||||
|
|
||||||
#define OP_B_SHIFTS(op) \
|
#define OP_B_SHIFTS(op) \
|
||||||
op(b_shift_left) \
|
op (b_shift_left) \
|
||||||
op(b_shift_right) \
|
op (b_shift_right) \
|
||||||
op(b_shift_uright)
|
op (b_shift_uright)
|
||||||
|
|
||||||
#define OP_B_BITWISE(op) \
|
#define OP_B_BITWISE(op) \
|
||||||
op(b_and) \
|
op (b_and) \
|
||||||
op(b_or) \
|
op (b_or) \
|
||||||
op(b_xor) \
|
op (b_xor) \
|
||||||
op(b_not)
|
op (b_not)
|
||||||
|
|
||||||
#define OP_B_LOGICAL(op) \
|
#define OP_B_LOGICAL(op) \
|
||||||
op(logical_and) \
|
op (logical_and) \
|
||||||
op(logical_or) \
|
op (logical_or) \
|
||||||
op(logical_not)
|
op (logical_not)
|
||||||
|
|
||||||
#define OP_EQUALITY(op) \
|
#define OP_EQUALITY(op) \
|
||||||
op(equal_value) \
|
op (equal_value) \
|
||||||
op(not_equal_value) \
|
op (not_equal_value) \
|
||||||
op(equal_value_type) \
|
op (equal_value_type) \
|
||||||
op(not_equal_value_type)
|
op (not_equal_value_type)
|
||||||
|
|
||||||
#define OP_RELATIONAL(op) \
|
#define OP_RELATIONAL(op) \
|
||||||
op(less_than) \
|
op (less_than) \
|
||||||
op(greater_than) \
|
op (greater_than) \
|
||||||
op(less_or_equal_than) \
|
op (less_or_equal_than) \
|
||||||
op(greater_or_equal_than) \
|
op (greater_or_equal_than) \
|
||||||
op(instanceof) \
|
op (instanceof) \
|
||||||
op(in)
|
op (in)
|
||||||
|
|
||||||
#define OP_ARITHMETIC(op) \
|
#define OP_ARITHMETIC(op) \
|
||||||
op(post_incr) \
|
op (post_incr) \
|
||||||
op(post_decr) \
|
op (post_decr) \
|
||||||
op(pre_incr) \
|
op (pre_incr) \
|
||||||
op(pre_decr) \
|
op (pre_decr) \
|
||||||
op(addition) \
|
op (addition) \
|
||||||
op(substraction) \
|
op (substraction) \
|
||||||
op(division) \
|
op (division) \
|
||||||
op(multiplication) \
|
op (multiplication) \
|
||||||
op(remainder)
|
op (remainder)
|
||||||
|
|
||||||
#define OP_UNCONDITIONAL_JUMPS(op) \
|
#define OP_UNCONDITIONAL_JUMPS(op) \
|
||||||
op(jmp) \
|
op (jmp) \
|
||||||
op(jmp_up) \
|
op (jmp_up) \
|
||||||
op(jmp_down) \
|
op (jmp_down) \
|
||||||
op(nop)
|
op (nop)
|
||||||
|
|
||||||
#define OP_UNARY_OPS(op) \
|
#define OP_UNARY_OPS(op) \
|
||||||
op(is_true_jmp) \
|
op (is_true_jmp) \
|
||||||
op(is_false_jmp)
|
op (is_false_jmp)
|
||||||
|
|
||||||
#define OP_LIST(op) \
|
#define OP_LIST(op) \
|
||||||
OP_CALLS_AND_ARGS(op) \
|
OP_CALLS_AND_ARGS (op) \
|
||||||
OP_INITS(op) \
|
OP_INITS (op) \
|
||||||
OP_ASSIGNMENTS(op) \
|
OP_ASSIGNMENTS (op) \
|
||||||
OP_B_LOGICAL(op) \
|
OP_B_LOGICAL (op) \
|
||||||
OP_B_BITWISE(op) \
|
OP_B_BITWISE (op) \
|
||||||
OP_B_SHIFTS(op) \
|
OP_B_SHIFTS (op) \
|
||||||
OP_EQUALITY(op) \
|
OP_EQUALITY (op) \
|
||||||
OP_RELATIONAL(op) \
|
OP_RELATIONAL (op) \
|
||||||
OP_ARITHMETIC(op) \
|
OP_ARITHMETIC (op) \
|
||||||
OP_UNCONDITIONAL_JUMPS(op) \
|
OP_UNCONDITIONAL_JUMPS (op) \
|
||||||
OP_UNARY_OPS(op) \
|
OP_UNARY_OPS (op) \
|
||||||
op(var_decl) \
|
op (var_decl) \
|
||||||
op(reg_var_decl)
|
op (reg_var_decl)
|
||||||
|
|
||||||
#include "opcode-structures.h"
|
#include "opcode-structures.h"
|
||||||
|
|
||||||
|
|||||||
+697
-272
File diff suppressed because it is too large
Load Diff
+57
-57
@@ -62,9 +62,9 @@ typedef uint8_t keyword;
|
|||||||
/* Type of tokens. */
|
/* Type of tokens. */
|
||||||
typedef uint8_t token_type;
|
typedef uint8_t token_type;
|
||||||
|
|
||||||
#define TOK_EOF 0 // End of file
|
#define TOK_EOF 0 // End of file
|
||||||
#define TOK_NAME 1 // Identifier
|
#define TOK_NAME 1 // Identifier
|
||||||
#define TOK_KEYWORD 2 // Keyword
|
#define TOK_KEYWORD 2 // Keyword
|
||||||
#define TOK_INT 3
|
#define TOK_INT 3
|
||||||
#define TOK_FLOAT 4
|
#define TOK_FLOAT 4
|
||||||
|
|
||||||
@@ -72,64 +72,64 @@ typedef uint8_t token_type;
|
|||||||
#define TOK_BOOL 6
|
#define TOK_BOOL 6
|
||||||
#define TOK_NEWLINE 7
|
#define TOK_NEWLINE 7
|
||||||
#define TOK_STRING 8
|
#define TOK_STRING 8
|
||||||
#define TOK_OPEN_BRACE 9 // {
|
#define TOK_OPEN_BRACE 9 // {
|
||||||
|
|
||||||
#define TOK_CLOSE_BRACE 10 // }
|
#define TOK_CLOSE_BRACE 10 // }
|
||||||
#define TOK_OPEN_PAREN 11 // (
|
#define TOK_OPEN_PAREN 11 // (
|
||||||
#define TOK_CLOSE_PAREN 12 // )
|
#define TOK_CLOSE_PAREN 12 // )
|
||||||
#define TOK_OPEN_SQUARE 13 // [
|
#define TOK_OPEN_SQUARE 13 // [
|
||||||
#define TOK_CLOSE_SQUARE 14 // [
|
#define TOK_CLOSE_SQUARE 14 // [
|
||||||
|
|
||||||
#define TOK_DOT 15 // .
|
#define TOK_DOT 15 // .
|
||||||
#define TOK_SEMICOLON 16 // ;
|
#define TOK_SEMICOLON 16 // ;
|
||||||
#define TOK_COMMA 17 // ,
|
#define TOK_COMMA 17 // ,
|
||||||
#define TOK_LESS 18 // <
|
#define TOK_LESS 18 // <
|
||||||
#define TOK_GREATER 19 // >
|
#define TOK_GREATER 19 // >
|
||||||
|
|
||||||
#define TOK_LESS_EQ 20 // <=
|
#define TOK_LESS_EQ 20 // <=
|
||||||
#define TOK_GREATER_EQ 21 // <=
|
#define TOK_GREATER_EQ 21 // <=
|
||||||
#define TOK_DOUBLE_EQ 22 // ==
|
#define TOK_DOUBLE_EQ 22 // ==
|
||||||
#define TOK_NOT_EQ 23 // !=
|
#define TOK_NOT_EQ 23 // !=
|
||||||
#define TOK_TRIPLE_EQ 24 // ===
|
#define TOK_TRIPLE_EQ 24 // ===
|
||||||
|
|
||||||
#define TOK_NOT_DOUBLE_EQ 25 // !==
|
#define TOK_NOT_DOUBLE_EQ 25 // !==
|
||||||
#define TOK_PLUS 26 // +
|
#define TOK_PLUS 26 // +
|
||||||
#define TOK_MINUS 27 // -
|
#define TOK_MINUS 27 // -
|
||||||
#define TOK_MULT 28 // *
|
#define TOK_MULT 28 // *
|
||||||
#define TOK_MOD 29 // %
|
#define TOK_MOD 29 // %
|
||||||
|
|
||||||
#define TOK_DOUBLE_PLUS 30 // ++
|
#define TOK_DOUBLE_PLUS 30 // ++
|
||||||
#define TOK_DOUBLE_MINUS 31 // --
|
#define TOK_DOUBLE_MINUS 31 // --
|
||||||
#define TOK_LSHIFT 32 // <<
|
#define TOK_LSHIFT 32 // <<
|
||||||
#define TOK_RSHIFT 33 // >>
|
#define TOK_RSHIFT 33 // >>
|
||||||
#define TOK_RSHIFT_EX 34 // >>>
|
#define TOK_RSHIFT_EX 34 // >>>
|
||||||
|
|
||||||
#define TOK_AND 35 // &
|
#define TOK_AND 35 // &
|
||||||
#define TOK_OR 36 // |
|
#define TOK_OR 36 // |
|
||||||
#define TOK_XOR 37 // ^
|
#define TOK_XOR 37 // ^
|
||||||
#define TOK_NOT 38 // !
|
#define TOK_NOT 38 // !
|
||||||
#define TOK_COMPL 39 // ~
|
#define TOK_COMPL 39 // ~
|
||||||
|
|
||||||
#define TOK_DOUBLE_AND 40 // &&
|
#define TOK_DOUBLE_AND 40 // &&
|
||||||
#define TOK_DOUBLE_OR 41 // ||
|
#define TOK_DOUBLE_OR 41 // ||
|
||||||
#define TOK_QUERY 42 // ?
|
#define TOK_QUERY 42 // ?
|
||||||
#define TOK_COLON 43 // :
|
#define TOK_COLON 43 // :
|
||||||
#define TOK_EQ 44 // =
|
#define TOK_EQ 44 // =
|
||||||
|
|
||||||
#define TOK_PLUS_EQ 45 // +=
|
#define TOK_PLUS_EQ 45 // +=
|
||||||
#define TOK_MINUS_EQ 46 // -=
|
#define TOK_MINUS_EQ 46 // -=
|
||||||
#define TOK_MULT_EQ 47 // *=
|
#define TOK_MULT_EQ 47 // *=
|
||||||
#define TOK_MOD_EQ 48 // %=
|
#define TOK_MOD_EQ 48 // %=
|
||||||
#define TOK_LSHIFT_EQ 49 // <<=
|
#define TOK_LSHIFT_EQ 49 // <<=
|
||||||
|
|
||||||
#define TOK_RSHIFT_EQ 50 // >>=
|
#define TOK_RSHIFT_EQ 50 // >>=
|
||||||
#define TOK_RSHIFT_EX_EQ 51 // >>>=
|
#define TOK_RSHIFT_EX_EQ 51 // >>>=
|
||||||
#define TOK_AND_EQ 52 // &=
|
#define TOK_AND_EQ 52 // &=
|
||||||
#define TOK_OR_EQ 53 // |=
|
#define TOK_OR_EQ 53 // |=
|
||||||
#define TOK_XOR_EQ 54 // ^=
|
#define TOK_XOR_EQ 54 // ^=
|
||||||
|
|
||||||
#define TOK_DIV 55 // /
|
#define TOK_DIV 55 // /
|
||||||
#define TOK_DIV_EQ 56 // /=
|
#define TOK_DIV_EQ 56 // /=
|
||||||
#define TOK_EMPTY 57
|
#define TOK_EMPTY 57
|
||||||
|
|
||||||
|
|
||||||
@@ -139,17 +139,17 @@ typedef struct
|
|||||||
token_type type;
|
token_type type;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
keyword kw;
|
keyword kw;
|
||||||
uint8_t uid;
|
uint8_t uid;
|
||||||
}
|
}
|
||||||
data;
|
data;
|
||||||
} __packed
|
} __packed
|
||||||
token;
|
token;
|
||||||
|
|
||||||
void lexer_init(const char *, size_t, bool);
|
void lexer_init (const char *, size_t, bool);
|
||||||
void lexer_free (void);
|
void lexer_free (void);
|
||||||
void lexer_run_first_pass( void);
|
void lexer_run_first_pass (void);
|
||||||
token lexer_next_token (void);
|
token lexer_next_token (void);
|
||||||
void lexer_save_token (token);
|
void lexer_save_token (token);
|
||||||
void lexer_dump_buffer_state (void);
|
void lexer_dump_buffer_state (void);
|
||||||
|
|||||||
+803
-703
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
for (; i < 100; i++) {}
|
||||||
|
assert (i == 100);
|
||||||
|
|
||||||
|
for (var j = 0; j < 100; j++) {}
|
||||||
|
assert (i == 100);
|
||||||
|
|
||||||
|
// for (i = 0;;) {
|
||||||
|
// if (i == 100) {
|
||||||
|
// // break;
|
||||||
|
// // assert (0);
|
||||||
|
// }
|
||||||
|
// i++;
|
||||||
|
// }
|
||||||
|
assert (i == 100);
|
||||||
|
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
for (j = 0; j < 10; j++) {}
|
||||||
|
}
|
||||||
|
assert (i == 100);
|
||||||
|
assert (j == 100);
|
||||||
Reference in New Issue
Block a user