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
@@ -16,110 +16,131 @@
16
16
 
17
17
  Prodbuffer::Prodbuffer()
18
18
  {
19
- size=PRODBUFFER_FIRSTSIZE;
20
- buffer=new char[size];
21
- index=0;
19
+ size=PRODBUFFER_FIRSTSIZE;
20
+ buffer=new char[size];
21
+ index=0;
22
22
  };
23
23
 
24
24
  Prodbuffer::~Prodbuffer()
25
25
  {
26
- delete buffer;
26
+ delete buffer;
27
27
  };
28
28
 
29
29
 
30
30
  // initialiation du buffer (à appeler au début de toute nouvelle production)
31
31
  void Prodbuffer::reinit()
32
32
  {
33
- index=0;
33
+ index=0;
34
34
  }
35
35
 
36
36
  void Prodbuffer::bigger()
37
37
  {
38
- char* newbuf=new char[size*2];
39
- memcpy(newbuf,buffer,size);
40
- delete buffer;
41
- size*=2;
42
- buffer=newbuf;
38
+ char* newbuf=new char[size*2];
39
+ memcpy(newbuf,buffer,size);
40
+ delete buffer;
41
+ size*=2;
42
+ buffer=newbuf;
43
43
  }
44
44
 
45
45
  // ajout d'un caractère en fin de buffer
46
46
  void Prodbuffer::addchar(char c)
47
47
  {
48
- if (index>=size) bigger();
49
- buffer[index++]=c;
48
+ if (index>=size)
49
+ {
50
+ bigger();
51
+ }
52
+ buffer[index++]=c;
50
53
  }
51
54
 
52
55
  // printf à la suite du buffer
53
56
  void Prodbuffer::printf(const char *format, ...)
54
57
  {
55
- va_list arglist;
56
- int sizeout;
57
-
58
- va_start(arglist,format);
59
- //while(((sizeout=vsnprintf(buffer+index,size-index-1,format,arglist))<0)||(sizeout>=size-index-1)) bigger();
60
- va_end(arglist);
61
- index+=sizeout;
58
+ va_list arglist;
59
+ int sizeout;
60
+
61
+ va_start(arglist,format);
62
+ while(((sizeout=vsnprintf(buffer+index,size-index-1,format,arglist))<0)||(sizeout>=size-index-1))
63
+ {
64
+ bigger();
65
+ }
66
+ va_end(arglist);
67
+ index+=sizeout;
62
68
  }
63
69
 
64
70
  // ajout d'un entier en fin de buffer
65
71
  void Prodbuffer::addint(int i)
66
72
  {
67
- addchar(i); i>>=8;
68
- addchar(i); i>>=8;
69
- addchar(i); i>>=8;
70
- addchar(i);
73
+ addchar(i);
74
+ i>>=8;
75
+ addchar(i);
76
+ i>>=8;
77
+ addchar(i);
78
+ i>>=8;
79
+ addchar(i);
71
80
  }
72
81
 
73
82
  // ajout d'un short en fin de buffer
74
83
  void Prodbuffer::addshort(int i)
75
84
  {
76
- addchar(i); i>>=8;
77
- addchar(i);
85
+ addchar(i);
86
+ i>>=8;
87
+ addchar(i);
78
88
  }
79
89
 
80
90
  // ajout d'une chaîne
81
91
  void Prodbuffer::addstr(char *src,int len)
82
92
  {
83
93
  // addint(len);
84
- int i; for(i=0;i<len;i++) addchar(*(src++));
94
+ int i;
95
+ for(i=0; i<len; i++)
96
+ {
97
+ addchar(*(src++));
98
+ }
85
99
  }
86
100
 
87
101
  // modification d'un caractère dans le buffer
88
102
  void Prodbuffer::setchar(int ind,char c)
89
103
  {
90
- buffer[ind]=c;
104
+ buffer[ind]=c;
91
105
  }
92
106
 
93
107
  // modification d'un entier dans le buffer
94
108
  void Prodbuffer::setint(int ind,int i)
