Changeset 75 in dev for BasicCompiler64/Compile_Func.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/Compile_Func.cpp
r73 r75 40 40 } 41 41 void Opcode_Func_Len( const char *Parameter ){ 42 int type,TypeSize;43 LONG_PTR lpIndex;44 42 BOOL bArrayHead; 45 46 type=GetVarType(Parameter,&lpIndex,0);47 43 48 44 const char *tempParm=Parameter; 49 45 char temporary[VN_SIZE]; 50 46 char temp2[32]; 51 if(type==-1){ 47 Type type; 48 if( !GetVarType(Parameter,type,0) ){ 52 49 sprintf(temporary,"_System_DummyStr2=%s",Parameter); 53 50 OpcodeCalc(temporary); … … 57 54 58 55 extern CClass *pobj_StringClass; 59 type=DEF_OBJECT; 60 lpIndex=(LONG_PTR)pobj_StringClass; 61 } 62 63 TYPEINFO TypeInfo={type,lpIndex}; 64 if(IsStringObjectType(TypeInfo)){ 56 type.SetType( DEF_OBJECT, pobj_StringClass ); 57 } 58 59 if( type.IsStringObject() ){ 65 60 //Stringオブジェクトの場合 66 61 sprintf(temporary,"%s.Length",tempParm); 67 62 68 63 int reg=REG_RAX; 69 NumOpe(®,temporary, 0,0,NULL,NULL);64 NumOpe(®,temporary,Type(),Type(),NULL); 70 65 return; 71 66 } … … 74 69 int SubScripts[MAX_ARRAYDIM]; 75 70 RELATIVE_VAR RelativeVar; 76 if(!GetVarOffsetReadOnly(tempParm,& type,&RelativeVar,&lpIndex,SubScripts)) return;77 78 79 if(type &FLAG_PTR){80 type &=~FLAG_PTR;71 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,SubScripts)) return; 72 73 74 if(type.GetBasicType()&FLAG_PTR){ 75 type.SetBasicType( type.GetBasicType() & ( ~FLAG_PTR ) ); 81 76 82 77 bArrayHead=1; … … 84 79 else bArrayHead=0; 85 80 86 TypeSize=GetTypeSize(type,lpIndex);87 88 if(bArrayHead) TypeSize*=JumpSubScripts(SubScripts);81 int typeSize = type.GetSize(); 82 83 if(bArrayHead) typeSize*=JumpSubScripts(SubScripts); 89 84 90 85 //mov rax,TypeSize 91 op_mov_RV(sizeof(_int64),REG_RAX, TypeSize);86 op_mov_RV(sizeof(_int64),REG_RAX,typeSize); 92 87 93 88 return; … … 95 90 void Opcode_Func_AddressOf( const char *name ){ 96 91 extern int cp; 97 SubInfo *psi;92 UserProc *pUserProc; 98 93 99 94 extern LONG_PTR ProcPtr_BaseIndex; … … 101 96 //左辺の型にのっとり、オーバーロードを解決 102 97 103 std::vector< SubInfo*> subs;98 std::vector<UserProc *> subs; 104 99 GetOverloadSubHash( name, subs ); 105 100 if( subs.size() == 0 ){ … … 109 104 110 105 //オーバーロードを解決 111 extern P ROCPTRINFO *pProcPtrInfo;112 p si=OverloadSolution(name,subs,pProcPtrInfo[ProcPtr_BaseIndex].pParmInfo,pProcPtrInfo[ProcPtr_BaseIndex].ParmNum,NULL);113 114 if(!p si){106 extern ProcPointer **ppProcPointer; 107 pUserProc=OverloadSolution(name,subs,ppProcPointer[ProcPtr_BaseIndex]->Params(), Type() ); 108 109 if(!pUserProc){ 115 110 SetError(27,name,cp); 116 111 return; … … 118 113 } 119 114 else{ 120 p si=GetSubHash(name);121 if(!p si){115 pUserProc=GetSubHash(name); 116 if(!pUserProc){ 122 117 SetError(27,name,cp); 123 118 return; … … 125 120 } 126 121 127 128 if(psi->bVirtual){ 122 if( pUserProc->IsVirtual() ){ 129 123 /////////////////////////////// 130 124 // 仮想関数の場合 … … 142 136 else{ 143 137 RELATIVE_VAR RelativeVar; 144 inttype;145 if(!GetVarOffsetReadOnly(ObjectName,& type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;138 Type type; 139 if(!GetVarOffsetReadOnly(ObjectName,&RelativeVar,type)) return; 146 140 SetVarPtrToReg(REG_RCX,&RelativeVar); 147 141 148 142 //参照タイプが整合しているかをチェック 149 if(type !=RefType) SetError(104,ObjectName,cp);150 151 if(type ==DEF_PTR_OBJECT){143 if(type.GetBasicType()!=RefType) SetError(104,ObjectName,cp); 144 145 if(type.IsObjectPtr()){ 152 146 //mov rcx,qword ptr[rcx] 153 147 op_mov_RM(sizeof(_int64),REG_RCX,REG_RCX,0,MOD_BASE); … … 172 166 op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE); 173 167 174 int i2 = pobj_c->GetFuncNumInVtbl( p si);168 int i2 = pobj_c->GetFuncNumInVtbl( pUserProc ); 175 169 176 170 //mov rax,qword ptr[r11+func_index] … … 188 182 op_mov_RV(sizeof(_int64),REG_RAX,0); 189 183 obp-=sizeof(long); 190 pobj_SubAddrSchedule->add(p si,0);184 pobj_SubAddrSchedule->add(pUserProc,0); 191 185 obp+=sizeof(long); 192 186 } 193 187 194 p si->bUse=1;188 pUserProc->Using(); 195 189 } 196 190 void Opcode_Func_SizeOf( const char *Parameter ){ … … 210 204 op_mov_RV(sizeof(_int64),REG_RAX,size); 211 205 } 212 void Opcode_Func_VarPtr( const char *Parameter, TYPEINFO &ReturnTypeInfo ){ 206 void Opcode_Func_VarPtr( const char *Parameter, Type &resultType, bool isCallOn ){ 207 if( isCallOn == false ){ 208 // 戻り値の型を取得するだけ 209 210 //変数のアドレスを取得 211 if(!GetVarType( Parameter, resultType, true )) return; 212 213 resultType.PtrLevelUp(); 214 215 return; 216 } 217 213 218 RELATIVE_VAR RelativeVar; 214 219 215 220 //変数のアドレスを取得 216 if(!GetVarOffsetReadOnly( Parameter, &Re turnTypeInfo.type, &RelativeVar, &ReturnTypeInfo.u.lpIndex)) return;217 218 int beforeType = ReturnTypeInfo.type;219 220 PTR_LEVEL_UP( ReturnTypeInfo.type);221 if(!GetVarOffsetReadOnly( Parameter, &RelativeVar, resultType )) return; 222 223 int beforeType = resultType.GetBasicType(); 224 225 resultType.PtrLevelUp(); 221 226 222 227 SetVarPtrToReg(REG_RAX,&RelativeVar); … … 230 235 } 231 236 void Opcode_Func_GetPtrData( const char *Parameter, const int type ){ 232 int i2;233 234 237 int reg=REG_RAX; 235 i2=NumOpe(®,Parameter,0,0,0); 236 if(!IsWholeNumberType(i2)){ 237 extern int cp; 238 Type tempType; 239 if( !NumOpe(®,Parameter,Type(),tempType) ){ 240 return; 241 } 242 if(!tempType.IsWhole()){ 238 243 SetError(11,Parameter,cp); 239 244 return; … … 254 259 } 255 260 256 void Opcode_CallFunc( const char *Parameter, const int FuncNum, TYPEINFO &ReturnTypeInfo){261 bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn ){ 257 262 switch(FuncNum){ 258 263 case FUNC_LEN: 259 Opcode_Func_Len(Parameter);260 ReturnTypeInfo.type = DEF_LONG;264 if( isCallOn ) Opcode_Func_Len(Parameter); 265 resultType.SetBasicType( DEF_LONG ); 261 266 break; 262 267 case FUNC_ADDRESSOF: 263 Opcode_Func_AddressOf(Parameter);264 ReturnTypeInfo.type = DEF_PTR_VOID;268 if( isCallOn ) Opcode_Func_AddressOf(Parameter); 269 resultType.SetBasicType( DEF_PTR_VOID ); 265 270 break; 266 271 case FUNC_SIZEOF: 267 Opcode_Func_SizeOf(Parameter);268 ReturnTypeInfo.type = DEF_LONG;272 if( isCallOn ) Opcode_Func_SizeOf(Parameter); 273 resultType.SetBasicType( DEF_LONG ); 269 274 break; 270 275 case FUNC_VARPTR: 271 Opcode_Func_VarPtr( Parameter, ReturnTypeInfo);276 Opcode_Func_VarPtr( Parameter, resultType, isCallOn ); 272 277 break; 273 278 274 279 case FUNC_GETDOUBLE: 275 Opcode_Func_GetPtrData(Parameter,DEF_DOUBLE);276 ReturnTypeInfo.type = DEF_DOUBLE;280 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_DOUBLE); 281 resultType.SetBasicType( DEF_DOUBLE ); 277 282 break; 278 283 case FUNC_GETSINGLE: 279 Opcode_Func_GetPtrData(Parameter,DEF_SINGLE);280 ReturnTypeInfo.type = DEF_SINGLE;284 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_SINGLE); 285 resultType.SetBasicType( DEF_SINGLE ); 281 286 break; 282 287 case FUNC_GETQWORD: 283 Opcode_Func_GetPtrData(Parameter,DEF_QWORD);284 ReturnTypeInfo.type = DEF_QWORD;288 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_QWORD); 289 resultType.SetBasicType( DEF_QWORD ); 285 290 break; 286 291 case FUNC_GETDWORD: 287 Opcode_Func_GetPtrData(Parameter,DEF_DWORD);288 ReturnTypeInfo.type = DEF_DWORD;292 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_DWORD); 293 resultType.SetBasicType( DEF_DWORD ); 289 294 break; 290 295 case FUNC_GETWORD: 291 Opcode_Func_GetPtrData(Parameter,DEF_WORD);292 ReturnTypeInfo.type = DEF_WORD;296 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_WORD); 297 resultType.SetBasicType( DEF_WORD ); 293 298 break; 294 299 case FUNC_GETBYTE: 295 Opcode_Func_GetPtrData(Parameter,DEF_BYTE); 296 ReturnTypeInfo.type = DEF_BYTE; 297 break; 298 } 299 } 300 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_BYTE); 301 resultType.SetBasicType( DEF_BYTE ); 302 break; 303 default: 304 return false; 305 } 306 return true; 307 }
Note:
See TracChangeset
for help on using the changeset viewer.