Permalink
Browse files

fixed various bug, and add debug info to Makefile

  • Loading branch information...
1 parent 0679b0d commit 3934ac62566c087d87abbaddbb386af3ff07f9ad Jimmy Zhuo committed Apr 4, 2012
View
@@ -27,6 +27,7 @@ m0-debug : include/m0.h m0_interp.c m0_mob.c m0_ops.c
test: ../../../t/m0/integration/*.m0b
for file in `ls ../../../t/m0/integration/*.m0b`; \
do \
+ echo $$file; \
./m0 $$file; \
done
@@ -34,6 +34,7 @@ enum M0_OPS {
M0_DEREF_I,
M0_DEREF_N,
M0_DEREF_S,
+ M0_DEREF_P,
M0_SET_REF,
M0_SET_BYTE,
M0_GET_BYTE,
View
@@ -18,6 +18,12 @@ m0_op_set_imm( M0_CallFrame *frame, const unsigned char *ops )
}
static void
+m0_op_set_ref( M0_CallFrame *frame, const unsigned char *ops )
+{
+// frame->regs_ni.i[ops[1]] = ops[2] * 256 + ops[3];
+}
+
+static void
m0_op_deref_i( M0_CallFrame *frame, const unsigned char *ops )
{
unsigned char ref = ops[2];
@@ -88,6 +94,29 @@ m0_op_deref_s( M0_CallFrame *frame, const unsigned char *ops )
}
static void
+m0_op_deref_p( M0_CallFrame *frame, const unsigned char *ops )
+{
+ unsigned char ref = ops[2];
+
+ switch (ref) {
+ case CONSTS:
+ {
+ M0_Constants_Segment *consts =
+ (M0_Constants_Segment *)frame->registers[ref];
+ const unsigned long offset = frame->regs_ni.i[ops[3]];
+
+ frame->regs_ps.s[ops[1]] = consts->consts[offset];
+ //memcpy(&frame->regs_ni.i[ops[1]], (char *)consts->consts[offset], sizeof(char));
+ break;
+ }
+
+ default:
+ /* XXX: the rest of the system has non-uniform array handling */
+ break;
+ }
+}
+
+static void
m0_op_print_s( M0_CallFrame *frame, const unsigned char *ops )
{
/* note the lack of filehandle selection (ops[1]) for output */
@@ -321,6 +350,10 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
m0_op_set_imm( cf, &ops[pc] );
break;
+ case (M0_SET_REF):
+ m0_op_set_ref( cf, &ops[pc] );
+ break;
+
case (M0_DEREF_I):
m0_op_deref_i( cf, &ops[pc] );
break;
@@ -333,6 +366,10 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
m0_op_deref_s( cf, &ops[pc] );
break;
+ case (M0_DEREF_P):
+ m0_op_deref_p( cf, &ops[pc] );
+ break;
+
case (M0_PRINT_S):
m0_op_print_s( cf, &ops[pc] );
break;
@@ -657,6 +657,7 @@ sub parse_chunks {
deref_i
deref_n
deref_s
+deref_p
set_ref
set_byte
get_byte
@@ -19,8 +19,8 @@
set_imm I1, 0, 99
# N1 = 99.0 (from constants segment)
- set_imm I1, 0, 3
- deref_n N1, CONSTS, I1
+ set_imm I2, 0, 3
+ deref_n N1, CONSTS, I2
# N2 = 99 (from convert_i_n)
convert_i_n I2, N1, x
@@ -17,7 +17,7 @@
deref_n N0, CONSTS, N0
set N1, N0, x
set_imm N0, 0, 99
- sub_i N0, N0, N1
+ sub_n N0, N0, N1
goto_if set_nok, N0
goto set_ok, x

0 comments on commit 3934ac6

Please sign in to comment.