| [193] | 1 | #include <Compiler.h>
 | 
|---|
| [182] | 2 | 
 | 
|---|
| [4] | 3 | #include "../BasicCompiler_Common/common.h"
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | #ifdef _AMD64_
 | 
|---|
 | 6 | #include "../BasicCompiler64/opcode.h"
 | 
|---|
 | 7 | #else
 | 
|---|
| [5] | 8 | #include "../BasicCompiler32/opcode.h"
 | 
|---|
| [4] | 9 | #endif
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | extern HANDLE hHeap;
 | 
|---|
 | 12 | 
 | 
|---|
| [75] | 13 | void CallConstructor( const char *ObjectName,const int *SubScripts,const Type &type,const char *Parameter){
 | 
|---|
 | 14 |     if( !type.IsObject() ){
 | 
|---|
 | 15 |         return;
 | 
|---|
 | 16 |     }
 | 
|---|
| [4] | 17 | 
 | 
|---|
 | 18 |     /////////////////////////////////////
 | 
|---|
 | 19 |     // クラスオブジェクトの場合
 | 
|---|
 | 20 |     // ※コンストラクタの呼び出し
 | 
|---|
 | 21 |     /////////////////////////////////////
 | 
|---|
 | 22 | 
 | 
|---|
| [75] | 23 |     UserProc *pUserProc;
 | 
|---|
| [131] | 24 |     pUserProc=GetMethodHash(ObjectName,type.GetClass().GetName().c_str(),Parameter);
 | 
|---|
| [75] | 25 |     if(!pUserProc){
 | 
|---|
| [131] | 26 |         if(Parameter[0]) SetError(113,type.GetClass().GetName().c_str(),cp);
 | 
|---|
| [4] | 27 |         return;
 | 
|---|
 | 28 |     }
 | 
|---|
| [5] | 29 | 
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 |     char temporary[VN_SIZE];
 | 
|---|
 | 32 | 
 | 
|---|
| [4] | 33 |     if(SubScripts[0]!=-1){
 | 
|---|
 | 34 |         int ss[MAX_ARRAYDIM];
 | 
|---|
 | 35 |         memset(ss,0,MAX_ARRAYDIM*sizeof(int));
 | 
|---|
 | 36 |         while(1){
 | 
|---|
 | 37 |             int i3;
 | 
|---|
 | 38 |             for(i3=0;;i3++){
 | 
|---|
 | 39 |                 if(SubScripts[i3]==-1) break;
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 |                 if(ss[i3]>SubScripts[i3]){
 | 
|---|
 | 42 |                     ss[i3]=0;
 | 
|---|
 | 43 |                     ss[i3+1]++;
 | 
|---|
 | 44 |                 }
 | 
|---|
 | 45 |                 else break;
 | 
|---|
 | 46 |             }
 | 
|---|
 | 47 |             if(SubScripts[i3]==-1) break;
 | 
|---|
| [5] | 48 |             sprintf(temporary,"%s[%d",ObjectName,ss[0]);
 | 
|---|
| [4] | 49 |             for(i3=1;;i3++){
 | 
|---|
 | 50 |                 if(SubScripts[i3]==-1) break;
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 |                 sprintf(temporary+lstrlen(temporary),",%d",ss[i3]);
 | 
|---|
 | 53 |             }
 | 
|---|
 | 54 |             lstrcat(temporary,"]");
 | 
|---|
 | 55 | 
 | 
|---|
| [75] | 56 |             Type dummyType;
 | 
|---|
| [131] | 57 |             sprintf(temporary+lstrlen(temporary),".%s",type.GetClass().GetName().c_str());
 | 
|---|
| [75] | 58 |             CallProc( PROC_DEFAULT,
 | 
|---|
 | 59 |                 pUserProc,
 | 
|---|
| [4] | 60 |                 temporary,
 | 
|---|
 | 61 |                 Parameter,
 | 
|---|
| [75] | 62 |                 dummyType );
 | 
|---|
| [4] | 63 | 
 | 
|---|
 | 64 |             ss[0]++;
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 |             //ネイティブコードバッファの再確保
 | 
|---|
| [89] | 68 |             ReallocNativeCodeBuffer();
 | 
|---|
| [4] | 69 |         }
 | 
|---|
 | 70 |     }
 | 
|---|
 | 71 |     else{
 | 
|---|
| [75] | 72 |         Type dummyType;
 | 
|---|
| [131] | 73 |         sprintf(temporary,"%s.%s",ObjectName,type.GetClass().GetName().c_str());
 | 
|---|
| [75] | 74 |         CallProc( PROC_DEFAULT,
 | 
|---|
 | 75 |             pUserProc,
 | 
|---|
| [4] | 76 |             temporary,
 | 
|---|
 | 77 |             Parameter,
 | 
|---|
| [75] | 78 |             dummyType );
 | 
|---|
| [4] | 79 |     }
 | 
|---|
 | 80 | }
 | 
