fixed Makefile and tests, wrapped interpreter and opcodes

This commit is contained in:
e.gavrin
2014-07-04 21:34:44 +04:00
parent 7759e4b99f
commit aace544c55
7 changed files with 170 additions and 112 deletions
+18 -16
View File
@@ -13,37 +13,38 @@
* limitations under the License.
*/
#include "error.h"
#include "lexer.h"
#include "parser.h"
#include "pretty-printer.h"
#include "interpreter.h"
#include "opcodes.h"
#include "actuators.h"
void
gen_bytecode ()
{
#ifdef __HOST
FILE *file = fopen (FILE_NAME, "w+b");
#endif
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));
//TODO REMOVE
{
save_op_data (file, get_op_loop_inf (1));
save_op_data (file, get_op_call_1 (0, 12));
save_op_data (file, get_op_call_1 (0, 13));
save_op_data (file, get_op_call_1 (0, 14));
save_op_data (file, get_op_call_1 (0, 15));
save_op_data (file, get_op_jmp (0)); // mandatory!
}
#ifdef __HOST
fclose (file);
#endif
}
void
run_int ()
{
FILE *file = fopen (FILE_NAME, "rb");
OPCODE op_curr;
__int_data.pos = 0;
#ifdef __HOST
FILE *file = fopen (FILE_NAME, "rb");
if (file == NULL)
{
@@ -59,11 +60,12 @@ run_int ()
}
__int_data.pos++;
op_curr.opfunc_ptr (op_curr);
fseek (file, __int_data.pos * sizeof (OPCODE), SEEK_SET);
}
fclose (file);
#endif
}