Remove preparser lexer pass and pass for searching of "eval" and "arguments" literals.

JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
Andrey Shitov
2015-08-12 15:50:16 +03:00
parent cc4283b945
commit a870a07972
7 changed files with 352 additions and 344 deletions
+49 -9
View File
@@ -17,6 +17,7 @@
#include "bytecode-data.h"
#include "pretty-printer.h"
#include "array-list.h"
#include "scopes-tree.h"
static bytecode_data_t bytecode_data;
static scopes_tree current_scope;
@@ -33,6 +34,18 @@ serializer_get_op_meta (vm_instr_counter_t oc)
return scopes_tree_op_meta (current_scope, oc);
}
/**
* Get variable declaration of the current scope
*
* @return variable declaration instruction
*/
op_meta
serializer_get_var_decl (vm_instr_counter_t oc) /**< index of variable declaration */
{
JERRY_ASSERT (current_scope);
return scopes_tree_var_decl (current_scope, oc);
} /* serializer_get_var_decl */
/**
* Get byte-code instruction from current scope, or specified byte-code array
*
@@ -102,28 +115,33 @@ serializer_dump_subscope (scopes_tree tree) /**< scope to dump */
JERRY_ASSERT (tree != NULL);
vm_instr_counter_t instr_pos;
bool header = true;
for (instr_pos = 0; instr_pos < tree->instrs_num; instr_pos++)
for (instr_pos = 0; instr_pos < tree->instrs_count; instr_pos++)
{
op_meta *om = (op_meta *) linked_list_element (tree->instrs, instr_pos);
if (om->op.op_idx != VM_OP_VAR_DECL
&& om->op.op_idx != VM_OP_META && !header)
op_meta *om_p = (op_meta *) linked_list_element (tree->instrs, instr_pos);
if (om_p->op.op_idx != VM_OP_VAR_DECL
&& om_p->op.op_idx != VM_OP_META && !header)
{
break;
}
if (om->op.op_idx == VM_OP_REG_VAR_DECL)
if (om_p->op.op_idx == VM_OP_REG_VAR_DECL)
{
header = false;
}
scopes_tree_add_op_meta (current_scope, *om);
scopes_tree_add_op_meta (current_scope, *om_p);
}
for (vm_instr_counter_t var_decl_pos = 0; var_decl_pos < tree->var_decls_cout; var_decl_pos++)
{
op_meta *om_p = (op_meta *) linked_list_element (tree->var_decls, var_decl_pos);
scopes_tree_add_op_meta (current_scope, *om_p);
}
for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++)
{
serializer_dump_subscope (*(scopes_tree *) linked_list_element (tree->t.children, child_id));
}
for (; instr_pos < tree->instrs_num; instr_pos++)
for (; instr_pos < tree->instrs_count; instr_pos++)
{
op_meta *om = (op_meta *) linked_list_element (tree->instrs, instr_pos);
scopes_tree_add_op_meta (current_scope, *om);
op_meta *om_p = (op_meta *) linked_list_element (tree->instrs, instr_pos);
scopes_tree_add_op_meta (current_scope, *om_p);
}
} /* serializer_dump_subscope */
@@ -180,12 +198,34 @@ serializer_dump_op_meta (op_meta op)
#endif
}
/**
* Dump variable declaration into the current scope
*/
void
serializer_dump_var_decl (op_meta op) /**< variable declaration instruction */
{
JERRY_ASSERT (scopes_tree_instrs_num (current_scope) + current_scope->var_decls_cout < MAX_OPCODES);
scopes_tree_add_var_decl (current_scope, op);
} /* serializer_dump_var_decl */
vm_instr_counter_t
serializer_get_current_instr_counter (void)
{
return scopes_tree_instrs_num (current_scope);
}
/**
* Get number of variable declarations in the current scope
*
* @return count of variable declarations
*/
vm_instr_counter_t
serializer_get_current_var_decls_counter (void)
{
return scopes_tree_var_decls_num (current_scope);
} /* serializer_get_current_var_decls_counter */
vm_instr_counter_t
serializer_count_instrs_in_subscopes (void)
{