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

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

・ジェネリックな型をパラメータに持つメソッドのオーバーロード解決に対応した。
・型パラメータの制約クラス指定に対応した。

File size: 18.8 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 break;
460 default:
461 OpcodeOthers(Command);
462 break;
463 }
464}
465
466void GetGlobalDataForDll(void){
467 extern char *basbuf;
468 extern HANDLE hHeap;
469 int i2,BufferSize;
470 char *Command;
471 DWORD dwRetCode;
472
473 dwRetCode=0;
474 BufferSize=128;
475 Command=(char *)HeapAlloc(hHeap,0,BufferSize);
476 for(cp++,i2=0;;cp++,i2++){
477 if(i2>=BufferSize){
478 //バッファ領域が足りなくなった場合はバッファを増量する
479 BufferSize+=128;
480 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
481 }
482 if(basbuf[cp]=='\"'){
483 Command[i2]=basbuf[cp];
484 for(cp++,i2++;;cp++,i2++){
485 if(i2>=BufferSize){
486 //バッファ領域が足りなくなった場合はバッファを増量する
487 BufferSize+=128;
488 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
489 }
490 Command[i2]=basbuf[cp];
491 if(basbuf[cp]=='\"') break;
492 }
493 continue;
494 }
495 if(IsCommandDelimitation(basbuf[cp])){
496 Command[i2]=0;
497
498 if(Command[0]==1&&Command[1]==ESC_SUB){
499 i2=cp;
500 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDSUB)){
501 if(basbuf[cp]=='\0'){
502 SetError(22,"Sub",i2);
503 break;
504 }
505 cp++;
506 }
507 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
508 cp+=2;
509 i2=-1;
510 continue;
511 }
512 if(Command[0]==1&&Command[1]==ESC_FUNCTION){
513 i2=cp;
514 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDFUNCTION)){
515 if(basbuf[cp]=='\0'){
516 SetError(22,"Function",i2);
517 break;
518 }
519 cp++;
520 }
521 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
522 cp+=2;
523 i2=-1;
524 continue;
525 }
526 if(Command[0]==1&&Command[1]==ESC_MACRO){
527 i2=cp;
528 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDMACRO)){
529 if(basbuf[cp]=='\0'){
530 SetError(22,"Macro",i2);
531 break;
532 }
533 cp++;
534 }
535 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
536 cp+=2;
537 i2=-1;
538 continue;
539 }
540 if(Command[0]==1&&Command[1]==ESC_TYPE){
541 i2=cp;
542 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDTYPE)){
543 if(basbuf[cp]=='\0'){
544 SetError(22,"Type",i2);
545 break;
546 }
547 cp++;
548 }
549 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
550 cp+=2;
551 i2=-1;
552 continue;
553 }
554 if(Command[0]==1&&Command[1]==ESC_CLASS){
555 i2=cp;
556 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDCLASS)){
557 if(basbuf[cp]=='\0'){
558 SetError(22,"Class",i2);
559 break;
560 }
561 cp++;
562 }
563 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
564 cp+=2;
565 i2=-1;
566 continue;
567 }
568 if(Command[0]==1&&Command[1]==ESC_INTERFACE){
569 i2=cp;
570 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDINTERFACE)){
571 if(basbuf[cp]=='\0'){
572 SetError(22,"Interface",i2);
573 break;
574 }
575 cp++;
576 }
577 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
578 cp+=2;
579 i2=-1;
580 continue;
581 }
582
583 //DLLのグローバルデータに必要なコマンドだけ
584 if(MAKEWORD(Command[1],Command[0])==COM_DIM)
585 OpcodeDim(Command+2,0);
586
587 if(basbuf[cp]=='\0') break;
588 i2=-1;
589 continue;
590 }
591 Command[i2]=basbuf[cp];
592 }
593 HeapDefaultFree(Command);
594}
595DWORD CompileBuffer(char Return_Sequence,WORD Return_Command){
596 extern char *basbuf;
597 extern HANDLE hHeap;
598 int i,i2,i3,i4,BufferSize,ScopeStart;
599 char *Command,temporary[VN_SIZE],*temp2,temp3[32];
600 DWORD dwRetCode;
601
602 ScopeStart=cp;
603
604 dwRetCode=0;
605 BufferSize=128;
606 Command=(char *)HeapAlloc(hHeap,0,BufferSize);
607
608 for(cp++,i2=0;;cp++,i2++){
609 if(i2>=BufferSize){
610 //バッファ領域が足りなくなった場合はバッファを増量する
611 BufferSize+=128;
612 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
613 }
614 if(basbuf[cp]=='\"'){
615 Command[i2]=basbuf[cp];
616 for(cp++,i2++;;cp++,i2++){
617 if(i2>=BufferSize){
618 //バッファ領域が足りなくなった場合はバッファを増量する
619 BufferSize+=128;
620 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
621 }
622 Command[i2]=basbuf[cp];
623 if(basbuf[cp]=='\"') break;
624 }
625 continue;
626 }
627 if(IsCommandDelimitation(basbuf[cp])){
628 Command[i2]=0;
629
630 if(Command[0]==1&&Command[1]==ESC_LINENUM){
631 for(i=2,i2=0;;i++,i2++){
632 if(Command[i]==','){
633 temporary[i2]=0;
634 break;
635 }
636 temporary[i2]=Command[i];
637 }
638 i3=atoi(temporary);
639 i4=i+1;
640
641 //Goto先ラベル
642 compiler.codeGenerator.gotoLabels.push_back( GotoLabel( (long)i3, compiler.codeGenerator.GetNativeCodeSize() ) );
643
644 //書き込みスケジュール
645 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
646 while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
647 {
648 if( (*it)->GetName().size() == 0 && (*it)->GetLineNum() == i3 )
649 {
650 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
651
652 //詰める
653 it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
654 }
655 else
656 {
657 it++;
658 }
659 }
660
661 temp2=(char *)HeapAlloc(hHeap,0,lstrlen(Command+i4)+1);
662 lstrcpy(temp2,Command+i4);
663 lstrcpy(Command,temp2);
664 HeapDefaultFree(temp2);
665 }
666
667 if(Command[0]==1&&
668 (((Command[1]==ESC_VIRTUAL||Command[1]==ESC_OVERRIDE)&&Command[2]==1&&(Command[3]==ESC_SUB||Command[3]==ESC_FUNCTION))||
669 Command[1]==ESC_SUB||
670 Command[1]==ESC_FUNCTION||
671 Command[1]==ESC_MACRO||
672 Command[1]==ESC_TYPE||
673 Command[1]==ESC_CLASS||
674 Command[1]==ESC_INTERFACE||
675 Command[1]==ESC_ENUM||
676 (Command[1]==ESC_CONST&&Command[2]==1&&Command[3]==ESC_ENUM)
677 )
678 ){
679 if(Command[1]==ESC_VIRTUAL||Command[1]==ESC_OVERRIDE||Command[1]==ESC_CONST){
680 GetDefaultNameFromES(Command[3],temporary);
681 }
682 else{
683 GetDefaultNameFromES(Command[1],temporary);
684 }
685 if(Return_Sequence){
686 SetError(12,temporary,cp);
687 break;
688 }
689
690 if(Command[1]==ESC_CONST) i3=GetEndXXXCommand(Command[3]);
691 else i3=GetEndXXXCommand(Command[1]);
692 for(i2=cp;;cp++){
693 if(basbuf[cp]==1){
694 if(basbuf[cp+1]==i3) break;
695 if(Command[1]==ESC_CLASS||Command[1]==ESC_INTERFACE){
696 //クラス、インターフェイスではSub、Functionの定義を可能にしておく
697 if(basbuf[cp+1]==ESC_MACRO||
698 basbuf[cp+1]==ESC_TYPE||
699 basbuf[cp+1]==ESC_CLASS||
700 basbuf[cp+1]==ESC_INTERFACE||
701 basbuf[cp+1]==ESC_ENUM){
702 GetDefaultNameFromES(basbuf[cp+1],temp3);
703 SetError(12,temp3,cp);
704 }
705 }
706 else{
707 if(basbuf[cp-1]!='*'&&(
708 basbuf[cp+1]==ESC_VIRTUAL||
709 basbuf[cp+1]==ESC_OVERRIDE||
710 basbuf[cp+1]==ESC_SUB||
711 basbuf[cp+1]==ESC_FUNCTION||
712 basbuf[cp+1]==ESC_MACRO||
713 basbuf[cp+1]==ESC_TYPE||
714 basbuf[cp+1]==ESC_CLASS||
715 basbuf[cp+1]==ESC_INTERFACE||
716 basbuf[cp+1]==ESC_ENUM)){
717 GetDefaultNameFromES(basbuf[cp+1],temp3);
718 SetError(12,temp3,cp);
719 }
720 }
721 }
722 if(basbuf[cp]=='\0'){
723 //error
724 //既にエラー発行済みのため、何もせずに抜ける
725 break;
726 }
727 }
728 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
729 cp+=2;
730 i2=-1;
731 continue;
732 }
733
734 if(Command[0]==0x10||Command[0]==0x11){
735 //Wend、Next、Loopなど
736 if(Return_Command==MAKEWORD(Command[1],Command[0])){
737 if(Return_Command==COM_NEXT){
738 //Nextの場合は、パラメータ(省略化)の整合性を判断する必要がある(OpcodeFor関数を参照)
739 extern char szNextVariable[VN_SIZE];
740 if(Command[2]) lstrcpy(szNextVariable,Command+2);
741 else szNextVariable[0]=0;
742 }
743 break;
744 }
745 }
746
747 compiler.codeGenerator.NextSourceLine();
748
749 if(Command[0]==1){
750 if(Return_Sequence==ESC_ENDIF&&Command[1]==ESC_ELSE){
751 dwRetCode=ESC_ELSE;
752 break;
753 }
754
755 if(Command[1]==Return_Sequence){
756 dwRetCode=Command[1];
757 break;
758 }
759 }
760
761 try
762 {
763 ChangeOpcode(Command);
764 }
765 catch( const SmoothieException &smoothieException )
766 {
767 SetError(
768 smoothieException.GetErrorCode(),
769 smoothieException.GetKeyword(),
770 smoothieException.GetNowLine()
771 );
772 }
773
774
775 epi_check();
776
777
778 //コンパイルを中断するとき
779 extern BOOL bStopCompile;
780 if(bStopCompile) return 0;
781
782 if(basbuf[cp]=='\0'){
783 switch(Return_Command){
784 case COM_WEND:
785 SetError(4,"\"While\" - \"Wend\" ",ScopeStart);
786 break;
787 case COM_NEXT:
788 SetError(4,"\"For\" - \"Next\" ",ScopeStart);
789 break;
790 case COM_LOOP:
791 SetError(4,"\"Do\" - \"Loop\" ",ScopeStart);
792 break;
793 }
794 switch(Return_Sequence){
795 case ESC_ENDSUB:
796 SetError(4,"\"Sub\" - \"End Sub\" ",ScopeStart);
797 break;
798 case ESC_ENDFUNCTION:
799 SetError(4,"\"Function\" - \"End Function\" ",ScopeStart);
800 break;
801 case ESC_ENDMACRO:
802 SetError(4,"\"Macro\" - \"End Macro\" ",ScopeStart);
803 break;
804 case ESC_ENDIF:
805 SetError(22,"If",ScopeStart);
806 break;
807 }
808 break;
809 }
810 i2=-1;
811 continue;
812 }
813 Command[i2]=basbuf[cp];
814 }
815 HeapDefaultFree(Command);
816
817 return dwRetCode;
818}
Note: See TracBrowser for help on using the repository browser.