Permalink
Browse files

Merge pull request #783 from gerdr/m0

m0 C interpreter cleanup (work in progress)
  • Loading branch information...
2 parents 9d4e705 + e61cf8f commit 8d65bf27c680f2b1d05e22430855449797fc0a9d Jimmy Zhuo committed Jun 6, 2012
View
@@ -519,9 +519,14 @@ cachegrind.out.*
/src/string/encoding/*.gcov
/winxed
/winxed.*
+
+# ignore m0 binaries
+/src/m0/c/m0
+/src/m0/c/m0-debug
+/src/m0/c/m0.exe
+/src/m0/c/m0-debug.exe
+
# Local variables:
# mode: text
# buffer-read-only: t
# End:
-src/m0/c/m0
-src/m0/c/m0-debug
View
@@ -1,63 +1,14 @@
-all: m0 m0-debug
-
-include/m0.h: include/m0_constants.h include/m0_compiler_defines.h \
- include/m0_interp.h include/m0_mob.h
-
-include/m0_interp.h: include/m0_interp_structures.h
-
-include/m0_interp_structures.h: include/m0_mob_structures.h
-
-include/m0_mob.h: include/m0_interp_structures.h include/m0_mob_structures.h
-
-include/m0_ops.h: include/m0_interp_structures.h
-
-m0_interp.c: include/m0.h include/m0_mob.h include/m0_constants.h \
- include/m0_compiler_defines.h
-
-m0_mob.c: include/m0_mob.h include/m0_constants.h include/m0_compiler_defines.h
+CFLAGS := -std=c99 -pedantic -Wall -Wextra
-m0_ops.c: include/m0_ops.h include/m0_mob_structures.h
+all: m0 m0-debug
-m0 : include/m0.h m0_interp.c m0_mob.c m0_ops.c
- $(CC) -O3 -W -Wall -g -Iinclude -o m0 m0_mob.c m0_interp.c m0_ops.c
+m0 : m0.h interp.c mob.c ops.c
+ $(CC) $(CFLAGS) -O3 -g -o m0 mob.c interp.c ops.c
-m0-debug : include/m0.h m0_interp.c m0_mob.c m0_ops.c
- $(CC) -O0 -W -Wall -g -Iinclude -o m0-debug m0_mob.c m0_interp.c m0_ops.c
+m0-debug : m0.h interp.c mob.c ops.c
+ $(CC) $(CFLAGS) -O0 -g -o m0-debug mob.c interp.c ops.c
clean:
- rm -f *.o m0
-
-tags-emacs: tags.emacs.dummy
- rm -f TAGS
- ctags -e \
- --links=no --totals \
- -R --exclude=blib --exclude=.git \
- --languages=c,perl --langmap=c:+.h,c:+.pmc,c:+.ops \
- -I NOTNULL,NULLOK,ARGIN,ARGMOD,ARGOUT,ARGINOUT,ARGIN_NULLOK,ARGOUT_NULLOK,ARGMOD_NULLOK,ARGFREE,ARGFREE_NOTNULL \
- .
-
-# this works with an old etags (XEmacs 21.5*)
-tags-xemacs: tags.emacs.dummy
- rm -f TAGS
- find . \
- -name \*.c -o -name \*.h -o -name \*.pmc -o -name \*.ops | etags -l c - -o TAGS
-
-tags.emacs.dummy:
-
-# vim ctags
-# this needs exuberant-ctags
-
-tags-vi: tags.vi.dummy
- rm -f tags
- ctags \
- --links=no --totals \
- -R --exclude=blib --exclude=.git \
- --languages=c,perl --langmap=c:+.h,c:+.pmc,c:+.ops \
- -I NOTNULL,NULLOK,ARGIN,ARGMOD,ARGOUT,ARGINOUT,ARGIN_NULLOK,ARGOUT_NULLOK,ARGMOD_NULLOK,ARGFREE,ARGFREE_NOTNULL
-
-tags.vi.dummy:
-
-tags: tags.dummy
- @echo 'There is no "tags" target. You want tags-vi or tags-emacs.'
+ rm -f *.o m0 m0-debug
-tags.dummy:
+include tags.mk
View
@@ -1,12 +0,0 @@
-#ifndef M0_H
-
-# include "m0_constants.h"
-# include "m0_compiler_defines.h"
-# include "m0_interp.h"
-# include "m0_mob.h"
-
-# define M0_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
@@ -1,13 +0,0 @@
-#ifndef M0_COMPILER_DEFINES_H
-
-# ifdef __clang__
-# define UNUSED(a) (void)(a);
-# else
-# define UNUSED(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
-# endif
-
-# define M0_COMPILER_DEFINES_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
@@ -1,12 +0,0 @@
-#ifndef M0_CONSTANTS_H
-
-# define M0_DIR_SEG 0x01
-# define M0_CONST_SEG 0x02
-# define M0_META_SEG 0x03
-# define M0_BC_SEG 0x04
-
-# define M0_CONSTANTS_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
@@ -1,9 +0,0 @@
-#ifndef M0_INTERP_H
-
-# include "m0_interp_structures.h"
-
-# define M0_INTERP_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
@@ -1,65 +0,0 @@
-#ifndef M0_INTERP_STRUCTURES_H
-# include "m0_mob_structures.h"
-# include <stdint.h>
-
-typedef uint64_t M0_Config[8];
-
-typedef struct {
- uint64_t registers[256];
-} M0_CallFrame;
-
-typedef uint64_t M0_Interp[8];
-
-enum CF_NAMED_REGS {
- CF,
- PCF,
- PC,
- RETPC,
- EH,
- CHUNK,
- CONSTS,
- MDS,
- BCS,
- INTERP,
- SPC4RENT,
- SPILLCF
-};
-
-enum M0_INTERP_DATA {
- OP_FUNCS,
- CHUNKS,
- CHUNK_INFO,
- CHUNK_MAP,
- CALL_FRAMES,
- CONFIG,
- ARGC,
- ARGV
-};
-
-enum M0_CONFIG_DATA {
- CFG_M0V,
- CFG_REGSZ,
- CFG_CFSZ,
- CFG_IREGSZ,
- CFG_NREGSZ,
- CFG_OPCODESZ,
- CFG_PTRSZ,
- CFG_ENDIANNESS
-};
-
-typedef enum {
- INVALID,
- NAMED,
- INTEGER,
- NUMBER,
- STRING,
- POINTER
-} M0_RegisterType;
-
-
-
-# define M0_INTERP_STRUCTURES_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
View
@@ -1,12 +0,0 @@
-#ifndef M0_MOB_H
-
-# include "m0_mob_structures.h"
-# include "m0_interp_structures.h"
-
-int load_mob_file( M0_Interp *interp, const char *filename );
-
-# define M0_MOB_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
@@ -1,40 +0,0 @@
-#ifndef M0_MOB_STRUCTURES_H
-# include <stdint.h>
-
-typedef struct M0_Constants_Segment {
- uint64_t *consts;
- unsigned int *pointers;
- unsigned long count;
-} M0_Constants_Segment;
-
-typedef struct M0_Metadata_Entry {
- unsigned long offset;
- unsigned long name_index;
- unsigned long value_index;
-} M0_Metadata_Entry;
-
-typedef struct M0_Metadata_Segment {
- const M0_Metadata_Entry **entries;
- unsigned long count;
-} M0_Metadata_Segment;
-
-typedef struct M0_Bytecode_Segment {
- unsigned long op_count;
- unsigned char *ops;
-} M0_Bytecode_Segment;
-
-typedef struct M0_Chunk {
- unsigned int id;
- unsigned long name_length;
- const char *name;
- struct M0_Chunk *next;
- M0_Constants_Segment *constants;
- M0_Metadata_Segment *metadata;
- M0_Bytecode_Segment *bytecode;
-} M0_Chunk;
-
-# define M0_MOB_STRUCTURES_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
View
@@ -1,61 +0,0 @@
-#ifndef M0_OPS_H
-
-# include "m0_interp_structures.h"
-
-enum M0_OPS {
- M0_NOOP,
- M0_GOTO,
- M0_GOTO_IF,
- M0_GOTO_CHUNK,
- M0_ADD_I,
- M0_ADD_N,
- M0_SUB_I,
- M0_SUB_N,
- M0_MULT_I,
- M0_MULT_N,
- M0_DIV_I,
- M0_DIV_N,
- M0_MOD_I,
- M0_MOD_N,
- M0_ISGT_I,
- M0_ISGT_N,
- M0_ISGE_I,
- M0_ISGE_N,
- M0_ITON,
- M0_NTOI,
- M0_ASHR,
- M0_LSHR,
- M0_SHL,
- M0_AND,
- M0_OR,
- M0_XOR,
- M0_GC_ALLOC,
- M0_SYS_ALLOC,
- M0_SYS_FREE,
- M0_COPY_MEM,
- M0_SET,
- M0_SET_IMM,
- M0_DEREF,
- M0_SET_REF,
- M0_SET_BYTE,
- M0_GET_BYTE,
- M0_SET_WORD,
- M0_GET_WORD,
- M0_CSYM,
- M0_CCALL_ARG,
- M0_CCALL_RET,
- M0_CCALL,
- M0_PRINT_S,
- M0_PRINT_I,
- M0_PRINT_N,
- M0_EXIT
-};
-
-int
-run_ops( M0_Interp *interp, M0_CallFrame *cf );
-
-# define M0_OPS_H 1
-#endif
-
-/* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
-*/
@@ -1,13 +1,9 @@
+#include "m0.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "include/m0.h"
-#include "include/m0_mob.h"
-#include "include/m0_ops.h"
-#include "include/m0_constants.h"
-#include "include/m0_compiler_defines.h"
-
static M0_Interp *
new_interp();
Oops, something went wrong.

0 comments on commit 8d65bf2

Please sign in to comment.