Permalink
Browse files

implement print_n op

  • Loading branch information...
Jimmy Zhuo
Jimmy Zhuo committed Jun 4, 2012
1 parent 8db2a14 commit 739fa609a09d55af9df73351d136ed04d2478b4b
Showing with 14 additions and 2 deletions.
  1. +2 −1 src/m0/c/m0_mob.c
  2. +12 −1 src/m0/c/m0_ops.c
View
@@ -241,7 +241,8 @@ parse_mob_constants_segment( M0_Interp *interp, FILE *stream ) {
}
} else {
if (constant)
- segment->consts[i] = *(uint64_t*)constant;
+ segment->consts[i] = *(uint64_t *)constant;
+ free((void *)constant);
}
}
View
@@ -62,7 +62,14 @@ static void
m0_op_print_i( M0_CallFrame *frame, const unsigned char *ops )
{
/* note the lack of filehandle selection (ops[1]) for output */
- fprintf( stdout, "%d", (unsigned int)frame->registers[ ops[2] ] );
+ fprintf( stdout, "%ld", (unsigned int)frame->registers[ ops[2] ] );
+}
+
+static void
+m0_op_print_n( M0_CallFrame *frame, const unsigned char *ops )
+{
+ /* note the lack of filehandle selection (ops[1]) for output */
+ fprintf( stdout, "%.15g", (unsigned long)frame->registers[ ops[2] ] );
}
static void
@@ -386,6 +393,10 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
M0_EXEC_OP(print_i, cf, ops, pc);
break;
+ case (M0_PRINT_N):
+ M0_EXEC_OP(print_n, cf, ops, pc);
+ break;
+
case (M0_NOOP):
break;

0 comments on commit 739fa60

Please sign in to comment.