Ignore:
Timestamp:
Mar 11, 2008, 4:02:38 PM (16 years ago)
Author:
dai_9181
Message:

_System_Newに対応(32bit版のみ)。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/Compile_Func.cpp

    r426 r431  
    77#include "../BasicCompiler_Common/common.h"
    88#include "Opcode.h"
     9
     10#ifdef _AMD64_
     11#include "../BasicCompiler64/FunctionValue.h"
     12#else
     13#include "../BasicCompiler32/FunctionValue.h"
     14#endif
    915
    1016int GetFunctionFromName(char *FuncName){
     
    2228    if( lstrcmpi( FuncName, "_System_GetBp" ) == 0 )    return FUNC_SYSTEM_GET_BP;
    2329    if( lstrcmpi( FuncName, "_System_GetSp" ) == 0 )    return FUNC_SYSTEM_GET_SP;
    24     if( lstrcmp( FuncName, "_System_New" ) == 0 )       return FUNC_SYSTEM_NEW;
     30    if( lstrcmp( FuncName, "_System_GetComVtbl" ) == 0 )        return FUNC_SYSTEM_GET_COM_VTBL;
     31    if( lstrcmp( FuncName, "_System_GetVtblList" ) == 0 )       return FUNC_SYSTEM_GET_VTBL_LIST;
     32    if( lstrcmp( FuncName, "_System_GetDefaultConstructor" ) == 0 ) return FUNC_SYSTEM_GET_DEFAULT_CONSTRUCTOR;
     33    if( lstrcmp( FuncName, "_System_GetDestructor" ) == 0 )         return FUNC_SYSTEM_GET_DESTRUCTOR;
    2534    if( lstrcmpi( FuncName, "GetDouble" ) == 0 )        return FUNC_GETDOUBLE;
    2635    if( lstrcmpi( FuncName, "GetSingle" ) == 0 )        return FUNC_GETSINGLE;
     
    607616}
    608617
    609 void Opcode_Func_System_New( const char *parameter, Type &resultType, bool isCallOn )
    610 {
    611     if( !compiler.StringToType( parameter, resultType ) )
    612     {
    613         SetError();
    614         return;
    615     }
    616     if( !resultType.IsObject() )
    617     {
    618         SetError();
    619         return;
    620     }
    621 
    622     if( isCallOn )
    623     {
    624         Type tempResultType;
    625         if( !Operator_New( parameter, resultType, tempResultType ) )
    626         {
    627             return;
    628         }
    629 
    630         if( !resultType.Equals( tempResultType ) )
    631         {
    632             SetError();
    633         }
    634 
    635         //pop eax
    636         compiler.codeGenerator.op_pop( REG_EAX );
    637     }
     618void Opcode_Func_System_GetComVtbl( const char *parameter )
     619{
     620    Type classType;
     621    compiler.StringToType( parameter, classType );
     622
     623    // mov eax,com_vtbl
     624    compiler.codeGenerator.op_mov_RV_com_vtbl( REG_EAX, &classType.GetClass() );
     625}
     626void Opcode_Func_System_GetVtblList( const char *parameter )
     627{
     628    Type classType;
     629    compiler.StringToType( parameter, classType );
     630
     631    // mov eax,com_vtbl
     632    compiler.codeGenerator.op_mov_RV_vtbl( REG_EAX, &classType.GetClass() );
     633}
     634void Opcode_Func_System_GetDefaultConstructor( const char *parameter )
     635{
     636    Type classType;
     637    compiler.StringToType( parameter, classType );
     638
     639    if( classType.GetClass().GetConstructorMethod() )
     640    {
     641        //mov eax,ProcAddr
     642        compiler.codeGenerator.op_addressof( REG_EAX, &classType.GetClass().GetConstructorMethod()->GetUserProc() );
     643    }
     644    else
     645    {
     646        // デフォルトコンストラクタを持たない
     647
     648        //xor eax,eax
     649        compiler.codeGenerator.op_zero_reg( REG_EAX );
     650    }
     651}
     652void Opcode_Func_System_GetDestructor( const char *parameter )
     653{
     654    Type classType;
     655    compiler.StringToType( parameter, classType );
     656
     657    //mov eax,ProcAddr
     658    compiler.codeGenerator.op_addressof( REG_EAX, &classType.GetClass().GetDestructorMethod()->GetUserProc() );
    638659}
    639660
     
    748769            resultType.SetBasicType( DEF_LONG );
    749770            break;
    750         case FUNC_SYSTEM_NEW:
    751             Opcode_Func_System_New( Parameter, resultType, isCallOn );
     771        case FUNC_SYSTEM_GET_COM_VTBL:
     772            if( isCallOn ) Opcode_Func_System_GetComVtbl( Parameter );
     773            resultType.SetBasicType( DEF_PTR_VOID );
     774            break;
     775        case FUNC_SYSTEM_GET_VTBL_LIST:
     776            if( isCallOn ) Opcode_Func_System_GetVtblList( Parameter );
     777            resultType.SetBasicType( DEF_PTR_VOID );
     778            break;
     779        case FUNC_SYSTEM_GET_DEFAULT_CONSTRUCTOR:
     780            if( isCallOn ) Opcode_Func_System_GetDefaultConstructor( Parameter );
     781            resultType.SetBasicType( DEF_PTR_VOID );
     782            break;
     783        case FUNC_SYSTEM_GET_DESTRUCTOR:
     784            if( isCallOn ) Opcode_Func_System_GetDestructor( Parameter );
     785            resultType.SetBasicType( DEF_PTR_VOID );
    752786            break;
    753787
Note: See TracChangeset for help on using the changeset viewer.