fixes
This commit is contained in:
@@ -23,37 +23,18 @@
|
||||
#include "actuators.h"
|
||||
|
||||
void
|
||||
gen_bytecode (FILE *src_file)
|
||||
gen_bytecode ()
|
||||
{
|
||||
statement *st;
|
||||
lexer_set_file (src_file);
|
||||
parser_init ();
|
||||
st = parser_parse_statement ();
|
||||
assert (st);
|
||||
while (st->type != STMT_EOF)
|
||||
{
|
||||
//pp_statement (st);
|
||||
st = parser_parse_statement ();
|
||||
assert (st);
|
||||
}
|
||||
//pp_finish ();
|
||||
FILE *file = fopen (FILE_NAME, "w+b");
|
||||
|
||||
// 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);
|
||||
// save_op_call_1 (file, op0, 0, LED_ORANGE);
|
||||
// save_op_call_1 (file, op0, 0, LED_RED);
|
||||
// save_op_call_1 (file, op0, 0, LED_GREEN);
|
||||
// save_op_call_1 (file, op0, 0, LED_BLUE);
|
||||
// save_op_call_1 (file, op0, 0, LED_ORANGE);
|
||||
// save_op_call_1 (file, op0, 0, LED_RED);
|
||||
// save_op_jmp (file, op0, 0);
|
||||
//
|
||||
// fclose (file);
|
||||
save_op_data(file, get_op_loop_inf (1));
|
||||
save_op_data(file, get_op_call_1(0, LED_GREEN));
|
||||
save_op_data(file, get_op_call_1(0, LED_BLUE));
|
||||
save_op_data(file, get_op_call_1(0, LED_ORANGE));
|
||||
save_op_data(file, get_op_call_1(0, LED_RED));
|
||||
save_op_data(file, get_op_jmp(0));
|
||||
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -30,7 +30,7 @@ struct
|
||||
} __int_data;
|
||||
|
||||
|
||||
void gen_bytecode (FILE*);
|
||||
void gen_bytecode ();
|
||||
void run_int ();
|
||||
|
||||
#endif /* INTERPRETER_H */
|
||||
|
||||
+20
-18
@@ -45,45 +45,47 @@ opfunc_op_jmp (OPCODE opdata)
|
||||
__int_data.pos = opdata.data.jmp.opcode_idx;
|
||||
}
|
||||
|
||||
void
|
||||
save_op_jmp (FILE *file, OPCODE opdata, int arg1)
|
||||
OPCODE
|
||||
get_op_jmp (int arg1)
|
||||
{
|
||||
if (file == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OPCODE opdata;
|
||||
|
||||
opdata.opfunc_ptr = opfunc_op_jmp;
|
||||
opdata.data.jmp.opcode_idx = arg1;
|
||||
|
||||
fwrite (&opdata, sizeof (OPCODE), 1, file);
|
||||
return opdata;
|
||||
}
|
||||
|
||||
void
|
||||
save_op_call_1 (FILE *file, OPCODE opdata, int arg1, int arg2)
|
||||
OPCODE
|
||||
get_op_call_1 (int arg1, int arg2)
|
||||
{
|
||||
if (file == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OPCODE opdata;
|
||||
|
||||
opdata.opfunc_ptr = opfunc_op_call_1;
|
||||
opdata.data.call_1.name_literal_idx = arg1;
|
||||
opdata.data.call_1.arg1_literal_idx = arg2;
|
||||
|
||||
fwrite (&opdata, sizeof (OPCODE), 1, file);
|
||||
return opdata;
|
||||
}
|
||||
|
||||
OPCODE
|
||||
get_op_loop_inf (int arg1)
|
||||
{
|
||||
OPCODE opdata;
|
||||
|
||||
opdata.opfunc_ptr = opfunc_op_call_1;
|
||||
opdata.data.loop_inf.opcode_idx = arg1;
|
||||
|
||||
return opdata;
|
||||
}
|
||||
|
||||
void
|
||||
save_op_loop_inf (FILE *file, OPCODE opdata, int arg1)
|
||||
save_op_data (FILE *file, OPCODE opdata)
|
||||
{
|
||||
if (file == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
opdata.opfunc_ptr = opfunc_loop_inf;
|
||||
opdata.data.loop_inf.opcode_idx = arg1;
|
||||
|
||||
fwrite (&opdata, sizeof (OPCODE), 1, file);
|
||||
}
|
||||
@@ -42,6 +42,7 @@ OP_DEF (decl) { };
|
||||
OP_DEF (decl_func_named)
|
||||
{
|
||||
OP_TYPE_IDX name_literal_idx;
|
||||
|
||||
};
|
||||
|
||||
OP_DEF (decl_func_anon) { };
|
||||
@@ -117,9 +118,12 @@ OPCODE{
|
||||
}
|
||||
__packed;
|
||||
|
||||
void save_op_jmp (FILE *, OPCODE, int);
|
||||
void save_op_call_1 (FILE *, OPCODE, int, int);
|
||||
void save_op_loop_inf (FILE *, OPCODE, int);
|
||||
|
||||
void save_op_data (FILE *, OPCODE);
|
||||
|
||||
OPCODE get_op_loop_inf (int);
|
||||
OPCODE get_op_call_1 (int, int);
|
||||
OPCODE get_op_jmp (int arg1);
|
||||
|
||||
#endif /* OPCODES_H */
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ main (int argc, char **argv)
|
||||
|
||||
//gen_bytecode (generated_source);
|
||||
gen_bytecode (file);
|
||||
//run_int ();
|
||||
run_int ();
|
||||
|
||||
#ifdef __TARGET_MCU
|
||||
fake_exit ();
|
||||
|
||||
Reference in New Issue
Block a user