source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/Compile.cpp@ 668

Last change on this file since 668 was 668, checked in by dai_9181, 16 years ago

NamespaceSupporter::ClearImportedNamespacesを追加。
NamespaceSupporter::GetImportedNamespacesをconstにした。

File size: 19.5 KB
Line 
1#include "stdafx.h"
2
3#include <LexicalScope.h>
4#include <CodeGenerator.h>
5#include <Compiler.h>
6
7#include "../BasicCompiler_Common/common.h"
8
9#ifdef _AMD64_
10#include "../compiler_x64/opcode.h"
11#else
12#include "../compiler_x86/opcode.h"
13#endif
14
15//With情報
16WITHINFO WithInfo;
17
18//デバッグ用行番号情報
19SourceLines oldSourceLines;
20
21// オブジェクトモジュールリストに類似したソースコードリスト
22BasicSources sourcesLinkRelationalObjectModule;
23
24
25
26///////////////////////////////////////////////////
27// トークンを取得
28///////////////////////////////////////////////////
29void GetIdentifierToken( char *token, const char *source, int &pos )
30{
31 for( int i=0; ; i++, pos++ ){
32 if( ! IsVariableChar( source[pos] ) ){
33 token[i] = 0;
34 break;
35 }
36 token[i] = source[pos];
37 }
38}
39void GetCommandToken( char *token, const char *source, int &pos )
40{
41 for( int i=0; ; i++, pos++ ){
42 if( IsCommandDelimitation( source[pos] ) ){
43 token[i] = 0;
44 break;
45 }
46 token[i] = source[pos];
47 }
48}
49void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence )
50{
51 for( int i=0; ; i++, pos++ ){
52 if( isEscapeSequence )
53 {
54 if( source[pos] == 1 && source[pos+1] == delimitation )
55 {
56 token[i] = 0;
57 pos++;
58 break;
59 }
60 }
61 else
62 {
63 if( source[pos] == delimitation )
64 {
65 token[i] = 0;
66 break;
67 }
68 }
69
70 token[i] = source[pos];
71
72 if( source[pos] == '\0' )
73 {
74 break;
75 }
76 }
77}
78
79
80///////////////////////////////////////////////////
81// ジェネリクスのクラス型記述を分析
82///////////////////////////////////////////////////
83void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass, Jenga::Common::Strings *pTypeParameterBaseClassNames )
84{
85 if( isDefiningClass )
86 {
87 if( !pTypeParameterBaseClassNames )
88 {
89 compiler.errorMessenger.OutputFatalError();
90 }
91 pTypeParameterBaseClassNames->clear();
92 }
93
94 int i = 0;
95 typeParameters.clear();
96
97 //クラス名を取得
98 GetIdentifierToken( className, fullName, i );
99
100
101 /////////////////////////////////////////////////////////
102 // ☆★☆ ジェネリクスサポート ☆★☆
103 if( fullName[i] == '<' )
104 {
105 while( true )
106 {
107 i++;
108
109 // 型パラメータを取得
110 char temporary[VN_SIZE];
111 GetIdentifierToken( temporary, fullName, i );
112 if( temporary[0] == '\0' )
113 {
114 extern int cp;
115 compiler.errorMessenger.Output(1,NULL,cp);
116 }
117 typeParameters.push_back( temporary );
118
119 if( isDefiningClass )
120 {
121 // クラス定義中にこの関数が呼び出されたとき
122
123 if( fullName[i] == 1 && fullName[i+1] == ESC_AS )
124 {
125 // 型パラメータの制約クラスを取得
126 i += 2;
127 GetIdentifierToken( temporary, fullName, i );
128 if( temporary[0] == '\0' )
129 {
130 extern int cp;
131 compiler.errorMessenger.Output(1,NULL,cp);
132 }
133 }
134 else
135 {
136 temporary[0] = 0;
137 }
138 pTypeParameterBaseClassNames->push_back( temporary );
139 }
140
141 if( fullName[i] == ',' )
142 {
143 continue;
144 }
145 else if( fullName[i] == '>' )
146 {
147 break;
148 }
149 else
150 {
151 extern int cp;
152 compiler.errorMessenger.Output(1,NULL,cp);
153 }
154 }
155 }
156 /////////////////////////////////////////////////////////
157}
158
159
160///////////////////////////////////////////////////
161// 対になっているステートメントを飛び越す
162// ※グローバル領域用
163///////////////////////////////////////////////////
164int JumpStatement(const char *source, int &pos){
165 if( source[pos] != 1 ) return 0;
166
167 if( ! IsCommandDelimitation( source[pos - 1] ) ){
168 //直前がコマンド区切りではない場合
169 return 0;
170 }
171
172 char cStatement = source[pos + 1];
173
174 char cEnd = GetEndXXXCommand( cStatement );
175 if( cEnd == 0 ) return 0;
176
177 pos += 2;
178 while( ! ( source[pos] == 1 && source[pos + 1] == cEnd ) ){
179
180 if( source[pos] == '\0' ){
181 char temporary[64];
182 GetDefaultNameFromES( cStatement, temporary );
183 compiler.errorMessenger.Output( 22, temporary, pos );
184 return -1;
185 }
186
187 pos++;
188 }
189 if( ! ( source[pos] == '\0' || source[pos + 2] == '\0' ) ){
190 pos += 2;
191 }
192
193 return 1;
194}
195
196void Compile( const char *source )
197{
198 char *temporary = (char *)malloc( lstrlen( source ) + 8192 );
199 lstrcpy( temporary, source );
200 int backCp = cp;
201 MakeMiddleCode( temporary );
202 cp = backCp;
203 ChangeOpcode( temporary );
204 cp = backCp;
205 free( temporary );
206}
207
208void ChangeOpcode(char *Command){
209 extern HANDLE hHeap;
210
211 if(Command[0]=='\0')
212 {
213 return;
214 }
215
216 trace_for_sourcecodestep( FormatEscapeSequenceStringToDefaultString(Command) );
217
218 if(Command[0]=='*'&&IsVariableTopChar(Command[1])){
219 //Goto先ラベル
220 compiler.codeGenerator.gotoLabels.push_back( GotoLabel( Command + 1, compiler.codeGenerator.GetNativeCodeSize() ) );
221
222 //書き込みスケジュール
223 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
224 while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
225 {
226 if( (*it)->GetName() == Command+1 )
227 {
228 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
229
230 //詰める
231 it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
232 }
233 else
234 {
235 it++;
236 }
237 }
238 return;
239 }
240 if(Command[0]==1){
241 switch(Command[1]){
242 case ESC_CONST:
243 OpcodeDim(Command+2, DIMFLAG_CONST);
244 break;
245
246 case ESC_TYPEDEF:
247 if( compiler.IsLocalAreaCompiling() ){
248 // ローカル領域をコンパイルしているとき
249 compiler.errorMessenger.Output(65,"TypeDef",cp );
250 }
251
252 //既に収集済み
253 break;
254
255 case ESC_DELEGATE:
256 if( compiler.IsLocalAreaCompiling() ){
257 // ローカル領域をコンパイルしているとき
258 compiler.errorMessenger.Output(65,"Delegate",cp );
259 }
260
261 //既に収集済み
262 break;
263
264 case ESC_STATIC:
265 OpcodeDim(Command+2,DIMFLAG_STATIC);
266 break;
267
268 case ESC_IF:
269 OpcodeIf(Command+2);
270 break;
271 case ESC_EXITWHILE:
272 {
273 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_WHILE );
274 if( !pScope ){
275 compiler.errorMessenger.Output(12,"Exit While",cp);
276 return;
277 }
278 pScope->Break();
279 }
280 break;
281 case ESC_EXITFOR:
282 {
283 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_FOR );
284 if( !pScope ){
285 compiler.errorMessenger.Output(12,"Exit For",cp);
286 return;
287 }
288 pScope->Break();
289 }
290 break;
291 case ESC_EXITDO:
292 {
293 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_DO );
294 if( !pScope ){
295 compiler.errorMessenger.Output(12,"Exit Do",cp);
296 return;
297 }
298 pScope->Break();
299 }
300 break;
301 case ESC_CONTINUE:
302 OpcodeContinue();
303 break;
304
305 case ESC_EXITSUB:
306 case ESC_EXITFUNCTION:
307 case ESC_EXITMACRO:
308 OpcodeExitSub();
309 break;
310
311 case ESC_SELECTCASE:
312 OpcodeSelect(Command+2);
313 break;
314 case ESC_CASE:
315 case ESC_CASEELSE:
316 OpcodeCase(Command+2);
317 break;
318
319 case ESC_WITH:
320 extern WITHINFO WithInfo;
321
322 WithInfo.ppName=(char **)HeapReAlloc(hHeap,0,WithInfo.ppName,(WithInfo.num+1)*sizeof(char **));
323 WithInfo.ppName[WithInfo.num]=(char *)HeapAlloc(hHeap,0,lstrlen(Command+2)+1);
324 lstrcpy(WithInfo.ppName[WithInfo.num],Command+2);
325
326 WithInfo.pWithCp=(int *)HeapReAlloc(hHeap,0,WithInfo.pWithCp,(WithInfo.num+1)*sizeof(int));
327 WithInfo.pWithCp[WithInfo.num]=cp;
328
329 WithInfo.num++;
330 break;
331 case ESC_ENDWITH:
332 if(WithInfo.num<=0){
333 compiler.errorMessenger.Output(12,"End With",cp);
334 return;
335 }
336 WithInfo.num--;
337 HeapDefaultFree(WithInfo.ppName[WithInfo.num]);
338 break;
339 case ESC_DECLARE:
340 if( compiler.IsLocalAreaCompiling() ){
341 // ローカル領域をコンパイルしているとき
342 compiler.errorMessenger.Output(65,"Declare",cp );
343 }
344 break;
345
346 case ESC_NAMESPACE:
347 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().push_back( Command + 2 );
348 break;
349 case ESC_ENDNAMESPACE:
350 if( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().size() <= 0 ){
351 compiler.errorMessenger.Output(12,"End Namespace",cp);
352 }
353 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().pop_back();
354 break;
355 case ESC_IMPORTS:
356 compiler.GetNamespaceSupporter().ImportsNamespace( Command + 2 );
357 break;
358 case ESC_CLEARNAMESPACEIMPORTED:
359 // Imports情報のクリア
360 compiler.GetNamespaceSupporter().ClearImportedNamespaces();
361 break;
362
363 //Tryによる例外処理
364 case ESC_TRY:
365 Exception::TryCommand();
366 break;
367 case ESC_CATCH:
368 Exception::CatchCommand( Command + 2 );
369 break;
370 case ESC_FINALLY:
371 Exception::FinallyCommand();
372 break;
373 case ESC_ENDTRY:
374 Exception::EndTryCommand();
375 break;
376 case ESC_THROW:
377 Exception::ThrowCommand( Command + 2 );
378 break;
379
380 default:
381 char temporary[64];
382 GetDefaultNameFromES(Command[1],temporary);
383 compiler.errorMessenger.Output(30,temporary,cp);
384 break;
385 }
386 return;
387 }
388 switch(MAKEWORD(Command[1],Command[0])){
389 case COM_DIM:
390 OpcodeDim(Command+2,0);
391 break;
392 case COM_DELETE:
393 OpcodeDelete(Command+2, false);
394 break;
395 case COM_SWEEPINGDELETE:
396 OpcodeDelete(Command+2, true);
397 break;
398
399 case COM_GOTO:
400 OpcodeGoto(Command+2);
401 break;
402 case COM_WHILE:
403 OpcodeWhile(Command+2);
404 break;
405 case COM_FOR:
406 OpcodeFor(Command+2);
407 break;
408 case COM_FOREACH:
409 OpcodeForeach(Command+2);
410 break;
411 case COM_DO:
412 OpcodeDo(Command+2);
413 break;
414
415 case COM_GOSUB:
416 OpcodeGosub(Command+2);
417 break;
418 case COM_RETURN:
419 OpcodeReturn(Command+2);
420 break;
421
422 case COM_SETDOUBLE:
423 OpcodeSetPtrData(Command+2,DEF_DOUBLE);
424 break;
425 case COM_SETSINGLE:
426 OpcodeSetPtrData(Command+2,DEF_SINGLE);
427 break;
428 case COM_SETQWORD:
429 OpcodeSetPtrData(Command+2,DEF_QWORD);
430 break;
431 case COM_SETDWORD:
432 OpcodeSetPtrData(Command+2,DEF_DWORD);
433 break;
434 case COM_SETWORD:
435 OpcodeSetPtrData(Command+2,DEF_WORD);
436 break;
437 case COM_SETBYTE:
438 OpcodeSetPtrData(Command+2,DEF_BYTE);
439 break;
440
441 case COM_DEBUG:
442 //int 3
443 if( compiler.IsDebug() )
444 {
445 breakpoint;
446 }
447 else
448 {
449//#if defined(_DEBUG)
450 breakpoint;
451//#endif
452 }
453 break;
454
455 case COM_LET:
456 OpcodeCalc(Command+2);
457
458 break;
459 default:
460 OpcodeOthers(Command);
461
462 // コード生成過程で発生した構造体の一時メモリを破棄する
463 compiler.codeGenerator.op_FreeTempStructure();
464
465 break;
466 }
467}
468
469void GetGlobalDataForDll(void){
470 extern char *basbuf;
471 extern HANDLE hHeap;
472 int i2,BufferSize;
473 char *Command;
474 DWORD dwRetCode;
475
476 dwRetCode=0;
477 BufferSize=128;
478 Command=(char *)HeapAlloc(hHeap,0,BufferSize);
479 for(cp++,i2=0;;cp++,i2++){
480 if(i2>=BufferSize){
481 //バッファ領域が足りなくなった場合はバッファを増量する
482 BufferSize+=128;
483 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
484 }
485 if(basbuf[cp]=='\"'){
486 Command[i2]=basbuf[cp];
487 for(cp++,i2++;;cp++,i2++){
488 if(i2>=BufferSize){
489 //バッファ領域が足りなくなった場合はバッファを増量する
490 BufferSize+=128;
491 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
492 }
493 Command[i2]=basbuf[cp];
494 if(basbuf[cp]=='\"') break;
495 }
496 continue;
497 }
498 if(IsCommandDelimitation(basbuf[cp])){
499 Command[i2]=0;
500
501 if(Command[0]==1&&Command[1]==ESC_SUB){
502 i2=cp;
503 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDSUB)){
504 if(basbuf[cp]=='\0'){
505 compiler.errorMessenger.Output(22,"Sub",i2);
506 break;
507 }
508 cp++;
509 }
510 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
511 cp+=2;
512 i2=-1;
513 continue;
514 }
515 if(Command[0]==1&&Command[1]==ESC_FUNCTION){
516 i2=cp;
517 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDFUNCTION)){
518 if(basbuf[cp]=='\0'){
519 compiler.errorMessenger.Output(22,"Function",i2);
520 break;
521 }
522 cp++;
523 }
524 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
525 cp+=2;
526 i2=-1;
527 continue;
528 }
529 if(Command[0]==1&&Command[1]==ESC_MACRO){
530 i2=cp;
531 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDMACRO)){
532 if(basbuf[cp]=='\0'){
533 compiler.errorMessenger.Output(22,"Macro",i2);
534 break;
535 }
536 cp++;
537 }
538 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
539 cp+=2;
540 i2=-1;
541 continue;
542 }
543 if(Command[0]==1&&Command[1]==ESC_TYPE){
544 i2=cp;
545 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDTYPE)){
546 if(basbuf[cp]=='\0'){
547 compiler.errorMessenger.Output(22,"Type",i2);
548 break;
549 }
550 cp++;
551 }
552 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
553 cp+=2;
554 i2=-1;
555 continue;
556 }
557 if(Command[0]==1&&Command[1]==ESC_CLASS){
558 i2=cp;
559 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDCLASS)){
560 if(basbuf[cp]=='\0'){
561 compiler.errorMessenger.Output(22,"Class",i2);
562 break;
563 }
564 cp++;
565 }
566 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
567 cp+=2;
568 i2=-1;
569 continue;
570 }
571 if(Command[0]==1&&Command[1]==ESC_INTERFACE){
572 i2=cp;
573 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDINTERFACE)){
574 if(basbuf[cp]=='\0'){
575 compiler.errorMessenger.Output(22,"Interface",i2);
576 break;
577 }
578 cp++;
579 }
580 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
581 cp+=2;
582 i2=-1;
583 continue;
584 }
585
586 //DLLのグローバルデータに必要なコマンドだけ
587 if(MAKEWORD(Command[1],Command[0])==COM_DIM)
588 OpcodeDim(Command+2,0);
589
590 if(basbuf[cp]=='\0') break;
591 i2=-1;
592 continue;
593 }
594 Command[i2]=basbuf[cp];
595 }
596 HeapDefaultFree(Command);
597}
598DWORD CompileBuffer(char Return_Sequence,WORD Return_Command){
599 extern char *basbuf;
600 extern HANDLE hHeap;
601 int i,i2,i3,i4,BufferSize,ScopeStart;
602 char *Command,temporary[VN_SIZE],*temp2,temp3[32];
603 DWORD dwRetCode;
604
605 ScopeStart=cp;
606
607 dwRetCode=0;
608 BufferSize=128;
609 Command=(char *)HeapAlloc(hHeap,0,BufferSize);
610
611 for(cp++,i2=0;;cp++,i2++){
612 if(i2>=BufferSize){
613 //バッファ領域が足りなくなった場合はバッファを増量する
614 BufferSize+=128;
615 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
616 }
617 if(basbuf[cp]=='\"'){
618 Command[i2]=basbuf[cp];
619 for(cp++,i2++;;cp++,i2++){
620 if(i2>=BufferSize){
621 //バッファ領域が足りなくなった場合はバッファを増量する
622 BufferSize+=128;
623 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
624 }
625 Command[i2]=basbuf[cp];
626 if(basbuf[cp]=='\"') break;
627 }
628 continue;
629 }
630 if(IsCommandDelimitation(basbuf[cp])){
631 Command[i2]=0;
632
633 if(Command[0]==1&&Command[1]==ESC_LINENUM){
634 for(i=2,i2=0;;i++,i2++){
635 if(Command[i]==','){
636 temporary[i2]=0;
637 break;
638 }
639 temporary[i2]=Command[i];
640 }
641 i3=atoi(temporary);
642 i4=i+1;
643
644 //Goto先ラベル
645 compiler.codeGenerator.gotoLabels.push_back( GotoLabel( (long)i3, compiler.codeGenerator.GetNativeCodeSize() ) );
646
647 //書き込みスケジュール
648 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
649 while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
650 {
651 if( (*it)->GetName().size() == 0 && (*it)->GetLineNum() == i3 )
652 {
653 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
654
655 //詰める
656 it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
657 }
658 else
659 {
660 it++;
661 }
662 }
663
664 temp2=(char *)HeapAlloc(hHeap,0,lstrlen(Command+i4)+1);
665 lstrcpy(temp2,Command+i4);
666 lstrcpy(Command,temp2);
667 HeapDefaultFree(temp2);
668 }
669
670 if(Command[0]==1&&
671 (((Command[1]==ESC_VIRTUAL||Command[1]==ESC_OVERRIDE)&&Command[2]==1&&(Command[3]==ESC_SUB||Command[3]==ESC_FUNCTION))||
672 Command[1]==ESC_SUB||
673 Command[1]==ESC_FUNCTION||
674 Command[1]==ESC_MACRO||
675 Command[1]==ESC_TYPE||
676 Command[1]==ESC_CLASS||
677 Command[1]==ESC_INTERFACE||
678 Command[1]==ESC_ENUM||
679 (Command[1]==ESC_CONST&&Command[2]==1&&Command[3]==ESC_ENUM)
680 )
681 ){
682 if(Command[1]==ESC_VIRTUAL||Command[1]==ESC_OVERRIDE||Command[1]==ESC_CONST){
683 GetDefaultNameFromES(Command[3],temporary);
684 }
685 else{
686 GetDefaultNameFromES(Command[1],temporary);
687 }
688 if(Return_Sequence){
689 compiler.errorMessenger.Output(12,temporary,cp);
690 break;
691 }
692
693 if(Command[1]==ESC_CONST) i3=GetEndXXXCommand(Command[3]);
694 else i3=GetEndXXXCommand(Command[1]);
695 for(i2=cp;;cp++){
696 if(basbuf[cp]==1){
697 if(basbuf[cp+1]==i3) break;
698 if(Command[1]==ESC_CLASS||Command[1]==ESC_INTERFACE){
699 //クラス、インターフェイスではSub、Functionの定義を可能にしておく
700 if(basbuf[cp+1]==ESC_MACRO||
701 basbuf[cp+1]==ESC_TYPE||
702 basbuf[cp+1]==ESC_CLASS||
703 basbuf[cp+1]==ESC_INTERFACE||
704 basbuf[cp+1]==ESC_ENUM){
705 GetDefaultNameFromES(basbuf[cp+1],temp3);
706 compiler.errorMessenger.Output(12,temp3,cp);
707 }
708 }
709 else{
710 if(basbuf[cp-1]!='*'&&(
711 basbuf[cp+1]==ESC_VIRTUAL||
712 basbuf[cp+1]==ESC_OVERRIDE||
713 basbuf[cp+1]==ESC_SUB||
714 basbuf[cp+1]==ESC_FUNCTION||
715 basbuf[cp+1]==ESC_MACRO||
716 basbuf[cp+1]==ESC_TYPE||
717 basbuf[cp+1]==ESC_CLASS||
718 basbuf[cp+1]==ESC_INTERFACE||
719 basbuf[cp+1]==ESC_ENUM)){
720 GetDefaultNameFromES(basbuf[cp+1],temp3);
721 compiler.errorMessenger.Output(12,temp3,cp);
722 }
723 }
724 }
725 if(basbuf[cp]=='\0'){
726 //error
727 //既にエラー発行済みのため、何もせずに抜ける
728 break;
729 }
730 }
731 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
732 cp+=2;
733 i2=-1;
734 continue;
735 }
736
737 if(Command[0]==0x10||Command[0]==0x11){
738 //Wend、Next、Loopなど
739 if(Return_Command==MAKEWORD(Command[1],Command[0])){
740 if(Return_Command==COM_NEXT){
741 //Nextの場合は、パラメータ(省略化)の整合性を判断する必要がある(OpcodeFor関数を参照)
742 extern char szNextVariable[VN_SIZE];
743 if(Command[2]) lstrcpy(szNextVariable,Command+2);
744 else szNextVariable[0]=0;
745 }
746 break;
747 }
748 }
749
750 if( basbuf[cp] != '\0' )
751 {
752 compiler.codeGenerator.NextSourceLine(
753 SourceCodePosition( compiler.GetCurrentRelationalObjectModuleIndexForSource(), cp ),
754 compiler.GetCompilingUserProc().IsSystem()
755 );
756 }
757
758 if(Command[0]==1){
759 if(Return_Sequence==ESC_ENDIF&&Command[1]==ESC_ELSE){
760 dwRetCode=ESC_ELSE;
761 break;
762 }
763
764 if(Command[1]==Return_Sequence){
765 dwRetCode=Command[1];
766 break;
767 }
768 }
769
770 if( Command[0] )
771 {
772 ChangeOpcode(Command);
773 }
774
775
776 epi_check();
777
778
779 //コンパイルを中断するとき
780 extern BOOL bStopCompile;
781 if(bStopCompile) return 0;
782
783 if(basbuf[cp]=='\0'){
784 switch(Return_Command){
785 case COM_WEND:
786 compiler.errorMessenger.Output(4,"\"While\" - \"Wend\" ",ScopeStart);
787 break;
788 case COM_NEXT:
789 compiler.errorMessenger.Output(4,"\"For\" - \"Next\" ",ScopeStart);
790 break;
791 case COM_LOOP:
792 compiler.errorMessenger.Output(4,"\"Do\" - \"Loop\" ",ScopeStart);
793 break;
794 }
795 switch(Return_Sequence){
796 case ESC_ENDSUB:
797 compiler.errorMessenger.Output(4,"\"Sub\" - \"End Sub\" ",ScopeStart);
798 break;
799 case ESC_ENDFUNCTION:
800 compiler.errorMessenger.Output(4,"\"Function\" - \"End Function\" ",ScopeStart);
801 break;
802 case ESC_ENDMACRO:
803 compiler.errorMessenger.Output(4,"\"Macro\" - \"End Macro\" ",ScopeStart);
804 break;
805 case ESC_ENDIF:
806 compiler.errorMessenger.Output(22,"If",ScopeStart);
807 break;
808 }
809 break;
810 }
811 i2=-1;
812 continue;
813 }
814 Command[i2]=basbuf[cp];
815 }
816 HeapDefaultFree(Command);
817
818 return dwRetCode;
819}
Note: See TracBrowser for help on using the repository browser.