mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
jmps
This commit is contained in:
parent
7f878fd8a7
commit
052efb86a9
@ -39,9 +39,9 @@ gen_bytecode (FILE *src_file)
|
||||
pp_finish ();
|
||||
|
||||
FILE *file = fopen (FILE_NAME, "w+b");
|
||||
|
||||
|
||||
OPCODE op0;
|
||||
|
||||
|
||||
save_op_loop_inf (file, op0, 1);
|
||||
save_op_call_1 (file, op0, 0, LED_GREEN);
|
||||
save_op_call_1 (file, op0, 0, LED_BLUE);
|
||||
@ -61,6 +61,8 @@ run_int ()
|
||||
{
|
||||
FILE *file = fopen (FILE_NAME, "rb");
|
||||
OPCODE op_curr;
|
||||
__int_data.pos = 0;
|
||||
|
||||
|
||||
if (file == NULL)
|
||||
{
|
||||
@ -74,8 +76,11 @@ run_int ()
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
__int_data.pos++;
|
||||
|
||||
op_curr.opfunc_ptr (op_curr);
|
||||
fseek (file, __int_data.pos * sizeof (OPCODE), SEEK_SET);
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
|
||||
@ -24,8 +24,14 @@
|
||||
|
||||
#define FILE_NAME "application.bin"
|
||||
|
||||
void gen_bytecode(FILE*);
|
||||
void run_int();
|
||||
struct
|
||||
{
|
||||
int pos;
|
||||
} __int_data;
|
||||
|
||||
|
||||
void gen_bytecode (FILE*);
|
||||
void run_int ();
|
||||
|
||||
#endif /* INTERPRETER_H */
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "interpreter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -23,6 +24,8 @@ opfunc_loop_inf (OPCODE opdata)
|
||||
{
|
||||
printf ("loop_inf:idx:%d\n",
|
||||
opdata.data.loop_inf.opcode_idx);
|
||||
|
||||
__int_data.pos = opdata.data.loop_inf.opcode_idx;
|
||||
}
|
||||
|
||||
void
|
||||
@ -38,11 +41,10 @@ opfunc_op_jmp (OPCODE opdata)
|
||||
{
|
||||
printf ("op_jmp:idx:%d\n",
|
||||
opdata.data.jmp.opcode_idx);
|
||||
|
||||
__int_data.pos = opdata.data.jmp.opcode_idx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
save_op_jmp (FILE *file, OPCODE opdata, int arg1)
|
||||
{
|
||||
@ -65,7 +67,7 @@ save_op_call_1 (FILE *file, OPCODE opdata, int arg1, int arg2)
|
||||
return;
|
||||
}
|
||||
|
||||
opdata.opfunc_ptr = opfunc_op_call_1;
|
||||
opdata.opfunc_ptr = opfunc_op_call_1;
|
||||
opdata.data.call_1.name_literal_idx = arg1;
|
||||
opdata.data.call_1.arg1_literal_idx = arg2;
|
||||
|
||||
@ -79,7 +81,7 @@ save_op_loop_inf (FILE *file, OPCODE opdata, int arg1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
opdata.opfunc_ptr = opfunc_loop_inf;
|
||||
opdata.data.loop_inf.opcode_idx = arg1;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user