Permalink
Browse files

removed stdint.h

  • Loading branch information...
1 parent 8b3a6c6 commit 99719df160ce83ddf34d9e8120968240680a93c5 Jimmy Zhuo committed Apr 11, 2012
Showing with 20 additions and 20 deletions.
  1. +2 −2 src/m0/c/include/m0_interp_structures.h
  2. +3 −3 src/m0/c/m0_interp.c
  3. +15 −15 src/m0/c/m0_ops.c
View
4 src/m0/c/include/m0_interp_structures.h
@@ -1,6 +1,5 @@
#ifndef M0_INTERP_STRUCTURES_H
# include "m0_mob_structures.h"
-# include <stdint.h>
typedef struct {
unsigned short mob_version;
@@ -14,13 +13,14 @@ typedef struct {
} M0_Interp;
typedef long INT;
+typedef unsigned long UINT;
typedef double NUM;
typedef char * STRING;
typedef void * POINTER;
/* TODO: should change registers to context or any better name */
typedef struct {
- uint64_t registers[12];
+ UINT registers[12];
INT regs_i[256];
NUM regs_n[256];
STRING regs_s[256];
View
6 src/m0/c/m0_interp.c
@@ -71,9 +71,9 @@ new_call_frame( M0_Interp *interp ) {
M0_CallFrame *frame = malloc( sizeof (M0_CallFrame) );
/* this is a silly minimal hack for now */
- frame->registers[CHUNK] = (uint64_t)interp->first_chunk;
- frame->registers[PC] = (uint64_t)0;
- frame->registers[CONSTS] = (uint64_t)interp->first_chunk->constants;
+ frame->registers[CHUNK] = (UINT)interp->first_chunk;
+ frame->registers[PC] = (UINT)0;
+ frame->registers[CONSTS] = (UINT)interp->first_chunk->constants;
return frame;
}
View
30 src/m0/c/m0_ops.c
@@ -41,7 +41,7 @@ m0_op_deref_i( M0_CallFrame *frame, const unsigned char *ops )
(M0_Constants_Segment *)frame->registers[ref];
const unsigned long offset = IREG(3);
- IREG(1) = *(int64_t *)consts->consts[offset];
+ IREG(1) = *(INT *)consts->consts[offset];
break;
}
@@ -64,7 +64,7 @@ m0_op_deref_n( M0_CallFrame *frame, const unsigned char *ops )
(M0_Constants_Segment *)frame->registers[ref];
const unsigned long offset = IREG(3);
- NREG(1) = *(double *)consts->consts[offset];
+ NREG(1) = *(NUM *)consts->consts[offset];
break;
}
@@ -86,7 +86,7 @@ m0_op_deref_s( M0_CallFrame *frame, const unsigned char *ops )
(M0_Constants_Segment *)frame->registers[ref];
const unsigned long offset = IREG(3);
- SREG(1) = (char *)consts->consts[offset];
+ SREG(1) = (STRING)consts->consts[offset];
break;
}
@@ -167,13 +167,13 @@ m0_op_sub_n( M0_CallFrame *frame, const unsigned char *ops )
static void
m0_op_convert_n_i( M0_CallFrame *frame, const unsigned char *ops )
{
- NREG(1) = (double)IREG(2);
+ NREG(1) = (NUM)IREG(2);
}
static void
m0_op_convert_i_n( M0_CallFrame *frame, const unsigned char *ops )
{
- IREG(1) = (int64_t)NREG(2);
+ IREG(1) = (INT)NREG(2);
}
static void
@@ -222,7 +222,7 @@ m0_op_mod_i( M0_CallFrame *frame, const unsigned char *ops )
static void
m0_op_mod_n( M0_CallFrame *frame, const unsigned char *ops )
{
- NREG(1) = (uint64_t)NREG(2) % (uint64_t)NREG(3);
+ NREG(1) = (UINT)NREG(2) % (UINT)NREG(3);
}
static void
@@ -246,33 +246,33 @@ m0_op_xor( M0_CallFrame *frame, const unsigned char *ops )
static void
m0_op_lshr( M0_CallFrame *frame, const unsigned char *ops )
{
- IREG(1) = (uint64_t)IREG(2) >> IREG(3);
+ IREG(1) = (UINT)IREG(2) >> IREG(3);
}
static void
m0_op_ashr( M0_CallFrame *frame, const unsigned char *ops )
{
- IREG(1) = (int64_t)IREG(2) >> IREG(3);
+ IREG(1) = (INT)IREG(2) >> IREG(3);
}
static void
m0_op_shl( M0_CallFrame *frame, const unsigned char *ops )
{
- IREG(1) = (int64_t)IREG(2) << IREG(3);
+ IREG(1) = IREG(2) << IREG(3);
}
static void
m0_op_goto_chunk(M0_Interp *interp, M0_CallFrame *frame, const unsigned char *ops )
{
- uint64_t new_pc = IREG(2);
+ INT new_pc = IREG(2);
M0_Chunk *chunk = interp->first_chunk;
while(chunk) {
if(strncmp( chunk->name, SREG(1), chunk->name_length) == 0) {
- frame->registers[CHUNK] = (uint64_t)chunk;
- frame->registers[CONSTS] = (uint64_t)chunk->constants;
- frame->registers[MDS] = (uint64_t)chunk->metadata;
- frame->registers[BCS] = (uint64_t)chunk->bytecode;
- frame->registers[PC] = (uint64_t)new_pc;
+ frame->registers[CHUNK] = (UINT)chunk;
+ frame->registers[CONSTS] = (UINT)chunk->constants;
+ frame->registers[MDS] = (UINT)chunk->metadata;
+ frame->registers[BCS] = (UINT)chunk->bytecode;
+ frame->registers[PC] = (UINT)new_pc;
break;
}
chunk = chunk->next;

0 comments on commit 99719df

Please sign in to comment.