nabaztag_hack_kit 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. data/.gitignore +7 -0
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile +4 -0
  5. data/README.md +119 -0
  6. data/Rakefile +21 -0
  7. data/bin/mtl_comp +41 -0
  8. data/bin/mtl_merge +22 -0
  9. data/bin/mtl_simu +40 -0
  10. data/bytecode/lib/buffer.mtl +109 -0
  11. data/bytecode/lib/button.mtl +27 -0
  12. data/bytecode/lib/data_helper.mtl +88 -0
  13. data/bytecode/lib/ear.mtl +90 -0
  14. data/bytecode/lib/led.mtl +33 -0
  15. data/bytecode/lib/rfid.mtl +50 -0
  16. data/bytecode/main.mtl +129 -0
  17. data/config.ru +6 -0
  18. data/ext/bytecode/Commands.md +172 -0
  19. data/ext/bytecode/Docs.md +488 -0
  20. data/ext/bytecode/README.md +5 -0
  21. data/ext/bytecode/lib/arp.mtl +159 -0
  22. data/ext/bytecode/lib/cfg.mtl +74 -0
  23. data/ext/bytecode/lib/choreos.mtl +1487 -0
  24. data/ext/bytecode/lib/dhcp.mtl +152 -0
  25. data/ext/bytecode/lib/dns.mtl +89 -0
  26. data/ext/bytecode/lib/http.mtl +84 -0
  27. data/ext/bytecode/lib/tcp.mtl +340 -0
  28. data/ext/bytecode/lib/udp.mtl +49 -0
  29. data/ext/bytecode/lib/util.mtl +74 -0
  30. data/ext/bytecode/lib/var.mtl +15 -0
  31. data/ext/bytecode/lib/wifi.mtl +243 -0
  32. data/ext/bytecode/nominal-ping.mtl +5828 -0
  33. data/ext/mtl/Makefile +42 -0
  34. data/ext/mtl/README.md +13 -0
  35. data/ext/mtl/bc.cpp +1891 -0
  36. data/ext/mtl/conf.bin.sans_password +0 -0
  37. data/ext/mtl/config.txt +5 -0
  38. data/ext/mtl/dumpbc.c +2566 -0
  39. data/ext/mtl/extconf.rb +1 -0
  40. data/ext/mtl/linux_simu.c +271 -0
  41. data/ext/mtl/linux_simuaudio.c +16 -0
  42. data/ext/mtl/linux_simuaudio.h +18 -0
  43. data/ext/mtl/linux_simunet.c +620 -0
  44. data/ext/mtl/linux_simunet.h +7 -0
  45. data/ext/mtl/log.c +297 -0
  46. data/ext/mtl/log.h +20 -0
  47. data/ext/mtl/main_compiler.cpp +104 -0
  48. data/ext/mtl/main_simu.cpp +221 -0
  49. data/ext/mtl/mp3/GTKANAL.H +97 -0
  50. data/ext/mtl/mp3/LAYER3.C +2090 -0
  51. data/ext/mtl/mp3/TABINIT.C +82 -0
  52. data/ext/mtl/mp3/common.c +265 -0
  53. data/ext/mtl/mp3/dct64_i386.c +316 -0
  54. data/ext/mtl/mp3/decode_i386.c +155 -0
  55. data/ext/mtl/mp3/huffman.h +332 -0
  56. data/ext/mtl/mp3/interface.c +258 -0
  57. data/ext/mtl/mp3/mpg123.h +182 -0
  58. data/ext/mtl/mp3/mpglib.h +44 -0
  59. data/ext/mtl/properties.c +293 -0
  60. data/ext/mtl/properties.h +10 -0
  61. data/ext/mtl/simu.c +750 -0
  62. data/ext/mtl/simuaudio.c +662 -0
  63. data/ext/mtl/simuaudio.h +74 -0
  64. data/ext/mtl/simunet.c +400 -0
  65. data/ext/mtl/simunet.h +30 -0
  66. data/ext/mtl/utils/correct_const.sh +34 -0
  67. data/ext/mtl/vaudio.c +677 -0
  68. data/ext/mtl/vaudio.h +46 -0
  69. data/ext/mtl/vbc.h +160 -0
  70. data/ext/mtl/vbc_str.h +166 -0
  71. data/ext/mtl/vcomp/Makefile +29 -0
  72. data/ext/mtl/vcomp/bootstrap.cpp +89 -0
  73. data/ext/mtl/vcomp/compiler.cpp +470 -0
  74. data/ext/mtl/vcomp/compiler.h +200 -0
  75. data/ext/mtl/vcomp/compiler_file.cpp +929 -0
  76. data/ext/mtl/vcomp/compiler_prog.cpp +250 -0
  77. data/ext/mtl/vcomp/compiler_term.cpp +1053 -0
  78. data/ext/mtl/vcomp/compiler_type.cpp +872 -0
  79. data/ext/mtl/vcomp/compiler_var.cpp +289 -0
  80. data/ext/mtl/vcomp/file.cpp +79 -0
  81. data/ext/mtl/vcomp/file.h +39 -0
  82. data/ext/mtl/vcomp/filesystem.h +14 -0
  83. data/ext/mtl/vcomp/interpreter.cpp +85 -0
  84. data/ext/mtl/vcomp/interpreter.h +121 -0
  85. data/ext/mtl/vcomp/memory.cpp +241 -0
  86. data/ext/mtl/vcomp/memory.h +326 -0
  87. data/ext/mtl/vcomp/param.h +95 -0
  88. data/ext/mtl/vcomp/parser.cpp +427 -0
  89. data/ext/mtl/vcomp/parser.h +97 -0
  90. data/ext/mtl/vcomp/parser_xml.cpp +124 -0
  91. data/ext/mtl/vcomp/prodbuffer.cpp +125 -0
  92. data/ext/mtl/vcomp/prodbuffer.h +42 -0
  93. data/ext/mtl/vcomp/resource.h +17 -0
  94. data/ext/mtl/vcomp/stdlib_core.cpp +122 -0
  95. data/ext/mtl/vcomp/terminal.cpp +73 -0
  96. data/ext/mtl/vcomp/terminal.h +30 -0
  97. data/ext/mtl/vcomp/util.cpp +48 -0
  98. data/ext/mtl/vcomp/util.h +31 -0
  99. data/ext/mtl/vinterp.c +1349 -0
  100. data/ext/mtl/vinterp.h +11 -0
  101. data/ext/mtl/vloader.c +127 -0
  102. data/ext/mtl/vloader.h +31 -0
  103. data/ext/mtl/vlog.c +589 -0
  104. data/ext/mtl/vlog.h +69 -0
  105. data/ext/mtl/vmem.c +424 -0
  106. data/ext/mtl/vmem.h +107 -0
  107. data/ext/mtl/vnet.c +255 -0
  108. data/ext/mtl/vnet.h +19 -0
  109. data/lib/nabaztag_hack_kit/message/api.rb +39 -0
  110. data/lib/nabaztag_hack_kit/message/helper.rb +39 -0
  111. data/lib/nabaztag_hack_kit/message.rb +36 -0
  112. data/lib/nabaztag_hack_kit/server.rb +50 -0
  113. data/lib/nabaztag_hack_kit/version.rb +3 -0
  114. data/lib/nabaztag_hack_kit.rb +4 -0
  115. data/nabaztag_hack_kit.gemspec +29 -0
  116. data/public/bytecode.bin +0 -0
  117. data/test/bytecode/helper.mtl +60 -0
  118. data/test/bytecode/native.mtl +28 -0
  119. data/test/bytecode/test.mtl +221 -0
  120. data/test/spec_helper.rb +5 -0
  121. data/test/unit/message_spec.rb +56 -0
  122. metadata +209 -0
