source: dev/BasicCompiler32/NumOpe.cpp@ 93

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

"a=[10,20,30]" などのように、リテラルバイナリデータを指定できるようにした。

File size: 19.8 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2#include "Opcode.h"
3
4void PushReturnValue(int type){
5 //関数の戻り値をスタックへプッシュする
6 //※この処理内では、esi、ediは使用不可
7
8 if(type==DEF_OBJECT || type==DEF_STRUCT){
9 //push eax
10 op_push(REG_EAX);
11 }
12 else if(type==DEF_DOUBLE){
13 //sub esp,8
14 op_sub_esp(8);
15
16 //fstp qword ptr[esp]
17 OpBuffer[obp++]=(char)0xDD;
18 OpBuffer[obp++]=(char)0x1C;
19 OpBuffer[obp++]=(char)0x24;
20 }
21 else if(type==DEF_SINGLE){
22 //sub esp,4
23 op_sub_esp(4);
24
25 //fstp dword ptr[esp]
26 OpBuffer[obp++]=(char)0xD9;
27 OpBuffer[obp++]=(char)0x1C;
28 OpBuffer[obp++]=(char)0x24;
29 }
30 else if(type==DEF_INT64||type==DEF_QWORD){
31 //push edx
32 op_push(REG_EDX);
33
34 //push eax
35 op_push(REG_EAX);
36 }
37 else if(type==DEF_LONG){
38 //push eax
39 op_push(REG_EAX);
40 }
41 else if(type==DEF_INTEGER || (isUnicode&&type==DEF_CHAR)){
42 //movsx ebx,ax
43 OpBuffer[obp++]=(char)0x0F;
44 OpBuffer[obp++]=(char)0xBF;
45 OpBuffer[obp++]=(char)0xD8;
46
47 //push ebx
48 op_push(REG_EBX);
49 }
50 else if(type==DEF_SBYTE || (isUnicode==false&&type==DEF_CHAR)){
51 //movsx ebx,al
52 OpBuffer[obp++]=(char)0x0F;
53 OpBuffer[obp++]=(char)0xBE;
54 OpBuffer[obp++]=(char)0xD8;
55
56 //push ebx
57 op_push(REG_EBX);
58 }
59 else if(type==DEF_DWORD||type==DEF_WORD||type==DEF_BYTE||type==DEF_BOOLEAN||
60 IsPtrType(type)){
61 //push eax
62 op_push(REG_EAX);
63 }
64 else{
65 SetError();
66 }
67}
68
69void NewStringObject( const char *str ){
70 ///////////////////////////////////////////////////////
71 // lpszTextを元にStringオブジェクトを生成し、
72 // オブジェクトポインタをregに格納する
73 ///////////////////////////////////////////////////////
74
75 char *parameter = (char *)malloc( lstrlen( str ) + 32 );
76 sprintf( parameter, "\"%s\"%c%c*Char", str, 1, ESC_AS );
77 SetStringQuotes( parameter );
78
79 extern CClass *pobj_StringClass;
80 Operator_New( *pobj_StringClass, "", parameter, Type( DEF_OBJECT, *pobj_StringClass ) );
81
82 free( parameter );
83}
84
85
86bool NumOpe( const char *expression,
87 const Type &baseType,
88 Type &resultType,
89 BOOL *pbUseHeap ){
90
91 int i,i2,i3,i4;
92 char temporary[1024],temp2[1024],temp3[1024];
93
94 if(expression[0]=='\0'){
95 SetError(1,NULL,cp);
96 return false;
97 }
98
99 if(expression[0]==1&& expression[1]==ESC_NEW ){
100 //New演算子(オブジェクト生成)
101
102 if( !Operator_New( expression+2, baseType, resultType ) ){
103 return false;
104 }
105
106 return true;
107 }
108
109 if( !baseType.IsNull() && expression[0] == '[' ){
110 // リテラル配列の場合
111
112 if( !baseType.IsPointer() ){
113 SetError(1,NULL,cp);
114 return false;
115 }
116 Type tempBaseType( baseType );
117 tempBaseType.PtrLevelDown();
118
119 char *buffer = (char *)malloc( lstrlen( expression ) + 1 );
120 lstrcpy( buffer, expression );
121 RemoveStringBracket( buffer );
122
123 void *binary = malloc( 1 );
124 int num = 0;
125
126 i = 0;
127 while( buffer[i] ){
128 i = GetOneParameter( buffer, i, temporary );
129 if( buffer[i] == ',' ){
130 i++;
131 }
132
133 Type resultType;
134 _int64 i64data;
135 if( !StaticCalculation( true, temporary, tempBaseType.GetBasicType(), &i64data, resultType ) ){
136 return false;
137 }
138 if( !resultType.IsWhole() ){
139 // TODO: 実数に未対応
140 SetError();
141 return false;
142 }
143
144 binary = realloc( binary, ( num + 1 ) * tempBaseType.GetSize() );
145 memcpy( (char *)binary + (num * tempBaseType.GetSize()), &i64data, tempBaseType.GetSize() );
146 num++;
147 }
148
149 i2 = dataTable.AddBinary( binary, num * tempBaseType.GetSize() );
150
151 //mov eax,i2
152 op_mov_RV(REG_EAX,i2);
153 obp-=sizeof(long);
154 pobj_DataTableSchedule->add();
155 obp+=sizeof(long);
156
157 free( buffer );
158
159 resultType = baseType;
160
161 //push eax
162 op_push( REG_EAX );
163
164 return true;
165 }
166
167
168 /////////////////////////////////
169 // 式要素を逆ポーランド式で取得
170 /////////////////////////////////
171
172 char *values[255];
173 long calc[255];
174 long stack[255];
175 int pnum;
176 if(!GetNumOpeElements(expression,&pnum,values,calc,stack)){
177 for(i=0;i<pnum;i++){
178 if(values[i]) HeapDefaultFree(values[i]);
179 }
180 return false;
181 }
182
183
184 BOOL bError;
185 bError=0;
186
187 //リテラル値のみの計算かどうかを判別するためのフラグ
188 BOOL bLiteralCalculation=1;
189
190 //リテラル演算の場合を考慮した演算前のバッファ位置
191 int BeforeObp;
192 BeforeObp=obp;
193
194 //リテラル演算の場合を考慮した演算前のプロシージャスケジュール位置
195 //※64ビットの掛け算、除算などで特殊関数が呼ばれるため
196 int Before_ProcAddrScheduleNum;
197 Before_ProcAddrScheduleNum=pobj_SubAddrSchedule->num;
198
199 //リテラル演算の場合を考慮した演算前のデータテーブルスケジュール位置
200 int Before_DataTableScheduleNum;
201 Before_DataTableScheduleNum=pobj_DataTableSchedule->num;
202
203 //リテラル演算の場合を考慮した演算前の再配置スケジュール
204 CReloc *pobj_BackReloc;
205 pobj_BackReloc=new CReloc();
206 pobj_BackReloc->copy(pobj_Reloc);
207
208 double dbl;
209 int sp;
210 int type_stack[255];
211 bool isNothing_stack[255];
212 LONG_PTR index_stack[255];
213 BOOL bUseHeap[255];
214 _int64 i64data;
215 for(i=0,sp=0;i<pnum;i++){
216 int idCalc;
217 idCalc=calc[i]%100;
218
219 if(idCalc){
220 if(type_stack[sp-2]==DEF_OBJECT){
221 if( idCalc == CALC_AS
222 && type_stack[sp-1] == ( DEF_OBJECT | FLAG_CAST )
223 && index_stack[sp-1] == index_stack[sp-2]
224 || isNothing_stack[sp-2] ){
225 // 同一の型、またはNothingに対するAsはAs演算子を呼び出さない
226 }
227 else{
228 //オーバーロードされたオペレータを呼び出す
229 i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack,bUseHeap,sp);
230 if(i2==0){
231 if(idCalc==CALC_EQUAL) lstrcpy(temp2,"==");
232 else GetCalcName(idCalc,temp2);
233 sprintf(temporary,"Operator %s",temp2);
234 SetError(27,temporary,cp);
235 goto error;
236 }
237 else if(i2==-1) goto error;
238
239 continue;
240 }
241 }
242
243 if(!CheckCalcType(idCalc,type_stack,sp)) goto error;
244 }
245
246 switch(idCalc){
247 //数値
248 case 0:
249 index_stack[sp]=-1;
250 isNothing_stack[sp] = false;
251 bUseHeap[sp]=0;
252
253 char *term;
254 term=values[i];
255
256 if(term[0]=='\"'){
257 //リテラル文字列
258 if(!RemoveStringQuotes(term)){
259 SetError(43,NULL,cp);
260 goto error;
261 }
262 i3=lstrlen(term);
263StrLiteral:
264
265 if( baseType.IsObject() ){
266 if( baseType.IsStringObject() ){
267 //要求タイプがStringのとき
268
269 //String型オブジェクトを生成
270 NewStringObject(term);
271
272 extern CClass *pobj_StringClass;
273 type_stack[sp]=DEF_OBJECT;
274 index_stack[sp]=(LONG_PTR)pobj_StringClass;
275 bLiteralCalculation=0;
276
277 sp++;
278 break;
279 }
280 }
281
282
283 type_stack[sp]=typeOfPtrChar;
284 bLiteralCalculation=0;
285
286 i2=dataTable.AddString(term,i3);
287
288 //push DataSize
289 OpBuffer[obp++]=(char)0x68;
290 *((long *)(OpBuffer+obp))=i2;
291 pobj_DataTableSchedule->add();
292 obp+=sizeof(long);
293 }
294 else if((term[0]=='e'||term[0]=='E')&&
295 (term[1]=='x'||term[1]=='X')&&
296 term[2]=='\"'){
297 //拡張版リテラル文字列(エスケープシーケンス可能)
298 if(!RemoveStringQuotes(term+2)){
299 SetError(43,NULL,cp);
300 goto error;
301 }
302 i3=FormatString_EscapeSequence(term+2);
303 term+=2;
304
305 goto StrLiteral;
306 }
307 else if(IsVariableTopChar(term[0])||
308 term[0]=='*'||
309 (term[0]=='.'&&IsVariableTopChar(term[1]))){
310 //////////////////
311 // 何らかの識別子
312
313 //////////////////////////////////////
314 // 関数(DLL、ユーザー定義、組み込み)
315 //////////////////////////////////////
316
317 i2=GetCallProcName(term,temporary);
318 if(term[i2]=='('){
319 i4=GetStringInPare_RemovePare(temp2,term+i2+1);
320
321 void *pInfo;
322 int idProc=GetProc(temporary,(void **)&pInfo);
323
324 Type resultType;
325 if(idProc){
326 //閉じカッコ")"に続く文字がNULLでないとき
327 if(term[i2+1+i4+1]!='\0'){
328 if( term[i2+1+i4+1] == '.'
329 || term[i2+1+i4+1] == 1 && term[i2+1+i4+2] == ESC_PSMEM ){
330 goto NonProc;
331 }
332 else{
333 SetError(42,NULL,cp);
334 }
335 }
336
337 ////////////////
338 // 呼び出し
339 ////////////////
340
341 CallProc(idProc,pInfo,temporary,temp2,resultType);
342 if(resultType.IsNull()){
343 //戻り値が存在しないとき
344 for(i2=2;;i2++){
345 if(term[i2]=='('||term[i2]=='\0'){
346 term[i2]=0;
347 break;
348 }
349 }
350 SetError(38,term,cp);
351
352 goto error;
353 }
354
355
356 /////////////////////
357 // 戻り値の処理
358 /////////////////////
359
360 //大きな型への暗黙の変換
361 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
362 index_stack[sp] = resultType.GetIndex();
363 bLiteralCalculation=0;
364
365 //スタックへプッシュ
366 PushReturnValue( resultType.GetBasicType() );
367
368 if( Is64Type(type_stack[sp])
369 && resultType.IsWhole()
370 && resultType.GetBasicSize() <= sizeof(long) ){
371 //必要に応じて64ビット拡張
372 ExtendStackTo64( resultType.GetBasicType() );
373 }
374
375 if( resultType.IsStruct() ){
376 //構造体が戻ったときはヒープ領域にインスタンスが格納されている
377 //※後にfreeする必要あり
378 bUseHeap[sp]=1;
379 }
380
381 sp++;
382 break;
383 }
384 else if(GetConstCalcBuffer(temporary,temp2,temp3)){
385 /////////////////////////
386 // マクロ関数
387 /////////////////////////
388
389 //閉じカッコ")"に続く文字がNULLでないときはエラーにする
390 if(term[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
391
392 //マクロ関数の場合
393 NumOpe(temp3,Type(),resultType);
394
395 if(!IS_LITERAL(resultType.GetIndex())){
396 //リテラル値ではなかったとき
397 bLiteralCalculation=0;
398 }
399
400 type_stack[sp] = resultType.GetBasicType();
401 index_stack[sp] = resultType.GetIndex();
402
403 sp++;
404 break;
405 }
406 }
407NonProc:
408
409
410 //インデクサ(getアクセサ)
411 char variable[VN_SIZE],array_element[VN_SIZE];
412 GetArrayElement(term,variable,array_element);
413 if(array_element[0]){
414 Type resultType;
415 GetVarType(variable,resultType,0);
416 if( resultType.IsObject() ){
417 CallIndexerGetterProc(&resultType.GetClass(),variable,array_element,resultType);
418 type_stack[sp]=resultType.GetBasicType();
419 index_stack[sp]=resultType.GetIndex();
420 bLiteralCalculation=0;
421
422 //push eax
423 op_push(REG_EAX);
424
425 sp++;
426 break;
427 }
428 }
429
430
431 // Nothing
432 if( lstrcmp( term, "Nothing" ) == 0 ){
433 isNothing_stack[sp] = true;
434
435 type_stack[sp] = DEF_OBJECT;
436 if( baseType.IsObject() ){
437 index_stack[sp] = baseType.GetIndex();
438 }
439 else{
440 index_stack[sp] = (LONG_PTR)pobj_DBClass->GetObjectClass();
441 }
442
443 bLiteralCalculation = 0;
444
445 //push 0
446 op_push_V( 0 );
447
448 sp++;
449 break;
450 }
451
452 RELATIVE_VAR RelativeVar;
453 Type varType;
454 if(GetVarOffset(
455 false, //エラー表示あり
456 false, //読み込み専用
457 term,
458 &RelativeVar,varType)){
459 //////////
460 // 変数
461 //////////
462
463 //大きな型への暗黙の変換
464 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),varType.GetBasicType());
465 index_stack[sp] = varType.GetIndex();
466 bLiteralCalculation=0;
467
468 if(varType.GetBasicType()&FLAG_PTR){
469 //配列ポインタ
470 type_stack[sp]=GetPtrType(varType.GetBasicType()^FLAG_PTR);
471
472 SetVarPtrToEax(&RelativeVar);
473
474 //push eax
475 op_push(REG_EAX);
476 }
477 else if( varType.IsStruct() ){
478 //構造体ポインタをeaxへ格納(構造体は値型)
479 SetVarPtrToEax(&RelativeVar);
480
481 //push eax
482 op_push(REG_EAX);
483 }
484 else if( varType.GetBasicSize() == sizeof(_int64) ){
485 //64ビット型
486 PushDoubleVariable(&RelativeVar);
487 }
488 else if( varType.GetBasicSize() == sizeof(long) ){
489 //32ビット型
490 PushLongVariable(&RelativeVar);
491 }
492 else if( varType.IsInteger() ){
493 PushIntegerVariable(&RelativeVar);
494 }
495 else if( varType.IsWord() ){
496 PushWordVariable(&RelativeVar);
497 }
498 else if( varType.IsSByte() ){
499 PushCharVariable(&RelativeVar);
500 }
501 else if( varType.IsByte() || varType.IsBoolean() ){
502 PushByteVariable(&RelativeVar);
503 }
504 else SetError(11,term,cp);
505
506 if( Is64Type(type_stack[sp])
507 && varType.IsWhole()
508 && varType.GetBasicSize()<=sizeof(long)){
509 //必要に応じて64ビット拡張
510 ExtendStackTo64( varType.GetBasicType() );
511 }
512
513 sp++;
514 break;
515 }
516
517
518 //////////////
519 // 定数の場合
520 //////////////
521
522 i3 = CDBConst::obj.GetType(term);
523 if(i3){
524 type_stack[sp]=i3;
525 if(IsRealNumberType(i3)){
526 //実数
527 double dbl = CDBConst::obj.GetDoubleData(term);
528 memcpy(&i64data,&dbl,sizeof(double));
529 goto Literal;
530 }
531 else if(IsWholeNumberType(i3)){
532 //整数
533 i64data = CDBConst::obj.GetWholeData(term);
534 goto Literal;
535 }
536 /*else if(i3==DEF_STRING){
537 //リテラル文字列
538
539 //バイト数
540 i3=(int)dbl;
541
542 memcpy(term,temporary,i3);
543 goto StrLiteral;
544 }*/
545 else{
546 SetError(300,NULL,cp);
547 goto error;
548 }
549 }
550
551
552 //////////////
553 // 型名の場合
554 //////////////
555 Type tempType;
556 if( Type::StringToType( term, tempType ) ){
557 type_stack[sp] = tempType.GetBasicType() | FLAG_CAST;
558 index_stack[sp] = tempType.GetIndex();
559 sp++;
560 break;
561 }
562
563
564 /////////////////////////////////
565 // プロパティ用のメソッド
566 /////////////////////////////////
567
568 //配列要素を排除
569 char VarName[VN_SIZE],ArrayElements[VN_SIZE];
570 GetArrayElement(term,VarName,ArrayElements);
571
572 if(GetSubHash(VarName,0)){
573 Type resultType;
574 CallPropertyMethod(term,NULL,resultType);
575
576 //大きな型への暗黙の変換
577 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
578 index_stack[sp]=resultType.GetIndex();
579 bLiteralCalculation=0;
580
581 //スタックへプッシュ
582 PushReturnValue( resultType.GetBasicType() );
583
584 if(type_stack[sp]==DEF_STRUCT){
585 //構造体が戻ったときはヒープ領域にインスタンスが格納されている
586 //※後にfreeする必要あり
587 bUseHeap[sp]=1;
588 }
589
590 sp++;
591 break;
592 }
593
594
595
596 //該当する識別子が見当たらないときはエラー扱いにする
597 bError=1;
598 SetError(3,term,cp);
599 type_stack[sp]=DEF_DOUBLE;
600 }
601 else{
602 //リテラル値
603 type_stack[sp]=GetLiteralValue(term,&i64data,baseType.GetBasicType());
604Literal:
605 if(type_stack[sp]==DEF_INT64||
606 type_stack[sp]==DEF_QWORD||
607 type_stack[sp]==DEF_DOUBLE){
608 //64ビット(符号有り整数/実数)
609
610 //push HILONG(dbl)
611 op_push_V((long)*(long *)(((char *)(&i64data))+4));
612
613 //push LOLONG(dbl)
614 op_push_V(*(long *)(&i64data));
615 }
616 else if(type_stack[sp]==DEF_SINGLE){
617 //single実数
618
619 float flt;
620 memcpy(&dbl,&i64data,sizeof(double));
621 flt=(float)dbl;
622 memcpy(&i3,&flt,sizeof(long));
623
624 //push term
625 op_push_V(i3);
626 }
627 else{
628 //その他
629
630 //push term
631 op_push_V((long)i64data);
632
633 if((long)i64data==0) index_stack[sp]=LITERAL_NULL;
634 }
635
636
637 //リテラル値の種類
638 if(Is64Type(type_stack[sp])==0&&IsRealNumberType(type_stack[sp])==0){
639 //整数(符号有り/無し)
640
641 index_stack[sp]=GetLiteralIndex(i64data);
642 }
643 }
644 sp++;
645 break;
646
647 //論理演算子
648 case CALC_XOR:
649 //value[sp-2] xor= value[sp-1]
650 //xor演算
651 if(!Calc_Xor(type_stack,index_stack,&sp)) goto error;
652 break;
653 case CALC_OR:
654 //value[sp-2] or= value[sp-1]
655 //or演算
656 if(!Calc_Or(type_stack,index_stack,&sp)) goto error;
657 break;
658 case CALC_AND:
659 //value[sp-2] and= value[sp-1]
660 //and演算
661 if(!Calc_And(type_stack,index_stack,&sp)) goto error;
662 break;
663 case CALC_NOT:
664 //value[sp-1]=Not value[sp-1]
665 //NOT演算子
666 if(!Calc_Not(type_stack,sp)) goto error;
667 break;
668
669 //比較演算子
670 case CALC_PE:
671 //value[sp-2]<=value[sp-1]
672 if(!Calc_Relation_PE(type_stack,index_stack,&sp)) goto error;
673 break;
674 case CALC_QE:
675 //value[sp-2]>=value[sp-1]
676 if(!Calc_Relation_QE(type_stack,index_stack,&sp)) goto error;
677 break;
678 case CALC_P:
679 //value[sp-2]<value[sp-1]
680 if(!Calc_Relation_P(type_stack,index_stack,&sp)) goto error;
681 break;
682 case CALC_Q:
683 //value[sp-2]>value[sp-1]
684 if(!Calc_Relation_Q(type_stack,index_stack,&sp)) goto error;
685 break;
686 case CALC_NOTEQUAL:
687 //value[sp-2]<>value[sp-1]
688 if(!Calc_Relation_NotEqual(type_stack,&sp)) goto error;
689 break;
690 case CALC_EQUAL:
691 //value[sp-2]=value[sp-1]
692 if(!Calc_Relation_Equal(type_stack,&sp)) goto error;
693 break;
694
695 //ビットシフト
696 case CALC_SHL:
697 //value[sp-2]=value[sp-2]<<value[sp-1]
698 if(!Calc_SHL(type_stack,&sp)) goto error;
699 break;
700 case CALC_SHR:
701 //value[sp-2]=value[sp-2]>>value[sp-1]
702 if(!Calc_SHR(type_stack,&sp)) goto error;
703 break;
704
705 //算術演算
706 case CALC_ADDITION:
707 case CALC_SUBTRACTION:
708 case CALC_PRODUCT:
709 if(!CalcTwoTerm_Arithmetic(idCalc,type_stack,index_stack,&sp)) goto error;
710 break;
711
712 case CALC_MOD:
713 //value[sp-2]%=value[sp-1]
714 //剰余演算
715 if(!Calc_Mod(type_stack,&sp)) goto error;
716 break;
717 case CALC_QUOTIENT:
718 //value[sp-2]/=value[sp-1];
719 //除算
720 if(!Calc_Divide(type_stack,&sp,baseType.GetBasicType())) goto error;
721 break;
722 case CALC_INTQUOTIENT:
723 //value[sp-2]/=value[sp-1]
724 //整数除算
725 if(!Calc_IntDivide(type_stack,index_stack,&sp)) goto error;
726 break;
727 case CALC_MINUSMARK:
728 //value[sp-1]=-value[sp-1]
729 //符号反転
730 if(!Calc_MinusMark(type_stack,sp)) goto error;
731 index_stack[sp-1]=-1;
732 break;
733 case CALC_POWER:
734 //べき乗演算(浮動小数点演算のみ)
735 if(!Calc_Power(type_stack,&sp)) goto error;
736 break;
737 case CALC_AS:
738 //キャスト
739 if(!Calc_Cast(type_stack,index_stack,&sp)) goto error;
740 break;
741
742 case CALC_BYVAL:
743 //ポインタ型→参照型
744 if( PTR_LEVEL( type_stack[sp-1] ) <= 0 ){
745 //ポインタ型ではないとき
746 SetError( 3, NULL, cp );
747 goto error;
748 }
749
750 type_stack[sp-1] = PTR_LEVEL_DOWN( type_stack[sp-1] );
751
752 break;
753
754 default:
755 SetError(300,NULL,cp);
756 goto error;
757 }
758 }
759
760 if(bError) goto error;
761
762 if(sp!=1){
763 SetError(1,NULL,cp);
764 goto error;
765 }
766
767 if(bLiteralCalculation){
768 //右辺値が数値の定数式の場合
769 Type resultType;
770 StaticCalculation(true, expression,baseType.GetBasicType(),&i64data,resultType);
771
772 obp=BeforeObp;
773 pobj_SubAddrSchedule->num=Before_ProcAddrScheduleNum;
774 pobj_DataTableSchedule->num=Before_DataTableScheduleNum;
775 pobj_Reloc->copy(pobj_BackReloc);
776
777 if( resultType.GetBasicSize() == sizeof(_int64) ){
778 //64ビット(符号有り整数/実数)
779
780 //push HILONG(i64data)
781 op_push_V((long)*(long *)(((char *)(&i64data))+4));
782
783 //push LOLONG(i64data)
784 op_push_V(*(long *)(&i64data));
785 }
786 else if( resultType.IsSingle() ){
787 //single実数
788
789 memcpy(&dbl,&i64data,sizeof(_int64));
790
791 float flt;
792 flt=(float)dbl;
793 memcpy(&i3,&flt,sizeof(long));
794
795 //push flt
796 op_push_V(i3);
797 }
798 else{
799 //整数(符号有り/無し)
800
801 i3=(long)i64data;
802
803 if(resultType.GetBasicSize()==sizeof(char)) i3=i3&0x000000FF;
804 if(resultType.GetBasicSize()==sizeof(short)) i3=i3&0x0000FFFF;
805
806 //push term
807 op_push_V(i3);
808 }
809
810 type_stack[0]=resultType.GetBasicType();
811 index_stack[0]=resultType.GetIndex();
812 }
813 else{
814 //右辺値が数値の定数式ではないとき
815 if(IS_LITERAL(index_stack[0])) index_stack[0]=-1;
816 }
817
818 if(pbUseHeap) *pbUseHeap=bUseHeap[0];
819
820 resultType.SetType( type_stack[0], index_stack[0] );
821
822 bool isSuccessful = true;
823 goto finish;
824
825
826error:
827 isSuccessful = false;
828 goto finish;
829
830
831finish:
832
833 for(i=0;i<pnum;i++){
834 if(values[i]) HeapDefaultFree(values[i]);
835 }
836
837 //再配置スケジュールバックアップ情報を解放
838 delete pobj_BackReloc;
839
840 return isSuccessful;
841}
Note: See TracBrowser for help on using the repository browser.