Changeset 316 in dev for trunk/abdev/BasicCompiler64
- Timestamp:
- Sep 7, 2007, 3:15:41 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler64
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/CParameter.cpp
r308 r316 185 185 186 186 187 void ParamImpl::SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum ){187 void ParamImpl::SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum, const UserProc *pUserProc ){ 188 188 if( SecondParmNum == -1 ) SecondParmNum = (int)params.size(); 189 189 … … 239 239 dummyType = *params[i2]; 240 240 bByVal = ( params[i2]->IsRef() == false ) ? TRUE:FALSE; 241 242 // 型パラメータを解決 243 ResolveFormalGenericTypeParameter( dummyType, leftType, pUserProc ); 241 244 } 242 245 -
trunk/abdev/BasicCompiler64/Compile_Calc.cpp
r308 r316 36 36 int i,i2,i3; 37 37 char variable[VN_SIZE]; 38 39 38 40 39 -
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r308 r316 149 149 else{ 150 150 if(dwFlags&PROCFLAG_NEW){ 151 GetVarType( ObjectName, leftType, false ); 152 151 153 //New演算子によるコンストラクタ呼び出し 152 154 pobj_c=pUserProc->GetParentClassPtr(); … … 242 244 pobj_parameter->ApplyDefaultParameters( pUserProc->RealParams() ); 243 245 246 // 型パラメータを適用 247 pobj_parameter->SetLeftType( leftType ); 248 244 249 //エラーチェック 245 250 if( !pobj_parameter->ErrorCheck(pUserProc->GetName(),pUserProc->RealParams(),pUserProc->GetSecondParmNum() ) ){ … … 260 265 261 266 //レジスタ、スタックフレームにセット 262 pobj_parameter->SetParameter(pUserProc->GetName(),pUserProc->RealParams(),pUserProc->GetRealSecondParmNum() );267 pobj_parameter->SetParameter(pUserProc->GetName(),pUserProc->RealParams(),pUserProc->GetRealSecondParmNum(), pUserProc ); 263 268 264 269 if(pUserProc->ReturnType().IsStruct() ){ -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r309 r316 190 190 int i3,i4; 191 191 char temporary[VN_SIZE]; 192 193 if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return;194 192 195 193 if( pUserProc->GetLocalVars().size() ){ … … 620 618 GetVarOffsetReadWrite(temp,&RelativeVar,Type()); 621 619 622 i3=pUserProc->ReturnType().GetBasicType();623 624 if(i3==DEF_OBJECT || i3==DEF_STRUCT){620 const Type &returnType = pUserProc->ReturnType(); 621 if( returnType.IsObject() || returnType.IsStruct() ) 622 { 625 623 SetVarPtrToReg(REG_RAX,&RelativeVar); 626 if( i3==DEF_OBJECT ){ 624 if( returnType.IsObject() ) 625 { 627 626 //mov rax,qword ptr[rax] 628 627 compiler.codeGenerator.op_mov_RM( sizeof(_int64), REG_RAX, REG_RAX, 0, MOD_BASE ); 629 628 } 630 629 } 631 else if(i3==DEF_DOUBLE){ 630 else if( returnType.IsDouble() ) 631 { 632 632 //64ビット実数型 633 633 SetXmmReg_DoubleVariable(&RelativeVar,REG_XMM0); 634 634 } 635 else if(i3==DEF_SINGLE){ 635 else if( returnType.IsSingle() ) 636 { 636 637 //32ビット実数型 637 638 SetXmmReg_SingleVariable(&RelativeVar,REG_XMM0); 638 639 } 639 else if(IsWholeNumberType(i3)){ 640 else if( returnType.IsWhole() ) 641 { 640 642 //整数型 641 SetReg_WholeVariable( Type(i3),&RelativeVar,REG_RAX);643 SetReg_WholeVariable(returnType.GetSize(),&RelativeVar,REG_RAX); 642 644 } 643 645 else SetError(300,NULL,cp); … … 699 701 HeapDefaultFree(SynonymErrorWords); 700 702 } 701 702 void CompileBufferInProcedure( const UserProc &userProc ){703 if( userProc.IsUsing() == false || userProc.IsCompiled() ) return;704 705 _compile_proc( &userProc );706 707 // ログを履く708 char temporary[8192];709 temporary[0]=0;710 lstrcat( temporary, "------------------------------------------------------------------\n" );711 sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.GetName().c_str() );712 sprintf( temporary + lstrlen(temporary), "code size: %d bytes\n", userProc.GetCodeSize() );713 lstrcat( temporary, "------------------------------------------------------------------\n" );714 lstrcat( temporary, "\n" );715 trace_for_size( temporary );716 }717 void CompileLocal(){718 if( compiler.IsDll() ){719 //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする720 const UserProc *pUserProc = GetSubHash("_System_InitDllGlobalVariables");721 if(pUserProc){722 CompileBufferInProcedure( *pUserProc );723 }724 else SetError(300,NULL,cp);725 }726 else727 {728 // グローバル領域を一番初めにコンパイルする729 extern const UserProc *pSub_System_GlobalArea;730 CompileBufferInProcedure( *pSub_System_GlobalArea );731 }732 733 //_System_TypeBase_InitializeUserTypesは一番最後にコンパイル734 extern const UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;735 pSubStaticMethod_System_TypeBase_InitializeUserTypes->CompleteCompile();736 737 //_System_InitStaticLocalVariablesは一番最後にコンパイル738 //※一般関数内の静的変数オブジェクトをすべて収集しなければならない739 extern const UserProc *pSub_System_InitStaticLocalVariables;740 pSub_System_InitStaticLocalVariables->CompleteCompile();741 742 //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル743 extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject;744 pSub_System_Call_Destructor_of_GlobalObject->CompleteCompile();745 746 repeat:747 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();748 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )749 {750 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();751 CompileBufferInProcedure( *pUserProc );752 }753 754 if( IsNeedProcCompile() ){755 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合756 goto repeat;757 }758 759 //_System_TypeBase_InitializeUserTypesは最後のほうでコンパイル760 pSubStaticMethod_System_TypeBase_InitializeUserTypes->KillCompileStatus();761 CompileBufferInProcedure( *pSubStaticMethod_System_TypeBase_InitializeUserTypes );762 763 if( IsNeedProcCompile() ){764 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合765 766 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();767 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )768 {769 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();770 CompileBufferInProcedure( *pUserProc );771 }772 }773 774 //_System_InitStaticLocalVariablesは一番最後にコンパイル775 pSub_System_InitStaticLocalVariables->KillCompileStatus();776 CompileBufferInProcedure( *pSub_System_InitStaticLocalVariables );777 778 //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル779 pSub_System_Call_Destructor_of_GlobalObject->KillCompileStatus();780 CompileBufferInProcedure( *pSub_System_Call_Destructor_of_GlobalObject );781 } -
trunk/abdev/BasicCompiler64/Compile_Var.cpp
r308 r316 191 191 return true; 192 192 } 193 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ 193 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess) 194 { 195 const CClass &objClass = classType.GetClass(); 194 196 195 197 ////////////////////////////////////// … … 252 254 resultType = pMember->GetType(); 253 255 256 // 型パラメータを解決 257 ResolveFormalGenericTypeParameter( resultType, classType ); 258 254 259 //ポインタ変数の場合 255 260 if( resultType.IsPointer() ){ … … 352 357 isErrorEnabled, 353 358 isWriteAccess, 354 pMember->GetType() .GetClass(),359 pMember->GetType(), 355 360 NestMember, 356 361 pRelativeVar, … … 441 446 pSubscripts = &pVar->GetSubscripts(); 442 447 bConst = pVar->IsConst(); 448 449 ///////////////////////////////////////////////////////// 450 // ☆★☆ ジェネリクスサポート ☆★☆ 451 452 if( resultType.IsTypeParameter() ) 453 { 454 // 型パラメータだったとき 455 456 int ptrLevel = PTR_LEVEL( resultType.GetBasicType() ); 457 458 // TODO: ベースオブジェクト(指定されていないときはObjectクラス)にセットする 459 resultType.SetBasicType( DEF_OBJECT ); 460 461 for( int i=0; i<ptrLevel; i++ ) 462 { 463 resultType.PtrLevelUp(); 464 } 465 } 466 467 // 468 ///////////////////////////////////////////////////////// 443 469 444 470 goto ok; … … 498 524 isErrorEnabled, 499 525 isWriteAccess, 500 *compiler.pCompilingClass,526 Type( DEF_OBJECT, *compiler.pCompilingClass ), 501 527 variable, 502 528 pRelativeVar, … … 727 753 isErrorEnabled, 728 754 isWriteAccess, 729 resultType .GetClass(),755 resultType, 730 756 member,pRelativeVar,resultType,0)) return false; 731 757 -
trunk/abdev/BasicCompiler64/NumOpe.cpp
r308 r316 152 152 true, //エラー表示あり 153 153 false, //読み込み専用 154 objClass,154 leftType, 155 155 member,&relativeVar,resultType,0)){ 156 156 return false; … … 219 219 220 220 SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg); 221 222 // 型パラメータを解決 223 ResolveFormalGenericTypeParameter( resultType, leftType, pUserProc ); 221 224 222 225 … … 428 431 GetVarType(VarName,resultType,false); 429 432 if( resultType.IsObject() ){ 430 CallIndexerGetterProc(UseReg, &resultType.GetClass(),VarName,ArrayElements,resultType);433 CallIndexerGetterProc(UseReg,resultType,VarName,ArrayElements,resultType); 431 434 432 435 isLiteral = false; -
trunk/abdev/BasicCompiler64/Opcode.h
r309 r316 259 259 260 260 //Compile_Var.cpp 261 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);261 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess); 262 262 void SetThisPtrToReg(int reg); 263 263 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL ); … … 277 277 int ParmsNum; 278 278 279 Type leftType; 279 280 Type returnType; 280 281 … … 288 289 ParamImpl(const Parameters ¶ms); 289 290 ~ParamImpl(); 291 void SetLeftType( const Type &type ) 292 { 293 this->leftType = type; 294 } 290 295 void SetReturnType( const Type &returnType ); 291 296 … … 301 306 void MacroParameterSupport( const Parameters ¶ms ); 302 307 void SetStructParameter( int reg, const Type &baseType, const char *expression ); 303 void SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );308 void SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum = -1, const UserProc *pUserProc = NULL ); 304 309 305 310 //一時オブジェクトパラメータの生成と破棄 … … 330 335 331 336 //Compile_ProcOp.cpp 332 void CompileLocal();337 void _compile_proc(const UserProc *pUserProc); 333 338 334 339 //Compile_Func.cpp … … 340 345 int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp); 341 346 void CallCastOperatorProc(int reg,Type &calcType,BOOL bCalcUseHeap,const Type &toType); 342 void CallIndexerGetterProc(int reg, const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType);347 void CallIndexerGetterProc(int reg, const Type &classType, char *ObjectName,char *Parameter,Type &resultType); 343 348 344 349 //Compile_Statement.cpp -
trunk/abdev/BasicCompiler64/OperatorProc.cpp
r308 r316 321 321 322 322 //インデクサ(getter)を呼び出す 323 void CallIndexerGetterProc(int reg, const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType ){323 void CallIndexerGetterProc(int reg, const Type &classType, char *ObjectName,char *Parameter,Type &resultType ){ 324 324 325 325 std::vector<const UserProc *> subs; 326 pobj_Class->GetMethods().Enum( CALC_ARRAY_GET, subs );326 classType.GetClass().GetMethods().Enum( CALC_ARRAY_GET, subs ); 327 327 if( subs.size() == 0 ){ 328 328 return; 329 329 } 330 330 331 const UserProc *pUserProc = subs[0]; 332 331 333 ////////////////////////////////////////////////////// 332 334 ///// レジスタ資源のバックアップ … … 334 336 ////////////////////////////////////////////////////// 335 337 336 Opcode_CallProc(Parameter, subs[0],0,ObjectName);337 resultType = subs[0]->ReturnType();338 Opcode_CallProc(Parameter,pUserProc,0,ObjectName); 339 resultType = pUserProc->ReturnType(); 338 340 339 341 //mov reg,rax … … 345 347 }//////////////////////////////////////////// 346 348 349 350 // 型パラメータを解決 351 ResolveFormalGenericTypeParameter( resultType, classType, pUserProc ); 347 352 }
Note:
See TracChangeset
for help on using the changeset viewer.