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,289 +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::parseval()
21
- {
22
- int k;
23
-
24
- if (k=parseval3()) return k;
25
-
26
- if (!parser->next(0)) return 0;
27
- if (strcmp(parser->token,"::"))
28
- {
29
- parser->giveback();
30
- return 0;
31
- }
32
- if (k=parseval()) return k; // r�cursion
33
-
34
- if (k=createnodetype(TYPENAME_LIST)) return k;
35
- if (k=createnodetype(TYPENAME_UNDEF)) return k; // noeud �lement
36
- TABSET(m,VALTOPNT(STACKGET(m,1)),TYPEHEADER_LENGTH,STACKGET(m,0)); // attachement du noeud �l�ment au noeud list
37
- if (k=unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(STACKGET(m,4)))) return k; // unification �lement
38
- if (k=unif(VALTOPNT(STACKGET(m,1)),VALTOPNT(STACKGET(m,2)))) return k; // unification list
39
- STACKSET(m,4,STACKGET(m,1)); // remplacement du type
40
-
41
- int* p=MALLOCCLEAR(m,LIST_LENGTH); // cr�ation du tuple liste
42
- if (!p) return MTLERR_OM;
43
- TABSET(m,p,LIST_VAL,STACKGET(m,5));
44
- TABSET(m,p,LIST_NEXT,STACKGET(m,3));
45
- STACKSET(m,5,PNTTOVAL(p));
46
- STACKDROPN(m,4);
47
- return 0;
48
- }
49
-
50
-
51
- int Compiler::parseval3()
52
- {
53
- int k,op,typ;
54
-
55
- if (k=parseval4()) return k;
56
- while(1)
57
- {
58
- if (!parser->next(0)) return 0;
59
- if (!strcmp(parser->token,"+")) { op=OPadd; typ=1;}
60
- else if (!strcmp(parser->token,"-")) { op=OPsub; typ=1;}
61
- else
62
- {
63
- parser->giveback();
64
- return 0;
65
- }
66
- if (k=parseval4()) return k;
67
- if (op==OPadd) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))+VALTOINT(STACKGET(m,1))));
68
- else if (op==OPsub) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))-VALTOINT(STACKGET(m,1))));
69
- int* ptyp;
70
- if (typ==1) ptyp=VALTOPNT(TABGET(stdtypes,STDTYPE_I));
71
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
72
- if (k=unif(VALTOPNT(STACKGET(m,2)),ptyp)) return k;
73
- STACKDROPN(m,2);
74
- }
75
- }
76
-
77
- int Compiler::parseval4()
78
- {
79
- int k,op,typ;
80
-
81
- if (k=parseval5()) return k;
82
- while(1)
83
- {
84
- if (!parser->next(0)) return 0;
85
- if (!strcmp(parser->token,"*")) { op=OPmul; typ=1;}
86
- else if (!strcmp(parser->token,"/")) { op=OPdiv; typ=1;}
87
- else if (!strcmp(parser->token,"%")) { op=OPmod; typ=1;}
88
- else
89
- {
90
- parser->giveback();
91
- return 0;
92
- }
93
- if (k=parseval5()) return k;
94
-
95
- if (op==OPmul) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))*VALTOINT(STACKGET(m,1))));
96
- else if (op==OPdiv)
97
- {
98
- if (VALTOINT(STACKGET(m,1))==0) return MTLERR_DIV;
99
- STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))/VALTOINT(STACKGET(m,1))));
100
- }
101
- else if (op==OPmod) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))%VALTOINT(STACKGET(m,1))));
102
- int* ptyp;
103
- if (typ==1) ptyp=VALTOPNT(TABGET(stdtypes,STDTYPE_I));
104
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
105
- if (k=unif(VALTOPNT(STACKGET(m,2)),ptyp)) return k;
106
- STACKDROPN(m,2);
107
- }
108
- }
109
-
110
- int Compiler::parseval5()
111
- {
112
- int k,op;
113
-
114
- if (k=parseval6()) return k;
115
- while(1)
116
- {
117
- if (!parser->next(0)) return 0;
118
- if (!strcmp(parser->token,"&")) op=OPand;
119
- else if (!strcmp(parser->token,"|")) op=OPor;
120
- else if (!strcmp(parser->token,"^")) op=OPeor;
121
- else if (!strcmp(parser->token,"<<")) op=OPshl;
122
- else if (!strcmp(parser->token,">>")) op=OPshr;
123
- else
124
- {
125
- parser->giveback();
126
- return 0;
127
- }
128
- if (k=parseval6()) return k;
129
-
130
- if (op==OPand) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))&VALTOINT(STACKGET(m,1))));
131
- else if (op==OPor) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))|VALTOINT(STACKGET(m,1))));
132
- else if (op==OPeor) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))^VALTOINT(STACKGET(m,1))));
133
- else if (op==OPshl) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))<<VALTOINT(STACKGET(m,1))));
134
- else if (op==OPshr) STACKSET(m,3,INTTOVAL(VALTOINT(STACKGET(m,3))>>VALTOINT(STACKGET(m,1))));
135
-
136
- int* ptyp=VALTOPNT(TABGET(stdtypes,STDTYPE_I));
137
- if (k=unif(VALTOPNT(STACKGET(m,0)),ptyp)) return k;
138
- if (k=unif(VALTOPNT(STACKGET(m,2)),ptyp)) return k;
139
- STACKDROPN(m,2);
140
- }
141
- }
142
-
143
- int Compiler::parseval6()
144
- {
145
- int k;
146
-
147
- if (!parser->next(0)) return parseval7();
148
-
149
- if (!strcmp(parser->token,"-"))
150
- {
151
- if (!parser->next(0)) return parseval6();
152
- if (isdecimal(parser->token)) // gestion des entiers
153
- {
154
- int i=-mtl_atoi(parser->token);
155
- if (k=STACKPUSH(m,INTTOVAL(i))) return k;
156
- return STACKPUSH(m,TABGET(stdtypes,STDTYPE_I));
157
- }
158
- parser->giveback();
159
- if (k=parseval6()) return k;
160
- STACKSET(m,1,INTTOVAL(-VALTOINT(STACKGET(m,0))));
161
- return unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)));
162
- }
163
- else if (!strcmp(parser->token,"~"))
164
- {
165
- if (k=parseval6()) return k;
166
- STACKSET(m,1,INTTOVAL(~VALTOINT(STACKGET(m,0))));
167
- return unif(VALTOPNT(STACKGET(m,0)),VALTOPNT(TABGET(stdtypes,STDTYPE_I)));
168
- }
169
- parser->giveback();
170
- return parseval7();
171
- }
172
-
173
-
174
- int Compiler::parseval7()
175
- {
176
- int k;
177
-
178
- if (!parser->next(0))
179
- {
180
- PRINTF(m)(LOG_COMPILER,"Compiler : term expected (found EOF)\n");
181
- return MTLERR_SN;
182
- }
183
- if (!strcmp(parser->token,"(")) // gestion des parenth�ses
184
- {
185
- if (k=parseval()) return k;
186
- return parser->parsekeyword(")");
187
- }
188
- else if (!strcmp(parser->token,"[")) // gestion des tuples
189
- {
190
- int nval=0;
191
- if (k=STACKPUSH(m,NIL)) return k; // valeur finale
192
- if (k=STACKPUSH(m,NIL)) return k; // type final
193
- int sref=STACKREF(m);
194
- while(1)
195
- {
196
- if (!parser->next(0))
197
- {
198
- PRINTF(m)(LOG_COMPILER,"Compiler : ']' expected (found EOF)\n");
199
- return MTLERR_SN;
200
- }
201
- if (!strcmp(parser->token,"]"))
202
- {
203
- int* p=MALLOCCLEAR(m,nval); // cr�ation du tuple liste
204
- if (!p) return MTLERR_OM;
205
- int i;
206
- for(i=0;i<nval;i++) TABSET(m,p,i,STACKGET(m,(nval-i)*2-1));
207
- STACKSETFROMREF(m,sref,1,PNTTOVAL(p));
208
- if (k=createnodetupleval(nval)) return k;
209
- STACKSETFROMREF(m,sref,0,STACKPULL(m));
210
- STACKRESTOREREF(m,sref);
211
- return 0;
212
- }
213
- parser->giveback();
214
- if (k=parseval()) return k;
215
- nval++;
216
- }
217
- }
218
- else if (!strcmp(parser->token,"{")) // gestion des tableaux
219
- {
220
- int nval=0;
221
- if (k=STACKPUSH(m,NIL)) return k; // valeur finale
222
- if (k=createnodetype(TYPENAME_TAB)) return k; // type final
223
- if (k=createnodetype(TYPENAME_UNDEF)) return k;
224
- TABSET(m,VALTOPNT(STACKGET(m,1)),TYPEHEADER_LENGTH,STACKGET(m,0));
225
- int* p=VALTOPNT(STACKPULL(m));
226
-
227
- while(1)
228
- {
229
- if (!parser->next(0))
230
- {
231
- PRINTF(m)(LOG_COMPILER,"Compiler : '}' expected (found EOF)\n");
232
- return MTLERR_SN;
233
- }
234
- if (!strcmp(parser->token,"}"))
235
- {
236
-
237
- if (k=DEFTAB(m,nval)) return k;
238
-
239
- STACKSET(m,2,STACKGET(m,0)); // report de la valeur du tableau
240
- STACKDROP(m);
241
- return 0;
242
- }
243
- parser->giveback();
244
- if (k=parseval()) return k;
245
- if (k=unif(VALTOPNT(STACKGET(m,0)),p)) return k;
246
- STACKDROP(m);
247
- nval++;
248
- }
249
- }
250
- else if (!strcmp(parser->token,"nil")) // gestion du nil
251
- {
252
- if (k=STACKPUSH(m,NIL)) return k; // valeur
253
- return createnodetype(TYPENAME_WEAK);
254
- }
255
- else if (!strcmp(parser->token,"'")) // gestion des 'char
256
- {
257
- if (!parser->next(0))
258
- {
259
- PRINTF(m)(LOG_COMPILER,"Compiler : 'char expected (found EOF)\n");
260
- return MTLERR_SN;
261
- }
262
- if (k=STACKPUSH(m,INTTOVAL(parser->token[0]&255))) return k; // valeur
263
- if (k=parser->parsekeyword("'")) return k;
264
- return STACKPUSH(m,TABGET(stdtypes,STDTYPE_I));
265
- }
266
- else if (isdecimal(parser->token)) // gestion des entiers
267
- {
268
- int i=mtl_atoi(parser->token);
269
- if (k=STACKPUSH(m,INTTOVAL(i))) return k; // valeur
270
- return STACKPUSH(m,TABGET(stdtypes,STDTYPE_I));
271
- }
272
- else if ((parser->token[0]=='0')&&(parser->token[1]=='x')
273
- &&(ishexadecimal(parser->token+2))) // gestion des entiers
274
- {
275
- int i=mtl_htoi(parser->token+2);
276
- if (k=STACKPUSH(m,INTTOVAL(i))) return k; // valeur
277
- return STACKPUSH(m,TABGET(stdtypes,STDTYPE_I));
278
- }
279
- else if (parser->token[0]=='"') // gestion des chaines
280
- {
281
- if (k=parser->getstring(m,'"')) return k;
282
- return STACKPUSH(m,TABGET(stdtypes,STDTYPE_S));
283
- }
284
- else
285
- {
286
- PRINTF(m)(LOG_COMPILER,"Compiler : unexpected term '%s'\n",parser->token);
287
- return MTLERR_SN;
288
- }
289
- }
@@ -1,79 +0,0 @@
1
- //-------------------
2
- // Moteur 3d
3
- // version WIN32 et POCKETPC
4
- // Sylvain Huet
5
- // Premiere version : 03/09/2002
6
- // Derniere mise a jour : 05/10/2002
7
- //
8
-
9
- #include <stdio.h>
10
- #include <stdarg.h>
11
- #include <string.h>
12
-
13
- #include "param.h"
14
- #include "filesystem.h"
15
- #include "file.h"
16
-
17
- ///////////////
18
- // File - gestion simple de fichiers
19
-
20
-
21
- File::File(FileSystem *fs)
22
- {
23
- filesystem=fs;
24
- file=NULL;
25
- sizeinternalbuffer=64;
26
- internalbuffer=new char[sizeinternalbuffer];
27
- }
28
-
29
- File::~File()
30
- {
31
- if (file) fclose(file);
32
- delete internalbuffer;
33
- }
34
-
35
- int File::close()
36
- {
37
- if (file) fclose(file);
38
- file=NULL;
39
- return 0;
40
- }
41
-
42
-
43
- int File::openread(const char* name)
44
- {
45
- file=fopen(name,"rb");
46
- if (file) return 0;
47
- return -1;
48
- }
49
-
50
- char* File::getcontent(int *size)
51
- {
52
- if (file==NULL) return NULL;
53
-
54
- fseek(file,0,SEEK_END);
55
- *size=ftell(file);
56
- fseek(file,0,SEEK_SET);
57
-
58
- char* buffer;
59
- buffer=new char[(*size)+1];
60
- fread((void*)buffer,1,*size,file);
61
- buffer[*size]=0;
62
- close();
63
- return buffer;
64
- }
65
- int File::openwrite(const char* name)
66
- {
67
- file=fopen(name,"wb");
68
- if (file) return 0;
69
- return -1;
70
- }
71
- int File::write(const char *outbuf,int size)
72
- {
73
- if (file==NULL) return 0;
74
-
75
- int k=fwrite((void*)outbuf,1,size,file);
76
- if (k<0) return -1;
77
- fflush(file);
78
- return 0;
79
- }
@@ -1,85 +0,0 @@
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
- #include <stdio.h>
10
- #include <string.h>
11
-
12
- #include "param.h"
13
- #include "terminal.h"
14
- #include "prodbuffer.h"
15
- #include "memory.h"
16
- #include "util.h"
17
- #include "interpreter.h"
18
- #include "compiler.h"
19
-
20
- #include"../vbc_str.h"
21
-
22
- void displaybc(Memory* m,char* p)
23
- {
24
- PRINTF(m)(LOG_DEVCORE,"dump %x\n",p);
25
- const char* spaces=" ";
26
- int ind=0;
27
- while(1)
28
- {
29
- int i=*p;
30
- if ((i<0)||(i>=MaxOpcode)) PRINTF(m)(LOG_DEVCORE,"%4d ??\n",ind);
31
- else if ((i==OPint))
32
- {
33
- p++;
34
- int v=(p[0]&255)+((p[1]&255)<<8)+((p[2]&255)<<16)+((p[3]&255)<<24);
35
- PRINTF(m)(LOG_DEVCORE,"%4d %s%s %d\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]),v);
36
- ind+=4;
37
- p+=3;
38
- }
39
- else if ((i==OPgoto)||(i==OPelse))
40
- {
41
- p++;
42
- int v=(p[0]&255)+((p[1]&255)<<8);
43
- PRINTF(m)(LOG_DEVCORE,"%4d %s%s %d\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]),v);
44
- ind+=2;
45
- p+=1;
46
- } else if ((i==OPgetlocalb)||(i==OPgetglobalb)||(i==OPfetchb)||(i==OPdeftabb)||(i==OPsetlocalb)||
47
- (i==OPmktabb)||(i==OPsetstructb)||(i==OPcallrb)||(i==OPintb))
48
- {
49
- p++;
50
- int v=p[0]&255;
51
- PRINTF(m)(LOG_DEVCORE,"%4d %s%s %d\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]),v);
52
- ind++;
53
- }
54
- else if (i==OPret)
55
- {
56
- PRINTF(m)(LOG_DEVCORE,"%4d %s%s\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]));
57
- return;
58
- }
59
- else PRINTF(m)(LOG_DEVCORE,"%4d %s%s\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]));
60
- ind++;
61
- p++;
62
- }
63
- }
64
-
65
-
66
- Interpreter::Interpreter(Memory* memory)
67
- {
68
- m=memory;
69
- output=new Prodbuffer();
70
- };
71
-
72
- Interpreter::~Interpreter()
73
- {
74
- delete output;
75
- };
76
-
77
- int Interpreter::start()
78
- {
79
- return 0;
80
- }
81
-
82
- void Interpreter::stop()
83
- {
84
- }
85
-
@@ -1,121 +0,0 @@
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"../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