BASIC compiler/interpreter for PIC32MX/MZ-80K
リビジョン | 6fd552c51671d35f2ecc1f8969324ec7ed99e3f3 (tree) |
---|---|
日時 | 2019-02-13 05:47:30 |
作者 | Katsumi <kmorimatsu@sour...> |
コミッター | Katsumi |
Debug CMPTYPE_STATIC_METHOD
@@ -790,6 +790,7 @@ char* static_method(char type){ | ||
790 | 790 | // Check class name |
791 | 791 | i=check_var_name(); |
792 | 792 | if (i<65536) return ERR_SYNTAX; |
793 | + record[0]=i; | |
793 | 794 | // Check if the class exists |
794 | 795 | cmpdata_reset(); |
795 | 796 | while(data=cmpdata_find(CMPDATA_CLASS)){ |
@@ -799,7 +800,6 @@ char* static_method(char type){ | ||
799 | 800 | break; |
800 | 801 | } |
801 | 802 | } |
802 | - record[0]=i; | |
803 | 803 | // Check '::' |
804 | 804 | if (g_source[g_srcpos]!=':') return ERR_SYNTAX; |
805 | 805 | g_srcpos++; |
@@ -844,7 +844,7 @@ char* static_method(char type){ | ||
844 | 844 | // label2: |
845 | 845 | // Register CMPDATA if required. |
846 | 846 | if (!data) { |
847 | - cmpdata_insert(CMPDATA_UNSOLVED,CMPTYPE_STATIC_METHOD,(int*)record[0],3); | |
847 | + cmpdata_insert(CMPDATA_UNSOLVED,CMPTYPE_STATIC_METHOD,(int*)&record[0],3); | |
848 | 848 | g_allow_shift_obj=0; |
849 | 849 | } |
850 | 850 | // Remove stack |
@@ -32,7 +32,8 @@ const unsigned char _debug_filename[] __attribute__((address(FILENAME_FLASH_ADDR | ||
32 | 32 | |
33 | 33 | static const char initext[]; |
34 | 34 | static const char bastext[]; |
35 | -static const char classtext[]; | |
35 | +static const char class1text[]; | |
36 | +static const char class2text[]; | |
36 | 37 | |
37 | 38 | static char* readtext; |
38 | 39 | static int filepos; |
@@ -130,10 +131,12 @@ FSFILE* FSfopen(const char * fileName, const char *mode){ | ||
130 | 131 | // INI file |
131 | 132 | readtext=(char*)&initext[0]; |
132 | 133 | } else if (fileName[i+1]=='B' && fileName[i+2]=='A' && fileName[i+3]=='S') { |
133 | - // BAS file | |
134 | + // Select BAS file | |
134 | 135 | if (fileName[i-6]=='C' && fileName[i-5]=='L' && fileName[i-4]=='A' && |
135 | - fileName[i-3]=='S' && fileName[i-2]=='S' && fileName[i-1]=='1') { | |
136 | - readtext=(char*)&classtext[0]; | |
136 | + fileName[i-3]=='S' && fileName[i-2]=='S') { | |
137 | + if (fileName[i-1]=='1') readtext=(char*)&class1text[0]; | |
138 | + else if (fileName[i-1]=='2') readtext=(char*)&class2text[0]; | |
139 | + else readtext=(char*)&bastext[0]; | |
137 | 140 | } else { |
138 | 141 | readtext=(char*)&bastext[0]; |
139 | 142 | } |
@@ -228,36 +231,29 @@ static const char initext[]= | ||
228 | 231 | static const char bastext[]= |
229 | 232 | "USECLASS CLASS1\n" |
230 | 233 | "CLS\n" |
231 | -"dim o(95),v(95)\n" | |
232 | -"for i=1 to 85\n" | |
233 | -" o(i)=new(CLASS1)\n" | |
234 | -"next\n" | |
235 | -"for i=1 to 100\n" | |
236 | -" for j=1 to 85\n" | |
237 | -" v(j)=rnd()\n" | |
238 | -" o(j).T1=v(j)\n" | |
239 | -" next\n" | |
240 | -" for j=86 to 95\n" | |
241 | -" o(j)=new(CLASS1)\n" | |
242 | -" next\n" | |
243 | -" for j=86 to 95\n" | |
244 | -" DELETE o(j)\n" | |
245 | -" next\n" | |
246 | -" for j=1 to 85\n" | |
247 | -" if v(j)!=o(j).T1 then print \"ERR\":end\n" | |
248 | -" next\n" | |
249 | -"next\n" | |
250 | -"print \"OK\"\n" | |
251 | -"\n" | |
234 | +"a=new(CLASS1)" | |
235 | +"print a.T1()\n" | |
252 | 236 | "\n" |
253 | 237 | "\n" |
254 | 238 | "\n"; |
255 | 239 | |
240 | +static const char class1text[]= | |
241 | +"useclass CLASS2\n" | |
242 | +"field private T2\n" | |
243 | +"method INIT\n" | |
244 | +" T2=new(CLASS2)\n" | |
245 | +" return\n" | |
246 | +"METHOD T1\n" | |
247 | +" return T2.T1()\n" | |
248 | +"method T3\n" | |
249 | +" return 456\n" | |
250 | +"\n" | |
251 | +"\n"; | |
256 | 252 | |
257 | -static const char classtext[]= | |
258 | -"FIELD T1,T2\n" | |
259 | -"METHOD T3\n" | |
260 | -" return 123\n" | |
253 | +static const char class2text[]= | |
254 | +"useclass CLASS1\n" | |
255 | +"method T1\n" | |
256 | +" return CLASS1::T3()\n" | |
261 | 257 | "\n" |
262 | 258 | "\n" |
263 | 259 | "\n" |