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
data/bytecode/src/mtl/vmem.c
DELETED
@@ -1,424 +0,0 @@
|
|
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/bytecode/src/mtl/vnet.c
DELETED
@@ -1,255 +0,0 @@
|
|
1
|
-
// VLISP Virtual Machine - 2006 - by Sylvain Huet
|
2
|
-
// Lowcost IS Powerfull
|
3
|
-
#include"vmem.h"
|
4
|
-
#include"properties.h"
|
5
|
-
|
6
|
-
#ifdef VSIMU
|
7
|
-
#include <string.h>
|
8
|
-
#include<stdio.h>
|
9
|
-
#include<time.h>
|
10
|
-
#include "log.h"
|
11
|
-
int netstatesimu=1;
|
12
|
-
#endif
|
13
|
-
#ifdef VREAL
|
14
|
-
#include "rt2501usb.h"
|
15
|
-
#endif
|
16
|
-
#include"vloader.h"
|
17
|
-
#include"vnet.h"
|
18
|
-
#include"vlog.h"
|
19
|
-
#include"vinterp.h"
|
20
|
-
int netState()
|
21
|
-
{
|
22
|
-
#ifdef VSIMU
|
23
|
-
return netstatesimu;
|
24
|
-
#endif
|
25
|
-
#ifdef VREAL
|
26
|
-
return rt2501_state();
|
27
|
-
#endif
|
28
|
-
}
|
29
|
-
|
30
|
-
int netSend(char* src,int indexsrc,int lentosend,int lensrc,char* macdst,int inddst,int lendst,int speed)
|
31
|
-
{
|
32
|
-
#ifdef VSIMU
|
33
|
-
my_printf(LOG_SIMUNET, "xxxx netSend\n");
|
34
|
-
return -1;
|
35
|
-
#endif
|
36
|
-
#ifdef VREAL
|
37
|
-
if (indexsrc<0) return -1;
|
38
|
-
if (indexsrc+lentosend>lensrc) lentosend=lensrc-indexsrc;
|
39
|
-
if (lentosend<=0) return -1;
|
40
|
-
if (inddst<0) return -1;
|
41
|
-
if (inddst+6>lendst) return -1;
|
42
|
-
return rt2501_send((const unsigned char *)(src+indexsrc),lentosend,(const unsigned char *)(macdst+inddst),speed,1);
|
43
|
-
#endif
|
44
|
-
}
|
45
|
-
|
46
|
-
int netCb(char* src,int lensrc,char* macsrc)
|
47
|
-
{
|
48
|
-
VPUSH(PNTTOVAL(VMALLOCSTR(src,lensrc)));
|
49
|
-
VPUSH(PNTTOVAL(VMALLOCSTR(macsrc,6)));
|
50
|
-
VPUSH(VCALLSTACKGET(sys_start,SYS_CBTCP));
|
51
|
-
if (VSTACKGET(0)!=NIL) interpGo();
|
52
|
-
else { VPULL();VPULL();}
|
53
|
-
VPULL();
|
54
|
-
return 0;
|
55
|
-
}
|
56
|
-
|
57
|
-
extern unsigned char rt2501_mac[6];
|
58
|
-
|
59
|
-
#ifdef VSIMU
|
60
|
-
int htoi2(char* src)
|
61
|
-
{
|
62
|
-
char buf[3];
|
63
|
-
buf[0]=src[0];
|
64
|
-
buf[1]=src[1];
|
65
|
-
buf[2]=0;
|
66
|
-
return sysHtoi(buf);
|
67
|
-
}
|
68
|
-
#endif
|
69
|
-
|
70
|
-
char mac[6];
|
71
|
-
|
72
|
-
char* netMac()
|
73
|
-
{
|
74
|
-
#ifdef VSIMU
|
75
|
-
int i;
|
76
|
-
char *p=PropGet("MAC");
|
77
|
-
for(i=0;i<6;i++) mac[i]=htoi2(&p[i*2]);
|
78
|
-
return mac;
|
79
|
-
// return "abcdef";
|
80
|
-
#endif
|
81
|
-
#ifdef VREAL
|
82
|
-
return (char*) rt2501_mac;
|
83
|
-
#endif
|
84
|
-
}
|
85
|
-
|
86
|
-
int netChk(char* src,int indexsrc,int lentosend,int lensrc,unsigned int val)
|
87
|
-
{
|
88
|
-
unsigned short* p;
|
89
|
-
|
90
|
-
if (indexsrc<0) return val;
|
91
|
-
if (indexsrc+lentosend>lensrc) lentosend=lensrc-indexsrc;
|
92
|
-
if (lentosend<=0) return val;
|
93
|
-
|
94
|
-
src+=indexsrc;
|
95
|
-
p=(unsigned short*)src;
|
96
|
-
|
97
|
-
val=((val<<8)&0xff00)+((val>>8)&0xff);
|
98
|
-
while(lentosend>1)
|
99
|
-
{
|
100
|
-
val+=*(p++);
|
101
|
-
lentosend-=2;
|
102
|
-
}
|
103
|
-
if (lentosend) val+=*(unsigned char*)p;
|
104
|
-
|
105
|
-
val=(val>>16)+(val&0xffff);
|
106
|
-
val=(val>>16)+(val&0xffff);
|
107
|
-
val=((val<<8)&0xff00)+((val>>8)&0xff);
|
108
|
-
return val;
|
109
|
-
}
|
110
|
-
|
111
|
-
void netSetmode(int mode,char* ssid,int chn)
|
112
|
-
{
|
113
|
-
#ifdef VSIMU
|
114
|
-
my_printf(LOG_SIMUNET, "xxxx netSetmode %d %s %d\n",mode,ssid,chn);
|
115
|
-
netstatesimu=(mode)?5:4;
|
116
|
-
#endif
|
117
|
-
#ifdef VREAL
|
118
|
-
rt2501_setmode(mode,ssid,chn);
|
119
|
-
#endif
|
120
|
-
}
|
121
|
-
|
122
|
-
|
123
|
-
int nscan;
|
124
|
-
#ifdef VREAL
|
125
|
-
void netScan_(struct rt2501_scan_result *scan_result, void *userparam)
|
126
|
-
{
|
127
|
-
char buf[256];
|
128
|
-
sprintf(buf,">>> %s %d %d %d %d\n",scan_result->ssid,scan_result->rssi,scan_result->channel,scan_result->rateset,scan_result->encryption);
|
129
|
-
consolestr((UBYTE*)buf);
|
130
|
-
VPUSH(PNTTOVAL(VMALLOCSTR(scan_result->ssid,strlen(scan_result->ssid))));
|
131
|
-
VPUSH(PNTTOVAL(VMALLOCSTR((char*)scan_result->mac,6)));
|
132
|
-
VPUSH(PNTTOVAL(VMALLOCSTR((char*)scan_result->bssid,6)));
|
133
|
-
VPUSH(INTTOVAL(scan_result->rssi));
|
134
|
-
VPUSH(INTTOVAL(scan_result->channel));
|
135
|
-
VPUSH(INTTOVAL(scan_result->rateset));
|
136
|
-
VPUSH(INTTOVAL(scan_result->encryption));
|
137
|
-
VMKTAB(7);
|
138
|
-
nscan++;
|
139
|
-
}
|
140
|
-
#endif
|
141
|
-
|
142
|
-
void netScan(char* ssid)
|
143
|
-
{
|
144
|
-
nscan=0;
|
145
|
-
#ifdef VSIMU
|
146
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("foo",3)));
|
147
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
148
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
149
|
-
VPUSH(INTTOVAL(-20));
|
150
|
-
VPUSH(INTTOVAL(11));
|
151
|
-
VPUSH(INTTOVAL(1));
|
152
|
-
VPUSH(INTTOVAL(0));
|
153
|
-
VMKTAB(7);
|
154
|
-
nscan++;
|
155
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("foo",3)));
|
156
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
157
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
158
|
-
VPUSH(INTTOVAL(-10));
|
159
|
-
VPUSH(INTTOVAL(11));
|
160
|
-
VPUSH(INTTOVAL(1));
|
161
|
-
VPUSH(INTTOVAL(0));
|
162
|
-
VMKTAB(7);
|
163
|
-
nscan++;
|
164
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("zzzz",3)));
|
165
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
166
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
167
|
-
VPUSH(INTTOVAL(-10));
|
168
|
-
VPUSH(INTTOVAL(11));
|
169
|
-
VPUSH(INTTOVAL(1));
|
170
|
-
VPUSH(INTTOVAL(0));
|
171
|
-
VMKTAB(7);
|
172
|
-
nscan++;
|
173
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("",3)));
|
174
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
175
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
176
|
-
VPUSH(INTTOVAL(-10));
|
177
|
-
VPUSH(INTTOVAL(11));
|
178
|
-
VPUSH(INTTOVAL(1));
|
179
|
-
VPUSH(INTTOVAL(0));
|
180
|
-
VMKTAB(7);
|
181
|
-
nscan++;
|
182
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("a\"a<a'a a\\a",strlen("a\"a<a'a a\\a"))));
|
183
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
184
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
185
|
-
VPUSH(INTTOVAL(-10));
|
186
|
-
VPUSH(INTTOVAL(11));
|
187
|
-
VPUSH(INTTOVAL(1));
|
188
|
-
VPUSH(INTTOVAL(3));
|
189
|
-
VMKTAB(7);
|
190
|
-
nscan++;
|
191
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("foo",3)));
|
192
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
193
|
-
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
194
|
-
VPUSH(INTTOVAL(-30));
|
195
|
-
VPUSH(INTTOVAL(11));
|
196
|
-
VPUSH(INTTOVAL(1));
|
197
|
-
VPUSH(INTTOVAL(0));
|
198
|
-
VMKTAB(7);
|
199
|
-
nscan++;
|
200
|
-
#endif
|
201
|
-
#ifdef VREAL
|
202
|
-
rt2501_scan(ssid, netScan_, NULL);
|
203
|
-
#endif
|
204
|
-
VPUSH(NIL);
|
205
|
-
while(nscan--) VMKTAB(2);
|
206
|
-
}
|
207
|
-
|
208
|
-
void netAuth(char* ssid,char* mac,char* bssid,int chn,int rate,int authmode,int encrypt,char* key)
|
209
|
-
{
|
210
|
-
#ifdef VSIMU
|
211
|
-
my_printf(LOG_SIMUNET, "xxxx netAuth %s %d %d %d %d\n",ssid,chn,rate,authmode,encrypt);
|
212
|
-
netstatesimu=4;
|
213
|
-
#endif
|
214
|
-
#ifdef VREAL
|
215
|
-
rt2501_auth((const char*)ssid,(const unsigned char*)mac,(const unsigned char*)bssid,chn,rate,authmode,encrypt,(const unsigned char*)key);
|
216
|
-
#endif
|
217
|
-
}
|
218
|
-
|
219
|
-
void netSeqAdd(unsigned char* seq,int n)
|
220
|
-
{
|
221
|
-
unsigned char res[4];
|
222
|
-
unsigned int val;
|
223
|
-
val=(seq[0]<<24)+(seq[1]<<16)+(seq[2]<<8)+seq[3];
|
224
|
-
val+=n;
|
225
|
-
res[3]=val; val>>=8;
|
226
|
-
res[2]=val; val>>=8;
|
227
|
-
res[1]=val; val>>=8;
|
228
|
-
res[0]=val;
|
229
|
-
VPUSH(PNTTOVAL(VMALLOCSTR((char*)res,4)));
|
230
|
-
}
|
231
|
-
|
232
|
-
void mypassword_to_pmk(const char *password, char *ssid, int ssidlength, unsigned char *pmk);
|
233
|
-
|
234
|
-
void netPmk(char* ssid,char* key,char* buf)
|
235
|
-
{
|
236
|
-
#ifdef VSIMU
|
237
|
-
my_printf(LOG_SIMUNET, "xxxx netPmk %s %s\n",ssid,key);
|
238
|
-
strcpy(buf,"01234567012345670123456701234567");
|
239
|
-
#endif
|
240
|
-
#ifdef VREAL
|
241
|
-
// strcpy(buf,"01234567012345670123456701234567");
|
242
|
-
mypassword_to_pmk(key,ssid,strlen(ssid), (unsigned char*)buf);
|
243
|
-
#endif
|
244
|
-
}
|
245
|
-
|
246
|
-
int netRssi()
|
247
|
-
{
|
248
|
-
#ifdef VSIMU
|
249
|
-
return -20;
|
250
|
-
#endif
|
251
|
-
#ifdef VREAL
|
252
|
-
return rt2501_rssi_average();
|
253
|
-
#endif
|
254
|
-
}
|
255
|
-
|
data/examples/basic/Procfile
DELETED
data/examples/basic/server.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "nabaztag_hack_kit/server"
|
2
|
-
|
3
|
-
require 'nabaztag_hack_kit/mods/callback'
|
4
|
-
# require 'nabaztag_hack_kit/mods/logger'
|
5
|
-
require 'nabaztag_hack_kit/mods/playground'
|
6
|
-
|
7
|
-
module Basic
|
8
|
-
class Server < NabaztagHackKit::Server
|
9
|
-
register NabaztagHackKit::Mods::Callback
|
10
|
-
# register Mods::Logger
|
11
|
-
register NabaztagHackKit::Mods::Playground
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|