source: dev/trunk/abdev/BasicCompiler32/Compile_Statement.cpp@ 226

Last change on this file since 226 was 225, checked in by dai_9181, 17 years ago

CodeGeneratorクラスのベースを実装

File size: 31.8 KB
Line 
1#include "stdafx.h"
2
3#include <jenga/include/smoothie/LexicalAnalysis.h>
4
5#include <LexicalScopingImpl.h>
6#include <Compiler.h>
7
8#include "../BasicCompiler_Common/common.h"
9#include "Opcode.h"
10
11void OpcodeOthers( const char *Command ){
12 int i,i2;
13
14 char leftTerm[8192];
15 int lastParePos = 0;
16 for(i=0;;i++){
17 if(Command[i]=='\"'){
18 //ダブルクォートは不正なのでエラー扱い
19 leftTerm[i]=0;
20 SetError(3,leftTerm,cp);
21 return;
22 }
23
24 if(Command[i]=='('){
25 lastParePos = i;
26 i2=GetStringInPare(leftTerm+i,Command+i);
27 i+=i2-1;
28 continue;
29 }
30 if(Command[i]=='['){
31 i2=GetStringInBracket(leftTerm+i,Command+i);
32 i+=i2-1;
33 continue;
34 }
35 if(Command[i]=='\0'){
36 leftTerm[i] = 0;
37 break;
38 }
39
40 if( IsNumCalcMark( Command, i ) ){
41 leftTerm[i] = 0;
42 break;
43 }
44
45 leftTerm[i]=Command[i];
46 }
47 if(!(
48 IsVariableTopChar(leftTerm[0])||
49 leftTerm[0]=='.'||
50 (leftTerm[0]==1&&leftTerm[1]==ESC_PSMEM)
51 )){
52 SetError(1,NULL,cp);
53 return;
54 }
55
56
57 if(Command[i]=='\0' && lastParePos == 0){
58 //////////////////////////////
59 // パラメータ無しのマクロ検索
60 //////////////////////////////
61
62 const UserProc *pUserProc = GetSubHash(Command);
63
64 //GetSubHash内でエラー提示が行われた場合
65 if(pUserProc==(UserProc *)-1) return;
66
67 if(pUserProc==0){
68 char temporary[VN_SIZE];
69 lstrcpy(temporary,Command);
70
71 CharUpper(temporary);
72 pUserProc=GetSubHash(temporary);
73
74 //GetSubHash内でエラー提示が行われた場合
75 if(pUserProc==(UserProc *)-1) return;
76 }
77
78 if(pUserProc){
79 if( !pUserProc->IsMacro() ){
80 SetError(10,Command,cp);
81 }
82
83 Opcode_CallProc("",pUserProc,0,"",0);
84
85 return;
86 }
87 }
88 else if(IsNumCalcMark(Command,i)){
89 //代入演算
90 OpcodeCalc(Command);
91 return;
92 }
93
94
95 Type resultType;
96 bool isLiteral;
97 BOOL bUseHeap;
98 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, false, NULL, true );
99 if( result ){
100
101 /////////////////////
102 // 戻り値の処理
103 /////////////////////
104
105 if( resultType.IsReal() ){
106 //fstp st(0)
107 OpBuffer[obp++]=(char)0xDD;
108 OpBuffer[obp++]=(char)0xD8;
109 }
110 else if( resultType.IsStruct() ){
111 //mov ebx,eax
112 compiler.codeGenerator.op_mov_RR(REG_EBX,REG_EAX);
113
114 FreeTempObject(REG_EBX,&resultType.GetClass());
115 }
116
117 //成功
118 return;
119 }
120
121 // 失敗
122 SetError(1, NULL,cp);
123}
124
125void OpcodeIf(char *Parameter){
126 int i,i2,i3,i4;
127 Type tempType;
128
129 for(i=0;;i++){
130 if(Parameter[i]=='\0'){
131 SetError(21,NULL,cp);
132 return;
133 }
134 if(Parameter[i]==1&&Parameter[i+1]==ESC_THEN){
135 Parameter[i]=0;
136 break;
137 }
138 }
139
140 if( !NumOpe(Parameter,Type(),tempType) ){
141 //NumOpe内でエラー
142 i3=-1; //ダミー
143 }
144 else if( tempType.IsDouble() ){
145 //fld qword ptr[esp]
146 compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
147
148 //push 0
149 compiler.codeGenerator.op_push_V(0);
150
151 //fild dword ptr[esp]
152 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
153
154 //add esp,sizeof(double)+sizeof(long)
155 compiler.codeGenerator.op_add_esp(sizeof(double)+sizeof(long));
156
157 //fcompp
158 compiler.codeGenerator.op_fcompp();
159
160 //fnstsw ax
161 compiler.codeGenerator.op_fnstsw_ax();
162
163 //test ah,40
164 compiler.codeGenerator.op_test_ah( (char)0x40 );
165
166 //jne (endif、または else まで)
167 OpBuffer[obp++]=(char)0x0F;
168 OpBuffer[obp++]=(char)0x85;
169 obp+=sizeof(long);
170
171 //jneの番地
172 i3=obp;
173 }
174 else if( tempType.IsSingle() ){
175 //fld dword ptr[esp]
176 compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
177
178 //push 0
179 compiler.codeGenerator.op_push_V(0);
180
181 //fild dword ptr[esp]
182 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
183
184 //add esp,sizeof(float)+sizeof(long)
185 compiler.codeGenerator.op_add_esp(sizeof(float)+sizeof(long));
186
187 //fcompp
188 compiler.codeGenerator.op_fcompp();
189
190 //fnstsw ax
191 compiler.codeGenerator.op_fnstsw_ax();
192
193 //test ah,40
194 compiler.codeGenerator.op_test_ah( (char)0x40 );
195
196 //jne (endif、または else まで)
197 OpBuffer[obp++]=(char)0x0F;
198 OpBuffer[obp++]=(char)0x85;
199 obp+=sizeof(long);
200
201 //jneの番地
202 i3=obp;
203 }
204 else if( tempType.Is64() ){
205 //64ビット型
206
207 //pop eax
208 compiler.codeGenerator.op_pop(REG_EAX);
209
210 //pop ebx
211 compiler.codeGenerator.op_pop(REG_EBX);
212
213 //cmp eax,0
214 OpBuffer[obp++]=(char)0x83;
215 OpBuffer[obp++]=(char)0xF8;
216 OpBuffer[obp++]=(char)0x00;
217
218 //jne
219 OpBuffer[obp++]=(char)0x0F;
220 OpBuffer[obp++]=(char)0x85;
221 obp+=sizeof(long);
222 i3=obp;
223
224
225 //cmp ebx,0
226 OpBuffer[obp++]=(char)0x83;
227 OpBuffer[obp++]=(char)0xFB;
228 OpBuffer[obp++]=(char)0x00;
229
230 //jne
231 OpBuffer[obp++]=(char)0x0F;
232 OpBuffer[obp++]=(char)0x85;
233 obp+=sizeof(long);
234 i4=obp;
235
236
237
238 //jmp (endif、または else までジャンプ)
239 OpBuffer[obp++]=(char)0xE9;
240 obp+=sizeof(long);
241
242 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3;
243 *((long *)(OpBuffer+i4-sizeof(long)))=obp-i4;
244
245 //jmpの番地
246 i3=obp;
247 }
248 else{
249 //32ビット型
250
251 //pop eax
252 compiler.codeGenerator.op_pop(REG_EAX);
253
254 //cmp eax,0
255 OpBuffer[obp++]=(char)0x83;
256 OpBuffer[obp++]=(char)0xF8;
257 OpBuffer[obp++]=(char)0x00;
258
259 //je (endif、または else まで条件ジャンプ)
260 OpBuffer[obp++]=(char)0x0F;
261 OpBuffer[obp++]=(char)0x84;
262 obp+=sizeof(long);
263
264 //jeの番地
265 i3=obp;
266 }
267
268
269 /////////////////////////
270 // If内をコード化
271 /////////////////////////
272
273 //レキシカルスコープをレベルアップ
274 GetLexicalScopes().Start( obp, SCOPE_TYPE_IF );
275
276 i2=CompileBuffer(ESC_ENDIF,0);
277
278 //レキシカルスコープをレベルダウン
279 GetLexicalScopes().End();
280
281
282 if(i3==-1) return;
283
284 if(i2==ESC_ELSE){
285 //jmp (endifまで)
286 OpBuffer[obp++]=(char)0xE9;
287 obp+=sizeof(long);
288
289 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //ifからelseへのジャンプ先のオフセット値
290
291 i3=obp;
292
293
294 /////////////////////////
295 // Else内をコード化
296 /////////////////////////
297
298 //レキシカルスコープをレベルアップ
299 GetLexicalScopes().Start( obp, SCOPE_TYPE_IF );
300
301 CompileBuffer(ESC_ENDIF,0);
302
303 //レキシカルスコープをレベルダウン
304 GetLexicalScopes().End();
305
306
307 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //jmpジャンプ先のオフセット値
308 }
309 else{
310 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //jeジャンプ先のオフセット値
311 }
312}
313
314int GetLabelAddress(char *LabelName,int LineNum){
315 extern int MaxLabelNum;
316 extern LABEL *pLabelNames;
317 int i;
318
319 if(LabelName){
320 for(i=0;i<MaxLabelNum;i++){
321 if(pLabelNames[i].pName){
322 if(lstrcmp(LabelName,pLabelNames[i].pName)==0) return pLabelNames[i].address;
323 }
324 }
325 }
326 else{
327 for(i=0;i<MaxLabelNum;i++){
328 if(pLabelNames[i].pName==0){
329 if(LineNum==pLabelNames[i].line) return pLabelNames[i].address;
330 }
331 }
332 }
333 return -1;
334}
335void OpcodeGoto(char *Parameter){
336 extern HANDLE hHeap;
337 extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
338 extern int GotoLabelScheduleNum;
339 int i,LineNum;
340
341 if(Parameter[0]=='*'){
342 i=GetLabelAddress(Parameter+1,0);
343
344 //jmp ...
345 OpBuffer[obp++]=(char)0xE9;
346 if(i==-1){
347 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
348 pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1);
349 lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1);
350 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
351 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
352 GotoLabelScheduleNum++;
353 }
354 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
355 obp+=sizeof(long);
356 }
357 else{
358 LineNum=atoi(Parameter);
359 i=GetLabelAddress(0,LineNum);
360
361 //jmp ...
362 OpBuffer[obp++]=(char)0xE9;
363 if(i==-1){
364 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
365 pGotoLabelSchedule[GotoLabelScheduleNum].pName=0;
366 pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum;
367 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
368 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
369 GotoLabelScheduleNum++;
370 }
371 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
372 obp+=sizeof(long);
373 }
374}
375void OpcodeWhile(char *Parameter){
376 extern HANDLE hHeap;
377 int i2,i3 = 0;
378
379 //Continueアドレスのバックアップとセット
380 extern DWORD dwContinueAddress;
381 DWORD dwTempContinue;
382 dwTempContinue=dwContinueAddress;
383 dwContinueAddress=obp;
384
385 if(!Parameter[0]) SetError(10,"While",cp);
386
387 int je_schedule;
388 Type tempType;
389 if( !NumOpe(Parameter,Type(),tempType) ){
390 //ダミー
391 i3=-1;
392 }
393 else if( tempType.IsDouble() ){
394 //fld qword ptr[esp]
395 compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
396
397 //push 0
398 compiler.codeGenerator.op_push_V(0);
399
400 //fild dword ptr[esp]
401 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
402
403 //add esp,sizeof(double)+sizeof(long)
404 compiler.codeGenerator.op_add_esp(sizeof(double)+sizeof(long));
405
406 //fcompp
407 compiler.codeGenerator.op_fcompp();
408
409 //fnstsw ax
410 compiler.codeGenerator.op_fnstsw_ax();
411
412 //test ah,40
413 compiler.codeGenerator.op_test_ah( (char)0x40 );
414
415 //jne (Wend まで)
416 OpBuffer[obp++]=(char)0x0F;
417 OpBuffer[obp++]=(char)0x85;
418 obp+=sizeof(long);
419
420 //jeの番地
421 je_schedule=obp;
422 }
423 else if( tempType.IsSingle() ){
424 //fld dword ptr[esp]
425 compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
426
427 //push 0
428 compiler.codeGenerator.op_push_V(0);
429
430 //fild dword ptr[esp]
431 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
432
433 //add esp,sizeof(float)+sizeof(long)
434 compiler.codeGenerator.op_add_esp(sizeof(float)+sizeof(long));
435
436 //fcompp
437 compiler.codeGenerator.op_fcompp();
438
439 //fnstsw ax
440 compiler.codeGenerator.op_fnstsw_ax();
441
442 //test ah,40
443 compiler.codeGenerator.op_test_ah( (char)0x40 );
444
445 //jne (Wend まで)
446 OpBuffer[obp++]=(char)0x0F;
447 OpBuffer[obp++]=(char)0x85;
448 obp+=sizeof(long);
449
450 //jeの番地
451 je_schedule=obp;
452 }
453 else if( tempType.Is64() ){
454 //64ビット型
455
456 //pop eax
457 compiler.codeGenerator.op_pop(REG_EAX);
458
459 //pop ebx
460 compiler.codeGenerator.op_pop(REG_EBX);
461
462 //cmp eax,0
463 OpBuffer[obp++]=(char)0x83;
464 OpBuffer[obp++]=(char)0xF8;
465 OpBuffer[obp++]=(char)0x00;
466
467 //jne
468 OpBuffer[obp++]=(char)0x0F;
469 OpBuffer[obp++]=(char)0x85;
470 obp+=sizeof(long);
471 i2=obp;
472
473
474 //cmp ebx,0
475 OpBuffer[obp++]=(char)0x83;
476 OpBuffer[obp++]=(char)0xFB;
477 OpBuffer[obp++]=(char)0x00;
478
479 //jne
480 OpBuffer[obp++]=(char)0x0F;
481 OpBuffer[obp++]=(char)0x85;
482 obp+=sizeof(long);
483 i3=obp;
484
485
486 //jmp (endif、または else までジャンプ)
487 OpBuffer[obp++]=(char)0xE9;
488 obp+=sizeof(long);
489
490 *((long *)(OpBuffer+i2-sizeof(long)))=obp-i2;
491 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3;
492
493 //jmpの番地
494 je_schedule=obp;
495 }
496 else{
497 //その他整数型
498
499 //pop eax
500 compiler.codeGenerator.op_pop(REG_EAX);
501
502 //cmp eax,0
503 OpBuffer[obp++]=(char)0x83;
504 OpBuffer[obp++]=(char)0xF8;
505 OpBuffer[obp++]=(char)0x00;
506
507 //je (Wend まで)
508 OpBuffer[obp++]=(char)0x0F;
509 OpBuffer[obp++]=(char)0x84;
510 obp+=sizeof(long);
511
512 //実行中の番地
513 je_schedule=obp;
514 }
515
516 //レキシカルスコープをレベルアップ
517 GetLexicalScopes().Start( obp, SCOPE_TYPE_WHILE );
518
519 //While内をコンパイル
520 CompileBuffer(0,COM_WEND);
521
522 GetLexicalScopes().CallDestructorsOfScopeEnd();
523
524 if( i3 == -1 ){
525 return;
526 }
527
528 //jmp ...
529 OpBuffer[obp++]=(char)0xE9;
530 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long));
531 obp+=sizeof(long);
532
533 //レキシカルスコープをレベルダウン
534 GetLexicalScopes().End();
535
536 *((long *)(OpBuffer+je_schedule-sizeof(long)))=obp-je_schedule; //jeジャンプ先のオフセット値
537
538 //Continueアドレスを復元
539 dwContinueAddress=dwTempContinue;
540}
541
542char szNextVariable[VN_SIZE];
543void OpcodeFor(char *Parameter){
544 extern HANDLE hHeap;
545 int i,i2,i3;
546 char temporary[VN_SIZE],variable[VN_SIZE],JudgeNum[VN_SIZE],StepNum[VN_SIZE];
547
548 //第1パラメータを取得
549 i=GetOneParameter(Parameter,0,temporary);
550 if(!Parameter[i]){
551 SetError(12,"For",cp);
552 goto ErrorStep;
553 }
554
555 for(i2=0;;i2++){
556 if(temporary[i2]=='='){
557 variable[i2]=0;
558
559 //カウンタ初期化
560 OpcodeCalc(temporary);
561 break;
562 }
563 if(temporary[i2]=='\0'){
564 SetError(12,"For",cp);
565 goto ErrorStep;
566 }
567 variable[i2]=temporary[i2];
568 }
569
570 //jmp ...
571 OpBuffer[obp++]=(char)0xE9;
572 i2=obp;
573 obp+=sizeof(long);
574
575 //Continueアドレスのバックアップとセット
576 extern DWORD dwContinueAddress;
577 DWORD dwTempContinue;
578 dwTempContinue=dwContinueAddress;
579 dwContinueAddress=obp;
580
581 //第2パラメータを取得(to~)
582 i=GetOneParameter(Parameter,i,JudgeNum);
583
584 //第3パラメータを取得(step~)
585 if(Parameter[i]){
586 i=GetOneParameter(Parameter,i,StepNum);
587 if(Parameter[i]) SetError(12,"For",cp);
588 }
589 else lstrcpy(StepNum,"1");
590
591 //カウンタを増加させる
592 sprintf(temporary,"%s=(%s)+(%s)",variable,variable,StepNum);
593 OpcodeCalc(temporary);
594
595 *((long *)(OpBuffer+i2))=obp-(i2+sizeof(long));
596
597 //増加か減少かを区別する
598 sprintf(temporary,"(%s)>=0",StepNum);
599 NumOpe(temporary,Type(),Type());
600
601 //pop eax
602 compiler.codeGenerator.op_pop(REG_EAX);
603
604 //cmp eax,0
605 OpBuffer[obp++]=(char)0x83;
606 OpBuffer[obp++]=(char)0xF8;
607 OpBuffer[obp++]=(char)0x00;
608
609 //je [カウンタ減少の場合の判定]
610 OpBuffer[obp++]=(char)0x0F;
611 OpBuffer[obp++]=(char)0x84;
612 i2=obp;
613 obp+=sizeof(long);
614
615 //判定(カウンタ増加の場合)
616 sprintf(temporary,"%s<=(%s)",variable,JudgeNum);
617 NumOpe(temporary,Type(),Type());
618
619 //pop eax
620 compiler.codeGenerator.op_pop(REG_EAX);
621
622 //jmp [カウンタ減少の場合の判定を飛び越す]
623 OpBuffer[obp++]=(char)0xE9;
624 i3=obp;
625 obp+=sizeof(long);
626
627 *((long *)(OpBuffer+i2))=obp-(i2+sizeof(long)); //jeジャンプ先のオフセット値
628
629 //判定(カウンタ減少の場合)
630 sprintf(temporary,"%s>=(%s)",variable,JudgeNum);
631 NumOpe(temporary,Type(),Type());
632
633 //pop eax
634 compiler.codeGenerator.op_pop(REG_EAX);
635
636 *((long *)(OpBuffer+i3))=obp-(i3+sizeof(long)); //jmpジャンプ先のオフセット値
637
638 //cmp eax,0
639 OpBuffer[obp++]=(char)0x83;
640 OpBuffer[obp++]=(char)0xF8;
641 OpBuffer[obp++]=(char)0x00;
642
643ErrorStep:
644
645 //je ...
646 OpBuffer[obp++]=(char)0x0F;
647 OpBuffer[obp++]=(char)0x84;
648 int je_schedule=obp;
649 obp+=sizeof(long);
650
651 //レキシカルスコープをレベルアップ
652 GetLexicalScopes().Start( obp, SCOPE_TYPE_FOR );
653
654 //For内をコンパイル
655 CompileBuffer(0,COM_NEXT);
656
657 GetLexicalScopes().CallDestructorsOfScopeEnd();
658
659 if(szNextVariable[0]){
660 if(lstrcmp(szNextVariable,variable)!=0){
661 SetError(55,szNextVariable,cp);
662 }
663 }
664
665 //jmp ...
666 OpBuffer[obp++]=(char)0xE9;
667 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long));
668 obp+=sizeof(long);
669
670 //レキシカルスコープをレベルダウン
671 GetLexicalScopes().End();
672
673 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long)); //jeジャンプ先のオフセット値
674
675 //Continueアドレスを復元
676 dwContinueAddress=dwTempContinue;
677}
678
679void OpcodeDo(char *Parameter){
680 extern HANDLE hHeap;
681 int i,i2,i3,i4;
682
683 if(Parameter[0]) SetError(10,"Do",cp);
684
685 //Continueアドレスのバックアップとセット
686 extern DWORD dwContinueAddress;
687 DWORD dwTempContinue;
688 dwTempContinue=dwContinueAddress;
689 dwContinueAddress=obp;
690
691 //レキシカルスコープをレベルアップ
692 GetLexicalScopes().Start( obp, SCOPE_TYPE_DO );
693
694 //Do内をコンパイル
695 CompileBuffer(0,COM_LOOP);
696
697 GetLexicalScopes().CallDestructorsOfScopeEnd();
698
699 extern char *basbuf;
700 char temporary[VN_SIZE];
701 for(i=cp-1;;i--){
702 if(IsCommandDelimitation(basbuf[i])){
703 i+=3;
704 if(!(basbuf[i]=='0'||basbuf[i]=='1')){
705 //無条件ループ
706 break;
707 }
708 i3=i;
709
710 for(i+=2,i2=0;;i++,i2++){
711 if(IsCommandDelimitation(basbuf[i])){
712 temporary[i2]=0;
713 break;
714 }
715 temporary[i2]=basbuf[i];
716 }
717
718 Type tempType;
719 NumOpe(temporary,Type(),tempType);
720
721 if( tempType.IsDouble() ){
722 //fld qword ptr[esp]
723 compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
724
725 //push 0
726 compiler.codeGenerator.op_push_V(0);
727
728 //fild dword ptr[esp]
729 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
730
731 //add esp,sizeof(double)+sizeof(long)
732 compiler.codeGenerator.op_add_esp(sizeof(double)+sizeof(long));
733
734 //fcompp
735 compiler.codeGenerator.op_fcompp();
736
737 //fnstsw ax
738 compiler.codeGenerator.op_fnstsw_ax();
739
740 //test ah,40
741 compiler.codeGenerator.op_test_ah( (char)0x40 );
742
743 if(basbuf[i3]=='0'){
744 //While
745
746 //jne 5(ループ終了)
747 OpBuffer[obp++]=(char)0x75;
748 OpBuffer[obp++]=(char)0x05;
749 }
750 else if(basbuf[i3]=='1'){
751 //Until
752
753 //je 5(ループ終了)
754 OpBuffer[obp++]=(char)0x74;
755 OpBuffer[obp++]=(char)0x05;
756 }
757 }
758 else if( tempType.IsSingle() ){
759 //fld dword ptr[esp]
760 compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
761
762 //push 0
763 compiler.codeGenerator.op_push_V(0);
764
765 //fild dword ptr[esp]
766 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
767
768 //add esp,sizeof(float)+sizeof(long)
769 compiler.codeGenerator.op_add_esp(sizeof(float)+sizeof(long));
770
771 //fcompp
772 compiler.codeGenerator.op_fcompp();
773
774 //fnstsw ax
775 compiler.codeGenerator.op_fnstsw_ax();
776
777 //test ah,40
778 compiler.codeGenerator.op_test_ah( (char)0x40 );
779
780 if(basbuf[i3]=='0'){
781 //While
782
783 //jne 5(ループ終了)
784 OpBuffer[obp++]=(char)0x75;
785 OpBuffer[obp++]=(char)0x05;
786 }
787 else if(basbuf[i3]=='1'){
788 //Until
789
790 //je 5(ループ終了)
791 OpBuffer[obp++]=(char)0x74;
792 OpBuffer[obp++]=(char)0x05;
793 }
794 }
795 else if( tempType.Is64() ){
796 //64ビット型
797
798 //pop eax
799 compiler.codeGenerator.op_pop(REG_EAX);
800
801 //pop ebx
802 compiler.codeGenerator.op_pop(REG_EBX);
803
804 //cmp eax,0
805 OpBuffer[obp++]=(char)0x83;
806 OpBuffer[obp++]=(char)0xF8;
807 OpBuffer[obp++]=(char)0x00;
808
809 //jne
810 OpBuffer[obp++]=(char)0x0F;
811 OpBuffer[obp++]=(char)0x85;
812 obp+=sizeof(long);
813 i2=obp;
814
815
816 //cmp ebx,0
817 OpBuffer[obp++]=(char)0x83;
818 OpBuffer[obp++]=(char)0xFB;
819 OpBuffer[obp++]=(char)0x00;
820
821 //jne
822 OpBuffer[obp++]=(char)0x0F;
823 OpBuffer[obp++]=(char)0x85;
824 obp+=sizeof(long);
825 i4=obp;
826
827
828 if(basbuf[i3]=='0'){
829 //While
830
831 //jmp 5(ループ終了)
832 OpBuffer[obp++]=(char)0xEB;
833 OpBuffer[obp++]=(char)0x05;
834
835 *((long *)(OpBuffer+i2-sizeof(long)))=obp-i2;
836 *((long *)(OpBuffer+i4-sizeof(long)))=obp-i4;
837 }
838 else if(basbuf[i3]=='1'){
839 //Until
840
841 //jmp 2(ループを続ける)
842 OpBuffer[obp++]=(char)0xEB;
843 OpBuffer[obp++]=(char)0x02;
844
845 *((long *)(OpBuffer+i2-sizeof(long)))=obp-i2;
846 *((long *)(OpBuffer+i4-sizeof(long)))=obp-i4;
847
848 //jmp 5(ループ終了)
849 OpBuffer[obp++]=(char)0xEB;
850 OpBuffer[obp++]=(char)0x05;
851 }
852 }
853 else{
854 //pop eax
855 compiler.codeGenerator.op_pop(REG_EAX);
856
857 //cmp eax,0
858 OpBuffer[obp++]=(char)0x83;
859 OpBuffer[obp++]=(char)0xF8;
860 OpBuffer[obp++]=(char)0x00;
861
862 if(basbuf[i3]=='0'){
863 //While
864
865 //je 5(ループ終了)
866 OpBuffer[obp++]=(char)0x74;
867 OpBuffer[obp++]=(char)0x05;
868 }
869 else if(basbuf[i3]=='1'){
870 //Until
871
872 //jne 5(ループ終了)
873 OpBuffer[obp++]=(char)0x75;
874 OpBuffer[obp++]=(char)0x05;
875 }
876 }
877 break;
878 }
879 }
880
881 //jmp ...
882 OpBuffer[obp++]=(char)0xE9;
883 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long));
884 obp+=sizeof(long);
885
886 //jmp ...
887 OpBuffer[obp++]=(char)0xE9;
888 int je_schedule=obp;
889 obp+=sizeof(long);
890
891 //レキシカルスコープをレベルダウン
892 GetLexicalScopes().End();
893
894 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long)); //jmpジャンプ先のオフセット値
895
896
897 //Continueアドレスを復元
898 dwContinueAddress=dwTempContinue;
899}
900void OpcodeContinue(void){
901 extern DWORD dwContinueAddress;
902
903 if(dwContinueAddress==-1){
904 SetError(12,"Continue",cp);
905 return;
906 }
907
908 //jmp ...(Continue addr)
909 OpBuffer[obp++]=(char)0xE9;
910
911 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long));
912 obp+=sizeof(long);
913}
914
915void OpcodeExitSub(void){
916 extern DWORD *pExitSubSchedule;
917 extern int ExitSubScheduleNum;
918 extern HANDLE hHeap;
919
920 if( UserProc::IsGlobalAreaCompiling() ){
921 SetError(12,"Exit Sub/Function",cp);
922 return;
923 }
924
925 //未解放のローカルオブジェクトのデストラクタを呼び出す
926 GetLexicalScopes().CallDestructorsOfReturn();
927
928 //jmp ...(End Sub/Function)
929 OpBuffer[obp++]=(char)0xE9;
930
931 pExitSubSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitSubSchedule,(ExitSubScheduleNum+1)*sizeof(DWORD));
932 pExitSubSchedule[ExitSubScheduleNum]=obp;
933 ExitSubScheduleNum++;
934
935 obp+=sizeof(long);
936}
937
938void AddCaseSchedule(void){
939 extern DWORD *pCaseSchedule;
940 extern int CaseScheduleNum;
941 extern HANDLE hHeap;
942
943 pCaseSchedule=(DWORD *)HeapReAlloc(hHeap,0,pCaseSchedule,(CaseScheduleNum+1)*sizeof(DWORD));
944 pCaseSchedule[CaseScheduleNum]=obp;
945 CaseScheduleNum++;
946}
947
948int CaseTypeSize;
949void OpcodeSelect(const char *lpszParms){
950 extern DWORD *pCaseSchedule;
951 extern int CaseScheduleNum;
952 extern int NowCaseSchedule;
953 extern int CaseTypeSize;
954 extern HANDLE hHeap;
955 extern char *basbuf;
956 int i,i2,i3,sw,NowCaseCp;
957 char temporary[VN_SIZE];
958
959 DWORD *temp_pCaseSchedule;
960 int temp_CaseScheduleNum;
961 int temp_NowCaseSchedule;
962 int temp_CaseTypeSize;
963
964 temp_pCaseSchedule=pCaseSchedule;
965 temp_CaseScheduleNum=CaseScheduleNum;
966 temp_NowCaseSchedule=NowCaseSchedule;
967 temp_CaseTypeSize=CaseTypeSize;
968 pCaseSchedule=(DWORD *)HeapAlloc(hHeap,0,1);
969 CaseScheduleNum=0;
970 NowCaseSchedule=0;
971
972 Type type1;
973 if( !NumOpe(lpszParms,Type(), type1 ) ){
974 return;
975 }
976
977 CaseTypeSize = type1.GetSize();
978 if( CaseTypeSize < sizeof(long) ){
979 CaseTypeSize=sizeof(long);
980 }
981
982 for(i=cp,sw=0;;i++){
983 if(basbuf[i]=='\0'){
984 HeapDefaultFree(pCaseSchedule);
985 pCaseSchedule=temp_pCaseSchedule;
986 CaseScheduleNum=temp_CaseScheduleNum;
987 NowCaseSchedule=temp_NowCaseSchedule;
988 CaseTypeSize=temp_CaseTypeSize;
989 SetError(22,"Select",cp);
990 return;
991 }
992 if(basbuf[i]==1&&basbuf[i+1]==ESC_SELECTCASE){
993 for(i2=0;;i++){
994 if(basbuf[i]==1&&basbuf[i+1]==ESC_SELECTCASE) i2++;
995 if(basbuf[i]==1&&basbuf[i+1]==ESC_ENDSELECT){
996 i2--;
997 if(i2==0) break;
998 }
999 }
1000 continue;
1001 }
1002 if(basbuf[i]==1&&basbuf[i+1]==ESC_ENDSELECT){
1003 if(sw==0){
1004 //add esp,CaseTypeSize
1005 compiler.codeGenerator.op_add_esp(CaseTypeSize);
1006 }
1007 break;
1008 }
1009 if(basbuf[i]==1&&basbuf[i+1]==ESC_CASE){
1010 NowCaseCp=i;
1011
1012 i++;
1013 while(1){
1014 for(i++,i2=0;;i++,i2++){
1015 if(basbuf[i]=='\"'){
1016 i3=GetStringInQuotation(temporary+i2,basbuf+i);
1017 i+=i3-1;
1018 i2+=i3-1;
1019 continue;
1020 }
1021 if(basbuf[i]=='('){
1022 i3=GetStringInPare(temporary+i2,basbuf+i);
1023 i+=i3-1;
1024 i2+=i3-1;
1025 continue;
1026 }
1027 if(basbuf[i]=='['){
1028 i3=GetStringInBracket(temporary+i2,basbuf+i);
1029 i+=i3-1;
1030 i2+=i3-1;
1031 continue;
1032 }
1033
1034 if(IsCommandDelimitation(basbuf[i])){
1035 temporary[i2]=0;
1036 break;
1037 }
1038 if(basbuf[i]==','){
1039 temporary[i2]=0;
1040 break;
1041 }
1042
1043 temporary[i2]=basbuf[i];
1044 }
1045
1046 //エラー用
1047 i2=cp;
1048 cp=NowCaseCp;
1049
1050 Type type2;
1051 if( !NumOpe(temporary,type1,type2) ){
1052 return;
1053 }
1054
1055 cp=i2;
1056
1057 if(type1.IsObject()){
1058 std::vector<const UserProc *> subs;
1059 type1.GetClass().GetMethods().Enum( CALC_EQUAL, subs );
1060 if( subs.size() == 0 ){
1061 return;
1062 }
1063
1064 Parameters params;
1065 params.push_back( new Parameter( "", Type( type2 ) ) );
1066
1067 //オーバーロードを解決
1068 const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL);
1069
1070 delete params[0];
1071
1072 if(!pUserProc){
1073 //エラー
1074 return;
1075 }
1076
1077
1078 //pop edx
1079 compiler.codeGenerator.op_pop(REG_EDX);
1080
1081 //mov ecx,dword ptr[esp]
1082 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_ESP,0,MOD_BASE);
1083
1084 //push edx
1085 compiler.codeGenerator.op_push(REG_EDX);
1086
1087 //push ecx
1088 compiler.codeGenerator.op_push(REG_ECX);
1089
1090 //call operator_proc ※ ==演算子
1091 compiler.codeGenerator.op_call(pUserProc);
1092
1093 //test eax,eax
1094 compiler.codeGenerator.op_test(REG_EAX,REG_EAX);
1095
1096 //jne ...
1097 OpBuffer[obp++]=(char)0x0F;
1098 OpBuffer[obp++]=(char)0x85;
1099 AddCaseSchedule();
1100 obp+=sizeof(long);
1101 }
1102 else if(type1.IsDouble()){
1103 ChangeTypeToDouble(type2.GetBasicType());
1104
1105 //fld qword ptr[esp]
1106 compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
1107
1108 //add esp,CaseTypeSize
1109 compiler.codeGenerator.op_add_esp(CaseTypeSize);
1110
1111 //fld qword ptr[esp]
1112 compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
1113
1114 //fcompp
1115 compiler.codeGenerator.op_fcompp();
1116
1117 //fnstsw ax
1118 compiler.codeGenerator.op_fnstsw_ax();
1119
1120 //test ah,40
1121 compiler.codeGenerator.op_test_ah( (char)0x40 );
1122
1123 //jne ...
1124 OpBuffer[obp++]=(char)0x0F;
1125 OpBuffer[obp++]=(char)0x85;
1126 AddCaseSchedule();
1127 obp+=sizeof(long);
1128 }
1129 else if(type1.IsSingle()){
1130 ChangeTypeToSingle(type2.GetBasicType());
1131
1132 //fld dword ptr[esp]
1133 compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
1134
1135 //add esp,CaseTypeSize
1136 compiler.codeGenerator.op_add_esp(CaseTypeSize);
1137
1138 //fld dword ptr[esp]
1139 compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
1140
1141 //fcompp
1142 compiler.codeGenerator.op_fcompp();
1143
1144 //fnstsw ax
1145 compiler.codeGenerator.op_fnstsw_ax();
1146
1147 //test ah,40
1148 compiler.codeGenerator.op_test_ah( (char)0x40 );
1149
1150 //jne ...
1151 OpBuffer[obp++]=(char)0x0F;
1152 OpBuffer[obp++]=(char)0x85;
1153 AddCaseSchedule();
1154 obp+=sizeof(long);
1155 }
1156 else{
1157 //その他整数型
1158
1159 //pop ebx
1160 compiler.codeGenerator.op_pop(REG_EBX);
1161
1162 //mov eax,dword ptr[esp]
1163 OpBuffer[obp++]=(char)0x8B;
1164 OpBuffer[obp++]=(char)0x04;
1165 OpBuffer[obp++]=(char)0x24;
1166
1167 //cmp eax,ebx
1168 OpBuffer[obp++]=(char)0x3B;
1169 OpBuffer[obp++]=(char)0xC3;
1170
1171 //je ...
1172 OpBuffer[obp++]=(char)0x0F;
1173 OpBuffer[obp++]=(char)0x84;
1174 AddCaseSchedule();
1175 obp+=sizeof(long);
1176 }
1177
1178 if(basbuf[i]!=',') break;
1179 }
1180 }
1181 if(basbuf[i]==1&&basbuf[i+1]==ESC_CASEELSE){
1182 sw=1;
1183
1184 //jmp ...
1185 OpBuffer[obp++]=(char)0xE9;
1186 AddCaseSchedule();
1187 obp+=sizeof(long);
1188 }
1189 }
1190
1191 //レキシカルスコープをレベルアップ
1192 GetLexicalScopes().Start( obp, SCOPE_TYPE_SELECT );
1193
1194 //Select Case内をコンパイル
1195 CompileBuffer(ESC_ENDSELECT,0);
1196
1197 //jmp EndSelect
1198 OpBuffer[obp++]=(char)0xE9;
1199 AddCaseSchedule();
1200 obp+=sizeof(long);
1201
1202 //最終スケジュール
1203 for(i=NowCaseSchedule;i<CaseScheduleNum;i++){
1204 *(long *)(OpBuffer+pCaseSchedule[i])=obp-(pCaseSchedule[i]+sizeof(long));
1205 }
1206 HeapDefaultFree(pCaseSchedule);
1207
1208 //レキシカルスコープをレベルダウン
1209 GetLexicalScopes().End();
1210
1211 pCaseSchedule=temp_pCaseSchedule;
1212 CaseScheduleNum=temp_CaseScheduleNum;
1213 NowCaseSchedule=temp_NowCaseSchedule;
1214 CaseTypeSize=temp_CaseTypeSize;
1215}
1216void OpcodeCase(char *Parameter){
1217 extern DWORD *pCaseSchedule;
1218 extern int NowCaseSchedule;
1219 extern int CaseTypeSize;
1220 int i;
1221
1222 if(!pCaseSchedule){
1223 SetError(30,"Case",cp);
1224 return;
1225 }
1226
1227 //jmp EndSelect
1228 OpBuffer[obp++]=(char)0xE9;
1229 AddCaseSchedule();
1230 obp+=sizeof(long);
1231
1232 i=0;
1233 while(1){
1234 //Caseスケジュール
1235 *(long *)(OpBuffer+pCaseSchedule[NowCaseSchedule])=obp-(pCaseSchedule[NowCaseSchedule]+sizeof(long));
1236 NowCaseSchedule++;
1237
1238 i=JumpOneParameter(Parameter,i);
1239 if(Parameter[i]=='\0') break;
1240 }
1241
1242 //add esp,CaseTypeSize
1243 compiler.codeGenerator.op_add_esp(CaseTypeSize);
1244}
1245
1246void OpcodeGosub(char *Parameter){
1247 extern HANDLE hHeap;
1248 extern GOTOLABELSCHEDULE *pGotoLabelSchedule;
1249 extern int GotoLabelScheduleNum;
1250 int i,LineNum;
1251
1252 if(Parameter[0]=='*'){
1253 i=GetLabelAddress(Parameter+1,0);
1254
1255 //call ...
1256 OpBuffer[obp++]=(char)0xE8;
1257 if(i==-1){
1258 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
1259 pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1);
1260 lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1);
1261 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
1262 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
1263 GotoLabelScheduleNum++;
1264 }
1265 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
1266 obp+=sizeof(long);
1267 }
1268 else{
1269 LineNum=atoi(Parameter);
1270 i=GetLabelAddress(0,LineNum);
1271
1272 //call ...
1273 OpBuffer[obp++]=(char)0xE8;
1274 if(i==-1){
1275 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));
1276 pGotoLabelSchedule[GotoLabelScheduleNum].pName=0;
1277 pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum;
1278 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;
1279 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;
1280 GotoLabelScheduleNum++;
1281 }
1282 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));
1283 obp+=sizeof(long);
1284 }
1285}
1286void OpcodeReturn(char *Parameter){
1287 if( UserProc::IsGlobalAreaCompiling() ){
1288 //Gosub~Returnとして扱う
1289
1290 //ret
1291 compiler.codeGenerator.op_ret();
1292 }
1293 else{
1294 //戻り値をセット
1295 if(Parameter[0]){
1296 const UserProc &proc = UserProc::CompilingUserProc();
1297
1298 const char *temp = "_System_ReturnValue";
1299 if(proc.GetName()[0]==1&&proc.GetName()[1]==ESC_OPERATOR)
1300 {
1301 }
1302 else{
1303 temp=proc.GetName().c_str();
1304 }
1305
1306 char temporary[VN_SIZE];
1307 sprintf(temporary,"%s=%s",temp,Parameter);
1308 OpcodeCalc(temporary);
1309 }
1310
1311 //プロシージャを抜け出す(C言語のreturnと同様の処理を行う)
1312 OpcodeExitSub();
1313 }
1314}
1315
1316
1317////////////
1318// ポインタ
1319
1320void OpcodeSetPtrData(char *Parameter,int type){
1321 int i;
1322 char temporary[VN_SIZE];
1323
1324 if(Parameter[0]=='('){
1325 i=JumpStringInPare(Parameter,1);
1326 if(Parameter[i+1]=='\0'){
1327 for(i=0;;i++){
1328 Parameter[i]=Parameter[i+1];
1329 if(Parameter[i]=='\0') break;
1330 }
1331 Parameter[i-1]=0;
1332 }
1333 }
1334
1335 //第1パラメータを取得
1336 i=GetOneParameter(Parameter,0,temporary);
1337 if(!Parameter[i]){
1338 SetError(1,NULL,cp);
1339 return;
1340 }
1341
1342 Type resultType;
1343 if( !NumOpe(temporary,Type(),resultType) ){
1344 return;
1345 }
1346 if(!resultType.IsWhole()){
1347 SetError(11,Parameter,cp);
1348 return;
1349 }
1350
1351 ChangeTypeToLong( resultType.GetBasicType() );
1352
1353 //第2パラメータを取得
1354 i=GetOneParameter(Parameter,i,temporary);
1355 if(Parameter[i]){
1356 SetError(1,NULL,cp);
1357 return;
1358 }
1359
1360 if( !NumOpe(temporary,Type(),resultType) ){
1361 return;
1362 }
1363
1364 if(type==DEF_DOUBLE){
1365 ChangeTypeToDouble_ToFpuReg( resultType.GetBasicType() );
1366
1367 //pop eax
1368 compiler.codeGenerator.op_pop(REG_EAX);
1369
1370 //fstp qword ptr[eax]
1371 OpBuffer[obp++]=(char)0xDD;
1372 OpBuffer[obp++]=(char)0x18;
1373 }
1374 else if(type==DEF_SINGLE){
1375 ChangeTypeToSingle( resultType.GetBasicType() );
1376
1377 //pop ebx
1378 compiler.codeGenerator.op_pop(REG_EBX);
1379
1380 //pop eax
1381 compiler.codeGenerator.op_pop(REG_EAX);
1382
1383 //mov dword ptr[eax],ebx
1384 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0, MOD_BASE );
1385 }
1386 else if(type==DEF_QWORD){
1387 ChangeTypeToInt64( resultType.GetBasicType() );
1388
1389 //pop ecx
1390 compiler.codeGenerator.op_pop(REG_ECX);
1391
1392 //pop ebx
1393 compiler.codeGenerator.op_pop(REG_EBX);
1394
1395 //pop eax
1396 compiler.codeGenerator.op_pop(REG_EAX);
1397
1398 //mov dword ptr[eax],ecx
1399 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE );
1400
1401 //mov dword ptr[eax+sizeof(long)],ebx
1402 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0x04, MOD_BASE_DISP8 );
1403 }
1404 else if(type==DEF_DWORD){
1405 ChangeTypeToLong( resultType.GetBasicType() );
1406
1407 //pop ebx
1408 compiler.codeGenerator.op_pop(REG_EBX);
1409
1410 //pop eax
1411 compiler.codeGenerator.op_pop(REG_EAX);
1412
1413 //mov dword ptr[eax],ebx
1414 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0, MOD_BASE );
1415 }
1416 else if(type==DEF_WORD){
1417 ChangeTypeToLong( resultType.GetBasicType() );
1418
1419 //pop ebx
1420 compiler.codeGenerator.op_pop(REG_EBX);
1421
1422 //pop eax
1423 compiler.codeGenerator.op_pop(REG_EAX);
1424
1425 //mov word ptr[eax],bx
1426 OpBuffer[obp++]=(char)0x66;
1427 OpBuffer[obp++]=(char)0x89;
1428 OpBuffer[obp++]=(char)0x18;
1429 }
1430 else if(type==DEF_BYTE){
1431 ChangeTypeToLong( resultType.GetBasicType() );
1432
1433 //pop ebx
1434 compiler.codeGenerator.op_pop(REG_EBX);
1435
1436 //pop eax
1437 compiler.codeGenerator.op_pop(REG_EAX);
1438
1439 //mov byte ptr[eax],bl
1440 OpBuffer[obp++]=(char)0x88;
1441 OpBuffer[obp++]=(char)0x18;
1442 }
1443}
Note: See TracBrowser for help on using the repository browser.