Skip to content

Commit

Permalink
remove typecheck, it should be done by complie time(i.e: M1/PIR => M0…
Browse files Browse the repository at this point in the history
…), not in runtime. also removed duplicate function.
  • Loading branch information
Jimmy Zhuo committed Apr 2, 2012
1 parent e21d417 commit 2a1224a
Showing 1 changed file with 1 addition and 54 deletions.
55 changes: 1 addition & 54 deletions src/m0/c/m0_ops.c
Expand Up @@ -11,21 +11,6 @@ Copyright (C) 2011-2012, Parrot Foundation.
#include "include/m0_interp_structures.h"
#include "include/m0_compiler_defines.h"

M0_RegisterType get_register_type(const unsigned int register_number) {
M0_RegisterType reg_type = INVALID;
if (register_number <= 11)
reg_type = NAMED;
else if (12 <= register_number && register_number <= 72)
reg_type = INTEGER;
else if (73 <= register_number && register_number <= 133)
reg_type = NUMBER;
else if (134 <= register_number && register_number <= 194)
reg_type = STRING;
else if (195 <= register_number && register_number <= 255)
reg_type = POINTER;
return reg_type;
}

static void
m0_op_set_imm( M0_CallFrame *frame, const unsigned char *ops )
{
Expand All @@ -43,25 +28,7 @@ m0_op_deref( M0_CallFrame *frame, const unsigned char *ops )
M0_Constants_Segment *consts =
(M0_Constants_Segment *)frame->registers[ ref ];
unsigned long offset = frame->registers[ ops[3] ];
size_t size = sizeof(uint64_t);
int use_address = 0;
switch ( get_register_type(ops[1])) {
case STRING:
case POINTER:
use_address = 1;
break;
case NUMBER:
size = 4;
break;
default:
break;
}

frame->registers[ ops[1] ] = (uint64_t)0;
if (use_address)
memcpy(&frame->registers[ ops[1] ], &(consts->consts[offset]), size);
else
memcpy(&frame->registers[ ops[1] ], (consts->consts[offset]), size);
frame->registers[ ops[1] ] = (uint64_t)consts->consts[ offset ];
break;
}
default:
Expand Down Expand Up @@ -109,16 +76,6 @@ m0_op_add_n( M0_CallFrame *frame, const unsigned char *ops )
frame->registers[ops[1]] = &result;
}

static void
m0_op_add_n( M0_CallFrame *frame, const unsigned char *ops )
{
float *r2 = (float*) &(frame->registers[ops[2]]);
float *r3 = (float*) &(frame->registers[ops[3]]);
float *result = (float*) &(frame->registers[ops[1]]);
frame->registers[ops[1]] = (uint64_t)0;
*result = *r2 + *r3;
}

static void
m0_op_sub_i( M0_CallFrame *frame, const unsigned char *ops )
{
Expand All @@ -137,16 +94,6 @@ m0_op_sub_n( M0_CallFrame *frame, const unsigned char *ops )
frame->registers[ops[1]] = &result;
}

static void
m0_op_sub_n( M0_CallFrame *frame, const unsigned char *ops )
{
float *r2 = (float*) &(frame->registers[ops[2]]);
float *r3 = (float*) &(frame->registers[ops[3]]);
float *result = (float*) &(frame->registers[ops[1]]);
frame->registers[ops[1]] = (uint64_t)0;
*result = *r2 - *r3;
}

static void
m0_op_convert_n_i( M0_CallFrame *frame, const unsigned char *ops )
{
Expand Down

0 comments on commit 2a1224a

Please sign in to comment.