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

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

関数パラメータに指定されたジェネリクスの型パラメータ解決に失敗してしまう不具合を修正。
また、エラー行番号がソースコード内の無関係な位置を指し示してしまう不具合を修正。

File size: 18.9 KB
RevLine 
[206]1#include "stdafx.h"
2
[182]3#include <jenga/include/smoothie/Smoothie.h>
4#include <jenga/include/smoothie/SmoothieException.h>
5
[248]6#include <LexicalScope.h>
[182]7#include <CodeGenerator.h>
[193]8#include <Compiler.h>
[195]9#include <NamespaceSupporter.h>
[182]10
[4]11#include "../BasicCompiler_Common/common.h"
12
13#ifdef _AMD64_
14#include "../BasicCompiler64/opcode.h"
15#else
[5]16#include "../BasicCompiler32/opcode.h"
[4]17#endif
18
[182]19#include <Exception.h>
20
[4]21//With情報
22WITHINFO WithInfo;
23
[263]24//デバッグ用行番号情報
25SourceLines oldSourceLines;
[4]26
[89]27
[263]28
[16]29///////////////////////////////////////////////////
[17]30// トークンを取得
31///////////////////////////////////////////////////
[296]32void GetIdentifierToken( char *token, const char *source, int &pos )
33{
[17]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}
[296]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}
[381]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 }
[17]72
[381]73 token[i] = source[pos];
[17]74
[381]75 if( source[pos] == '\0' )
76 {
77 break;
78 }
79 }
80}
81
82
[17]83///////////////////////////////////////////////////
[296]84// ジェネリクスのクラス型記述を分析
85///////////////////////////////////////////////////
[424]86void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass, Jenga::Common::Strings *pTypeParameterBaseClassNames )
[296]87{
[424]88 if( isDefiningClass )
89 {
90 if( !pTypeParameterBaseClassNames )
91 {
92 SetError();
93 }
94 pTypeParameterBaseClassNames->clear();
95 }
96
[296]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
[424]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
[296]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///////////////////////////////////////////////////
[16]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
[372]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 );
[438]205 cp = backCp;
[372]206 ChangeOpcode( temporary );
207 cp = backCp;
208 free( temporary );
209}
210
[4]211void ChangeOpcode(char *Command){
212 extern HANDLE hHeap;
213
[206]214 if(Command[0]=='\0')
215 {
216 return;
217 }
218
219 trace_for_sourcecodestep( FormatEscapeSequenceStringToDefaultString(Command) );
220
[4]221 if(Command[0]=='*'&&IsVariableTopChar(Command[1])){
222 //Goto先ラベル
[276]223 compiler.codeGenerator.gotoLabels.push_back( GotoLabel( Command + 1, compiler.codeGenerator.GetNativeCodeSize() ) );
[4]224
225 //書き込みスケジュール
[253]226 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
[246]227 while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
228 {
[253]229 if( (*it)->GetName() == Command+1 )
[246]230 {
[253]231 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
[246]232
[4]233 //詰める
[246]234 it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
[4]235 }
[246]236 else
237 {
238 it++;
239 }
[4]240 }
241 return;
242 }
243 if(Command[0]==1){
244 switch(Command[1]){
245 case ESC_CONST:
[7]246 OpcodeDim(Command+2, DIMFLAG_CONST);
247 break;
248
[4]249 case ESC_TYPEDEF:
[113]250 if( UserProc::IsLocalAreaCompiling() ){
251 // ローカル領域をコンパイルしているとき
252 SetError(65,"TypeDef",cp );
253 }
254
[78]255 //既に収集済み
[4]256 break;
257
[322]258 case ESC_DELEGATE:
259 if( UserProc::IsLocalAreaCompiling() ){
260 // ローカル領域をコンパイルしているとき
261 SetError(65,"Delegate",cp );
262 }
263
264 //既に収集済み
265 break;
266
[4]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:
[182]275 {
[248]276 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_WHILE );
[182]277 if( !pScope ){
278 SetError(12,"Exit While",cp);
279 return;
280 }
281 pScope->Break();
282 }
[4]283 break;
284 case ESC_EXITFOR:
[182]285 {
[248]286 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_FOR );
[182]287 if( !pScope ){
288 SetError(12,"Exit For",cp);
289 return;
290 }
291 pScope->Break();
292 }
[4]293 break;
294 case ESC_EXITDO:
[182]295 {
[248]296 LexicalScope *pScope = compiler.codeGenerator.lexicalScopes.SearchScope( LexicalScope::SCOPE_TYPE_DO );
[182]297 if( !pScope ){
298 SetError(12,"Exit Do",cp);
299 return;
300 }
301 pScope->Break();
302 }
[4]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:
[113]343 if( UserProc::IsLocalAreaCompiling() ){
344 // ローカル領域をコンパイルしているとき
345 SetError(65,"Declare",cp );
346 }
[4]347 break;
[26]348
[99]349 case ESC_NAMESPACE:
[199]350 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().push_back( Command + 2 );
[103]351 break;
[99]352 case ESC_ENDNAMESPACE:
[199]353 if( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().size() <= 0 ){
[103]354 SetError(12,"End Namespace",cp);
355 }
[199]356 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().pop_back();
[99]357 break;
[107]358 case ESC_IMPORTS:
[199]359 compiler.GetNamespaceSupporter().ImportsNamespace( Command + 2 );
[107]360 break;
361 case ESC_CLEARNAMESPACEIMPORTED:
[199]362 compiler.GetNamespaceSupporter().GetImportedNamespaces().clear();
[107]363 break;
[99]364
[26]365 //Tryによる例外処理
366 case ESC_TRY:
367 Exception::TryCommand();
368 break;
369 case ESC_CATCH:
[359]370 Exception::CatchCommand( Command + 2 );
[26]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
[4]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:
[64]395 OpcodeDelete(Command+2, false);
[4]396 break;
[64]397 case COM_SWEEPINGDELETE:
398 OpcodeDelete(Command+2, true);
399 break;
[4]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;
[372]410 case COM_FOREACH:
411 OpcodeForeach(Command+2);
412 break;
[4]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 extern BOOL bDebugCompile;
445 //int 3
[253]446 if(bDebugCompile)
447 {
448 breakpoint;
449 }
450 else
451 {
[263]452//#if defined(_DEBUG)
[253]453 breakpoint;
[263]454//#endif
[253]455 }
[4]456 break;
457
458 case COM_LET:
459 OpcodeCalc(Command+2);
[435]460
[4]461 break;
462 default:
463 OpcodeOthers(Command);
[435]464
465 // コード生成過程で発生した構造体の一時メモリを破棄する
466 compiler.codeGenerator.op_FreeTempStructure();
467
[4]468 break;
469 }
470}
471
472void GetGlobalDataForDll(void){
473 extern char *basbuf;
474 extern HANDLE hHeap;
475 int i2,BufferSize;
476 char *Command;
477 DWORD dwRetCode;
478
479 dwRetCode=0;
480 BufferSize=128;
481 Command=(char *)HeapAlloc(hHeap,0,BufferSize);
482 for(cp++,i2=0;;cp++,i2++){
483 if(i2>=BufferSize){
484 //バッファ領域が足りなくなった場合はバッファを増量する
485 BufferSize+=128;
486 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
487 }
488 if(basbuf[cp]=='\"'){
489 Command[i2]=basbuf[cp];
490 for(cp++,i2++;;cp++,i2++){
491 if(i2>=BufferSize){
492 //バッファ領域が足りなくなった場合はバッファを増量する
493 BufferSize+=128;
494 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
495 }
496 Command[i2]=basbuf[cp];
497 if(basbuf[cp]=='\"') break;
498 }
499 continue;
500 }
501 if(IsCommandDelimitation(basbuf[cp])){
502 Command[i2]=0;
503
504 if(Command[0]==1&&Command[1]==ESC_SUB){
505 i2=cp;
506 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDSUB)){
507 if(basbuf[cp]=='\0'){
508 SetError(22,"Sub",i2);
509 break;
510 }
511 cp++;
512 }
513 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
514 cp+=2;
515 i2=-1;
516 continue;
517 }
518 if(Command[0]==1&&Command[1]==ESC_FUNCTION){
519 i2=cp;
520 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDFUNCTION)){
521 if(basbuf[cp]=='\0'){
522 SetError(22,"Function",i2);
523 break;
524 }
525 cp++;
526 }
527 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
528 cp+=2;
529 i2=-1;
530 continue;
531 }
532 if(Command[0]==1&&Command[1]==ESC_MACRO){
533 i2=cp;
534 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDMACRO)){
535 if(basbuf[cp]=='\0'){
536 SetError(22,"Macro",i2);
537 break;
538 }
539 cp++;
540 }
541 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
542 cp+=2;
543 i2=-1;
544 continue;
545 }
546 if(Command[0]==1&&Command[1]==ESC_TYPE){
547 i2=cp;
548 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDTYPE)){
549 if(basbuf[cp]=='\0'){
550 SetError(22,"Type",i2);
551 break;
552 }
553 cp++;
554 }
555 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
556 cp+=2;
557 i2=-1;
558 continue;
559 }
560 if(Command[0]==1&&Command[1]==ESC_CLASS){
561 i2=cp;
562 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDCLASS)){
563 if(basbuf[cp]=='\0'){
564 SetError(22,"Class",i2);
565 break;
566 }
567 cp++;
568 }
569 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
570 cp+=2;
571 i2=-1;
572 continue;
573 }
574 if(Command[0]==1&&Command[1]==ESC_INTERFACE){
575 i2=cp;
576 while(!(basbuf[cp]==1&&basbuf[cp+1]==ESC_ENDINTERFACE)){
577 if(basbuf[cp]=='\0'){
578 SetError(22,"Interface",i2);
579 break;
580 }
581 cp++;
582 }
583 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
584 cp+=2;
585 i2=-1;
586 continue;
587 }
588
589 //DLLのグローバルデータに必要なコマンドだけ
590 if(MAKEWORD(Command[1],Command[0])==COM_DIM)
591 OpcodeDim(Command+2,0);
592
593 if(basbuf[cp]=='\0') break;
594 i2=-1;
595 continue;
596 }
597 Command[i2]=basbuf[cp];
598 }
599 HeapDefaultFree(Command);
600}
601DWORD CompileBuffer(char Return_Sequence,WORD Return_Command){
602 extern char *basbuf;
603 extern HANDLE hHeap;
604 int i,i2,i3,i4,BufferSize,ScopeStart;
605 char *Command,temporary[VN_SIZE],*temp2,temp3[32];
606 DWORD dwRetCode;
607
608 ScopeStart=cp;
609
610 dwRetCode=0;
611 BufferSize=128;
612 Command=(char *)HeapAlloc(hHeap,0,BufferSize);
[15]613
[4]614 for(cp++,i2=0;;cp++,i2++){
615 if(i2>=BufferSize){
616 //バッファ領域が足りなくなった場合はバッファを増量する
617 BufferSize+=128;
618 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
619 }
620 if(basbuf[cp]=='\"'){
621 Command[i2]=basbuf[cp];
622 for(cp++,i2++;;cp++,i2++){
623 if(i2>=BufferSize){
624 //バッファ領域が足りなくなった場合はバッファを増量する
625 BufferSize+=128;
626 Command=(char *)HeapReAlloc(hHeap,0,Command,BufferSize);
627 }
628 Command[i2]=basbuf[cp];
629 if(basbuf[cp]=='\"') break;
630 }
631 continue;
632 }
633 if(IsCommandDelimitation(basbuf[cp])){
634 Command[i2]=0;
635
636 if(Command[0]==1&&Command[1]==ESC_LINENUM){
637 for(i=2,i2=0;;i++,i2++){
638 if(Command[i]==','){
639 temporary[i2]=0;
640 break;
641 }
642 temporary[i2]=Command[i];
643 }
644 i3=atoi(temporary);
645 i4=i+1;
646
647 //Goto先ラベル
[276]648 compiler.codeGenerator.gotoLabels.push_back( GotoLabel( (long)i3, compiler.codeGenerator.GetNativeCodeSize() ) );
[4]649
650 //書き込みスケジュール
[253]651 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();
[246]652 while( it != compiler.codeGenerator.gotoLabelSchedules.end() )
653 {
[253]654 if( (*it)->GetName().size() == 0 && (*it)->GetLineNum() == i3 )
[246]655 {
[253]656 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) );
657
[4]658 //詰める
[246]659 it = compiler.codeGenerator.gotoLabelSchedules.erase( it );
[4]660 }
[246]661 else
662 {
663 it++;
664 }
[4]665 }
666
667 temp2=(char *)HeapAlloc(hHeap,0,lstrlen(Command+i4)+1);
668 lstrcpy(temp2,Command+i4);
669 lstrcpy(Command,temp2);
670 HeapDefaultFree(temp2);
671 }
672
673 if(Command[0]==1&&
674 (((Command[1]==ESC_VIRTUAL||Command[1]==ESC_OVERRIDE)&&Command[2]==1&&(Command[3]==ESC_SUB||Command[3]==ESC_FUNCTION))||
675 Command[1]==ESC_SUB||
676 Command[1]==ESC_FUNCTION||
677 Command[1]==ESC_MACRO||
678 Command[1]==ESC_TYPE||
679 Command[1]==ESC_CLASS||
680 Command[1]==ESC_INTERFACE||
681 Command[1]==ESC_ENUM||
682 (Command[1]==ESC_CONST&&Command[2]==1&&Command[3]==ESC_ENUM)
683 )
684 ){
685 if(Command[1]==ESC_VIRTUAL||Command[1]==ESC_OVERRIDE||Command[1]==ESC_CONST){
686 GetDefaultNameFromES(Command[3],temporary);
687 }
688 else{
689 GetDefaultNameFromES(Command[1],temporary);
690 }
691 if(Return_Sequence){
692 SetError(12,temporary,cp);
693 break;
694 }
695
696 if(Command[1]==ESC_CONST) i3=GetEndXXXCommand(Command[3]);
697 else i3=GetEndXXXCommand(Command[1]);
698 for(i2=cp;;cp++){
699 if(basbuf[cp]==1){
700 if(basbuf[cp+1]==i3) break;
701 if(Command[1]==ESC_CLASS||Command[1]==ESC_INTERFACE){
702 //クラス、インターフェイスではSub、Functionの定義を可能にしておく
703 if(basbuf[cp+1]==ESC_MACRO||
704 basbuf[cp+1]==ESC_TYPE||
705 basbuf[cp+1]==ESC_CLASS||
706 basbuf[cp+1]==ESC_INTERFACE||
707 basbuf[cp+1]==ESC_ENUM){
708 GetDefaultNameFromES(basbuf[cp+1],temp3);
709 SetError(12,temp3,cp);
710 }
711 }
712 else{
713 if(basbuf[cp-1]!='*'&&(
714 basbuf[cp+1]==ESC_VIRTUAL||
715 basbuf[cp+1]==ESC_OVERRIDE||
716 basbuf[cp+1]==ESC_SUB||
717 basbuf[cp+1]==ESC_FUNCTION||
718 basbuf[cp+1]==ESC_MACRO||
719 basbuf[cp+1]==ESC_TYPE||
720 basbuf[cp+1]==ESC_CLASS||
721 basbuf[cp+1]==ESC_INTERFACE||
722 basbuf[cp+1]==ESC_ENUM)){
723 GetDefaultNameFromES(basbuf[cp+1],temp3);
724 SetError(12,temp3,cp);
725 }
726 }
727 }
728 if(basbuf[cp]=='\0'){
729 //error
730 //既にエラー発行済みのため、何もせずに抜ける
731 break;
732 }
733 }
734 if(basbuf[cp+2]=='\0'||basbuf[cp]=='\0') break;
735 cp+=2;
736 i2=-1;
737 continue;
738 }
739
740 if(Command[0]==0x10||Command[0]==0x11){
741 //Wend、Next、Loopなど
742 if(Return_Command==MAKEWORD(Command[1],Command[0])){
743 if(Return_Command==COM_NEXT){
744 //Nextの場合は、パラメータ(省略化)の整合性を判断する必要がある(OpcodeFor関数を参照)
745 extern char szNextVariable[VN_SIZE];
746 if(Command[2]) lstrcpy(szNextVariable,Command+2);
747 else szNextVariable[0]=0;
748 }
749 break;
750 }
751 }
752
[263]753 compiler.codeGenerator.NextSourceLine();
[4]754
755 if(Command[0]==1){
756 if(Return_Sequence==ESC_ENDIF&&Command[1]==ESC_ELSE){
757 dwRetCode=ESC_ELSE;
758 break;
759 }
760
761 if(Command[1]==Return_Sequence){
762 dwRetCode=Command[1];
763 break;
764 }
765 }
766
[182]767 try
768 {
769 ChangeOpcode(Command);
770 }
771 catch( const SmoothieException &smoothieException )
772 {
773 SetError(
774 smoothieException.GetErrorCode(),
775 smoothieException.GetKeyword(),
776 smoothieException.GetNowLine()
777 );
778 }
[4]779
[232]780
[4]781 epi_check();
782
[232]783
[4]784 //コンパイルを中断するとき
785 extern BOOL bStopCompile;
786 if(bStopCompile) return 0;
787
788 if(basbuf[cp]=='\0'){
789 switch(Return_Command){
790 case COM_WEND:
791 SetError(4,"\"While\" - \"Wend\" ",ScopeStart);
792 break;
793 case COM_NEXT:
794 SetError(4,"\"For\" - \"Next\" ",ScopeStart);
795 break;
796 case COM_LOOP:
797 SetError(4,"\"Do\" - \"Loop\" ",ScopeStart);
798 break;
799 }
800 switch(Return_Sequence){
801 case ESC_ENDSUB:
802 SetError(4,"\"Sub\" - \"End Sub\" ",ScopeStart);
803 break;
804 case ESC_ENDFUNCTION:
805 SetError(4,"\"Function\" - \"End Function\" ",ScopeStart);
806 break;
807 case ESC_ENDMACRO:
808 SetError(4,"\"Macro\" - \"End Macro\" ",ScopeStart);
809 break;
810 case ESC_ENDIF:
811 SetError(22,"If",ScopeStart);
812 break;
813 }
814 break;
815 }
816 i2=-1;
817 continue;
818 }
819 Command[i2]=basbuf[cp];
820 }
821 HeapDefaultFree(Command);
822
823 return dwRetCode;
824}
Note: See TracBrowser for help on using the repository browser.