Split parser into parser itself, opcodes dumper and syntax errors checker.
Add internal hash map of literal indexes: In this hash map key is pair of block number and literal's unique identifier in the block, and the value is a literal index that unique in the whole program. Block is a continues array of opcodes. So, bytecode is splitted into blocks. Each block has its own uid counter. To get literal index the interpreter looks up it in the hash map. Thus, now JS program is able to have more than 255 identifiers/string literals. The first 128 (0-127) uids are reserved for block's uid counter, the other 128 (128-255) are reserved for tmp variables.
This commit is contained in:
@@ -44,8 +44,10 @@ typedef uint8_t idx_t; /** index values */
|
||||
typedef enum
|
||||
{
|
||||
OPCODE_ARG_TYPE_SIMPLE, /**< ecma_simple_value_t */
|
||||
OPCODE_ARG_TYPE_SMALLINT, /**< small integer: from -128 to 127 */
|
||||
OPCODE_ARG_TYPE_SMALLINT, /**< small integer: from 0 to 255 */
|
||||
OPCODE_ARG_TYPE_SMALLINT_NEGATE, /**< small integer: from -255 to -0 */
|
||||
OPCODE_ARG_TYPE_NUMBER, /**< index of number literal */
|
||||
OPCODE_ARG_TYPE_NUMBER_NEGATE, /**< index of number literal with negation */
|
||||
OPCODE_ARG_TYPE_STRING, /**< index of string literal */
|
||||
OPCODE_ARG_TYPE_VARIABLE /**< index of variable name */
|
||||
} opcode_arg_type_operand;
|
||||
@@ -270,5 +272,10 @@ OP_ARGS_LIST (GETOP_DECL)
|
||||
#undef GETOP_DECL_2
|
||||
#undef GETOP_DECL_3
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t uids[4];
|
||||
}
|
||||
raw_opcode;
|
||||
|
||||
#endif /* OPCODES_H */
|
||||
|
||||
Reference in New Issue
Block a user