95
109
  {
96
- setchar(ind,i); i>>=8;
97
- setchar(ind+1,i); i>>=8;
98
- setchar(ind+2,i); i>>=8;
99
- setchar(ind+3,i);
110
+ setchar(ind,i);
111
+ i>>=8;
112
+ setchar(ind+1,i);
113
+ i>>=8;
114
+ setchar(ind+2,i);
115
+ i>>=8;
116
+ setchar(ind+3,i);
100
117
  }
101
118
 
102
119
  // modification d'un short dans le buffer
103
120
  void Prodbuffer::setshort(int ind,int i)
104
121
  {
105
- setchar(ind,i); i>>=8;
106
- setchar(ind+1,i);
122
+ setchar(ind,i);
123
+ i>>=8;
124
+ setchar(ind+1,i);
107
125
  }
108
126
 
109
127
  // diminue la taille actuelle
110
128
  void Prodbuffer::cut(int len)
111
129
  {
112
- if ((len>=0)&&(len<index)) index=len;
130
+ if ((len>=0)&&(len<index))
131
+ {
132
+ index=len;
133
+ }
113
134
  }
114
135
 
115
136
  // retourne la taille actuelle
116
137
  int Prodbuffer::getsize()
117
138
  {
118
- return index;
139
+ return index;
119
140
  }
120
141
 
121
142
  // retourne un pointeur vers le début du buffer
122
143
  char* Prodbuffer::getstart()
123
144
  {
124
- return buffer;
145
+ return buffer;
125
146
  }