data/ext/mtl/vmem.c ADDED
@@ -0,0 +1,424 @@
1
+ // VLISP Virtual Machine - 2006 - by Sylvain Huet
2
+ // Lowcost IS Powerfull
3
+
4
+ #include"vmem.h"
5
+ #include"vloader.h"
6
+ #include"vlog.h"
7
+
8
+ void play_check(int nocb);
9
+
10
+ #ifdef VSIMU
11
+ #include <stdio.h>
12
+ #include <stdlib.h>
13
+ #include <string.h>
14
+ int vmem_heap[VMEM_LENGTH];
15
+ #endif
16
+
17
+ #define VMEM_DBG
18
+
19
+
20
+ int vmem_heapindex;
21
+ int *vmem_top;
22
+ int vmem_stack;
23
+ int vmem_start;
24
+ int vmem_broken;
25
+
26
+ // initialisation de la m�moire
27
+ void vmemInit(int start)
28
+ {
29
+ vmem_top=&vmem_heap[VMEM_LENGTH];
30
+ vmem_stack=0;
31
+ vmem_start=vmem_heapindex=start;
32
+ vmem_broken=0;
33
+ }
34
+
35
+ void vmemSetstart(int start)
36
+ {
37
+ int size;
38
+
39
+ if (start>=vmem_start-HEADER_LENGTH) return;
40
+
41
+ size=((vmem_start-HEADER_LENGTH-start)<<2)-1;
42
+
43
+ vmem_heap[start]=(size<<8)+(TYPE_BINARY);
44
+ vmem_heap[start+HEADER_GC]=0;
45
+ vmem_heap[start+HEADER_LIST]=0;
46
+
47
+ vmem_start=start;
48
+ }
49
+
50
+
51
+ void vmemGCfirst()
52
+ {
53
+ int i,k,j,n;
54
+ int first;
55
+
56
+ first=-1;
57
+ for(i=vmem_stack;i<0;i++)
58
+ {
59
+ k=vmem_top[i];
60
+ if ((ISVALPNT(k))&&(k!=NIL))
61
+ {
62
+ k=VALTOPNT(k);
63
+ #ifdef VMEM_DBG
64
+ if ((k<0)||(k>=VMEM_LENGTH)) consolestr("1.k out of space\n");
65
+ #endif
66
+ if (!HEADER_USED(k))
67
+ {
68
+ HEADER_MARK(k);
69
+ vmem_heap[k+HEADER_LIST]=first;
70
+ first=k;
71
+ }
72
+ }
73
+ }
74
+ while(first!=-1)
75
+ {
76
+ k=first;
77
+ #ifdef VMEM_DBG
78
+ if ((k<0)||(k>=VMEM_LENGTH)) consolestr("1.first out of space\n");
79
+ #endif
80
+ first=vmem_heap[k+HEADER_LIST];
81
+ if (HEADER_TYPE(k)) // bloc table
82
+ {
83
+ n=VSIZE(k);
84
+ j=k+HEADER_LENGTH;
85
+ for(i=0;i<n;i++)
86
+ {
87
+ k=vmem_heap[j+i];
88
+ if ((ISVALPNT(k))&&(k!=NIL))
89
+ {
90
+ k=VALTOPNT(k);
91
+ #ifdef VMEM_DBG
92
+ if ((k<0)||(k>=VMEM_LENGTH)) consolestr("1.k2 out of space\n");
93
+ #endif
94
+ if (!HEADER_USED(k))
95
+ {
96
+ HEADER_MARK(k);
97
+ vmem_heap[k+HEADER_LIST]=first;
98
+ first=k;
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ #ifdef VMEM_DBG
106
+ void dumpheap()
107
+ {
108
+ int pos,realsize;
109
+ #ifdef VSIMU
110
+ FILE *f;
111
+
112
+ f=fopen("mem.bin","wb");
113
+ fwrite(&vmem_start,1,4,f);
114
+ fwrite(&vmem_heapindex,1,4,f);
115
+ fwrite(&vmem_stack,1,4,f);
116
+ fwrite(vmem_heap,VMEM_LENGTH,1,f);
117
+ fclose(f);
118
+ #endif
119
+ pos=vmem_start;
120
+
121
+ while(pos < vmem_heapindex)
122
+ {
123
+ realsize=VSIZE(pos)+HEADER_LENGTH;
124
+ consolehx(pos); consolestr(":pos ");consolehx(realsize);
125
+ consolestr(":realsize\n");
126
+ if ((realsize<0)||(realsize>=VMEM_LENGTH))
127
+ {
128
+ consolestr("2.realsize out of range\n");
129
+ dump((char*)&vmem_heap[pos-32],128);
130
+ return;
131
+ }
132
+ dump((char*)&vmem_heap[pos],32);
133
+ pos+=realsize;
134
+ }
135
+
136
+
137
+ }
138
+ #endif
139
+ void vmemGCsecond()
140
+ {
141
+ int pos,newpos,realsize;
142
+
143
+ pos=newpos=vmem_start;
144
+
145
+ while(pos < vmem_heapindex)
146
+ {
147
+ realsize=VSIZE(pos)+HEADER_LENGTH;
148
+ #ifdef VMEM_DBG
149
+ if ((realsize<0)||(realsize>=VMEM_LENGTH))
150
+ {
151
+ dumpheap();
152
+ #ifdef VSIMU
153
+ printf("CORE DUMP\n");
154
+ getchar();
155
+ exit(0);
156
+ #endif
157
+ }
158
+ #endif
159
+ if (HEADER_USED(pos))
160
+ {
161
+ vmem_heap[pos+HEADER_GC]=newpos<<1;
162
+ newpos+=realsize;
163
+ }
164
+ pos+=realsize;
165
+ }
166
+ }
167
+
168
+ void vmemGCthird()
169
+ {
170
+ int i,k,j,n;
171
+ int first;
172
+
173
+ first=-1;
174
+ for(i=vmem_stack;i<0;i++)
175
+ {
176
+ k=vmem_top[i];
177
+ if ((ISVALPNT(k))&&(k!=NIL))
178
+ {
179
+ k=VALTOPNT(k);
180
+ vmem_top[i]=vmem_heap[k+HEADER_GC]|1; // attention, hack
181
+ if (!HEADER_USED(k))
182
+ {
183
+ HEADER_MARK(k);
184
+ vmem_heap[k+HEADER_LIST]=first;
185
+ first=k;
186
+ }
187
+ }
188
+ }
189
+ while(first!=-1)
190
+ {
191
+ k=first;
192
+ first=vmem_heap[k+HEADER_LIST];
193
+ if (HEADER_TYPE(k)) // bloc table
194
+ {
195
+ n=VSIZE(k);
196
+ j=k+HEADER_LENGTH;
197
+ for(i=0;i<n;i++)
198
+ {
199
+ k=vmem_heap[j+i];
200
+ if ((ISVALPNT(k))&&(k!=NIL))
201
+ {
202
+ k=VALTOPNT(k);
203
+ vmem_heap[j+i]=vmem_heap[k+HEADER_GC]|1; // attention, hack
204
+ if (!HEADER_USED(k))
205
+ {
206
+ HEADER_MARK(k);
207
+ vmem_heap[k+HEADER_LIST]=first;
208
+ first=k;
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ void vmemGCfourth()
216
+ {
217
+ int pos,newpos,realsize,i;
218
+
219
+ pos=newpos=vmem_start;
220
+
221
+ while(pos < vmem_heapindex)
222
+ {
223
+ realsize=VSIZE(pos)+HEADER_LENGTH;
224
+ if (HEADER_USED(pos))
225
+ {
226
+ vmem_heap[pos+HEADER_GC]=0;
227
+ if (newpos!=pos)
228
+ {
229
+ if (newpos+realsize<=pos)
230
+ memcpy(&vmem_heap[newpos],&vmem_heap[pos],realsize<<2);
231
+ else
232
+ {
233
+ consolestr("########GC : BIG MOVE\n");
234
+ for(i=0;i<realsize;i++) vmem_heap[newpos+i]=vmem_heap[pos+i];
235
+ }
236
+
237
+ newpos+=realsize;
238
+ pos+=realsize;
239
+ // for(i=0;i<realsize;i++) vmem_heap[newpos++]=vmem_heap[pos++];
240
+ }
241
+ else newpos=pos=pos+realsize;
242
+ }
243
+ else
244
+ {
245
+ // ## ajouter ici la gestion des types externes : if (HEADER_EXT(pos)) ...
246
+ pos+=realsize;
247
+ }
248
+ }
249
+ vmem_heapindex=newpos;
250
+ }
251
+
252
+ void vmemGC()
253
+ {
254
+ // logGC();
255
+ #ifdef VREAL
256
+ play_check(1);
257
+ #endif
258
+ vmemGCfirst();
259
+ #ifdef VREAL
260
+ play_check(1);
261
+ #endif
262
+ vmemGCsecond();
263
+ #ifdef VREAL
264
+ play_check(1);
265
+ #endif
266
+ vmemGCthird();
267
+ #ifdef VREAL
268
+ play_check(1);
269
+ #endif
270
+ vmemGCfourth();
271
+ #ifdef VREAL
272
+ play_check(1);
273
+ #endif
274
+ logGC();
275
+ // dump(bytecode,32);
276
+ }
277
+
278
+ int vmemAllocBin(int size,int ext)
279
+ {
280
+ int wsize,p;
281
+ wsize=HEADER_LENGTH+((size+4)>>2);
282
+
283
+ if (VMEM_LENGTH+vmem_stack-vmem_heapindex-wsize<VMEM_GCTHRESHOLD)
284
+ {
285
+ vmemGC();
286
+ if (VMEM_LENGTH+vmem_stack-vmem_heapindex-wsize<VMEM_GCTHRESHOLD)
287
+ {
288
+ consolestr("?OM Error\n");
289
+ vmem_broken=1;
290
+ sysReboot();
291
+ return -1;
292
+ }
293
+ }
294
+ p=vmem_heapindex;
295
+ vmem_heapindex+=wsize;
296
+ vmem_heap[p]=(size<<8)+((ext&127)<<1)+(TYPE_BINARY);
297
+ vmem_heap[p+HEADER_GC]=0;
298
+ vmem_heap[p+HEADER_LIST]=0;
299
+ vmem_heap[p+wsize-1]=0;
300
+ return p;
301
+ }
302
+
303
+ int vmemAllocString(char *p,int len)
304
+ {
305
+ int i;
306
+ char *q;
307
+ int iq=vmemAllocBin(len,0);
308
+ if (iq<0) return iq;
309
+ q=VSTARTBIN(iq);
310
+ for(i=0;i<len;i++) q[i]=p[i];
311
+ return iq;
312
+ }
313
+
314
+ int vmemAllocTab(int size,int ext)
315
+ {
316
+ int wsize,p;
317
+ wsize=HEADER_LENGTH+size;
318
+
319
+ if (VMEM_LENGTH+vmem_stack-vmem_heapindex-wsize<VMEM_GCTHRESHOLD)
320
+ {
321
+ vmemGC();
322
+ if (VMEM_LENGTH+vmem_stack-vmem_heapindex-wsize<VMEM_GCTHRESHOLD)
323
+ {
324
+ consolestr("?OM Error\n");
325
+ vmem_broken=1;
326
+ sysReboot();
327
+ return -1;
328
+ }
329
+ }
330
+ p=vmem_heapindex;
331
+ vmem_heapindex+=wsize;
332
+ size=(size<<2)-1;
333
+ vmem_heap[p]=(size<<8)+((ext&127)<<1)+(TYPE_TAB);
334
+ vmem_heap[p+HEADER_GC]=0;
335
+ vmem_heap[p+HEADER_LIST]=0;
336
+ vmem_heap[p+wsize-1]=0;
337
+ return p;
338
+ }
339
+
340
+ int vmemAllocTabClear(int size,int ext)
341
+ {
342
+ int p=vmemAllocTab(size,ext);
343
+ if (p>=0)
344
+ {
345
+ int i;
346
+ for(i=0;i<size;i++)vmem_heap[p+HEADER_LENGTH+i]=NIL;
347
+ }
348
+ return p;
349
+ }
350
+
351
+ int vmemPush(int val)
352
+ {
353
+ vmem_top[--vmem_stack]=val;
354
+ if (VMEM_LENGTH+vmem_stack-vmem_heapindex<VMEM_GCTHRESHOLD)
355
+ {
356
+ vmemGC();
357
+ if (VMEM_LENGTH+vmem_stack-vmem_heapindex<VMEM_GCTHRESHOLD)
358
+ {
359
+ consolestr("?OM Error\n");
360
+ vmem_broken=1;
361
+ sysReboot();
362
+ return -1;
363
+ }
364
+ }
365
+ return 0;
366
+ }
367
+
368
+ void vmemStacktotab(int n)
369
+ {
370
+ int *q;
371
+ int p=vmemAllocTab(n,0);
372
+ q=VSTART(p);
373
+ while(n>0) q[--n]=VPULL();
374
+ VPUSH(PNTTOVAL(p));
375
+ }
376
+
377
+
378
+ void vmemDumpHeap()
379
+ {
380
+ #ifdef VSIMU
381
+ int i,pos,realsize,n;
382
+ #endif
383
+ consolestr("HEAP\n----\n");
384
+ #ifdef VSIMU
385
+ pos=vmem_start;
386
+ n=0;
387
+ while(pos < vmem_heapindex)
388
+ {
389
+ realsize=VSIZE(pos)+HEADER_LENGTH;
390
+ printf("%06X : %s %d\n",pos,HEADER_TYPE(pos)?"Tab":"Bin",VSIZE(pos));
391
+ for(i=0;i<realsize;i++) printf("%x ",vmem_heap[pos+i]);
392
+ printf("\n");
393
+ pos+=realsize;
394
+ n++;
395
+ }
396
+ #endif
397
+ logGC();
398
+ }
399
+
400
+ void vmemDumpStack()
401
+ {
402
+ #ifdef VSIMU
403
+ int i,k;
404
+ #endif
405
+ consolestr("STACK\n-----\n");
406
+ #ifdef VSIMU
407
+ for(i=-1;i>=vmem_stack;i--)
408
+ {
409
+ k=vmem_top[i];
410
+ printf("%d : %6x -> %6x (%d)\n",i,k,k>>1,k>>1);
411
+ }
412
+ #endif
413
+ }
414
+
415
+ void vmemDump()
416
+ {
417
+ vmemDumpHeap();
418
+ vmemDumpStack();
419
+ }
420
+
421
+ void vmemDumpShort()
422
+ {
423
+ logGC();
424
+ }
data/ext/mtl/vmem.h ADDED
@@ -0,0 +1,107 @@
1
+ // VLISP Virtual Machine - 2006 - by Sylvain Huet
2
+ // Lowcost IS Powerfull
3
+
4
+ #ifndef _MEMORY_
5
+ #define _MEMORY_
6
+
7
+ // #define VSIMU /// d�fini dans le Makefile : -DVSIMU
8
+ //#define VREAL
9
+
10
+ // taille en mots 32 bits (128kwords -> 512ko)
11
+ //#define VMEM_LENGTH (1024*200)
12
+ #define VMEM_LENGTH (1024*200)
13
+ #define VMEM_GCTHRESHOLD 16
14
+
15
+ #ifdef VREAL
16
+ #include<stdio.h>
17
+ #include<string.h>
18
+ #include "uart.h"
19
+ #endif
20
+
21
+ #ifdef VSIMU
22
+ extern int vmem_heap[VMEM_LENGTH];
23
+ #define ENDLINE "\n"
24
+ #define uchar unsigned char
25
+ #define CLR_WDT
26
+
27
+ #endif
28
+ #ifdef VREAL
29
+ #define vmem_heap ((int*)(0xD0010000))
30
+ #define ENDLINE "\r\n"
31
+ #endif
32
+
33
+ void dump(uchar *src,int len);
34
+
35
+ extern int vmem_heapindex;
36
+ extern int *vmem_top;
37
+ extern int vmem_stack;
38
+ extern int vmem_start;
39
+ extern int vmem_broken;
40
+
41
+ int vmemAllocBin(int size,int ext);
42
+ int vmemAllocTab(int size,int ext);
43
+ int vmemAllocTabClear(int size,int ext);
44
+ int vmemAllocString(char *p,int len);
45
+ int vmemPush(int val);
46
+ void vmemStacktotab(int n);
47
+
48
+ void vmemInit(int start);
49
+ void vmemSetstart(int start);
50
+
51
+ void vmemGC();
52
+
53
+
54
+ #define TYPE_BINARY 0 // type binaire pour allocation
55
+ #define TYPE_TAB 1 // type table pour allocation
56
+
57
+ #define PNTTOVAL(p) (1+((p)<<1)) // conversion pointeur vers mot mv
58
+ #define INTTOVAL(i) ((i)<<1) // conversion entier vers mot mv
59
+
60
+ #define VALTOPNT(v) ((v)>>1) // conversion mot mv vers pointeur
61
+ #define VALTOINT(v) ((v)>>1) // conversion mot mv vers entier
62
+
63
+ #define NIL (-1) // nil
64
+ #define ISVALPNT(v) ((v)&1) // teste si un mot mv est un pointeur
65
+
66
+ #define HEADER_LENGTH 3
67
+ #define HEADER_SIZETYPE 0 // la taille contient le header
68
+ #define HEADER_GC 1 // bit 0 : marquage, autres bits : adresse apr�s GC
69
+ #define HEADER_LIST 2 // pile GC
70
+
71
+ #define HEADER_TYPE(p) (vmem_heap[p]&1)
72
+ #define HEADER_EXT(p) ((vmem_heap[p]>>1)&127)
73
+ #define HEADER_SIZE(p) (vmem_heap[p]>>8)
74
+ #define HEADER_USED(p) (vmem_heap[(p)+HEADER_GC]&1)
75
+ #define HEADER_MARK(p) vmem_heap[(p)+HEADER_GC]|=1
76
+
77
+ // Stack management
78
+ #define VPUSH(v) vmemPush(v)
79
+ #define VPULL() (vmem_top[vmem_stack++])
80
+ #define VSTACKGET(n) (vmem_top[vmem_stack+(n)])
81
+ #define VSTACKSET(n,v) vmem_top[vmem_stack+(n)]=(v)
82
+ #define VDROPN(n) vmem_stack+=(n)
83
+ #define VCALLSTACKGET(off,n) (vmem_top[(off)-(n)])
84
+ #define VCALLSTACKSET(off,n,v) vmem_top[(off)-(n)]=(v)
85
+
86
+ // Heap management
87
+ #define VMALLOC(n) vmemAllocTab(n,0)
88
+ #define VMALLOCCLEAR(n) vmemAllocTabClear(n,0)
89
+ #define VMALLOCBIN(n) vmemAllocBin(n,0)
90
+ #define VMALLOCSTR(p,n) vmemAllocString(p,n)
91
+ #define VMKTAB(n) vmemStacktotab(n)
92
+ #define VSIZE(p) (((vmem_heap[p]>>8)+4)>>2)
93
+ #define VSIZEBIN(p) (vmem_heap[p]>>8)
94
+ #define VSTART(p) (&vmem_heap[(p)+HEADER_LENGTH])
95
+ #define VSTARTBIN(p) ((char*)&vmem_heap[(p)+HEADER_LENGTH])
96
+ #define VFETCH(p,i) (vmem_heap[(p)+HEADER_LENGTH+(i)])
97
+ #define VSTORE(p,i,v) vmem_heap[(p)+HEADER_LENGTH+(i)]=(v)
98
+
99
+
100
+
101
+ void vmemDumpHeap();
102
+ void vmemDumpStack();
103
+ void vmemDump();
104
+ void vmemDumpShort();
105
+
106
+ #endif
107
+