Changeset 75 in dev for BasicCompiler32/Compile_Object.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_Object.cpp
r73 r75 2 2 #include "opcode.h" 3 3 4 void _call_constructor( CClass *pobj_c, const char *CreateParameter,int ObjectSize,BOOL bSomeObjects){4 void _call_constructor( const CClass *pobj_c, const char *CreateParameter,int ObjectSize,BOOL bSomeObjects){ 5 5 //////////////////////////// 6 6 // コンストラクタの呼び出し … … 31 31 //////////////////////// 32 32 33 std::vector< SubInfo*> subs;33 std::vector<UserProc *> subs; 34 34 pobj_c->EnumMethod( pobj_c->name, subs ); 35 35 36 SubInfo *psi;36 UserProc *pUserProc; 37 37 if( subs.size() > 0 ){ 38 38 //オーバーロードを解決 39 p si=OverloadSolutionWithStrParam(pobj_c->name,40 subs,CreateParameter,"" ,NULL);41 42 if(!p si) return;39 pUserProc=OverloadSolutionWithStrParam(pobj_c->name, 40 subs,CreateParameter,""); 41 42 if(!pUserProc) return; 43 43 } 44 44 45 45 //コンストラクタを呼び出す 46 46 Opcode_CallProc(CreateParameter, 47 p si,47 pUserProc, 48 48 PROCFLAG_NEW,"",0); 49 49 … … 74 74 } 75 75 } 76 void Operator_New( CClass &classObj, const char *objectSizeStr, const char *parameter, const TYPEINFO &baseTypeInfo){76 void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType ){ 77 77 int typeSize = classObj.GetSize(); 78 78 … … 82 82 } 83 83 84 BOOL bSomeObjects=0; 84 85 if(objectSizeStr[0]){ 85 int type = NumOpe(objectSizeStr,0,0,0); 86 ChangeTypeToLong(type); 86 bSomeObjects=1; 87 88 Type tempType; 89 NumOpe(objectSizeStr,Type(),tempType); 90 if( !tempType.IsWhole() ) SetError(49,NULL,cp); 91 ChangeTypeToLong(tempType.GetBasicType()); 87 92 88 93 //pop eax … … 129 134 } 130 135 131 if( baseTypeInfo.type == DEF_OBJECT ){ 132 //DeleteはGCで処理 136 if( baseType.IsObject() ){ 137 // オブジェクト インスタンス 138 // ※DeleteはGCで処理 133 139 134 140 //call _System_GC_malloc_ForObject 135 extern SubInfo*pSub_System_GC_malloc_ForObject;141 extern UserProc *pSub_System_GC_malloc_ForObject; 136 142 op_call(pSub_System_GC_malloc_ForObject); 137 143 } 138 144 else{ 139 //明示的なDeleteが必要 145 // オブジェクトポインタ 146 // ※明示的なDeleteが必要 140 147 141 148 //call _System_GC_malloc_ForObjectPtr 142 extern SubInfo*pSub_System_GC_malloc_ForObjectPtr;149 extern UserProc *pSub_System_GC_malloc_ForObjectPtr; 143 150 op_call(pSub_System_GC_malloc_ForObjectPtr); 144 151 } … … 184 191 //mov ecx,DestructorProcAddr 185 192 OpBuffer[obp++]=(char)0xB9; 186 pobj_SubAddrSchedule->add(method->p si,0);187 method->p si->bUse=1;193 pobj_SubAddrSchedule->add(method->pUserProc,0); 194 method->pUserProc->Using(); 188 195 obp+=sizeof(long); 189 196 … … 209 216 //////////////////////////// 210 217 211 BOOL bSomeObjects;212 if(objectSizeStr[0]) bSomeObjects=1;213 else bSomeObjects=0;214 218 _call_constructor(&classObj,parameter,typeSize,bSomeObjects); 215 219 } 216 int Operator_New(const char *Parameter,LONG_PTR *plpIndex,const TYPEINFO &baseTypeInfo ){217 char TypeName[VN_SIZE],CreateParameter[VN_SIZE],objectSizeStr[VN_SIZE];218 int i,i2;219 220 i=0;221 222 if(Parameter[0]=='['){223 i=GetStringInBracket(objectSizeStr,Parameter);224 225 SlideString(objectSizeStr+1,-1);226 objectSizeStr[i-2]=0;227 }228 else objectSizeStr[0]=0;229 230 for(i2=0;;i++,i2++){231 if(Parameter[i]=='('){232 TypeName[i2]=0;233 234 //コンストラクタに渡すパラメータを取得235 i2=GetStringInPare(CreateParameter,Parameter+i);236 RemoveStringPare(CreateParameter);237 i+=i2;238 if(Parameter[i]!='\0'){239 SetError(42,NULL,cp);240 return -1;241 }242 break;243 }244 TypeName[i2]=Parameter[i];245 if(Parameter[i]=='\0'){246 CreateParameter[0]=0;247 break;248 }249 }250 251 int type,TypeSize;252 type=GetTypeFixed(TypeName,plpIndex);253 if(type==-1){254 SetError(3,TypeName,cp);255 return -1;256 }257 TypeSize=GetTypeSize(type,*plpIndex);258 259 if(type!=DEF_OBJECT){260 ////////////////////////261 // 通常のデータ型の場合262 ////////////////////////263 264 SetError(121,NULL,cp);265 return -1;266 }267 268 CClass *pobj_c;269 pobj_c=(CClass *)*plpIndex;270 271 Operator_New( *pobj_c, objectSizeStr, CreateParameter, baseTypeInfo );272 273 if( baseTypeInfo.type == DEF_OBJECT ){274 return DEF_OBJECT;275 }276 return DEF_PTR_OBJECT;277 }278 279 220 void OpcodeDelete(const char *Parameter, bool isSweeping){ 280 int type;281 282 type=NumOpe(Parameter,0,0,0);283 if(type==-1) return;284 if(!( type==DEF_PTR_OBJECT||type==DEF_PTR_VOID)) SetError(122,NULL,cp);221 Type tempType; 222 if( !NumOpe(Parameter,Type(),tempType) ){ 223 return; 224 } 225 if(!( tempType.IsObjectPtr() || tempType.IsVoidPtr() )) SetError(122,NULL,cp); 285 226 286 227 //pop eax … … 376 317 if( isSweeping ){ 377 318 //call _System_GC_free_for_SweepingDelete 378 extern SubInfo*pSub_System_GC_free_for_SweepingDelete;319 extern UserProc *pSub_System_GC_free_for_SweepingDelete; 379 320 op_call(pSub_System_GC_free_for_SweepingDelete); 380 321 } 381 322 else{ 382 323 //call free 383 extern SubInfo*pSub_free;324 extern UserProc *pSub_free; 384 325 op_call(pSub_free); 385 326 }
Note:
See TracChangeset
for help on using the changeset viewer.