@@ -0,0 +1,130 @@
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 "param.h"
10
+ #include <stdio.h>
11
+ #include <stdint.h>
12
+
13
+ #include <stdlib.h>
14
+ #include <string.h>
15
+ #include <time.h>
16
+ #include <math.h>
17
+
18
+
19
+ #include "terminal.h"
20
+ #include "prodbuffer.h"
21
+ #include "memory.h"
22
+ #include "util.h"
23
+ #include "interpreter.h"
24
+ #include "parser.h"
25
+ #include "compiler.h"
26
+
27
+
28
+ // types de base
29
+ #define NBcore 119 /******** A ACTUALISER! ************/
30
+ // mnemonic
31
+ const char* corename[]=
32
+ /* 1*/ {NULL,NULL,NULL,NULL,NULL,"hd","tl","Secholn","Secho","Iecholn", //10
33
+ /* 2*/"Iecho","time_ms","tabnew","abs","min","max","rand","srand", //10+8
34
+ /* 3*/"time","strnew","strset","strcpy","vstrcmp","strfind","strfindrev","strlen", //10+8+8
35
+ /* 4*/"strget","strsub","strcat","tablen","strcatlist","led","motorset","motorget", //10+8+8+8
36
+ /* 5*/"fixarg1","fixarg2","fixarg3","fixarg4","fixarg5","fixarg6","fixarg7","fixarg8", //10+8+8+8+8
37
+ /* 6*/"button2","button3","playStart","playFeed","playStop","recStart","recStop","recVol", //10+8+8+8+8+8
38
+ /* 7*/"load","gc","save","bytecode","loopcb", //10+8+8+8+8+8+5
39
+ /* 8*/"udpStart","udpCb","udpStop","udpSend","tcpOpen","tcpClose","tcpSend","tcpCb","tcpListen","tcpEnable", //10+8+8+8+8+8+5+10
40
+ /* 9*/"envget","envset","sndVol","rfidGet","playTime","sndRefresh","sndWrite","sndRead","sndFeed","sndAmpli", //10+8+8+8+8+8+5+10+10
41
+ /*10*/"netCb","netSend","netState","netMac","netChk","netSetmode","netScan","netAuth","netPmk","netRssi", //10+8+8+8+8+8+5+10+10+10
42
+ /*11*/"netSeqAdd","strgetword","strputword","atoi","htoi","itoa","ctoa","itoh", //10+8+8+8+8+8+5+10+10+10+8
43
+ /*12*/"ctoh","itobin2","listswitch","listswitchstr","corePP","corePush","corePull","coreBit0", //10+8+8+8+8+8+5+10+10+10+8+8
44
+ /*13*/"reboot","flashFirmware","strcmp","adp2wav","wav2adp","alaw2wav","wav2alaw", //10+8+8+8+8+8+5+10+10+10+8+8+7
45
+ /*14*/"crypt","uncrypt","rfidGetList","rfidRead","rfidWrite", //10+8+8+8+8+8+5+10+10+10+8+8+7+5
46
+ /*15*/"i2cRead", "i2cWrite", //10+8+8+8+8+8+5+10+10+10+8+8+7+5+2 => 115
47
+ /*16*/"strright","strcrypt8","loadf","savef"
48
+ };
49
+
50
+ // Opcode
51
+ int coreval[]=
52
+ /* 1*/ {0,0,0,0,0,OPhd,OPtl,OPSecholn,OPSecho,OPIecholn,
53
+ /* 2*/OPIecho,OPtime_ms,OPtabnew,OPabs,OPmin,OPmax,OPrand,OPsrand,
54
+ /* 3*/OPtime,OPstrnew,OPstrset,OPstrcpy,OPvstrcmp,OPstrfind,OPstrfindrev,OPstrlen,
55
+ /* 4*/OPstrget,OPstrsub,OPstrcat,OPtablen,OPstrcatlist,OPled,OPmotorset,OPmotorget,
56
+ /* 5*/OPfixarg,OPfixarg,OPfixarg,OPfixarg,OPfixarg,OPfixarg,OPfixarg,OPfixarg,
57
+ /* 6*/OPbutton2,OPbutton3,OPplayStart,OPplayFeed,OPplayStop,OPrecStart,OPrecStop,OPrecVol,
58
+ /* 7*/OPload,OPgc,OPsave,OPbytecode,OPloopcb,
59
+ /* 8*/OPudpStart,OPudpCb,OPudpStop,OPudpSend,OPtcpOpen,OPtcpClose,OPtcpSend,OPtcpCb,OPtcpListen,OPtcpEnable,
60
+ /* 9*/OPenvget,OPenvset,OPsndVol,OPrfidGet,OPplayTime,OPsndRefresh,OPsndWrite,OPsndRead,OPsndFeed,OPsndAmpli,
61
+ /*10*/OPnetCb,OPnetSend,OPnetState,OPnetMac,OPnetChk,OPnetSetmode,OPnetScan,OPnetAuth,OPnetPmk,OPnetRssi,
62
+ /*11*/OPnetSeqAdd,OPstrgetword,OPstrputword,OPatoi,OPhtoi,OPitoa,OPctoa,OPitoh,
63
+ /*12*/OPctoh,OPitobin2,OPlistswitch,OPlistswitchstr,OPcorePP,OPcorePush,OPcorePull,OPcoreBit0,
64
+ /*13*/OPreboot,OPflashFirmware,OPstrcmp,OPadp2wav,OPwav2adp,OPalaw2wav,OPwav2alaw,
65
+ /*14*/OPcrypt,OPuncrypt,OPrfidGetList,OPrfidRead,OPrfidWrite,
66
+ /*15*/OPi2cRead, OPi2cWrite,
67
+ /*16*/OPstrright,OPstrright,OPstrright,OPstrright,
68
+ };
69
+ // N args
70
+ int corecode[]=
71
+ /* 1*/ {CODE_TYPE,CODE_TYPE,CODE_TYPE,CODE_TYPE,CODE_TYPE,1,1,1,1,1,
72
+ /* 2*/1,0,2,1,2,2,0,1,
73
+ /* 3*/0,1,3,5,5,5,5,1,
74
+ /* 4*/2,3,2,1,1,2,2,1,
75
+ /* 5*/2,2,2,2,2,2,2,2,
76
+ /* 6*/0,0,2,3,0,3,0,2,
77
+ /* 7*/5,0,5,1,1,
78
+ /* 8*/1,1,1,6,2,1,4,1,1,2,
79
+ /* 9*/0,1,1,0,0,0,2,1,3,1,
80
+ /*10*/1,6,0,0,4,3,1,4,2,0,
81
+ /*11*/2,2,3,1,1,1,1,1,
82
+ /*12*/1,1,2,2,0,1,1,2,
83
+ /*13*/2,3,2,5,5,6,6,
84
+ /*14*/5,5,0,2,3,
85
+ /*15*/2,3,
86
+ /*16*/2,3,1,2
87
+ };
88
+ // Proto
89
+ const char* coretype[]=
90
+ /* 1*/ {"I","S","F","Env","Xml","fun[list u0]u0","fun[list u0]list u0","fun[S]S","fun[S]S","fun[u0]u0",
91
+ /* 2*/"fun[u0]u0","fun[]I","fun[u0 I]tab u0","fun[I]I","fun[I I]I","fun[I I]I","fun[]I","fun[I]I",
92
+ /* 3*/"fun[]I","fun[I]S","fun[S I I]S","fun[S I S I I]S","fun[S I S I I]I","fun[S I S I I]I","fun[S I S I I]I","fun[S]I",
93
+ /* 4*/"fun[S I]I","fun[S I I]S","fun[S S]S","fun[tab u0]I","fun[list S]S","fun[I I]I","fun[I I]I","fun[I]I",
94
+ /* 5*/"fun[fun[u0]u100 u0]fun[]u100",
95
+ "fun[fun[u1 u0]u100 u0]fun[u1]u100",
96
+ "fun[fun[u1 u2 u0]u100 u0]fun[u1 u2]u100",
97
+ "fun[fun[u1 u2 u3 u0]u100 u0]fun[u1 u2 u3]u100",
98
+ "fun[fun[u1 u2 u3 u4 u0]u100 u0]fun[u1 u2 u3 u4]u100",
99
+ "fun[fun[u1 u2 u3 u4 u5 u0]u100 u0]fun[u1 u2 u3 u4 u5]u100",
100
+ "fun[fun[u1 u2 u3 u4 u5 u6 u0]u100 u0]fun[u1 u2 u3 u4 u5 u6]u100",
101
+ "fun[fun[u1 u2 u3 u4 u5 u6 u7 u0]u100 u0]fun[u1 u2 u3 u4 u5 u6 u7]u100",
102
+ /* 6*/"fun[]I","fun[]I","fun[I fun[I]I]I","fun[S I I]I","fun[]I","fun[I I fun[S]I]I","fun[]I","fun[S I]I",
103
+ /* 7*/"fun[S I S I I]I","fun[]I","fun[S I S I I]I","fun[S]S","fun[fun[]I]fun[]I",
104
+ /* 8*/"fun[I]I","fun[fun[I S S]I]fun[I S S]I","fun[I]I","fun[I S I S I I]I","fun[S I]I","fun[I]I","fun[I S I I]I","fun[fun[I I S]I]fun[I I S]I","fun[I]I","fun[I I]I",
105
+ /* 9*/"fun[]S","fun[S]S","fun[I]I","fun[]S","fun[]I","fun[]I","fun[I I]I","fun[I]I","fun[S I I]I","fun[I]I",
106
+ /*10*/"fun[fun[S S]I]fun[S S]I","fun[S I I S I I]I","fun[]I","fun[]S","fun[S I I I]I","fun[I S I]I","fun[S]list[S S S I I I I]","fun[[S S S I I I I] I I S][S S S I I I I]","fun[S S]S","fun[]I",
107
+ /*11*/"fun[S I]S","fun[S I]I","fun[S I I]S","fun[S]I","fun[S]I","fun[I]S","fun[I]S","fun[I]S",
108
+ /*12*/"fun[I]S","fun[I]S","fun[list[u0 u1] u0]u1","fun[list[S u1] S]u1","fun[]I","fun[u0]u0","fun[I]I","fun[u0 I]u0",
109
+ /*13*/"fun[I I]I","fun[S I I]I","fun[S S]I","fun[S I S I I]S","fun[S I S I I]S","fun[S I S I I I]S","fun[S I S I I I]S",
110
+ /*14*/"fun[S I I I I]I","fun[S I I I I]I","fun[]list S","fun[S I]S","fun[S I S]I",
111
+ /*15*/"fun[I I]S", "fun[I S I]I",
112
+ /*16*/"fun[S I]S","fun[S I I][S I]","fun[S]S","fun[S S]I"
113
+ };
114
+
115
+
116
+ intptr_t Compiler::addstdlibcore()
117
+ {
118
+ intptr_t k;
119
+ if (k=addnative(NBcore,corename,coreval,corecode,coretype,m))
120
+ {
121
+ return k;
122
+ }
123
+ /* FILE* f=fopen("bc.txt","w");
124
+ for(k=0;k<NBcore;k++)
125
+ {
126
+ if (corename[k]) fprintf(f,"%s%c%s\n",corename[k],9,coretype[k]);
127
+ }
128
+ fclose(f);
129
+ */ return 0;
130
+ }
@@ -0,0 +1,80 @@
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 "resource.h"
10
+
11
+ #include "param.h"
12
+ #include <stdio.h>
13
+ #include <stdlib.h>
14
+ #include <string.h>
15
+ #include <stdint.h>
16
+
17
+ #include "filesystem.h"
18
+ #include "file.h"
19
+ #include "terminal.h"
20
+ #include "memory.h"
21
+ #include <stdarg.h>
22
+
23
+
24
+ Terminal::Terminal(void)
25
+ {
26
+ m=NULL;
27
+ sizeinternalbuffer=64;
28
+ internalbuffer=new char[sizeinternalbuffer];
29
+ }
30
+
31
+ Terminal::~Terminal()
32
+ {
33
+
34
+ }
35
+
36
+
37
+ void Terminal::echo(int msk,char *s)
38
+ {
39
+ if (s)
40
+ {
41
+ if (msk&LOG_USER)
42
+ {
43
+ fprintf(stdout,"%s",s);
44
+ }
45
+ else
46
+ {
47
+ fprintf(stderr,"%s",s);
48
+ }
49
+ }
50
+ }
51
+
52
+ void Terminal::echo(int msk,char* s,int size)
53
+ {
54
+ if (size+1>sizeinternalbuffer)
55
+ {
56
+ delete internalbuffer;
57
+ sizeinternalbuffer=size+1;
58
+ internalbuffer=new char[sizeinternalbuffer];
59
+ }
60
+ memcpy(internalbuffer,s,size);
61
+ internalbuffer[size]=0;
62
+ echo(msk,internalbuffer);
63
+ }
64
+
65
+ void Terminal::printf(int msk,const char *format, ...)
66
+ {
67
+ va_list arglist;
68
+ int sizeout;
69
+ va_start(arglist,format);
70
+ while(((sizeout=vsnprintf(internalbuffer,sizeinternalbuffer-1,format,arglist))<0)||(sizeout>=sizeinternalbuffer-1))
71
+ {
72
+ delete internalbuffer;
73
+ sizeinternalbuffer*=2;
74
+ internalbuffer=new char[sizeinternalbuffer];
75
+ }
76
+ va_end(arglist);
77
+ echo(msk,internalbuffer);
78
+ }
79
+
80
+
@@ -8,6 +8,7 @@
8
8
 
