source: dev/trunk/abdev/BasicCompiler_Common/Compile.cpp@ 437

Last change on this file since 437 was 435, checked in by dai_9181, 17 years ago

関数の戻り値の構造体など、一時メモリに保持された構造体のメンバに直接アクセスした場合、その一時メモリの解放が正常に行われないバグを修正(まずは32bit版のみ)

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 ChangeOpcode( temporary );
206 cp = backCp;
207 free( temporary );
208}
209
210void ChangeOpcode(char *Command){
211 extern HANDLE hHeap;
212
213 if(Command[0]=='\0')
214 {
215 return;
216 }
217
218 trace_for_sourcecodestep( FormatEscapeSequenceStringToDefaultString(Command) );
219
220 if(Command[0]=='*'&&IsVariableTopChar(Command[1])){
221 //Goto先ラベル
222 compiler.codeGenerator.gotoLabels.push_back( GotoLabel( Command + 1, compiler.codeGenerator.GetNativeCodeSize() ) );
223
224 //書き込みスケジュール
225 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
226 while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
227 {
228 if( (*it)->GetName() == Command+1 )
229 {
230 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
231
232 //詰める
233 it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
234 }
235 else
236 {
237 it++;
238 }
239 }
240 return;
241 }
242 if(Command[0]==1){
243 switch(Command[1]){
244 case ESC_CONST:
245 OpcodeDim(Command+2, DIMFLAG_CONST);
246 break;
247
248 case ESC_TYPEDEF:
249 if( UserProc::IsLocalAreaCompiling() ){
250 // ローカル領域をコンパイルしているとき
251 SetError(65,"TypeDef",cp );
252 }
253
254 //既に収集済み
255 break;
256
257 case ESC_DELEGATE:
258 if( UserProc::IsLocalAreaCompiling() ){
259 // ローカル領域をコンパイルしているとき
260 SetError(65,"Delegate",cp );
261 }
262
263 //既に収集済み
264 break;
265
266 case ESC_STATIC:
267 OpcodeDim(Command+2,DIMFLAG_STATIC);
268 break;
269
270 case ESC_IF:
271 OpcodeIf(Command+2);
272 break;
273 case ESC_EXITWHILE:
274 {
275 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_WHILE );
276 if( !pScope ){
277 SetError(12,"Exit While",cp);
278 return;
279 }
280 pScope->Break();
281 }
282 break;
283 case ESC_EXITFOR:
284 {
285 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_FOR );
286 if( !pScope ){
287 SetError(12,"Exit For",cp);
288 return;
289 }
290 pScope->Break();
291 }
292 break;
293 case ESC_EXITDO:
294 {
295 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_DO );
296 if( !pScope ){
297 SetError(12,"Exit Do",cp);
298 return;
299 }
300 pScope->Break();
301 }
302 break;
303 case ESC_CONTINUE:
304 OpcodeContinue();
305 break;
306
307 case ESC_EXITSUB:
308 case ESC_EXITFUNCTION:
309 case ESC_EXITMACRO:
310 OpcodeExitSub();
311 break;
312
313 case ESC_SELECTCASE:
314 OpcodeSelect(Command+2);
315 break;
316 case ESC_CASE:
317 case ESC_CASEELSE:
318 OpcodeCase(Command+2);
319 break;
320
321 case ESC_WITH:
322 extern WITHINFO WithInfo;
323
324 WithInfo.ppName=(char **)HeapReAlloc(hHeap,0,WithInfo.ppName,(WithInfo.num+1)*sizeof(char **));
325 WithInfo.ppName[WithInfo.num]=(char *)HeapAlloc(hHeap,0,lstrlen(Command+2)+1);
326 lstrcpy(WithInfo.ppName[WithInfo.num],Command+2);
327
328 WithInfo.pWithCp=(int *)HeapReAlloc(hHeap,0,WithInfo.pWithCp,(WithInfo.num+1)*sizeof(int));
329 WithInfo.pWithCp[WithInfo.num]=cp;
330
331 WithInfo.num++;
332 break;
333 case ESC_ENDWITH:
334 if(WithInfo.num<=0){
335 SetError(12,"End With",cp);
336 return;
337 }
338 WithInfo.num--;
339 HeapDefaultFree(WithInfo.ppName[WithInfo.num]);
340 break;
341 case ESC_DECLARE:
342 if( UserProc::IsLocalAreaCompiling() ){
343 // ローカル領域をコンパイルしているとき
344 SetError(65,"Declare",cp );
345 }
346 break;
347
348 case ESC_NAMESPACE:
349 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().push_back( Command + 2 );
350 break;
351 case ESC_ENDNAMESPACE:
352 if( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().size() <= 0 ){
353 SetError(12,"End Namespace",cp);
354 }
355 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().pop_back();
356 break;
357 case ESC_IMPORTS:
358 compiler.GetNamespaceSupporter().ImportsNamespace( Command + 2 );
359 break;
360 case ESC_CLEARNAMESPACEIMPORTED:
361 compiler.GetNamespaceSupporter().GetImportedNamespaces().clear();
362 break;
363
364 //Tryによる例外処理
365 case ESC_TRY:
366 Exception::TryCommand();
367 break;
368 case ESC_CATCH:
369 Exception::CatchCommand( Command + 2 );
370 break;
371 case ESC_FINALLY:
372 Exception::FinallyCommand();
373 break;
374 case ESC_ENDTRY:
375 Exception::EndTryCommand();
376 break;
377 case ESC_THROW:
378 Exception::ThrowCommand( Command + 2 );
379 break;
380
381 default:
382 char temporary[64];
383 GetDefaultNameFromES(Command[1],temporary);
384 SetError(30,temporary,cp);
385 break;
386 }
387 return;
388 }
389 switch(MAKEWORD(Command[1],Command[0])){
390 case COM_DIM:
391 OpcodeDim(Command+2,0);
392 break;
393 case COM_DELETE:
394 OpcodeDelete(Command+2, false);
395 break;
396 case COM_SWEEPINGDELETE:
397 OpcodeDelete(Command+2, true);
398 break;
399
400 case COM_GOTO:
401 OpcodeGoto(Command+2);
402 break;
403 case COM_WHILE:
404 OpcodeWhile(Command+2);
405 break;
406 case COM_FOR:
407 OpcodeFor(Command+2);
408 break;
409 case COM_FOREACH:
410 OpcodeForeach(Command+2);
411 break;
412 case COM_DO:
413 OpcodeDo(Command+2);
414 break;
415
416 case COM_GOSUB:
417 OpcodeGosub(Command+2);
418 break;
419 case COM_RETURN:
420 OpcodeReturn(Command+2);
421 break;
422
423 case COM_SETDOUBLE:
424 OpcodeSetPtrData(Command+2,DEF_DOUBLE);
425 break;
426 case COM_SETSINGLE:
427 OpcodeSetPtrData(Command+2,DEF_SINGLE);
428 break;
429 case COM_SETQWORD:
430 OpcodeSetPtrData(Command+2,DEF_QWORD);
431 break;
432 case COM_SETDWORD:
433 OpcodeSetPtrData(Command+2,DEF_DWORD);
434 break;
435 case COM_SETWORD:
436 OpcodeSetPtrData(Command+2,DEF_WORD);
437 break;
438 case COM_SETBYTE:
439 OpcodeSetPtrData(Command+2,DEF_BYTE);
440 break;
441
442 case COM_DEBUG:
443 extern BOOL bDebugCompile;
444 //int 3
445 if(bDebugCompile)
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.