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

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

・Compiler::IsDebugメソッドを導入した(bDebugCompileグローバル変数は廃止)。
・bStrictグローバル変数は意味を成さないので廃止した。

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