|---|
| [75] | 81 | 
 | 
|---|
 | 82 | bool Operator_New( const char *expression, const Type &baseType, Type &resultType ){
 | 
|---|
 | 83 |     char CreateParameter[VN_SIZE],objectSizeStr[VN_SIZE];
 | 
|---|
 | 84 |     int i,i2;
 | 
|---|
 | 85 | 
 | 
|---|
 | 86 |     i=0;
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 |     if(expression[0]=='['){
 | 
|---|
 | 89 |         i=GetStringInBracket(objectSizeStr,expression);
 | 
|---|
 | 90 | 
 | 
|---|
 | 91 |         SlideString(objectSizeStr+1,-1);
 | 
|---|
 | 92 |         objectSizeStr[i-2]=0;
 | 
|---|
 | 93 |     }
 | 
|---|
 | 94 |     else objectSizeStr[0]=0;
 | 
|---|
 | 95 | 
 | 
|---|
 | 96 |     char typeName[VN_SIZE];
 | 
|---|
 | 97 |     for(i2=0;;i++,i2++){
 | 
|---|
 | 98 |         if(expression[i]=='('){
 | 
|---|
 | 99 |             typeName[i2]=0;
 | 
|---|
 | 100 | 
 | 
|---|
 | 101 |             //コンストラクタに渡すパラメータを取得
 | 
|---|
 | 102 |             i2=GetStringInPare(CreateParameter,expression+i);
 | 
|---|
 | 103 |             RemoveStringPare(CreateParameter);
 | 
|---|
 | 104 |             i+=i2;
 | 
|---|
 | 105 |             if(expression[i]!='\0'){
 | 
|---|
 | 106 |                 SetError(42,NULL,cp);
 | 
|---|
 | 107 |                 return false;
 | 
|---|
 | 108 |             }
 | 
|---|
 | 109 |             break;
 | 
|---|
 | 110 |         }
 | 
|---|
 | 111 |         typeName[i2]=expression[i];
 | 
|---|
 | 112 |         if(expression[i]=='\0'){
 | 
|---|
 | 113 |             CreateParameter[0]=0;
 | 
|---|
 | 114 |             break;
 | 
|---|
 | 115 |         }
 | 
|---|
 | 116 |     }
 | 
|---|
 | 117 | 
 | 
|---|
| [193] | 118 |     if( !Compiler::StringToType( typeName, resultType ) ){
 | 
|---|
| [75] | 119 |         SetError(3,typeName,cp);
 | 
|---|
 | 120 |         return false;
 | 
|---|
 | 121 |     }
 | 
|---|
 | 122 | 
 | 
|---|
 | 123 |     if( !resultType.IsObject() ){
 | 
|---|
 | 124 |         ////////////////////////
 | 
|---|
 | 125 |         // 通常のデータ型の場合
 | 
|---|
 | 126 |         ////////////////////////
 | 
|---|
 | 127 | 
 | 
|---|
 | 128 |         SetError(121,NULL,cp);
 | 
|---|
 | 129 |         return false;
 | 
|---|
 | 130 |     }
 | 
|---|
 | 131 | 
 | 
|---|
 | 132 |     Operator_New( resultType.GetClass(), objectSizeStr, CreateParameter, baseType );
 | 
|---|
 | 133 | 
 | 
|---|
 | 134 |     if( !baseType.IsObject() ){
 | 
|---|
 | 135 |         // オブジェクトポインタ向け
 | 
|---|
 | 136 |         resultType.SetBasicType( DEF_PTR_OBJECT );
 | 
|---|
 | 137 |     }
 | 
|---|
 | 138 | 
 | 
|---|
 | 139 |     return true;
 | 
|---|
 | 140 | }
 | 
|---|