nabaztag_hack_kit 0.1.0.beta3 → 0.1.0.beta8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +17 -2
- data/LICENSE +21 -0
- data/README.md +115 -44
- data/Rakefile +2 -6
- data/bytecode/{Commands.md → _docs/commands.md} +0 -0
- data/bytecode/{Docs.md → _docs/grammar.md} +0 -0
- data/bytecode/_docs/grammar.pdf +0 -0
- data/bytecode/{src → _original}/README.md +0 -0
- data/bytecode/{src → _original}/lib/arp.mtl +0 -0
- data/bytecode/{src → _original}/lib/cfg.mtl +0 -0
- data/bytecode/{src → _original}/lib/choreos.mtl +0 -0
- data/bytecode/{src → _original}/lib/dhcp.mtl +0 -0
- data/bytecode/{src → _original}/lib/dns.mtl +0 -0
- data/bytecode/{src → _original}/lib/http.mtl +0 -0
- data/bytecode/{src → _original}/lib/tcp.mtl +0 -0
- data/bytecode/{src → _original}/lib/udp.mtl +0 -0
- data/bytecode/{src → _original}/lib/util.mtl +0 -0
- data/bytecode/{src → _original}/lib/var.mtl +0 -0
- data/bytecode/{src → _original}/lib/wav.mtl +0 -0
- data/bytecode/{src → _original}/lib/wifi.mtl +0 -0
- data/bytecode/{src → _original}/nominal-ping.mtl +0 -0
- data/bytecode/main.mtl +11 -11
- data/bytecode/test/test.mtl +8 -8
- data/examples/basic/Gemfile +1 -3
- data/examples/basic/config.ru +14 -4
- data/examples/record/Gemfile +0 -5
- data/examples/record/{config.ru.example → config.ru} +2 -2
- data/examples/record/server.rb +0 -2
- data/ext/Makefile +10 -0
- data/ext/bin/mtl_comp +29 -0
- data/{bytecode → ext}/bin/mtl_merge +0 -0
- data/ext/bin/mtl_simu +29 -0
- data/{bytecode/src/mtl → ext}/extconf.rb +0 -0
- data/ext/mtl_linux/.gitignore +7 -0
- data/ext/mtl_linux/LICENSE +21 -0
- data/ext/mtl_linux/Makefile +116 -0
- data/ext/mtl_linux/MetalC.project +196 -0
- data/ext/mtl_linux/conf.bin +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/conf.bin.sans_password +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/config.txt +0 -0
- data/ext/mtl_linux/inc/log.h +21 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/properties.h +0 -0
- data/{bytecode/src/mtl/linux_simuaudio.h → ext/mtl_linux/inc/simu/linux/simuaudio.h} +0 -0
- data/{bytecode/src/mtl/linux_simunet.h → ext/mtl_linux/inc/simu/linux/simunet.h} +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simuaudio.h +18 -18
- data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simunet.h +0 -0
- data/ext/mtl_linux/inc/vcomp/compiler.h +200 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/file.h +11 -11
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/filesystem.h +0 -0
- data/ext/mtl_linux/inc/vcomp/interpreter.h +121 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/memory.h +120 -92
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/param.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/parser.h +27 -27
- data/ext/mtl_linux/inc/vcomp/prodbuffer.h +42 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/resource.h +1 -1
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/terminal.h +8 -8
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/util.h +7 -7
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vaudio.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vbc.h +1 -1
- data/ext/mtl_linux/inc/vm/vbc_str.h +167 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vinterp.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vloader.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vlog.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vmem.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vnet.h +0 -0
- data/ext/mtl_linux/nominal.mtl +3959 -0
- data/ext/mtl_linux/src/comp/main.cpp +123 -0
- data/ext/mtl_linux/src/simu/dumpbc.c +2566 -0
- data/ext/mtl_linux/src/simu/linux/main.cpp +288 -0
- data/ext/mtl_linux/src/simu/linux/simu.c +309 -0
- data/ext/mtl_linux/src/simu/linux/simuaudio.c +44 -0
- data/ext/mtl_linux/src/simu/linux/simunet.c +707 -0
- data/ext/mtl_linux/src/simu/log.c +340 -0
- data/ext/mtl_linux/src/simu/properties.c +368 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/GTKANAL.H +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/LAYER3.C +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/TABINIT.C +0 -0
- data/ext/mtl_linux/src/simu/win/mp3/common.c +302 -0
- data/ext/mtl_linux/src/simu/win/mp3/dct64_i386.c +316 -0
- data/ext/mtl_linux/src/simu/win/mp3/decode_i386.c +160 -0
- data/ext/mtl_linux/src/simu/win/mp3/huffman.h +332 -0
- data/ext/mtl_linux/src/simu/win/mp3/interface.c +276 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/mpg123.h +34 -30
- data/ext/mtl_linux/src/simu/win/mp3/mpglib.h +47 -0
- data/ext/mtl_linux/src/simu/win/simu.c +819 -0
- data/ext/mtl_linux/src/simu/win/simuaudio.c +787 -0
- data/ext/mtl_linux/src/simu/win/simunet.c +489 -0
- data/ext/mtl_linux/src/vcomp/bootstrap.cpp +95 -0
- data/ext/mtl_linux/src/vcomp/compiler.cpp +587 -0
- data/ext/mtl_linux/src/vcomp/compiler_file.cpp +1253 -0
- data/ext/mtl_linux/src/vcomp/compiler_prog.cpp +437 -0
- data/ext/mtl_linux/src/vcomp/compiler_term.cpp +1500 -0
- data/ext/mtl_linux/src/vcomp/compiler_type.cpp +1238 -0
- data/ext/mtl_linux/src/vcomp/compiler_var.cpp +502 -0
- data/ext/mtl_linux/src/vcomp/file.cpp +100 -0
- data/ext/mtl_linux/src/vcomp/interpreter.cpp +93 -0
- data/ext/mtl_linux/src/vcomp/memory.cpp +313 -0
- data/ext/mtl_linux/src/vcomp/parser.cpp +584 -0
- data/ext/mtl_linux/src/vcomp/parser_xml.cpp +137 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/prodbuffer.cpp +57 -36
- data/ext/mtl_linux/src/vcomp/stdlib_core.cpp +130 -0
- data/ext/mtl_linux/src/vcomp/terminal.cpp +80 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/util.cpp +18 -11
- data/ext/mtl_linux/src/vm/vaudio.c +830 -0
- data/ext/mtl_linux/src/vm/vinterp.c +1780 -0
- data/ext/mtl_linux/src/vm/vloader.c +139 -0
- data/ext/mtl_linux/src/vm/vlog.c +782 -0
- data/ext/mtl_linux/src/vm/vmem.c +461 -0
- data/ext/mtl_linux/src/vm/vnet.c +298 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/utils/correct_const.sh +0 -0
- data/lib/nabaztag_hack_kit/server.rb +4 -7
- data/lib/nabaztag_hack_kit/version.rb +1 -1
- data/lib/nabaztag_hack_kit.rb +2 -2
- data/nabaztag_hack_kit.gemspec +10 -11
- data/spec/integration/server_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/message_spec.rb +12 -18
- data/spec/unit/server_spec.rb +13 -10
- metadata +145 -137
- data/bytecode/bin/mtl_comp +0 -50
- data/bytecode/bin/mtl_simu +0 -49
- data/bytecode/src/mtl/Makefile +0 -42
- data/bytecode/src/mtl/README.md +0 -13
- data/bytecode/src/mtl/bc.cpp +0 -1891
- data/bytecode/src/mtl/dumpbc.c +0 -2566
- data/bytecode/src/mtl/linux_simu.c +0 -271
- data/bytecode/src/mtl/linux_simuaudio.c +0 -16
- data/bytecode/src/mtl/linux_simunet.c +0 -620
- data/bytecode/src/mtl/log.c +0 -297
- data/bytecode/src/mtl/log.h +0 -20
- data/bytecode/src/mtl/main_compiler.cpp +0 -104
- data/bytecode/src/mtl/main_simu.cpp +0 -221
- data/bytecode/src/mtl/mp3/common.c +0 -265
- data/bytecode/src/mtl/mp3/dct64_i386.c +0 -316
- data/bytecode/src/mtl/mp3/decode_i386.c +0 -155
- data/bytecode/src/mtl/mp3/huffman.h +0 -332
- data/bytecode/src/mtl/mp3/interface.c +0 -258
- data/bytecode/src/mtl/mp3/mpglib.h +0 -44
- data/bytecode/src/mtl/properties.c +0 -293
- data/bytecode/src/mtl/simu.c +0 -750
- data/bytecode/src/mtl/simuaudio.c +0 -662
- data/bytecode/src/mtl/simunet.c +0 -400
- data/bytecode/src/mtl/vaudio.c +0 -677
- data/bytecode/src/mtl/vbc_str.h +0 -166
- data/bytecode/src/mtl/vcomp/Makefile +0 -29
- data/bytecode/src/mtl/vcomp/bootstrap.cpp +0 -89
- data/bytecode/src/mtl/vcomp/compiler.cpp +0 -470
- data/bytecode/src/mtl/vcomp/compiler.h +0 -200
- data/bytecode/src/mtl/vcomp/compiler_file.cpp +0 -929
- data/bytecode/src/mtl/vcomp/compiler_prog.cpp +0 -250
- data/bytecode/src/mtl/vcomp/compiler_term.cpp +0 -1053
- data/bytecode/src/mtl/vcomp/compiler_type.cpp +0 -872
- data/bytecode/src/mtl/vcomp/compiler_var.cpp +0 -289
- data/bytecode/src/mtl/vcomp/file.cpp +0 -79
- data/bytecode/src/mtl/vcomp/interpreter.cpp +0 -85
- data/bytecode/src/mtl/vcomp/interpreter.h +0 -121
- data/bytecode/src/mtl/vcomp/memory.cpp +0 -241
- data/bytecode/src/mtl/vcomp/parser.cpp +0 -427
- data/bytecode/src/mtl/vcomp/parser_xml.cpp +0 -124
- data/bytecode/src/mtl/vcomp/prodbuffer.h +0 -42
- data/bytecode/src/mtl/vcomp/stdlib_core.cpp +0 -122
- data/bytecode/src/mtl/vcomp/terminal.cpp +0 -73
- data/bytecode/src/mtl/vinterp.c +0 -1349
- data/bytecode/src/mtl/vloader.c +0 -127
- data/bytecode/src/mtl/vlog.c +0 -589
- data/bytecode/src/mtl/vmem.c +0 -424
- data/bytecode/src/mtl/vnet.c +0 -255
- data/examples/basic/Procfile +0 -2
- data/examples/basic/server.rb +0 -14
@@ -0,0 +1,121 @@
|
|
1
|
+
//-------------------
|
2
|
+
// MV
|
3
|
+
// version WIN32 et POCKETPC
|
4
|
+
// Sylvain Huet
|
5
|
+
// Premiere version : 07/01/2003
|
6
|
+
// Derniere mise a jour : 07/01/2003
|
7
|
+
//
|
8
|
+
|
9
|
+
#ifndef _INTERPRETER_
|
10
|
+
#define _INTERPRETER_
|
11
|
+
|
12
|
+
|
13
|
+
class Memory;
|
14
|
+
class Prodbuffer;
|
15
|
+
|
16
|
+
|
17
|
+
class Interpreter
|
18
|
+
{
|
19
|
+
private:
|
20
|
+
Memory* m;
|
21
|
+
int callstack;
|
22
|
+
char *pc; // pointeur vers le prochain bytecode
|
23
|
+
char *bc; // pointeur vers le d�but du bytecode
|
24
|
+
int locals; // pointeur vers les variable locales dans la pile
|
25
|
+
int* globals; // pointeur vers les variable globales
|
26
|
+
|
27
|
+
public:
|
28
|
+
Prodbuffer* output;
|
29
|
+
|
30
|
+
Interpreter(Memory* memory);
|
31
|
+
~Interpreter();
|
32
|
+
int start();
|
33
|
+
void stop();
|
34
|
+
|
35
|
+
int go();
|
36
|
+
|
37
|
+
int TFCtest(char* p);
|
38
|
+
|
39
|
+
int BCexec();
|
40
|
+
int BCret();
|
41
|
+
int BCdrop();
|
42
|
+
int BCdup();
|
43
|
+
int BCnil();
|
44
|
+
int BCgetlocal();
|
45
|
+
int BCsetlocal();
|
46
|
+
int BCgetglobal();
|
47
|
+
int BCgetglobalb();
|
48
|
+
int BCint();
|
49
|
+
int BCgoto();
|
50
|
+
int BCelse();
|
51
|
+
int BCfetch();
|
52
|
+
int BCstore();
|
53
|
+
int BCdeftab();
|
54
|
+
int BCnop();
|
55
|
+
int BCadd();
|
56
|
+
int BCsub();
|
57
|
+
int BCmul();
|
58
|
+
int BCdiv();
|
59
|
+
int BCneg();
|
60
|
+
int BCand();
|
61
|
+
int BCor();
|
62
|
+
int BCeor();
|
63
|
+
int BCnot();
|
64
|
+
int BCshl();
|
65
|
+
int BCshr();
|
66
|
+
int BCeq();
|
67
|
+
int BCne();
|
68
|
+
int BClt();
|
69
|
+
int BCgt();
|
70
|
+
int BCle();
|
71
|
+
int BCge();
|
72
|
+
int BCnon();
|
73
|
+
int BCsearch();
|
74
|
+
int BCfloat();
|
75
|
+
int BCcall();
|
76
|
+
int BCaddf();
|
77
|
+
int BCsubf();
|
78
|
+
int BCmulf();
|
79
|
+
int BCdivf();
|
80
|
+
int BCnegf();
|
81
|
+
int BCltf();
|
82
|
+
int BCgtf();
|
83
|
+
int BClef();
|
84
|
+
int BCgef();
|
85
|
+
int BCsetlocal2();
|
86
|
+
int BCsetglobal2();
|
87
|
+
int BCexecnative();
|
88
|
+
int BCgetlocalb();
|
89
|
+
int BCfetchb();
|
90
|
+
int BCdeftabb();
|
91
|
+
int BCsetlocalb();
|
92
|
+
int BCfirst();
|
93
|
+
int BCmod();
|
94
|
+
int BCmktab();
|
95
|
+
int BCmktabb();
|
96
|
+
int BCsetstruct();
|
97
|
+
int BCsetstructb();
|
98
|
+
int BCcallr();
|
99
|
+
int BCcallrb();
|
100
|
+
int BCgetglobalval();
|
101
|
+
int BCgetglobalvalb();
|
102
|
+
int BCupdate();
|
103
|
+
int BCupdateb();
|
104
|
+
int BCintb();
|
105
|
+
|
106
|
+
};
|
107
|
+
|
108
|
+
typedef int (Interpreter::*BCfunction)();
|
109
|
+
typedef int (*EXTfunction)(void*);
|
110
|
+
|
111
|
+
#include"vm/vbc.h"
|
112
|
+
|
113
|
+
#define CALLSTACK_LENGTH 6 // taille de la callstack sans les variables locales
|
114
|
+
#define CALLSTACK_BC 0 // pointeur bytecode
|
115
|
+
#define CALLSTACK_PC 1 // index bytecode
|
116
|
+
#define CALLSTACK_REF 2 // table r�f�rences globales
|
117
|
+
#define CALLSTACK_PREV 3 // callstack pr�c�dente
|
118
|
+
#define CALLSTACK_NBARGS 4 // nombre d'arguments et variables globales
|
119
|
+
#define CALLSTACK_FUN 5 // pointeur vers la r�f�rence de la fonction en cours
|
120
|
+
|
121
|
+
#endif
|
@@ -37,15 +37,15 @@ class Stack
|
|
37
37
|
{
|
38
38
|
private:
|
39
39
|
public:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
Stack();
|
41
|
+
~Stack();
|
42
|
+
intptr_t size; // taille du bloc allou�
|
43
|
+
intptr_t* base; // d�but de la pile
|
44
|
+
intptr_t* pp; // pointeur de pile
|
45
|
+
|
46
|
+
void initialize(int s);
|
47
|
+
int bigger(Memory* m);
|
48
|
+
void dump(FILE* f);
|
49
49
|
};
|
50
50
|
|
51
51
|
typedef void (*FORGET)(Memory*, void*);
|
@@ -55,54 +55,54 @@ class Memory
|
|
55
55
|
{
|
56
56
|
private:
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
// gestion du GC
|
59
|
+
int root; // bloc racine (initialis� avec le premier bloc allou�)
|
60
60
|
|
61
|
-
|
61
|
+
int size0;
|
62
62
|
|
63
63
|
public:
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
64
|
+
int gcincperiod;
|
65
|
+
int abort;
|
66
|
+
// stack courante
|
67
|
+
Stack stack;
|
68
|
+
Terminal* term;
|
69
|
+
FileSystem* filesystem;
|
70
|
+
Util *util;
|
71
|
+
Winutil *winutil;
|
72
|
+
Memory(int size,Terminal *t,FileSystem *fs);
|
73
|
+
~Memory();
|
74
|
+
|
75
|
+
int start();
|
76
|
+
void stop();
|
77
|
+
|
78
|
+
intptr_t addroot(intptr_t* p);
|
79
|
+
void removeroot(intptr_t *p);
|
80
|
+
|
81
|
+
intptr_t* malloc(int size,int type); // allocation (type vaut TYPE_BINARY ou TYPE_TAB)
|
82
|
+
intptr_t* mallocClear(int size); // allocation de type TYPE_TAB avec initialisation � NIL
|
83
|
+
intptr_t* mallocExternal(void* pnt,FORGET fun); // allocation de type TYPE_EXT (la fonction fun(pnt) sera appel�e lors de l'oubli du bloc)
|
84
|
+
intptr_t pushmalloc(int size,int type); // allocation (type vaut TYPE_BINARY ou TYPE_TAB)
|
85
|
+
intptr_t pushmallocClear(int size); // allocation de type TYPE_TAB avec initialisation � NIL
|
86
|
+
intptr_t pushExternal(void* pnt,FORGET fun);
|
87
|
+
|
88
|
+
intptr_t push(int val);
|
89
|
+
void tabset(intptr_t* p,int i,int val);
|
90
|
+
void stackset(intptr_t* p,int val);
|
91
|
+
|
92
|
+
|
93
|
+
intptr_t* storestring(const char* src);
|
94
|
+
intptr_t* storebinary(const char* src,int size);
|
95
|
+
intptr_t* storenosrc(int size);
|
96
|
+
intptr_t pushstring(const char* src);
|
97
|
+
intptr_t pushbinary(char* src,int size);
|
98
|
+
intptr_t pushnosrc(int size);
|
99
|
+
intptr_t pushpnt(void* pnt);
|
100
|
+
|
101
|
+
int deftab(int size);
|
102
|
+
|
103
|
+
void listing();
|
104
|
+
const char* errorname(int err);
|
105
|
+
void dump();
|
106
106
|
};
|
107
107
|
|
108
108
|
// structures en m�moire
|
@@ -120,14 +120,14 @@ public:
|
|
120
120
|
//// les champs suivants ne sont - pour l'instant - remplis que pour
|
121
121
|
//// les CODE_VAR et les CODE_CONST
|
122
122
|
#define REF_USED 7 // 0 au debut, 1 de plus � chaque fois que la
|
123
|
-
|
123
|
+
// r�f�rence est utilis�e
|
124
124
|
#define REF_SET 8 // pour les var. 0 si la var ne re�oit jamais de
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
// valeur, 1 si elle a seulement une valeur
|
126
|
+
// donn�e � la d�claration, et 2 si elle est
|
127
|
+
// 'set'-�e dans le programme
|
128
128
|
#define REF_USED_IN_IFDEF 9 // 0 au d�but, 1 de plus � chaque fois que
|
129
|
-
|
130
|
-
|
129
|
+
// la ref est utlis�e comme condition dans
|
130
|
+
// un ifdef
|
131
131
|
|
132
132
|
#define CODE_TYPE -1 // type
|
133
133
|
#define CODE_VAR -2 // variable
|
@@ -192,11 +192,11 @@ void AbortMetal(Memory* m,int donotstop);
|
|
192
192
|
#define TYPE_TAB 1 // type table pour allocation
|
193
193
|
#define TYPE_EXT 2 // type externe pour allocation
|
194
194
|
|
195
|
-
#define PNTTOVAL(p) (1+((
|
195
|
+
#define PNTTOVAL(p) (1+((intptr_t)(p))) // conversion pointeur vers mot metal
|
196
196
|
#define INTTOVAL(i) ((i)<<1) // conversion entier vers mot metal
|
197
197
|
#define FLOATTOVAL(v) ((~1)&(*(int*)(&(v)))) // conversion flottant vers mot metal
|
198
198
|
|
199
|
-
#define VALTOPNT(v) ((
|
199
|
+
#define VALTOPNT(v) ((intptr_t*)((intptr_t)(v)-1)) // conversion mot metal vers pointeur
|
200
200
|
#define VALTOINT(v) ((v)>>1) // conversion mot metal vers entier
|
201
201
|
#define VALTOFLOAT(v) (*((mtl_float*)(&(v)))) // conversion mot metal vers flottant
|
202
202
|
|
@@ -264,63 +264,91 @@ void AbortMetal(Memory* m,int donotstop);
|
|
264
264
|
#define LOG_COMPILER 8
|
265
265
|
#define LOG_USER 16
|
266
266
|
|
267
|
-
inline
|
267
|
+
inline intptr_t Memory::push(int val)
|
268
268
|
{
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
269
|
+
*(++stack.pp)=val;
|
270
|
+
if ((stack.pp-stack.base)>=stack.size-1)
|
271
|
+
{
|
272
|
+
intptr_t k;
|
273
|
+
if ((k=stack.bigger(this)))
|
274
|
+
{
|
275
|
+
return k;
|
276
|
+
}
|
273
277
|
// term->printf(LOG_DEVCORE,"## bigger stack %d\n",stack.size);
|
274
278
|
// stackprint(0);
|
275
|
-
|
276
|
-
|
279
|
+
}
|
280
|
+
return 0;
|
277
281
|
}
|
278
282
|
|
279
|
-
inline void Memory::tabset(
|
283
|
+
inline void Memory::tabset(intptr_t* p,int i,int val)
|
280
284
|
{
|
281
|
-
|
285
|
+
p[HEADER_LENGTH+i]=val; // r�gle une valeur d'une table
|
282
286
|
}
|
283
287
|
|
284
|
-
inline void Memory::stackset(
|
288
|
+
inline void Memory::stackset(intptr_t* p,int val)
|
285
289
|
{
|
286
|
-
|
290
|
+
*p=val;
|
287
291
|
}
|
288
292
|
|
289
|
-
inline
|
293
|
+
inline intptr_t Memory::pushmalloc(int size,int type)
|
290
294
|
{
|
291
|
-
|
292
|
-
|
295
|
+
intptr_t* p=malloc(size,type);
|
296
|
+
if (!p)
|
297
|
+
{
|
298
|
+
return MTLERR_OM;
|
299
|
+
}
|
300
|
+
return push(PNTTOVAL(p));
|
293
301
|
}
|
294
302
|
|
295
|
-
inline
|
303
|
+
inline intptr_t Memory::pushmallocClear(int size)
|
296
304
|
{
|
297
|
-
|
298
|
-
|
305
|
+
intptr_t* p=mallocClear(size);
|
306
|
+
if (!p)
|
307
|
+
{
|
308
|
+
return MTLERR_OM;
|
309
|
+
}
|
310
|
+
return push(PNTTOVAL(p));
|
299
311
|
}
|
300
312
|
|
301
|
-
inline
|
313
|
+
inline intptr_t Memory::pushstring(const char* src)
|
302
314
|
{
|
303
|
-
|
304
|
-
|
315
|
+
intptr_t* p=storestring(src);
|
316
|
+
if (!p)
|
317
|
+
{
|
318
|
+
return MTLERR_OM;
|
319
|
+
}
|
320
|
+
return push(PNTTOVAL(p));
|
305
321
|
}
|
306
322
|
|
307
|
-
inline
|
323
|
+
inline intptr_t Memory::pushbinary(char* src,int size)
|
308
324
|
{
|
309
|
-
|
310
|
-
|
325
|
+
intptr_t* p=storebinary(src,size);
|
326
|
+
if (!p)
|
327
|
+
{
|
328
|
+
return MTLERR_OM;
|
329
|
+
}
|
330
|
+
return push(PNTTOVAL(p));
|
311
331
|
}
|
312
332
|
|
313
|
-
inline
|
333
|
+
inline intptr_t Memory::pushnosrc(int size)
|
314
334
|
{
|
315
|
-
|
316
|
-
|
335
|
+
intptr_t* p=storenosrc(size);
|
336
|
+
if (!p)
|
337
|
+
{
|
338
|
+
return MTLERR_OM;
|
339
|
+
}
|
340
|
+
return push(PNTTOVAL(p));
|
317
341
|
}
|
318
342
|
|
319
|
-
inline
|
343
|
+
inline intptr_t Memory::pushpnt(void* pnt)
|
320
344
|
{
|
321
|
-
|
322
|
-
|
323
|
-
|
345
|
+
intptr_t* p=malloc(1,TYPE_BINARY);
|
346
|
+
if (!p)
|
347
|
+
{
|
348
|
+
return MTLERR_OM;
|
349
|
+
}
|
350
|
+
*(BINSTART(p))=((intptr_t)pnt);
|
351
|
+
return push(PNTTOVAL(p));
|
324
352
|
}
|
325
353
|
|
326
354
|
#endif
|
File without changes
|
@@ -20,43 +20,43 @@ class Memory;
|
|
20
20
|
class Parser
|
21
21
|
{
|
22
22
|
private :
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
Terminal* term;
|
24
|
+
char* srcname; // nom de la source
|
25
|
+
char* src; // buffer source
|
26
|
+
int index; // index de lecture
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
char savedchar; // caract�re sauvegard� (momentan�ment remplac� par \0)
|
29
|
+
int indexsavedchar; //index du caract�re sauvegard�
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
int again; // token a relire
|
32
|
+
int lign; // ligne courante
|
33
|
+
int offligne; // offset caractere debut ligne
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
int lign0; // ligne courante (DERNIER TOKEN LU)
|
36
|
+
int offligne0; // offset caractere debut ligne (DERNIER TOKEN LU)
|
37
|
+
int offchar0; // offset caractere courant (DERNIER TOKEN LU)
|
38
38
|
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
void savechar(int i);
|
41
|
+
void restorechar();
|
42
|
+
void againchar();
|
43
|
+
int nextchar();
|
44
|
+
int gettoken(int filter);
|
45
45
|
|
46
46
|
public :
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
char* token;
|
48
|
+
Parser(Terminal* t,FileSystem* fs,char *filename);
|
49
|
+
Parser(Terminal* t,const char *buffer);
|
50
|
+
~Parser();
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
char* next(int filter);
|
53
|
+
void giveback();
|
54
54
|
|
55
|
-
|
55
|
+
void echoposition();
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
int parsekeyword(const char* keyword);
|
58
|
+
int parsekeyword(const char* keyword,int filter);
|
59
|
+
int getstring(Memory* m,char separator);
|
60
60
|
};
|
61
61
|
|
62
62
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
//-------------------
|
2
|
+
// MV
|
3
|
+
// version WIN32 et POCKETPC
|
4
|
+
// Sylvain Huet
|
5
|
+
// Premiere version : 07/01/2003
|
6
|
+
// Derniere mise a jour : 07/01/2003
|
7
|
+
//
|
8
|
+
|
9
|
+
#ifndef _PRODBUFFER_
|
10
|
+
#define _PRODBUFFER_
|
11
|
+
|
12
|
+
class Prodbuffer
|
13
|
+
{
|
14
|
+
//public:
|
15
|
+
private:
|
16
|
+
int size; // taille du buffer de bytecode
|
17
|
+
char* buffer; // buffer de bytecode
|
18
|
+
int index; // index du buffer de bytecode
|
19
|
+
|
20
|
+
void bigger(); // augmentation de la taille du buffer
|
21
|
+
|
22
|
+
public:
|
23
|
+
// buffer bytecode
|
24
|
+
Prodbuffer();
|
25
|
+
~Prodbuffer();
|
26
|
+
void reinit();
|
27
|
+
void addchar(char c);
|
28
|
+
void addint(int i);
|
29
|
+
void addshort(int i);
|
30
|
+
void setchar(int index,char c);
|
31
|
+
void setint(int index,int i);
|
32
|
+
void setshort(int index,int i);
|
33
|
+
void addstr(char *src,int len);
|
34
|
+
void printf(const char *format, ...);
|
35
|
+
void cut(int len);
|
36
|
+
int getsize();
|
37
|
+
char* getstart();
|
38
|
+
};
|
39
|
+
|
40
|
+
#define PRODBUFFER_FIRSTSIZE 128
|
41
|
+
|
42
|
+
#endif
|
@@ -15,16 +15,16 @@ class Memory;
|
|
15
15
|
class Terminal
|
16
16
|
{
|
17
17
|
private:
|
18
|
-
|
19
|
-
|
18
|
+
char* internalbuffer;
|
19
|
+
int sizeinternalbuffer;
|
20
20
|
public:
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
Memory* m;
|
22
|
+
Terminal();
|
23
|
+
~Terminal();
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
void echo(int mask,char *s);
|
26
|
+
void echo(int mask,char *s,int size);
|
27
|
+
void printf(int mask,const char *format, ...);
|
28
28
|
};
|
29
29
|
|
30
30
|
#endif
|
@@ -18,14 +18,14 @@ class Interpreter;
|
|
18
18
|
class Util
|
19
19
|
{
|
20
20
|
private :
|
21
|
-
|
21
|
+
Memory* m;
|
22
22
|
public:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
Util(Memory* mem);
|
24
|
+
~Util();
|
25
|
+
int start();
|
26
|
+
void stop();
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
Compiler* compiler;
|
29
|
+
Interpreter* interpreter;
|
30
30
|
};
|
31
31
|
#endif
|
File without changes
|