source: dev/trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp@ 204

Last change on this file since 204 was 199, checked in by dai_9181, 17 years ago
File size: 17.3 KB
Line 
1#include <jenga/include/smoothie/Smoothie.h>
2#include <jenga/include/smoothie/LexicalAnalysis.h>
3
4#include <Compiler.h>
5
6#include "../BasicCompiler_Common/common.h"
7
8CONSTINFO *GetNewConstHash(char *name){
9 extern int cp;
10 CONSTINFO *pci;
11
12 int key;
13 key=hash_default(name);
14
15 extern CONSTINFO **ppConstHash;
16 if(ppConstHash[key]){
17 pci=ppConstHash[key];
18 while(1){
19 if(lstrcmp(pci->name,name)==0){
20 //重複エラー
21 SetError(15,name,cp);
22 return 0;
23 }
24
25 if(pci->pNextData==0){
26 pci->pNextData=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
27 break;
28 }
29 pci=pci->pNextData;
30 }
31 pci=pci->pNextData;
32 }
33 else{
34 ppConstHash[key]=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
35 pci=ppConstHash[key];
36 }
37
38 return pci;
39}
40
41// マクロ定数を追加するための関数
42void AddConstData(char *Command){
43 extern HANDLE hHeap;
44 extern int cp;
45 int i,i2;
46 char temporary[VN_SIZE];
47
48 for(i=0;;i++){
49 if(Command[i]=='\0'){
50 SetError(10,"Const",cp);
51 return;
52 }
53 if(Command[i]=='=' || Command[i] == 1 && Command[i+1] == ESC_AS ){
54 //定数定義は新しいクラスモジュール(CDBConst)へ移行
55 // ※この関数はマクロ定数のみを扱う
56 return;
57 }
58 if(Command[i]=='('){
59 temporary[i]=0;
60 break;
61 }
62 temporary[i]=Command[i];
63 }
64
65
66 /////////////////////////////////
67 // 格納位置を計算してpciにセット
68 /////////////////////////////////
69
70 CONSTINFO *pci;
71 pci=GetNewConstHash(temporary);
72 if(!pci) return;
73
74
75
76 ////////////////////
77 // 定数情報を取得
78 ////////////////////
79
80 //定数名
81 pci->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
82 lstrcpy(pci->name,temporary);
83
84 if(Command[i]=='('){
85 pci->ppParm=(char **)HeapAlloc(hHeap,0,1);
86 pci->ParmNum=0;
87 for(i++,i2=0;;i++,i2++){
88 if(Command[i]=='\0'){
89 SetError(1,NULL,cp);
90 return;
91 }
92 if(Command[i]==','||Command[i]==')'){
93 temporary[i2]=0;
94 pci->ppParm=(char **)HeapReAlloc(hHeap,0,pci->ppParm,(pci->ParmNum+1)*sizeof(char *));
95 pci->ppParm[pci->ParmNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
96 lstrcpy(pci->ppParm[pci->ParmNum],temporary);
97 pci->ParmNum++;
98 if(Command[i]==')'){
99 i++;
100 if(Command[i]!='='){
101 SetError(1,NULL,cp);
102 return;
103 }
104 break;
105 }
106
107 i2=-1;
108 continue;
109 }
110 temporary[i2]=Command[i];
111 }
112 }
113 else pci->ParmNum=0;
114
115 //データ
116 lstrcpy(temporary,Command+i+1);
117 if(pci->ParmNum){
118 pci->StrValue=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
119 lstrcpy(pci->StrValue,temporary);
120 }
121 else if(temporary[0]=='\"'){
122 //文字列定数
123 RemoveStringQuotes(temporary);
124 i2=lstrlen(temporary);
125
126 pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
127 memcpy(pci->StrValue,temporary,i2);
128 pci->StrValue[i2]=0;
129
130 pci->DblValue=(double)i2;
131
132 pci->type=DEF_STRING;
133 pci->lpIndex=-1;
134 }
135 else if((temporary[0]=='e'||temporary[0]=='E')&&
136 (temporary[1]=='x'||temporary[1]=='X')&&
137 temporary[2]=='\"'){
138 //文字列定数
139 RemoveStringQuotes(temporary+2);
140 i2=FormatString_EscapeSequence(temporary+2);
141 pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
142 memcpy(pci->StrValue,temporary+2,i2);
143 pci->StrValue[i2]=0;
144
145 pci->DblValue=(double)i2;
146
147 pci->type=DEF_STRING;
148 pci->lpIndex=-1;
149 }
150 else{
151 //数値定数
152 _int64 i64data;
153 Type resultType;
154 StaticCalculation(true, temporary,0,&i64data,resultType);
155 pci->type=resultType.GetBasicType();
156 if(IsRealNumberType(pci->type)){
157 //実数型
158 memcpy(&pci->DblValue,&i64data,sizeof(double));
159 }
160 else if(Is64Type(pci->type)){
161 //64ビット型
162 pci->i64Value=i64data;
163 }
164 else if(IsWholeNumberType(pci->type)){
165 //その他整数型
166 pci->DblValue=(double)i64data;
167 }
168
169 pci->StrValue=0;
170 }
171}
172void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){
173 extern int cp;
174 int i=0,i2;
175
176 if(!(buffer[i]==1&&buffer[i+1]==ESC_ENUM)) return;
177 i+=2;
178
179 //列挙体の名前を取得
180 char temporary[VN_SIZE];
181 for(i2=0;;i++,i2++){
182 if(IsCommandDelimitation(buffer[i])){
183 temporary[i2]=0;
184 break;
185 }
186 if(!IsVariableChar(buffer[i])){
187 SetError(1,NULL,i);
188 break;
189 }
190 temporary[i2]=buffer[i];
191 }
192
193 if(buffer[i]=='\0'){
194 SetError(22,"Enum",cp);
195 return;
196 }
197
198 int NextValue=0;
199 while(1){
200 i++;
201
202 if(buffer[i]==1&&buffer[i+1]==ESC_ENDENUM) break;
203
204 for(i2=0;;i2++,i++){
205 if(IsCommandDelimitation(buffer[i])){
206 temporary[i2]=0;
207 break;
208 }
209 if(buffer[i]=='='){
210 temporary[i2]=0;
211 break;
212 }
213 temporary[i2]=buffer[i];
214 }
215 if(temporary[0]=='\0'){
216 if(buffer[i]=='\0'){
217 SetError(22,"Enum",cp);
218 break;
219 }
220 continue;
221 }
222
223 if(buffer[i]!='='){
224 NextValue++;
225 }
226 else{
227 char temp2[VN_SIZE];
228 for(i++,i2=0;;i2++,i++){
229 if(IsCommandDelimitation(buffer[i])){
230 temp2[i2]=0;
231 break;
232 }
233 temp2[i2]=buffer[i];
234 }
235
236 _int64 i64data;
237 StaticCalculation(true, temp2,DEF_LONG,&i64data,Type());
238 NextValue=(int)i64data;
239 }
240
241 //定数を追加
242 CDBConst::obj.AddConst( namespaceScopes, temporary, NextValue);
243 }
244}
245bool GetConstInfo(void){
246 ////////////////////////////////////////////
247 // Const命令の情報を取得
248 ////////////////////////////////////////////
249
250 int i2;
251 char temporary[1024];
252
253 // 名前空間管理
254 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
255 namespaceScopes.clear();
256
257 //定数に関する情報
258 extern CONSTINFO **ppConstHash;
259 ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));
260
261 extern char *basbuf;
262 for(int i=0;;i++){
263 if( basbuf[i] == '\0' ) break;
264
265 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
266 for(i+=2,i2=0;;i2++,i++){
267 if( IsCommandDelimitation( basbuf[i] ) ){
268 temporary[i2]=0;
269 break;
270 }
271 temporary[i2]=basbuf[i];
272 }
273 namespaceScopes.push_back( temporary );
274
275 continue;
276 }
277 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
278 if( namespaceScopes.size() <= 0 ){
279 SetError(12, "End Namespace", i );
280 }
281 else{
282 namespaceScopes.pop_back();
283 }
284
285 i += 2;
286 continue;
287 }
288
289 if( basbuf[i] == 1 ){
290 if(basbuf[i]==1&&basbuf[i+1]==ESC_CONST){
291 i+=2;
292
293 extern int cp;
294 cp=i; //エラー用
295
296
297 if(basbuf[i]==1&&basbuf[i+1]==ESC_ENUM){
298 AddConstEnum( namespaceScopes, basbuf+i);
299 continue;
300 }
301
302 for(i2=0;;i++,i2++){
303 if(basbuf[i]=='\"'){
304 temporary[i2]=basbuf[i];
305 for(i++,i2++;;i++,i2++){
306 temporary[i2]=basbuf[i];
307 if(basbuf[i]=='\"') break;
308 }
309 continue;
310 }
311 if(IsCommandDelimitation(basbuf[i])){
312 temporary[i2]=0;
313 break;
314 }
315 temporary[i2]=basbuf[i];
316 }
317 CDBConst::obj.Add( namespaceScopes, temporary);
318 if(basbuf[i]=='\0') break;
319 }
320 else{
321 int result = JumpStatement( basbuf, i );
322 if( result == -1 ){
323 //エラー
324 return false;
325 }
326 else if( result == 1 ){
327 //ジャンプした場合
328 i--;
329 }
330 }
331 }
332 }
333 return true;
334}
335
336char ConstructorDestructorSchedule[MAX_PATH];
337void MakeConstructorAndDestructor(char *buffer,int nowLine,char *ClassName){
338 int i,i2;
339 char temporary[MAX_PATH],*pTemp;
340 BOOL bConstructor,bDestructor;
341
342 ConstructorDestructorSchedule[0]=0;
343 bConstructor=0;
344 bDestructor=0;
345
346 for(i=nowLine;;i++){
347 if(buffer[i]=='\0') break;
348 if(buffer[i]==1&&buffer[i+1]==ESC_ENDCLASS){
349 if((!bConstructor)||(!bDestructor)){
350 pTemp=ConstructorDestructorSchedule;
351
352 lstrcpy(pTemp,"Public:");
353
354 if(!bConstructor){
355 //コンストラクタが無いときは生成する
356 sprintf(pTemp+lstrlen(pTemp),"%c%c%s():%c%c:",
357 1,ESC_SUB,
358 ClassName,
359 1,ESC_ENDSUB);
360 }
361
362 if(!bDestructor){
363 //デストラクタが無いときは生成する
364 sprintf(pTemp+lstrlen(pTemp),"%c%c~%s():%c%c:",
365 1,ESC_SUB,
366 ClassName,
367 1,ESC_ENDSUB);
368 }
369 }
370 break;
371 }
372
373 if(buffer[i]==1&&(buffer[i+1]==ESC_SUB||buffer[i+1]==ESC_FUNCTION)){
374 i+=2;
375 while(IsBlank(buffer[i])) i++;
376 if(buffer[i]=='~'){
377 //デストラクタ
378 bDestructor=1;
379 }
380 else{
381 //コンストラクタかどうかをチェック
382 for(i2=0;;i++,i2++){
383 if(!IsVariableChar(buffer[i])){
384 temporary[i2]=0;
385 break;
386 }
387 temporary[i2]=buffer[i];
388 }
389 if(lstrcmp(temporary,ClassName)==0) bConstructor=1;
390 }
391 }
392 }
393}
394void ChangeCommand(char *buffer,int nowLine,char *Command){
395 int i,i2,IsStr;
396 unsigned _int16 ComNum;
397 char com[8192],pam[8192];
398
399 static int nCountOfNonGlobalScope = 0;
400
401 if(Command[0]==1){
402 switch(Command[1]){
403 case ESC_SELECTCASE:
404 case ESC_CASE:
405 KillStringSpaces(Command+2);
406 break;
407 case ESC_WITH:
408 KillStringSpaces(Command+2);
409 break;
410 case ESC_TYPEDEF:
411 KillStringSpaces(Command+2);
412 break;
413 case ESC_DECLARE:
414 KillStringSpaces(Command+2);
415 break;
416 case ESC_IF:
417 KillStringSpaces(Command+2);
418 break;
419
420 case ESC_CLASS:
421 KillStringSpaces(Command+2);
422 i2 = 2;
423 if( Command[i2] == 1 && Command[i2+1] == ESC_ENUM ){
424 i2 += 2;
425 }
426 else if( memicmp( Command + i2, "Blittable(", 10 ) == 0 ){
427 i2 += 10;
428 i2 = JumpStringInPare(Command,i2)+1;
429 }
430
431 //コンストラクタ、デストラクタを暗黙的に生成
432 MakeConstructorAndDestructor(buffer,nowLine,Command + i2);
433 break;
434 case ESC_INTERFACE:
435 KillStringSpaces(Command+2);
436 break;
437 case ESC_ENDCLASS:
438 if(ConstructorDestructorSchedule[0]){
439 //生成されたコンストラクタ、デストラクタを挿入
440 sprintf(Command,"%s%c%c",ConstructorDestructorSchedule,1,ESC_ENDCLASS);
441 }
442 break;
443
444 case ESC_TYPE:
445 KillStringSpaces(Command+2);
446 break;
447
448 case ESC_CONST:
449 KillStringSpaces(Command+2);
450 if( Command[2] == 1 && Command[3] == ESC_ENUM ){
451 nCountOfNonGlobalScope++;
452 }
453 break;
454
455 case ESC_ENUM:
456 nCountOfNonGlobalScope++;
457 KillStringSpaces(Command+2);
458 break;
459
460 case ESC_ENDENUM:
461 nCountOfNonGlobalScope--;
462 break;
463
464 case ESC_INHERITS:
465 case ESC_VIRTUAL:
466 case ESC_OVERRIDE:
467 case ESC_ABSTRACT:
468 case ESC_SUB:
469 case ESC_FUNCTION:
470 case ESC_MACRO:
471 case ESC_STATIC:
472 case ESC_NAMESPACE:
473 case ESC_IMPORTS:
474 KillStringSpaces(Command+2);
475 break;
476 }
477 return;
478 }
479
480 bool isPare = false;
481 for(i=0;;i++){
482 if(Command[i]==' '||Command[i]=='\t'||Command[i]=='('||Command[i]=='\"'||Command[i]=='@'||Command[i]=='-'){
483 com[i]=0;
484 while(Command[i]==' '||Command[i]=='\t') i++;
485 if( Command[i] == '(' ) isPare = true;
486 break;
487 }
488 if(Command[i]=='='){
489 KillStringSpaces(Command);
490 return;
491 }
492 com[i]=Command[i];
493 if(Command[i]=='\0') break;
494 }
495
496 //マクロによるコマンド
497 i2=1;
498 if( nCountOfNonGlobalScope == 0 ){
499 //グローバル
500 if(lstrcmpi(com,"Open")==0) ComOpen(Command+i,pam,nowLine);
501 else if(lstrcmpi(com,"Close")==0) ComClose(Command+i,pam);
502 else if(lstrcmpi(com,"Field")==0||
503 lstrcmpi(com,"Get")==0||
504 lstrcmpi(com,"Put")==0) ComField(Command+i,pam);
505 else if(lstrcmpi(com,"Line")==0) ComLine(Command+i,pam,nowLine);
506 else if(lstrcmpi(com,"Circle")==0) ComCircle(Command+i,pam,nowLine);
507 else if(lstrcmpi(com,"PSet")==0) ComPSet(Command+i,pam,nowLine);
508 else if(lstrcmpi(com,"Paint")==0) ComPaint(Command+i,pam,nowLine);
509
510 else if(
511 lstrcmpi(com,"EXEC")==0||
512 lstrcmpi(com,"INPUT")==0||
513 lstrcmpi(com,"PRINT")==0||
514 lstrcmpi(com,"RANDOMIZE")==0||
515 ( lstrcmpi(com,"WRITE")==0 && isPare == false )||
516 lstrcmpi(com,"MSGBOX")==0||
517 lstrcmpi(com,"WINDOW")==0||
518 lstrcmpi(com,"DELWND")==0||
519 lstrcmpi(com,"INSMENU")==0||
520 lstrcmpi(com,"CHDIR")==0||
521 lstrcmpi(com,"MKDIR")==0||
522 lstrcmpi(com,"KILL")==0||
523 lstrcmpi(com,"CLS")==0||
524 lstrcmpi(com,"COLOR")==0||
525 lstrcmpi(com,"LOCATE")==0
526 ){
527 KillSpaces(Command+i,pam);
528
529 //大文字に変換
530 CharUpper(com);
531
532 sprintf(Command,"%s(%s)",com,pam);
533 return;
534 }
535
536 else i2=0;
537 }
538 else i2=0;
539 if(i2){
540 //大文字に変換
541 CharUpper(com);
542
543 sprintf(Command,"%s(%s)",com,pam);
544 return;
545 }
546
547
548
549 //コンパイラに搭載されるコマンド
550 if(lstrcmpi(com,"Do")==0){
551 KillSpaces(Command+i,pam);
552 ComNum=COM_DO;
553 }
554 else if(lstrcmpi(com,"goto")==0){
555 KillSpaces(Command+i,pam);
556 ComNum=COM_GOTO;
557 }
558 else if(lstrcmpi(com,"gosub")==0){
559 KillSpaces(Command+i,pam);
560 ComNum=COM_GOSUB;
561 }
562 else if(lstrcmpi(com,"Loop")==0){
563 if((Command[i]=='w'||Command[i]=='W')&&(Command[i+1]=='h'||Command[i+1]=='H')&&(Command[i+2]=='i'||Command[i+2]=='I')&&(Command[i+3]=='l'||Command[i+3]=='L')&&(Command[i+4]=='e'||Command[i+4]=='E')){
564 lstrcpy(pam,"0,");
565 KillSpaces(Command+i+5,pam+2);
566 }
567 else if((Command[i]=='u'||Command[i]=='U')&&(Command[i+1]=='n'||Command[i+1]=='N')&&(Command[i+2]=='t'||Command[i+2]=='T')&&(Command[i+3]=='i'||Command[i+3]=='I')&&(Command[i+4]=='l'||Command[i+4]=='L')){
568 lstrcpy(pam,"1,");
569 KillSpaces(Command+i+5,pam+2);
570 }
571 else pam[0]=0;
572 ComNum=COM_LOOP;
573 }
574 else if(lstrcmpi(com,"For")==0){
575 for(i2=0,IsStr=0;;i++,i2++){
576 while(Command[i]==' '||Command[i]=='\t') i++;
577 if(Command[i]=='\"') IsStr^=1;
578 if((Command[i-1]==' '||Command[i-1]=='\t')&&(Command[i]=='t'||Command[i]=='T')&&(Command[i+1]=='o'||Command[i+1]=='O')&&(Command[i+2]==' '||Command[i+2]=='\t')&&IsStr==0){
579 pam[i2]=',';
580 break;
581 }
582 pam[i2]=Command[i];
583 if(Command[i]=='\0') break;
584 }
585 if(Command[i]){
586 for(i+=3,i2++,IsStr=0;;i++,i2++){
587 while(Command[i]==' '||Command[i]=='\t') i++;
588 if((Command[i-1]==' '||Command[i-1]=='\t')&&(Command[i]=='s'||Command[i]=='S')&&(Command[i+1]=='t'||Command[i+1]=='T')&&(Command[i+2]=='e'||Command[i+2]=='E')&&(Command[i+3]=='p'||Command[i+3]=='P')&&(Command[i+4]==' '||Command[i+4]=='\t')){
589 pam[i2]=',';
590 i+=4;
591 continue;
592 }
593 pam[i2]=Command[i];
594 if(Command[i]=='\0') break;
595 }
596 }
597 ComNum=COM_FOR;
598 }
599 else if(lstrcmpi(com,"Next")==0){
600 KillSpaces(Command+i,pam);
601 ComNum=COM_NEXT;
602 }
603 else if(lstrcmpi(com,"Return")==0){
604 KillSpaces(Command+i,pam);
605 ComNum=COM_RETURN;
606 }
607 else if(lstrcmpi(com,"While")==0){
608 KillSpaces(Command+i,pam);
609 ComNum=COM_WHILE;
610 }
611 else if(lstrcmpi(com,"Wend")==0){
612 pam[0]=0;
613 ComNum=COM_WEND;
614 }
615
616 //変数、データ操作
617 else if(lstrcmpi(com,"dim")==0){
618 KillSpaces(Command+i,pam);
619 ComNum=COM_DIM;
620 }
621 else if(lstrcmpi(com,"Delete")==0){
622 KillSpaces(Command+i,pam);
623 ComNum=COM_DELETE;
624 }
625 else if( lstrcmpi( com, "_System_SweepingDelete" ) == 0 ){
626 KillSpaces(Command+i,pam);
627 ComNum=COM_SWEEPINGDELETE;
628 }
629
630 //その他
631 else if(lstrcmpi(com,"Debug")==0){
632 pam[0]=0;
633 ComNum=COM_DEBUG;
634 }
635 else if(lstrcmpi(com,"let")==0){
636 KillSpaces(Command+i,pam);
637 ComNum=COM_LET;
638 }
639 else if(lstrcmpi(com,"rem")==0){
640 Command[0]=0;
641 return;
642 }
643
644 //ポインタ
645 else if(lstrcmpi(com,"SetDouble")==0){
646 KillSpaces(Command+i,pam);
647 ComNum=COM_SETDOUBLE;
648 }
649 else if(lstrcmpi(com,"SetSingle")==0){
650 KillSpaces(Command+i,pam);
651 ComNum=COM_SETSINGLE;
652 }
653 else if(lstrcmpi(com,"SetQWord")==0){
654 KillSpaces(Command+i,pam);
655 ComNum=COM_SETQWORD;
656 }
657 else if(lstrcmpi(com,"SetDWord")==0){
658 KillSpaces(Command+i,pam);
659 ComNum=COM_SETDWORD;
660 }
661 else if(lstrcmpi(com,"SetWord")==0){
662 KillSpaces(Command+i,pam);
663 ComNum=COM_SETWORD;
664 }
665 else if(lstrcmpi(com,"SetByte")==0){
666 KillSpaces(Command+i,pam);
667 ComNum=COM_SETBYTE;
668 }
669
670 else{
671 //その他のコマンド(一般コード)
672 lstrcpy(com,Command);
673 KillSpaces(com,Command);
674 return;
675 }
676
677 i=lstrlen(pam);
678 while(pam[i-1]==' '||pam[i-1]=='\t') i--;
679 pam[i]=0;
680 if(pam[0]) sprintf(Command,"%c%c%s",HIBYTE(ComNum),LOBYTE(ComNum),pam);
681 else sprintf(Command,"%c%c",HIBYTE(ComNum),LOBYTE(ComNum));
682
683 return;
684}
685
686void ChangeCommandToCode(char *buffer){
687 extern HANDLE hHeap;
688 int i,i2,i3,IsStr,CommandBufferSize;
689 char *temporary,*tempBase,temp2[VN_SIZE],*lpCommand;
690
691 tempBase=(char *)HeapAlloc(hHeap,0,(lstrlen(buffer)+1)*2+8192);
692 temporary=tempBase+1;
693 temporary[0]=0;
694 i=0;
695 i3=0;
696
697 CommandBufferSize=512;
698 lpCommand=(char *)HeapAlloc(hHeap,0,CommandBufferSize);
699
700 while(1){
701 i2=0;
702 while(buffer[i]==' '||buffer[i]=='\t') i++;
703 while(buffer[i]>='0'&&buffer[i]<='9'){
704 temp2[i2]=buffer[i];
705 i++;
706 i2++;
707 }
708 temp2[i2]=0;
709 while(buffer[i]==' '||buffer[i]=='\t') i++;
710 for(i2=0,IsStr=0;;i++,i2++){
711 if(i2>=CommandBufferSize){ //バッファ領域が足りなくなった場合はバッファを増量する
712 CommandBufferSize+=512;
713 lpCommand=(char *)HeapReAlloc(hHeap,0,lpCommand,CommandBufferSize);
714 }
715 if(buffer[i]=='\"') IsStr^=1;
716 if(buffer[i]=='\n'||(buffer[i]==':'&&IsStr==0)||buffer[i]=='\0'){
717 lpCommand[i2]=0;
718
719 if(temp2[0]){
720 //行番号ラベル
721 sprintf(temporary+i3,"%c%c%s,",1,ESC_LINENUM,temp2);
722 i3+=lstrlen(temporary+i3);
723
724 temp2[0]=0;
725 }
726
727 //命令コードへ変換
728 if(i2){
729 //エラー用
730 extern int cp;
731 cp=i;
732
733 ChangeCommand(buffer,i,lpCommand);
734
735 lstrcpy(temporary+i3,lpCommand);
736 i3+=lstrlen(temporary+i3);
737 }
738
739 if(!(lpCommand[0]=='\0'&&buffer[i]==':')){
740 temporary[i3++]=buffer[i];
741 temporary[i3]=0;
742 }
743
744 if(buffer[i]=='\n'){
745 i++;
746 break;
747 }
748 else if(buffer[i]==':'){
749 while(buffer[i+1]==' '||buffer[i+1]=='\t') i++;
750 }
751 if(buffer[i]=='\0') break;
752 i2=-1;
753 continue;
754 }
755 lpCommand[i2]=buffer[i];
756 }
757 if(buffer[i]=='\0') break;
758 }
759 HeapDefaultFree(lpCommand);
760 lstrcpy(buffer,temporary);
761
762 HeapDefaultFree(tempBase);
763}
Note: See TracBrowser for help on using the repository browser.