Changeset 431 in dev


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

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

Location:
trunk/abdev
Files:
4 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
  • trunk/abdev/BasicCompiler32/FunctionValue.h

    r426 r431  
    2121#define FUNC_SYSTEM_GET_BP  0x0625
    2222#define FUNC_SYSTEM_GET_SP  0x0626
    23 #define FUNC_SYSTEM_NEW     0x0627
     23#define FUNC_SYSTEM_GET_COM_VTBL    0x0627
     24#define FUNC_SYSTEM_GET_VTBL_LIST   0x0628
     25#define FUNC_SYSTEM_GET_DEFAULT_CONSTRUCTOR     0x0629
     26#define FUNC_SYSTEM_GET_DESTRUCTOR              0x062A
    2427
    2528//ポインタ
  • trunk/abdev/BasicCompiler_Common/common.h

    r424 r431  
    1111#include "../BasicCompiler64/resource.h"
    1212#include "../BasicCompiler64/CommandValue.h"
    13 #include "../BasicCompiler64/FunctionValue.h"
    1413#define OPCODE_H_PATH "../BasicCompiler64/opcode.h"
    1514#else
    1615#include "../BasicCompiler32/resource.h"
    1716#include "../BasicCompiler32/CommandValue.h"
    18 #include "../BasicCompiler32/FunctionValue.h"
    1917#define OPCODE_H_PATH "../BasicCompiler32/opcode.h"
    2018#endif
  • trunk/abdev/BasicCompiler_Common/src/Class.cpp

    r417 r431  
    13261326
    13271327    char temporary[8192];
    1328     sprintf(temporary, "%c%ctempType=Nothing%c%cTypeBaseImpl"
     1328    sprintf(temporary, "%c%ctempType=Nothing%c%c_System_TypeForClass"
    13291329        , HIBYTE( COM_DIM )
    13301330        , LOBYTE( COM_DIM )
     
    13471347        if( objClass.HasSuperClass() || objClass.GetDynamicMembers().size() ){
    13481348            sprintf( temporary
    1349                 , "tempType=Search(\"%s\")"
     1349                , "tempType=Search(\"%s\") As ActiveBasic.Core._System_TypeForClass"
    13501350                , objClass.GetFullName().c_str()
     1351            );
     1352
     1353            // コンパイル
     1354            MakeMiddleCode( temporary );
     1355            ChangeOpcode( temporary );
     1356
     1357            sprintf( temporary
     1358                , "tempType.SetClassInfo(%d,_System_GetComVtbl(%s),_System_GetVtblList(%s),_System_GetDefaultConstructor(%s),_System_GetDestructor(%s))"
     1359                , objClass.GetSize()
     1360                , objClass.GetFullName().c_str()
     1361                , objClass.GetFullName().c_str()
     1362                , objClass.GetFullName().c_str()
     1363                , objClass.GetFullName().c_str()
     1364                , objClass.GetName().c_str()
    13511365            );
    13521366
Note: See TracChangeset for help on using the changeset viewer.