9
9
 
10
10
  #include <stdio.h>
11
+ #include <stdint.h>
11
12
 
12
13
  #include "param.h"
13
14
  #include "filesystem.h"
@@ -21,28 +22,34 @@
21
22
 
22
23
  Util::Util(Memory* mem)
23
24
  {
24
- m=mem;
25
- compiler=new Compiler(m);
26
- interpreter=new Interpreter(m);
25
+ m=mem;
26
+ compiler=new Compiler(m);
27
+ interpreter=new Interpreter(m);
27
28
  }
28
29
 
29
30
  Util::~Util()
30
31
  {
31
- delete interpreter;
32
- delete compiler;
32
+ delete interpreter;
33
+ delete compiler;
33
34
  }
34
35
 
35
36
  void Util::stop()
36
37
  {
37
- interpreter->stop();
38
- compiler->stop();
38
+ interpreter->stop();
39
+ compiler->stop();
39
40
  }
40
41
 
41
42
  int Util::start()
42
43
  {
43
- int k;
44
- if (k=compiler->start()) return k;
45
- if (k=interpreter->start()) return k;
46
- return 0;
44
+ int k;
45
+ if (k=compiler->start())
46
+ {
47
+ return k;
48
+ }
49
+ if (k=interpreter->start())
50
+ {
51
+ return k;
52
+ }
53
+ return 0;
47
54
  }
48
55