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.
Files changed (173) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -2
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -2
  5. data/CHANGELOG.md +17 -2
  6. data/LICENSE +21 -0
  7. data/README.md +115 -44
  8. data/Rakefile +2 -6
  9. data/bytecode/{Commands.md → _docs/commands.md} +0 -0
  10. data/bytecode/{Docs.md → _docs/grammar.md} +0 -0
  11. data/bytecode/_docs/grammar.pdf +0 -0
  12. data/bytecode/{src → _original}/README.md +0 -0
  13. data/bytecode/{src → _original}/lib/arp.mtl +0 -0
  14. data/bytecode/{src → _original}/lib/cfg.mtl +0 -0
  15. data/bytecode/{src → _original}/lib/choreos.mtl +0 -0
  16. data/bytecode/{src → _original}/lib/dhcp.mtl +0 -0
  17. data/bytecode/{src → _original}/lib/dns.mtl +0 -0
  18. data/bytecode/{src → _original}/lib/http.mtl +0 -0
  19. data/bytecode/{src → _original}/lib/tcp.mtl +0 -0
  20. data/bytecode/{src → _original}/lib/udp.mtl +0 -0
  21. data/bytecode/{src → _original}/lib/util.mtl +0 -0
  22. data/bytecode/{src → _original}/lib/var.mtl +0 -0
  23. data/bytecode/{src → _original}/lib/wav.mtl +0 -0
  24. data/bytecode/{src → _original}/lib/wifi.mtl +0 -0
  25. data/bytecode/{src → _original}/nominal-ping.mtl +0 -0
  26. data/bytecode/main.mtl +11 -11
  27. data/bytecode/test/test.mtl +8 -8
  28. data/examples/basic/Gemfile +1 -3
  29. data/examples/basic/config.ru +14 -4
  30. data/examples/record/Gemfile +0 -5
  31. data/examples/record/{config.ru.example → config.ru} +2 -2
  32. data/examples/record/server.rb +0 -2
  33. data/ext/Makefile +10 -0
  34. data/ext/bin/mtl_comp +29 -0
  35. data/{bytecode → ext}/bin/mtl_merge +0 -0
  36. data/ext/bin/mtl_simu +29 -0
  37. data/{bytecode/src/mtl → ext}/extconf.rb +0 -0
  38. data/ext/mtl_linux/.gitignore +7 -0
  39. data/ext/mtl_linux/LICENSE +21 -0
  40. data/ext/mtl_linux/Makefile +116 -0
  41. data/ext/mtl_linux/MetalC.project +196 -0
  42. data/ext/mtl_linux/conf.bin +0 -0
  43. data/{bytecode/src/mtl → ext/mtl_linux}/conf.bin.sans_password +0 -0
  44. data/{bytecode/src/mtl → ext/mtl_linux}/config.txt +0 -0
  45. data/ext/mtl_linux/inc/log.h +21 -0
  46. data/{bytecode/src/mtl → ext/mtl_linux/inc}/properties.h +0 -0
  47. data/{bytecode/src/mtl/linux_simuaudio.h → ext/mtl_linux/inc/simu/linux/simuaudio.h} +0 -0
  48. data/{bytecode/src/mtl/linux_simunet.h → ext/mtl_linux/inc/simu/linux/simunet.h} +0 -0
  49. data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simuaudio.h +18 -18
  50. data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simunet.h +0 -0
  51. data/ext/mtl_linux/inc/vcomp/compiler.h +200 -0
  52. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/file.h +11 -11
  53. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/filesystem.h +0 -0
  54. data/ext/mtl_linux/inc/vcomp/interpreter.h +121 -0
  55. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/memory.h +120 -92
  56. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/param.h +0 -0
  57. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/parser.h +27 -27
  58. data/ext/mtl_linux/inc/vcomp/prodbuffer.h +42 -0
  59. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/resource.h +1 -1
  60. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/terminal.h +8 -8
  61. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/util.h +7 -7
  62. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vaudio.h +0 -0
  63. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vbc.h +1 -1
  64. data/ext/mtl_linux/inc/vm/vbc_str.h +167 -0
  65. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vinterp.h +0 -0
  66. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vloader.h +0 -0
  67. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vlog.h +0 -0
  68. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vmem.h +0 -0
  69. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vnet.h +0 -0
  70. data/ext/mtl_linux/nominal.mtl +3959 -0
  71. data/ext/mtl_linux/src/comp/main.cpp +123 -0
  72. data/ext/mtl_linux/src/simu/dumpbc.c +2566 -0
  73. data/ext/mtl_linux/src/simu/linux/main.cpp +288 -0
  74. data/ext/mtl_linux/src/simu/linux/simu.c +309 -0
  75. data/ext/mtl_linux/src/simu/linux/simuaudio.c +44 -0
  76. data/ext/mtl_linux/src/simu/linux/simunet.c +707 -0
  77. data/ext/mtl_linux/src/simu/log.c +340 -0
  78. data/ext/mtl_linux/src/simu/properties.c +368 -0
  79. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/GTKANAL.H +0 -0
  80. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/LAYER3.C +0 -0
  81. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/TABINIT.C +0 -0
  82. data/ext/mtl_linux/src/simu/win/mp3/common.c +302 -0
  83. data/ext/mtl_linux/src/simu/win/mp3/dct64_i386.c +316 -0
  84. data/ext/mtl_linux/src/simu/win/mp3/decode_i386.c +160 -0
  85. data/ext/mtl_linux/src/simu/win/mp3/huffman.h +332 -0
  86. data/ext/mtl_linux/src/simu/win/mp3/interface.c +276 -0
  87. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/mpg123.h +34 -30
  88. data/ext/mtl_linux/src/simu/win/mp3/mpglib.h +47 -0
  89. data/ext/mtl_linux/src/simu/win/simu.c +819 -0
  90. data/ext/mtl_linux/src/simu/win/simuaudio.c +787 -0
  91. data/ext/mtl_linux/src/simu/win/simunet.c +489 -0
  92. data/ext/mtl_linux/src/vcomp/bootstrap.cpp +95 -0
  93. data/ext/mtl_linux/src/vcomp/compiler.cpp +587 -0
  94. data/ext/mtl_linux/src/vcomp/compiler_file.cpp +1253 -0
  95. data/ext/mtl_linux/src/vcomp/compiler_prog.cpp +437 -0
  96. data/ext/mtl_linux/src/vcomp/compiler_term.cpp +1500 -0
  97. data/ext/mtl_linux/src/vcomp/compiler_type.cpp +1238 -0
  98. data/ext/mtl_linux/src/vcomp/compiler_var.cpp +502 -0
  99. data/ext/mtl_linux/src/vcomp/file.cpp +100 -0
  100. data/ext/mtl_linux/src/vcomp/interpreter.cpp +93 -0
  101. data/ext/mtl_linux/src/vcomp/memory.cpp +313 -0
  102. data/ext/mtl_linux/src/vcomp/parser.cpp +584 -0
  103. data/ext/mtl_linux/src/vcomp/parser_xml.cpp +137 -0
  104. data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/prodbuffer.cpp +57 -36
  105. data/ext/mtl_linux/src/vcomp/stdlib_core.cpp +130 -0
  106. data/ext/mtl_linux/src/vcomp/terminal.cpp +80 -0
  107. data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/util.cpp +18 -11
  108. data/ext/mtl_linux/src/vm/vaudio.c +830 -0
  109. data/ext/mtl_linux/src/vm/vinterp.c +1780 -0
  110. data/ext/mtl_linux/src/vm/vloader.c +139 -0
  111. data/ext/mtl_linux/src/vm/vlog.c +782 -0
  112. data/ext/mtl_linux/src/vm/vmem.c +461 -0
  113. data/ext/mtl_linux/src/vm/vnet.c +298 -0
  114. data/{bytecode/src/mtl → ext/mtl_linux}/utils/correct_const.sh +0 -0
  115. data/lib/nabaztag_hack_kit/server.rb +4 -7
  116. data/lib/nabaztag_hack_kit/version.rb +1 -1
  117. data/lib/nabaztag_hack_kit.rb +2 -2
  118. data/nabaztag_hack_kit.gemspec +10 -11
  119. data/spec/integration/server_spec.rb +3 -3
  120. data/spec/spec_helper.rb +2 -0
  121. data/spec/unit/message_spec.rb +12 -18
  122. data/spec/unit/server_spec.rb +13 -10
  123. metadata +145 -137
  124. data/bytecode/bin/mtl_comp +0 -50
  125. data/bytecode/bin/mtl_simu +0 -49
  126. data/bytecode/src/mtl/Makefile +0 -42
  127. data/bytecode/src/mtl/README.md +0 -13
  128. data/bytecode/src/mtl/bc.cpp +0 -1891
  129. data/bytecode/src/mtl/dumpbc.c +0 -2566
  130. data/bytecode/src/mtl/linux_simu.c +0 -271
  131. data/bytecode/src/mtl/linux_simuaudio.c +0 -16
  132. data/bytecode/src/mtl/linux_simunet.c +0 -620
  133. data/bytecode/src/mtl/log.c +0 -297
  134. data/bytecode/src/mtl/log.h +0 -20
  135. data/bytecode/src/mtl/main_compiler.cpp +0 -104
  136. data/bytecode/src/mtl/main_simu.cpp +0 -221
  137. data/bytecode/src/mtl/mp3/common.c +0 -265
  138. data/bytecode/src/mtl/mp3/dct64_i386.c +0 -316
  139. data/bytecode/src/mtl/mp3/decode_i386.c +0 -155
  140. data/bytecode/src/mtl/mp3/huffman.h +0 -332
  141. data/bytecode/src/mtl/mp3/interface.c +0 -258
  142. data/bytecode/src/mtl/mp3/mpglib.h +0 -44
  143. data/bytecode/src/mtl/properties.c +0 -293
  144. data/bytecode/src/mtl/simu.c +0 -750
  145. data/bytecode/src/mtl/simuaudio.c +0 -662
  146. data/bytecode/src/mtl/simunet.c +0 -400
  147. data/bytecode/src/mtl/vaudio.c +0 -677
  148. data/bytecode/src/mtl/vbc_str.h +0 -166
  149. data/bytecode/src/mtl/vcomp/Makefile +0 -29
  150. data/bytecode/src/mtl/vcomp/bootstrap.cpp +0 -89
  151. data/bytecode/src/mtl/vcomp/compiler.cpp +0 -470
  152. data/bytecode/src/mtl/vcomp/compiler.h +0 -200
  153. data/bytecode/src/mtl/vcomp/compiler_file.cpp +0 -929
  154. data/bytecode/src/mtl/vcomp/compiler_prog.cpp +0 -250
  155. data/bytecode/src/mtl/vcomp/compiler_term.cpp +0 -1053
  156. data/bytecode/src/mtl/vcomp/compiler_type.cpp +0 -872
  157. data/bytecode/src/mtl/vcomp/compiler_var.cpp +0 -289
  158. data/bytecode/src/mtl/vcomp/file.cpp +0 -79
  159. data/bytecode/src/mtl/vcomp/interpreter.cpp +0 -85
  160. data/bytecode/src/mtl/vcomp/interpreter.h +0 -121
  161. data/bytecode/src/mtl/vcomp/memory.cpp +0 -241
  162. data/bytecode/src/mtl/vcomp/parser.cpp +0 -427
  163. data/bytecode/src/mtl/vcomp/parser_xml.cpp +0 -124
  164. data/bytecode/src/mtl/vcomp/prodbuffer.h +0 -42
  165. data/bytecode/src/mtl/vcomp/stdlib_core.cpp +0 -122
  166. data/bytecode/src/mtl/vcomp/terminal.cpp +0 -73
  167. data/bytecode/src/mtl/vinterp.c +0 -1349
  168. data/bytecode/src/mtl/vloader.c +0 -127
  169. data/bytecode/src/mtl/vlog.c +0 -589
  170. data/bytecode/src/mtl/vmem.c +0 -424
  171. data/bytecode/src/mtl/vnet.c +0 -255
  172. data/examples/basic/Procfile +0 -2
  173. data/examples/basic/server.rb +0 -14
