nabaztag_hack_kit 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,250 @@
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
+