@@ -1,250 +0,0 @@
1
- //-------------------
2
- // MV
3
- // version WIN32 et POCKETPC
4
- // Sylvain Huet
5
- // Derniere mise a jour : 07/01/2003
6
- //
7
-
8
- #include <stdio.h>
9
- #include <string.h>
10
-
11
- #include "param.h"
12
- #include "terminal.h"
13
- #include "memory.h"
14
- #include "parser.h"
15
- #include "prodbuffer.h"
16
- #include "compiler.h"
17
- #include "interpreter.h"
18
-
19
-
20
- int Compiler::parseprogram()
21
- {
22
- int k;
23
-
24
- while(1)
25
- {
26
- if (k=parseexpression()) return k;
27
- if (!parser->next(0)) return 0;
28
- if (strcmp(parser->token,";"))
29
- {
30
- parser->giveback();
31
- return 0;
32
- }
33
- bc->addchar(OPdrop);
34
- STACKDROP(m); // on supprime le type de l'expression
35
- }
36
- }
37
-
38
- int Compiler::parseexpression()
39
- {
40
- int k;
41
-
42
- if (k=parsearithm()) return k;
43
-
44
- if (!parser->next(0)) return 0;
45
- if (strcmp(parser->token,"::"))
46
- {
47
- parser->giveback();
48
- return 0;
49
- }
50
- if (k=parseexpression()) return k; // r�cursion
51
-
52
- if (k=createnodetuple(2)) return k;
53
- if (k=copytype(VALTOPNT(TABGET(stdtypes,STDTYPE_fun__u0_list_u0__list_u0)))) return k;
54
- if (k=unif_argfun()) return k;
55
-
56
- bc->addchar(OPdeftabb);
57
- bc->addchar(2);
58
-
59
- return 0;
60
- }
61
-
62
-
63
- int Compiler::parsearithm()
64
- {
65
- int k;
66
-
67
- if (k=parsea1()) return k;
68
- while(1)
69
- {
70
- if (!parser->next(0)) return 0;
71
- if ((strcmp(parser->token,"&&"))&&(strcmp(parser->token,"||")))
72
- {
73
- parser->giveback();
74
- return 0;
75
- }
76
- bc->addchar(OPdup);
77
- if (strcmp(parser->token,"&&")) bc->addchar(OPnon);
78
- bc->addchar(OPelse);
79
- int bc_i=bc->getsize();
80
- bc->addshort(0); // on pr�pare le champ pour le saut
81
- bc->addchar(OPdrop);
82
- if (k=parsea1()) return k;
83
- bc->setshort(bc_i,bc->getsize()); // on r�gle le saut
84
-
85
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)))) return k;
86
- STACKDROP(m);
87
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)))) return k;
88
- }
89
- }
90
-
91
-
92
- int Compiler::parsea1()
93
- {
94
- int k;
95
-
96
- if ((parser->next(0))&&(!strcmp(parser->token,"!")))
97
- {
98
- if (k=parsea1()) return k;
99
- bc->addchar(OPnon);
100
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)))) return k;
101
- return 0;
102
- }
103
- parser->giveback();
104
- return parsea2();
105
- }
106
-
107
- int Compiler::parsea2()
108
- {
109
- int k,op,typ;
110
-
111
- if (k=parsea3()) return k;
112
- while(1)
113
- {
114
- if (!parser->next(0)) return 0;
115
- if (!strcmp(parser->token,"==")) { op=OPeq; typ=0;}
116
- else if (!strcmp(parser->token,"!=")) { op=OPne; typ=0;}
117
- else if (!strcmp(parser->token,"<")) { op=OPlt; typ=1;}
118
- else if (!strcmp(parser->token,">")) { op=OPgt; typ=1;}
119
- else if (!strcmp(parser->token,"<=")) { op=OPle; typ=1;}
120
- else if (!strcmp(parser->token,">=")) { op=OPge; typ=1;}
121
- else
122
- {
123
- parser->giveback();
124
- return 0;
125
- }
126
- if (k=parsea3()) return k;
127
- bc->addchar(op);
128
-
129
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(STACKGET(m,1)))) return k;
130
- STACKDROP(m);
131
- if (typ==1)
132
- {
133
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)))) return k;
134
- }
135
- STACKSET(m,0,TABGET(stdtypes,STDTYPE_I));
136
- }
137
- }
138
-
139
- int Compiler::parsea3()
140
- {
141
- int k,op,typ;
142
-
143
- if (k=parsea4()) return k;
144
- while(1)
145
- {
146
- if (!parser->next(0)) return 0;
147
- if (!strcmp(parser->token,"+")) { op=OPadd; typ=1;}
148
- else if (!strcmp(parser->token,"-")) { op=OPsub; typ=1;}
149
- else
150
- {
151
- parser->giveback();
152
- return 0;
153
- }
154
- if (k=parsea4()) return k;
155
- bc->addchar(op);
156
-
157
- int* ptyp;
158
- if (typ==1) ptyp=VALTOPNT(TABGET(stdtypes,STDTYPE_I));
159
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
160
- STACKDROP(m);
161
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
162
- }
163
- }
164
-
165
- int Compiler::parsea4()
166
- {
167
- int k,op,typ;
168
-
169
- if (k=parsea5()) return k;
170
- while(1)
171
- {
172
- if (!parser->next(0)) return 0;
173
- if (!strcmp(parser->token,"*")) { op=OPmul; typ=1;}
174
- else if (!strcmp(parser->token,"/")) { op=OPdiv; typ=1;}
175
- else if (!strcmp(parser->token,"%")) { op=OPmod; typ=1;}
176
- else
177
- {
178
- parser->giveback();
179
- return 0;
180
- }
181
- if (k=parsea5()) return k;
182
- bc->addchar(op);
183
-
184
- int* ptyp;
185
- if (typ==1) ptyp=VALTOPNT(TABGET(stdtypes,STDTYPE_I));
186
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
187
- STACKDROP(m);
188
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
189
- }
190
- }
191
-
192
- int Compiler::parsea5()
193
- {
194
- int k,op;
195
-
196
- if (k=parsea6()) return k;
197
- while(1)
198
- {
199
- if (!parser->next(0)) return 0;
200
- if (!strcmp(parser->token,"&")) op=OPand;
201
- else if (!strcmp(parser->token,"|")) op=OPor;
202
- else if (!strcmp(parser->token,"^")) op=OPeor;
203
- else if (!strcmp(parser->token,"<<")) op=OPshl;
204
- else if (!strcmp(parser->token,">>")) op=OPshr;
205
- else
206
- {
207
- parser->giveback();
208
- return 0;
209
- }
210
- if (k=parsea6()) return k;
211
- bc->addchar(op);
212
-
213
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)))) return k;
214
- STACKDROP(m);
215
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)))) return k;
216
- }
217
- }
218
-
219
- int Compiler::parsea6()
220
- {
221
- int k;
222
-
223
- if (!parser->next(0)) return parseterm();
224
-
225
- if (!strcmp(parser->token,"-"))
226
- {
227
- if (!parser->next(0)) return parsea6();
228
- if (isdecimal(parser->token)) // gestion des entiers
229
- {
230
- int i=-mtl_atoi(parser->token);
231
- bc->addchar(OPint);
232
- bc->addint(i);
233
- return STACKPUSH(m,TABGET(stdtypes,STDTYPE_I));
234
- }
235
- parser->giveback();
236
- if (k=parsea6()) return k;
237
- bc->addchar(OPneg);
238
- return unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)));
239
- }
240
- else if (!strcmp(parser->token,"~"))
241
- {
242
- if (k=parsea6()) return k;
243
- bc->addchar(OPnot);
244
- return unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)));
245
- }
246
- parser->giveback();
247
- return parseterm();
248
- }
249
-
250
-