Changeset 206 in dev


Ignore:
Timestamp:
Jul 12, 2007, 2:58:26 AM (17 years ago)
Author:
dai_9181
Message:

コード全体のリファクタリングを実施

Location:
trunk/abdev
Files:
13 added
3 deleted
96 edited
6 moved

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/BasicCompiler.vcproj

    r195 r206  
    5353                BasicRuntimeChecks="3"
    5454                RuntimeLibrary="1"
     55                UsePrecompiledHeader="2"
    5556                PrecompiledHeaderFile=".\Debug/BasicCompiler.pch"
    5657                AssemblerListingLocation=".\Debug/"
    5758                ObjectFile=".\Debug/"
    5859                ProgramDataBaseFileName=".\Debug/"
    59                 BrowseInformation="1"
     60                BrowseInformation="0"
    6061                WarningLevel="3"
    6162                SuppressStartupBanner="true"
     
    155156                EnableFunctionLevelLinking="true"
    156157                RuntimeTypeInfo="true"
     158                UsePrecompiledHeader="2"
    157159                PrecompiledHeaderFile=".\Release/BasicCompiler.pch"
    158160                AssemblerListingLocation=".\Release/"
     
    242244                </FileConfiguration>
    243245            </File>
     246            <File
     247                RelativePath=".\stdafx.cpp"
     248                >
     249                <FileConfiguration
     250                    Name="Debug|Win32"
     251                    >
     252                    <Tool
     253                        Name="VCCLCompilerTool"
     254                        UsePrecompiledHeader="1"
     255                    />
     256                </FileConfiguration>
     257                <FileConfiguration
     258                    Name="Release|Win32"
     259                    >
     260                    <Tool
     261                        Name="VCCLCompilerTool"
     262                        UsePrecompiledHeader="1"
     263                    />
     264                </FileConfiguration>
     265            </File>
    244266            <Filter
    245267                Name="32及び64共通"
     
    776798                    <File
    777799                        RelativePath="..\BasicCompiler_Common\PESchedule.h"
    778                         >
    779                     </File>
    780                 </Filter>
    781                 <Filter
    782                     Name="Constant"
    783                     >
    784                     <File
    785                         RelativePath="..\BasicCompiler_Common\Const.cpp"
    786                         >
    787                         <FileConfiguration
    788                             Name="Debug|Win32"
    789                             >
    790                             <Tool
    791                                 Name="VCCLCompilerTool"
    792                                 PreprocessorDefinitions=""
    793                             />
    794                         </FileConfiguration>
    795                         <FileConfiguration
    796                             Name="Release|Win32"
    797                             >
    798                             <Tool
    799                                 Name="VCCLCompilerTool"
    800                                 PreprocessorDefinitions=""
    801                             />
    802                         </FileConfiguration>
    803                     </File>
    804                     <File
    805                         RelativePath="..\BasicCompiler_Common\Const.h"
    806800                        >
    807801                    </File>
     
    12521246                >
    12531247                <File
    1254                     RelativePath="..\BasicCompiler_Common\src\ClassImpl.cpp"
     1248                    RelativePath="..\BasicCompiler_Common\src\Class.cpp"
    12551249                    >
    12561250                </File>
     
    12641258                </File>
    12651259                <File
     1260                    RelativePath="..\BasicCompiler_Common\src\Const.cpp"
     1261                    >
     1262                </File>
     1263                <File
    12661264                    RelativePath="..\BasicCompiler_Common\src\DataTable.cpp"
    12671265                    >
     
    12761274                </File>
    12771275                <File
     1276                    RelativePath="..\BasicCompiler_Common\src\Method.cpp"
     1277                    >
     1278                </File>
     1279                <File
    12781280                    RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp"
    12791281                    >
    12801282                </File>
    12811283                <File
    1282                     RelativePath="..\BasicCompiler_Common\src\ProcedureImpl.cpp"
     1284                    RelativePath="..\BasicCompiler_Common\src\Procedure.cpp"
    12831285                    >
    12841286                </File>
     
    12921294                </File>
    12931295                <File
     1296                    RelativePath="..\BasicCompiler_Common\src\Symbol.cpp"
     1297                    >
     1298                </File>
     1299                <File
     1300                    RelativePath="..\BasicCompiler_Common\src\Type.cpp"
     1301                    >
     1302                </File>
     1303                <File
    12941304                    RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp"
    12951305                    >
    12961306                </File>
    12971307                <File
    1298                     RelativePath="..\BasicCompiler_Common\src\VariableImpl.cpp"
     1308                    RelativePath="..\BasicCompiler_Common\src\Variable.cpp"
    12991309                    >
    13001310                </File>
     
    13101320            </File>
    13111321            <File
    1312                 RelativePath="..\BasicCompiler_Common\BasicFixed.h"
    1313                 >
    1314             </File>
    1315             <File
    13161322                RelativePath="CommandValue.h"
    13171323                >
     
    13271333            <File
    13281334                RelativePath="..\BasicCompiler_Common\include\option.h"
     1335                >
     1336            </File>
     1337            <File
     1338                RelativePath=".\stdafx.h"
    13291339                >
    13301340            </File>
     
    13531363                >
    13541364                <File
    1355                     RelativePath="..\BasicCompiler_Common\include\ClassImpl.h"
     1365                    RelativePath="..\BasicCompiler_Common\include\Class.h"
    13561366                    >
    13571367                </File>
     
    13651375                </File>
    13661376                <File
     1377                    RelativePath="..\BasicCompiler_Common\include\Const.h"
     1378                    >
     1379                </File>
     1380                <File
    13671381                    RelativePath="..\BasicCompiler_Common\include\DataTable.h"
    13681382                    >
     
    13771391                </File>
    13781392                <File
     1393                    RelativePath="..\BasicCompiler_Common\include\Member.h"
     1394                    >
     1395                </File>
     1396                <File
    13791397                    RelativePath="..\BasicCompiler_Common\include\MetaImpl.h"
    13801398                    >
    13811399                </File>
    13821400                <File
     1401                    RelativePath="..\BasicCompiler_Common\include\Method.h"
     1402                    >
     1403                </File>
     1404                <File
    13831405                    RelativePath="..\BasicCompiler_Common\include\NamespaceSupporter.h"
    13841406                    >
    13851407                </File>
    13861408                <File
    1387                     RelativePath="..\BasicCompiler_Common\include\ProcedureImpl.h"
     1409                    RelativePath="..\BasicCompiler_Common\include\Parameter.h"
     1410                    >
     1411                </File>
     1412                <File
     1413                    RelativePath="..\BasicCompiler_Common\include\Procedure.h"
    13881414                    >
    13891415                </File>
     
    13931419                </File>
    13941420                <File
     1421                    RelativePath="..\BasicCompiler_Common\include\Prototype.h"
     1422                    >
     1423                </File>
     1424                <File
    13951425                    RelativePath="..\BasicCompiler_Common\include\SmoothieImpl.h"
    13961426                    >
    13971427                </File>
    13981428                <File
     1429                    RelativePath="..\BasicCompiler_Common\include\Symbol.h"
     1430                    >
     1431                </File>
     1432                <File
     1433                    RelativePath="..\BasicCompiler_Common\include\Type.h"
     1434                    >
     1435                </File>
     1436                <File
    13991437                    RelativePath="..\BasicCompiler_Common\include\TypeDef.h"
    14001438                    >
    14011439                </File>
    14021440                <File
    1403                     RelativePath="..\BasicCompiler_Common\include\VariableImpl.h"
     1441                    RelativePath="..\BasicCompiler_Common\include\Variable.h"
    14041442                    >
    14051443                </File>
  • trunk/abdev/BasicCompiler32/CParameter.cpp

    r76 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "opcode.h"
     
    108110
    109111                //call free
    110                 extern UserProc *pSub_free;
     112                extern const UserProc *pSub_free;
    111113                op_call(pSub_free);
    112114            }
     
    135137
    136138    //call calloc
    137     extern UserProc *pSub_calloc;
     139    extern const UserProc *pSub_calloc;
    138140    op_call(pSub_calloc);
    139141
  • trunk/abdev/BasicCompiler32/Compile_Calc.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    481483            }
    482484            else{
    483                 if(GetConstHash(variable)){
     485                if( compiler.GetMeta().GetGlobalConsts().IsExist(variable)
     486                    || compiler.GetMeta().GetGlobalConstMacros().IsExist(variable) )
     487                {
    484488                    //定数リストに該当したとき
    485489                    SetError(1,NULL,cp);
     
    626630    if( varType.IsObject() && compiler.GetMeta().GetBlittableTypes().IsExist( calcType ) ){
    627631        // Blittable型をオブジェクトとして扱う
    628         vector<UserProc *> userProcs;
     632        vector<const UserProc *> userProcs;
    629633        compiler.GetMeta().GetBlittableTypes().GetClass( calcType ).GetStaticMethods().Enum( "_Create", userProcs );
    630634        if( userProcs.size() != 1 ){
     
    632636            return;
    633637        }
    634         UserProc *pUserProc = userProcs[0];
     638        const UserProc *pUserProc = userProcs[0];
    635639
    636640        // call System.[TypeClass]._Create
  • trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp

    r97 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler32/Compile_CallProc.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    1214void Call_DebugSys_SaveContext(){
    1315    //call _System_GetEip
    14     extern UserProc *pSub_System_GetEip;
     16    extern const UserProc *pSub_System_GetEip;
    1517    op_call(pSub_System_GetEip);
    1618
     
    2224
    2325    //call _DebugSys_SaveContext
    24     extern UserProc *pSub_DebugSys_SaveContext;
     26    extern const UserProc *pSub_DebugSys_SaveContext;
    2527    op_call(pSub_DebugSys_SaveContext);
    2628}
     
    9597}
    9698
    97 bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){
     99bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){
    98100    int i2;
    99101
     
    123125            if(lstrcmpi(ObjectName,"Super")==0){
    124126                //クラスメンバ関数内から基底クラスの呼び出し
    125                 pobj_c=Smoothie::Temp::pCompilingClass;
     127                pobj_c=compiler.pCompilingClass;
    126128            }
    127129            else{
     
    148150            else{
    149151                //クラスメンバ関数内から同一クラスのメンバ関数の呼び出し
    150                 pobj_c=Smoothie::Temp::pCompilingClass;
     152                pobj_c=compiler.pCompilingClass;
    151153            }
    152154        }
     
    177179        if(ObjectName[0]){
    178180            //外部からの呼び出し
    179             if(pobj_c==Smoothie::Temp::pCompilingClass){
     181            if(pobj_c==compiler.pCompilingClass){
    180182                //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    181183                if( pMethod->IsNoneAccess() ){
     
    261263
    262264        //call calloc
    263         extern UserProc *pSub_calloc;
     265        extern const UserProc *pSub_calloc;
    264266        op_call(pSub_calloc);
    265267
  • trunk/abdev/BasicCompiler32/Compile_Func.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    196198    }
    197199
    198     int SubScripts[MAX_ARRAYDIM];
     200    Subscripts subscripts;
    199201    RELATIVE_VAR RelativeVar;
    200     if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,SubScripts)) return;
     202    if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,&subscripts)) return;
    201203
    202204    if(type.GetBasicType()&FLAG_PTR){
     
    209211    int typeSize = type.GetSize();
    210212
    211     if(bArrayHead) typeSize*=JumpSubScripts(SubScripts);
     213    if(bArrayHead) typeSize*=JumpSubScripts(subscripts);
    212214
    213215    //mov eax,TypeSize
     
    218220void Opcode_Func_AddressOf( const char *name ){
    219221    extern int cp;
    220     UserProc *pUserProc;
     222    const UserProc *pUserProc;
    221223
    222224    extern LONG_PTR ProcPtr_BaseIndex;
     
    224226        //左辺の型にのっとり、オーバーロードを解決
    225227
    226         std::vector<UserProc *> subs;
     228        std::vector<const UserProc *> subs;
    227229        GetOverloadSubHash( name, subs );
    228230        if( subs.size() == 0 ){
     
    284286            SetThisPtrToReg(REG_RCX);
    285287
    286             pobj_c=Smoothie::Temp::pCompilingClass;
     288            pobj_c=compiler.pCompilingClass;
    287289        }
    288290
  • trunk/abdev/BasicCompiler32/Compile_Object.cpp

    r140 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "opcode.h"
     
    3537    ////////////////////////
    3638
    37     std::vector<UserProc *> subs;
     39    std::vector<const UserProc *> subs;
    3840    pobj_c->GetMethods().Enum( pobj_c->GetName().c_str(), subs );
    3941
    40     UserProc *pUserProc;
     42    const UserProc *pUserProc;
    4143    if( subs.size() > 0 ){
    4244        //オーバーロードを解決
     
    161163
    162164        //call _System_GC_malloc_ForObject
    163         extern UserProc *pSub_System_GC_malloc_ForObject;
     165        extern const UserProc *pSub_System_GC_malloc_ForObject;
    164166        op_call(pSub_System_GC_malloc_ForObject);
    165167    }
     
    169171
    170172        //call _System_GC_malloc_ForObjectPtr
    171         extern UserProc *pSub_System_GC_malloc_ForObjectPtr;
     173        extern const UserProc *pSub_System_GC_malloc_ForObjectPtr;
    172174        op_call(pSub_System_GC_malloc_ForObjectPtr);
    173175    }
     
    213215    //mov ecx,DestructorProcAddr
    214216    OpBuffer[obp++]=(char)0xB9;
    215     pobj_SubAddrSchedule->add(method->pUserProc,0);
    216     method->pUserProc->Using();
     217    pobj_SubAddrSchedule->add(&method->GetUserProc(),0);
     218    method->GetUserProc().Using();
    217219    obp+=sizeof(long);
    218220
     
    351353    if( isSweeping ){
    352354        //call _System_GC_free_for_SweepingDelete
    353         extern UserProc *pSub_System_GC_free_for_SweepingDelete;
     355        extern const UserProc *pSub_System_GC_free_for_SweepingDelete;
    354356        op_call(pSub_System_GC_free_for_SweepingDelete);
    355357    }
    356358    else{
    357359        //call free
    358         extern UserProc *pSub_free;
     360        extern const UserProc *pSub_free;
    359361        op_call(pSub_free);
    360362    }
  • trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp

    r204 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    57#include <Compiler.h>
    68#include <LexicalScopingImpl.h>
    7 #include <ClassImpl.h>
    8 #include <VariableImpl.h>
     9#include <Class.h>
     10#include <Variable.h>
    911#include <NamespaceSupporter.h>
    1012
     
    3638        }
    3739
    38         UserProc *pBackUserProc;
     40        const UserProc *pBackUserProc;
    3941        pBackUserProc = &UserProc::CompilingUserProc();
    4042        UserProc::CompileStartForGlobalArea();
     
    5456
    5557        //_System_StartupProgramの呼び出し
    56         extern UserProc *pSub_System_StartupProgram;
     58        extern const UserProc *pSub_System_StartupProgram;
    5759        op_call(pSub_System_StartupProgram);
    5860
     
    7173        //静的ローカルオブジェクトのコンストラクタ呼び出し
    7274
    73         BOOST_FOREACH( Variable *pVar, globalVars ){
     75        BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
    7476            if(memicmp(pVar->GetName().c_str(),"Static%",7)==0){
    7577                //コンストラクタ呼び出し
    76                 if( pVar->IsObject() ){
     78                if( pVar->GetType().IsObject() ){
    7779
    7880                    //エラー用
     
    8183                    CallConstructor(
    8284                        pVar->GetName().c_str(),
    83                         pVar->GetSubScriptsPtr(),
    84                         *pVar,
    85                         pVar->paramStrForConstructor.c_str());
     85                        pVar->GetSubscripts(),
     86                        pVar->GetType(),
     87                        pVar->GetParamStrForConstructor().c_str());
    8688                }
    8789            }
     
    9395    else if( userProc.GetName() == "_System_Call_Destructor_of_GlobalObject" ){
    9496
    95         UserProc *pBackUserProc;
     97        const UserProc *pBackUserProc;
    9698        pBackUserProc = &UserProc::CompilingUserProc();
    9799        UserProc::CompileStartForGlobalArea();
     
    222224    }
    223225}
    224 void AutoGeneration(UserProc &userProc){
     226void AutoGeneration( const UserProc &userProc){
    225227    if( userProc.GetName() == "InitializeUserTypes"
    226228        && userProc.HasParentClass()
     
    240242}
    241243
    242 void _compile_proc(UserProc *pUserProc){
     244void _compile_proc(const UserProc *pUserProc){
    243245    extern char *basbuf;
    244246    extern HANDLE hHeap;
    245     extern GlobalProc **ppSubHash;
    246247    extern BOOL bDebugCompile;
    247248    int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset;
     
    250251    if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return;
    251252
    252     if( pUserProc->localVars.size() ){
     253    if( pUserProc->GetLocalVars().size() ){
    253254        SetError();
    254255        return;
    255256    }
     257
     258    trace_for_sourcecodestep( "★★★ " << pUserProc->GetFullName() << "のコンパイルを開始" );
    256259
    257260    pUserProc->CompleteCompile();
     
    270273    else bDebugSupportProc=0;
    271274
    272     pUserProc->beginOpAddress=obp;
     275    pUserProc->SetBeginOpAddress( obp );
    273276
    274277    //コンパイル中の関数が属するクラス
    275     Smoothie::Temp::pCompilingClass=pUserProc->GetParentClassPtr();
     278    compiler.pCompilingClass=pUserProc->GetParentClassPtr();
    276279
    277280    //コンパイルスタートをクラス管理クラスに追加
     
    297300        SystemProc(*pUserProc);
    298301
    299         pUserProc->endOpAddress=obp;
     302        pUserProc->SetEndOpAddress( obp );
    300303        return;
    301304    }
     
    321324        Parameter &param = *pUserProc->RealParams()[i3];
    322325
    323         Variable *pVar = new VariableImpl( param.GetVarName(), param, false, param.IsRef() );
     326        Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef(), "" );
    324327
    325328        if( param.IsArray() ){
    326             pVar->SetArray( param.GetSubScriptsPtr() );
     329            pVar->SetArray( param.GetSubscripts() );
    327330        }
    328331
     
    342345        }
    343346        AllLocalVarSize+=varSize;
    344         pVar->offset=AllLocalVarSize;
     347        pVar->SetOffsetAddress( AllLocalVarSize );
    345348
    346349        //レキシカルスコープ情報
    347         pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    348         pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     350        pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     351        pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    349352        pVar->bLiving=TRUE;
    350353
    351         pUserProc->localVars.push_back( pVar );
     354        pUserProc->GetLocalVars().push_back( pVar );
    352355    }
    353356
     
    456459
    457460        //call _DebugSys_StartProc
    458         extern UserProc *pSub_DebugSys_StartProc;
     461        extern const UserProc *pSub_DebugSys_StartProc;
    459462        op_call(pSub_DebugSys_StartProc);
    460463    }
    461464
    462     if(Smoothie::Temp::pCompilingClass){
    463         if( pUserProc->GetName() == Smoothie::Temp::pCompilingClass->GetName() ){
     465    if(compiler.pCompilingClass){
     466        if( pUserProc->GetName() == compiler.pCompilingClass->GetName() ){
    464467            ////////////////////////////////////
    465468            // コンストラクタをコンパイルするとき
     
    467470
    468471            //コンストラクタのコンパイル開始を通知
    469             Smoothie::Temp::pCompilingClass->NotifyStartConstructorCompile();
     472            compiler.pCompilingClass->NotifyStartConstructorCompile();
    470473
    471474            //基底クラスかどうかの識別
    472475            //(継承元がインターフェイスの場合も基底クラスと見なす)
    473476            BOOL bThisIsSuperClass;
    474             if( !Smoothie::Temp::pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1;
    475             else if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){
     477            if( !compiler.pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1;
     478            else if( compiler.pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){
    476479                //インターフェイスを継承したときはコンストラクタを持たない
    477480                bThisIsSuperClass=1;
     
    492495                    temporary[i4]=basbuf[i3];
    493496                }
    494                 if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetName() == temporary ){
     497                if( compiler.pCompilingClass->GetSuperClass().GetName() == temporary ){
    495498                    //基底クラスのコンストラクタを呼び出す
    496499                    cp=i3;
     
    509512                    Type dummyType;
    510513                    CallProc( PROC_DEFAULT
    511                         , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc
    512                         , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc->GetName().c_str()
     514                        , &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc()
     515                        , compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc().GetName().c_str()
    513516                        , temporary
    514517                        , dummyType );
     
    517520                    //基底クラスのコンストラクタを暗黙的に呼び出す
    518521                    Opcode_CallProc("",
    519                         Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc,
     522                        &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc(),
    520523                        0,
    521524                        "",
     
    525528
    526529            //仮想関数テーブルを初期化
    527             if( Smoothie::Temp::pCompilingClass->IsExistVirtualFunctions()
    528                 && !Smoothie::Temp::pCompilingClass->IsAbstract() ){
     530            if( compiler.pCompilingClass->IsExistVirtualFunctions()
     531                && !compiler.pCompilingClass->IsAbstract() ){
    529532                    //関数テーブルに値をセット
    530                     int offset = (int)Smoothie::Temp::pCompilingClass->GetVtblGlobalOffset();
     533                    int offset = (int)compiler.pCompilingClass->GetVtblGlobalOffset();
    531534
    532535                    //mov eax,offset
     
    548551
    549552            //デストラクタのコンパイル開始を通知
    550             Smoothie::Temp::pCompilingClass->NotifyStartDestructorCompile();
     553            compiler.pCompilingClass->NotifyStartDestructorCompile();
    551554        }
    552555    }
     
    574577    //////////////////////////////////////////
    575578
    576     if( Smoothie::Temp::pCompilingClass ){
    577 
    578         if( Smoothie::Temp::pCompilingClass->IsCompilingConstructor() ){
     579    if( compiler.pCompilingClass ){
     580
     581        if( compiler.pCompilingClass->IsCompilingConstructor() ){
    579582            // コンストラクタをコンパイルしていたとき
    580583
    581584            // コンストラクタのコンパイルが完了したことを通知
    582             Smoothie::Temp::pCompilingClass->NotifyFinishConstructorCompile();
     585            compiler.pCompilingClass->NotifyFinishConstructorCompile();
    583586        }
    584587        else if( pUserProc->IsDestructor() ){
     
    588591
    589592            // デストラクタのコンパイルが完了したことを通知
    590             Smoothie::Temp::pCompilingClass->NotifyFinishDestructorCompile();
    591 
    592             if( Smoothie::Temp::pCompilingClass->HasSuperClass() ){
     593            compiler.pCompilingClass->NotifyFinishDestructorCompile();
     594
     595            if( compiler.pCompilingClass->HasSuperClass() ){
    593596                /* サブクラスのデストラクタをコンパイルしているときは、
    594597                    基底クラスのデストラクタを呼び出す */
    595598
    596                 const CMethod *method = Smoothie::Temp::pCompilingClass->GetSuperClass().GetDestructorMethod();
     599                const CMethod *method = compiler.pCompilingClass->GetSuperClass().GetDestructorMethod();
    597600                if( method ){
    598601                    Opcode_CallProc("",
    599                         method->pUserProc,
     602                        &method->GetUserProc(),
    600603                        0,
    601604                        "",
     
    649652
    650653        //call _DebugSys_EndProc
    651         extern UserProc *pSub_DebugSys_EndProc;
     654        extern const UserProc *pSub_DebugSys_EndProc;
    652655        op_call(pSub_DebugSys_EndProc);
    653656    }
     
    742745    }
    743746    HeapDefaultFree(pLocalVarAddrSchedule);
    744     BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){
     747    BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
    745748        //後にデバッグで利用する
    746         pVar->offset = AllLocalVarSize - pVar->offset;
     749        pVar->SetOffsetAddress( AllLocalVarSize - pVar->GetOffsetAddress() );
    747750    }
    748751
     
    771774
    772775        //call _esp_error
    773         extern UserProc *pSub_esp_error;
     776        extern const UserProc *pSub_esp_error;
    774777        op_call( pSub_esp_error );
    775778
     
    799802
    800803
    801     pUserProc->endOpAddress=obp;
     804    pUserProc->SetEndOpAddress( obp );
    802805
    803806
     
    811814}
    812815
    813 void CompileBufferInProcedure( UserProc &userProc ){
     816void CompileBufferInProcedure( const UserProc &userProc ){
    814817    if( userProc.IsUsing() == false || userProc.IsCompiled() ) return;
    815818
     
    827830}
    828831void CompileLocal(){
    829     extern GlobalProc **ppSubHash;
    830     int i2;
    831 
    832832    extern BOOL bDll;
    833833    if(bDll){
    834834        //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする
    835         UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");
     835        const UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");
    836836        if(pUserProc){
    837837            CompileBufferInProcedure( *pUserProc );
     
    841841
    842842    //_System_TypeBase_InitializeUserTypesは一番最後にコンパイル
    843     extern UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;
     843    extern const UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;
    844844    pSubStaticMethod_System_TypeBase_InitializeUserTypes->CompleteCompile();
    845845
    846846    //_System_InitStaticLocalVariablesは一番最後にコンパイル
    847847    //※一般関数内の静的変数オブジェクトをすべて収集しなければならない
    848     extern UserProc *pSub_System_InitStaticLocalVariables;
     848    extern const UserProc *pSub_System_InitStaticLocalVariables;
    849849    pSub_System_InitStaticLocalVariables->CompleteCompile();
    850850
    851851    //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル
    852     extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;
     852    extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject;
    853853    pSub_System_Call_Destructor_of_GlobalObject->CompleteCompile();
    854854
    855855repeat:
    856     GlobalProc *pGlobalProc;
    857     for(i2=0;i2<MAX_HASH;i2++){
    858         pGlobalProc=ppSubHash[i2];
    859         while(pGlobalProc){
    860             CompileBufferInProcedure( *pGlobalProc );
    861             pGlobalProc=pGlobalProc->pNextData;
    862         }
     856    compiler.GetMeta().GetUserProcs().Iterator_Reset();
     857    while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     858    {
     859        UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     860        CompileBufferInProcedure( *pUserProc );
    863861    }
    864862
     
    874872    if( IsNeedProcCompile() ){
    875873        //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合
    876         for(i2=0;i2<MAX_HASH;i2++){
    877             pGlobalProc=ppSubHash[i2];
    878             while(pGlobalProc){
    879                 CompileBufferInProcedure( *pGlobalProc );
    880                 pGlobalProc=pGlobalProc->pNextData;
    881             }
     874
     875        compiler.GetMeta().GetUserProcs().Iterator_Reset();
     876        while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     877        {
     878            UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     879            CompileBufferInProcedure( *pUserProc );
    882880        }
    883881    }
  • trunk/abdev/BasicCompiler32/Compile_Set_Var.cpp

    r183 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    4042
    4143                    //call free
    42                     extern UserProc *pSub_free;
     44                    extern const UserProc *pSub_free;
    4345                    op_call(pSub_free);
    4446                }
  • trunk/abdev/BasicCompiler32/Compile_Statement.cpp

    r183 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/LexicalAnalysis.h>
    24
     
    911void OpcodeOthers( const char *Command ){
    1012    int i,i2;
    11     UserProc *pUserProc;
    1213
    1314    char leftTerm[8192];
     
    5960        //////////////////////////////
    6061
    61         pUserProc=GetSubHash(Command);
     62        const UserProc *pUserProc = GetSubHash(Command);
    6263
    6364        //GetSubHash内でエラー提示が行われた場合
     
    10791080
    10801081                if(type1.IsObject()){
    1081                     std::vector<UserProc *> subs;
     1082                    std::vector<const UserProc *> subs;
    10821083                    type1.GetClass().GetMethods().Enum( CALC_EQUAL, subs );
    10831084                    if( subs.size() == 0 ){
     
    10891090
    10901091                    //オーバーロードを解決
    1091                     UserProc *pUserProc;
    1092                     pUserProc=OverloadSolution("==",subs, params, NULL);
     1092                    const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL);
    10931093
    10941094                    delete params[0];
     
    13261326        //戻り値をセット
    13271327        if(Parameter[0]){
    1328             UserProc &proc = UserProc::CompilingUserProc();
     1328            const UserProc &proc = UserProc::CompilingUserProc();
    13291329
    13301330            const char *temp = "_System_ReturnValue";
  • trunk/abdev/BasicCompiler32/Compile_Var.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    57#include <CodeGenerator.h>
    68#include <Compiler.h>
    7 #include <VariableImpl.h>
     9#include <Variable.h>
    810
    911#include "../BasicCompiler_Common/common.h"
     
    1113
    1214//変数
    13 Variables globalVars;
     15// TODO: xml未完成
    1416int AllGlobalVarSize;
    1517int AllInitGlobalVarSize;
     
    6466    }
    6567}
    66 bool GetArrayOffset(const int *SubScripts,char *array, const Type &type){
     68bool GetArrayOffset(const Subscripts &subscripts,char *array, const Type &type){
    6769    extern HANDLE hHeap;
    6870    int i,i2,i3,i4;
     
    8385        }
    8486        if(array[i]==','||array[i]=='\0'){
    85             if(SubScripts[i3]==-1){
     87            if( i3 >= (int)subscripts.size() )
     88            {
    8689                for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
    8790                return 0;
     
    9699
    97100            if(array[i]=='\0'){
    98                 if(SubScripts[i3]!=-1){
     101                if( i3 < (int)subscripts.size() )
     102                {
    99103                    for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
    100104                    return 0;
     
    131135        op_pop(REG_EAX);
    132136
    133         for(i2=i+1,i4=1;i2<i3;i2++) i4*=SubScripts[i2]+1;
     137        for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1;
    134138
    135139        //imul eax,i4
     
    175179    char lpPtrOffset[VN_SIZE];  //第2次配列
    176180    char NestMember[VN_SIZE];   //入れ子メンバ
    177     CClass::RefType refType;
     181    ReferenceKind refType;
    178182    lstrcpy(VarName,member);
    179183    if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false;
     
    195199
    196200    //アクセシビリティをチェック
    197     if(&objClass==Smoothie::Temp::pCompilingClass){
     201    if(&objClass==compiler.pCompilingClass){
    198202        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    199203        if(pMember->IsNoneAccess()){
     
    228232    //ポインタ変数の場合
    229233    if( resultType.IsPointer() ){
    230         if(pMember->SubScripts[0]==-1){
     234        if( pMember->GetSubscripts().size() == 0 ){
    231235            lstrcpy(lpPtrOffset,array);
    232236            array[0]=0;
     
    250254    if(array[0]){
    251255        //配列オフセット
    252         if(!GetArrayOffset(pMember->SubScripts,array,pMember->GetType())){
     256        if(!GetArrayOffset(pMember->GetSubscripts(),array,pMember->GetType())){
    253257            if(isErrorEnabled) SetError(14,member,cp);
    254258        }
    255259    }
    256     else if(pMember->SubScripts[0]!=-1){
     260    else if( pMember->GetSubscripts().size() > 0 ){
    257261        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    258262    }
     
    262266
    263267        if( resultType.IsObject() || resultType.IsStruct() ){
    264             if( refType != CClass::Dot ){
     268            if( refType != RefDot ){
    265269                if(isErrorEnabled) SetError(104,member,cp);
    266270                return false;
     
    278282                //pObj[n].member
    279283                if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() )
    280                     && refType != CClass::Dot ){
     284                    && refType != RefDot ){
    281285                        if(isErrorEnabled) SetError(104,member,cp);
    282286                        return false;
     
    292296                //pObj->member
    293297                if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() )
    294                     && refType != CClass::Pointer ){
     298                    && refType != RefPointer ){
    295299                        if(isErrorEnabled) SetError(104,member,cp);
    296300                        return false;
     
    306310            if(lpPtrOffset[0]){
    307311                //ppObj[n]->member
    308                 if( refType != CClass::Pointer ){
     312                if( refType != RefPointer ){
    309313                    if(isErrorEnabled) SetError(104,member,cp);
    310314                    return false;
     
    357361}
    358362
    359 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss){
     363bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){
    360364    char variable[VN_SIZE];
    361365
     
    371375
    372376    // 先頭オブジェクトまたはクラス名と入れ子メンバに分割
    373     CClass::RefType refType;
     377    ReferenceKind refType;
    374378    char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE];
    375379    GetVarFormatString(simpleName,array,lpPtrOffset,member,refType);
     
    384388    }
    385389
    386     const int *pSubScripts;
     390    const Subscripts *pSubscripts;
    387391    bool bConst = false;
    388392
     
    393397        //////////////////
    394398
    395         const Variable *pVar = UserProc::CompilingUserProc().localVars.BackSearch( Symbol( VarName ) );
     399        const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) );
    396400        if( pVar ){
    397401            //ポインタ変数の場合
    398             if( pVar->IsPointer() ){
     402            if( pVar->GetType().IsPointer() ){
    399403                if( !pVar->IsArray() ){
    400404                    lstrcpy(lpPtrOffset,array);
     
    410414            }
    411415
    412             pRelativeVar->offset=-pVar->offset;
     416            pRelativeVar->offset=-pVar->GetOffsetAddress();
    413417            pRelativeVar->bOffsetOffset=0;
    414418            if( pVar->IsRef() ){
     
    417421            }
    418422            else pRelativeVar->dwKind=VAR_LOCAL;
    419             resultType = *pVar;
    420             pSubScripts=pVar->GetSubScriptsPtr();
     423            resultType = pVar->GetType();
     424            pSubscripts = &pVar->GetSubscripts();
    421425            bConst = pVar->IsConst();
    422426
     
    425429    }
    426430
    427     if(Smoothie::Temp::pCompilingClass){
     431    if(compiler.pCompilingClass){
    428432        //////////////////////
    429433        // クラスメンバの参照
     
    438442            pRelativeVar->dwKind=VAR_DIRECTMEM;
    439443
    440             resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
     444            resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
    441445            return true;
    442446        }
     
    451455
    452456            bool isFound = false;
    453             BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){
     457            BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){
    454458                if( pMember->GetName() == VarName ){
    455459                    isFound = true;
     
    465469        if( isWriteAccess &&
    466470            pMethod->IsConst() &&
    467             Smoothie::Temp::pCompilingClass->IsCompilingConstructor() == false &&
    468             Smoothie::Temp::pCompilingClass->IsCompilingDestructor() == false
     471            compiler.pCompilingClass->IsCompilingConstructor() == false &&
     472            compiler.pCompilingClass->IsCompilingDestructor() == false
    469473            ){
    470474                SetError(131, NULL, cp );
     
    481485            isErrorEnabled,
    482486            isWriteAccess,
    483             *Smoothie::Temp::pCompilingClass,
     487            *compiler.pCompilingClass,
    484488            variable,
    485489            pRelativeVar,
     
    502506            GetNowStaticVarFullName(VarName,temporary);
    503507
    504             pVar = globalVars.Find( Symbol( temporary ) );
     508            pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) );
    505509            if( pVar ){
    506510                goto GlobalOk;
     
    521525            char tempArray[VN_SIZE];
    522526            {
    523                 CClass::RefType refType;
     527                ReferenceKind refType;
    524528                GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType );
    525529            }
     
    533537            char temp2[VN_SIZE];
    534538            sprintf(temp2,"%s.%s",VarName,temporary);
    535             pVar = globalVars.Find( Symbol( temp2 ) );
     539            pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
    536540            if( pVar ){
    537541                lstrcpy(member,tempMember);
     
    541545        }
    542546
    543         if(Smoothie::Temp::pCompilingClass){
     547        if(compiler.pCompilingClass){
    544548            //自身のクラスから静的メンバを参照する場合
    545549            char temp2[VN_SIZE];
    546             sprintf(temp2,"%s.%s",Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);
    547             pVar = globalVars.Find( Symbol( temp2 ) );
     550            sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName);
     551            pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
    548552            if( pVar ){
    549553                goto GlobalOk;
     
    555559        /////////////////////
    556560
    557         pVar = globalVars.BackSearch( Symbol( VarName ) );
     561        pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) );
    558562        if( pVar ){
    559563            goto GlobalOk;
     
    568572GlobalOk:
    569573        //ポインタ変数の場合
    570         if( pVar->IsPointer() ){
     574        if( pVar->GetType().IsPointer() ){
    571575            if( !pVar->IsArray() ){
    572576                lstrcpy(lpPtrOffset,array);
     
    582586        }
    583587
    584         pRelativeVar->offset=pVar->offset;
     588        pRelativeVar->offset=pVar->GetOffsetAddress();
    585589        pRelativeVar->bOffsetOffset=0;
    586590        if( pVar->IsRef() ){
     
    589593        }
    590594        else pRelativeVar->dwKind=VAR_GLOBAL;
    591         resultType = *pVar;
    592         pSubScripts=pVar->GetSubScriptsPtr();
     595        resultType = pVar->GetType();
     596        pSubscripts=&pVar->GetSubscripts();
    593597        bConst = pVar->IsConst();
    594598    }
     
    610614    }
    611615
    612     if(array[0]==0&&pSubScripts[0]!=-1){
     616    if( array[0] == 0 && pSubscripts->size() > 0 ){
    613617        //配列の先頭ポインタを示す場合
    614618        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    615         if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM);
     619
     620        if( pResultSubscripts )
     621        {
     622            (*pResultSubscripts) = *pSubscripts;
     623        }
    616624        return true;
    617625    }
     
    625633    }
    626634    if(array[0]){
    627         if(!GetArrayOffset(pSubScripts,array,resultType)){
     635        if(!GetArrayOffset(*pSubscripts,array,resultType)){
    628636            SetError(14,variable,cp);
    629637            pRelativeVar->dwKind=NON_VAR;
     
    634642        if( resultType.IsObject() || resultType.IsStruct() ){
    635643            //実態オブジェクトのメンバを参照(obj.member)
    636             if( refType != CClass::Dot ){
     644            if( refType != RefDot ){
    637645                SetError(104,VarName,cp);
    638646                pRelativeVar->dwKind=NON_VAR;
     
    649657            if(lpPtrOffset[0]){
    650658                //pObj[n].member
    651                 if( refType != CClass::Dot ){
     659                if( refType != RefDot ){
    652660                    SetError(104,VarName,cp);
    653661                    pRelativeVar->dwKind=NON_VAR;
     
    659667            else{
    660668                //pObj->member
    661                 if( refType != CClass::Pointer ){
     669                if( refType != RefPointer ){
    662670                    SetError(104,VarName,cp);
    663671                    pRelativeVar->dwKind=NON_VAR;
     
    677685            if(lpPtrOffset[0]){
    678686                //ppObj[n]->member
    679                 if( refType != CClass::Pointer ){
     687                if( refType != RefPointer ){
    680688                    SetError(104,VarName,cp);
    681689                    pRelativeVar->dwKind=NON_VAR;
     
    722730}
    723731
    724 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){
     732bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){
    725733    extern BYTE *initGlobalBuf;
    726734    int i2,i3;
     
    735743        int typeSize = type.GetSize();
    736744
    737         if(SubScripts[0]!=-1){
    738             typeSize*=JumpSubScripts(SubScripts+1);
    739             int i=0;
    740             i2=0;
    741             while(1){
    742                 if(SubScripts[0]<i2){
    743                     SetError(41,0,cp);
    744                     return 0;
    745                 }
    746                 i=GetOneParameter(InitBuf,i,temporary);
    747                 if(!SetInitGlobalData(
    748                     offset+i2*typeSize,
    749                     type,
    750                     SubScripts+1,
    751                     temporary)) return false;
    752                 i2++;
    753                 if(InitBuf[i]=='\0') break;
     745        if( subscripts.size() > 0 ){
     746            Subscripts nestSubscripts;
     747            for( int i=1; i<(int)subscripts.size(); i++ )
     748            {
     749                nestSubscripts.push_back( subscripts[i] );
     750            }
     751
     752            typeSize*=JumpSubScripts( nestSubscripts );
     753            {
     754                int i=0;
     755                i2=0;
     756                while(1){
     757                    if( subscripts[0] < i2 ){
     758                        SetError(41,0,cp);
     759                        return 0;
     760                    }
     761                    i=GetOneParameter(InitBuf,i,temporary);
     762                    if(!SetInitGlobalData(
     763                        offset+i2*typeSize,
     764                        type,
     765                        nestSubscripts,
     766                        temporary)) return false;
     767                    i2++;
     768                    if(InitBuf[i]=='\0') break;
     769                }
    754770            }
    755771            return true;
     
    772788                if(!SetInitGlobalData(offset+i3,
    773789                    pMember->GetType(),
    774                     pMember->SubScripts,
     790                    pMember->GetSubscripts(),
    775791                    temporary)) return false;
    776792            }
     
    793809    }
    794810
    795     if(SubScripts[0]!=-1){
     811    if( subscripts.size() > 0 ){
    796812        SetError(41,0,cp);
    797813        return false;
     
    861877    return true;
    862878}
    863 bool InitLocalVar(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){
    864     int i,i2,i3;
     879bool InitLocalVar(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){
     880    int i2,i3;
    865881    char temporary[VN_SIZE];
    866882    char InitBuf[VN_SIZE];
     
    873889        int typeSize = type.GetSize();
    874890
    875         if(SubScripts[0]!=-1){
    876             typeSize*=JumpSubScripts(SubScripts+1);
    877             i=0;
    878             i2=0;
    879             while(1){
    880                 if(SubScripts[0]<i2){
    881                     SetError(41,0,cp);
    882                     return false;
    883                 }
    884                 i=GetOneParameter(InitBuf,i,temporary);
    885                 if(!InitLocalVar(
    886                     offset+i2*typeSize,
    887                     type,
    888                     SubScripts+1,
    889                     temporary)) return false;
    890                 i2++;
    891                 if(InitBuf[i]=='\0') break;
     891        if( subscripts.size() > 0 ){
     892            Subscripts nestSubscripts;
     893            for( int i=1; i<(int)subscripts.size(); i++ )
     894            {
     895                nestSubscripts.push_back( subscripts[i] );
     896            }
     897
     898            typeSize*=JumpSubScripts( nestSubscripts );
     899            {
     900                int i=0;
     901                i2=0;
     902                while(1){
     903                    if( subscripts[0] < i2 ){
     904                        SetError(41,0,cp);
     905                        return 0;
     906                    }
     907                    i=GetOneParameter(InitBuf,i,temporary);
     908                    if(!InitLocalVar(
     909                        offset+i2*typeSize,
     910                        type,
     911                        nestSubscripts,
     912                        temporary)) return false;
     913                    i2++;
     914                    if(InitBuf[i]=='\0') break;
     915                }
    892916            }
    893917            return true;
     
    910934                if(!InitLocalVar(offset+i3,
    911935                    pMember->GetType(),
    912                     pMember->SubScripts,
     936                    pMember->GetSubscripts(),
    913937                    temporary)) return false;
    914938
     
    927951    ///////////////////////////////////////
    928952
    929     if(SubScripts[0]!=-1){
     953    if( subscripts.size() > 0 ){
    930954        SetError(41,0,cp);
    931955        return false;
     
    10751099}
    10761100
    1077 void dim( char *VarName,int *SubScripts,Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){
     1101void dim( char *VarName, const Subscripts &subscripts, Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){
    10781102    if( UserProc::IsGlobalAreaCompiling() ){
    10791103        /////////////////////////
     
    10811105        /////////////////////////
    10821106
    1083         AddGlobalVariable(VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags);
     1107        AddGlobalVariable(VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags);
    10841108    }
    10851109    else{
     
    10881112        /////////////////
    10891113
    1090         if( UserProc::CompilingUserProc().localVars.DuplicateCheck( Symbol( VarName ) ) ){
     1114        if( UserProc::CompilingUserProc().GetLocalVars().DuplicateCheck( Symbol( VarName ) ) ){
    10911115            //2重定義のエラー
    10921116            SetError(15,VarName,cp);
     
    10961120        bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false;
    10971121
    1098         Variable *pVar = new VariableImpl( VarName, type, isConst );
    1099 
    1100         if( SubScripts[0] != -1 ){
     1122        Variable *pVar = new Variable( VarName, type, isConst, false, ConstractParameter );
     1123
     1124        if( subscripts.size() > 0 ){
    11011125            //配列あり
    1102             pVar->SetArray( SubScripts );
    1103         }
    1104 
    1105         //コンストラクタ用パラメータ
    1106         pVar->paramStrForConstructor = ConstractParameter;
     1126            pVar->SetArray( subscripts );
     1127        }
    11071128
    11081129        //レキシカルスコープ
    1109         pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    1110         pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     1130        pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     1131        pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    11111132        pVar->bLiving=TRUE;
    11121133
     
    11151136
    11161137        // 変数を追加
    1117         UserProc::CompilingUserProc().localVars.push_back( pVar );
     1138        UserProc::CompilingUserProc().GetLocalVars().push_back( pVar );
    11181139
    11191140        //アラインメントを考慮
    1120         if( pVar->IsStruct() ){
    1121             int alignment = pVar->GetClass().iAlign;
     1141        if( pVar->GetType().IsStruct() ){
     1142            int alignment = pVar->GetType().GetClass().iAlign;
    11221143
    11231144            if( alignment ){
     
    11391160
    11401161        AllLocalVarSize += pVar->GetMemorySize();
    1141         pVar->offset = AllLocalVarSize;
     1162        pVar->SetOffsetAddress( AllLocalVarSize );
    11421163
    11431164        //レキシカルスコープ
    1144         pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    1145         pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     1165        pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     1166        pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    11461167        pVar->bLiving=TRUE;
    11471168
     
    11531174
    11541175            int result = 0;
    1155             if( !pVar->IsObject() ){
    1156                 result = InitLocalVar(-pVar->offset,
    1157                     *pVar,
    1158                     pVar->GetSubScriptsPtr(),
     1176            if( !pVar->GetType().IsObject() ){
     1177                result = InitLocalVar(-pVar->GetOffsetAddress(),
     1178                    pVar->GetType(),
     1179                    pVar->GetSubscripts(),
    11591180                    InitBuf);
    11601181            }
     
    11841205            //add eax,offset
    11851206            OpBuffer[obp++]=(char)0x05;
    1186             *((long *)(OpBuffer+obp))=-pVar->offset;
     1207            *((long *)(OpBuffer+obp))=-pVar->GetOffsetAddress();
    11871208            AddLocalVarAddrSchedule();
    11881209            obp+=sizeof(long);
     
    12041225    if( type.IsObject() &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&&InitBuf[0]=='\0'){
    12051226        char objectSize[255];
    1206         if( SubScripts[0] == -1 ){
     1227        if( subscripts.size() == 0 ){
    12071228            objectSize[0] = 0;
    12081229        }
    12091230        else{
    1210             if( SubScripts[1] != -1 ){
     1231            if( subscripts.size() > 1 ){
    12111232                SetError(300,NULL,cp);
    12121233            }
    1213             sprintf( objectSize, "%d", SubScripts[0] );
     1234            sprintf( objectSize, "%d", subscripts[0] );
    12141235        }
    12151236        Operator_New( type.GetClass(), objectSize, ConstractParameter, type );
     
    13231344
    13241345bool Compile_AddGlobalRootsForGc(){
    1325     UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
     1346    const UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
    13261347    if( !pUserProc_AddGlobalRootPtr ){
    13271348        SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 );
     
    13291350    }
    13301351
    1331     BOOST_FOREACH( const Variable *pVar, globalVars ){
    1332         if( pVar->IsObject() || pVar->IsPointer() || pVar->IsStruct() ){
     1352    BOOST_FOREACH( const Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
     1353        if( pVar->GetType().IsObject() || pVar->GetType().IsPointer() || pVar->GetType().IsStruct() ){
    13331354            // オブジェクトまたはポインタだったとき
    13341355            // ※構造体も含む(暫定対応)
     
    13421363
    13431364            //mov eax,offset
    1344             op_mov_RV(REG_EAX,(int)pVar->offset);
     1365            op_mov_RV(REG_EAX,(int)pVar->GetOffsetAddress());
    13451366            obp-=sizeof(long);
    13461367            pobj_GlobalVarSchedule->add();
  • trunk/abdev/BasicCompiler32/MakePeHdr.cpp

    r201 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/common/Environment.h>
    24
     
    46
    57#include <LexicalScopingImpl.h>
    6 #include <ClassImpl.h>
     8#include <Class.h>
    79#include <Compiler.h>
    810#include <NamespaceSupporter.h>
    911
     12#include <../Enum.h>
     13
    1014#include "../BasicCompiler_Common/common.h"
     15#include "../BasicCompiler_Common/DebugSection.h"
    1116#include "Opcode.h"
    1217
     
    1924
    2025// グローバル関数、静的メソッド
    21 UserProc
     26const UserProc
    2227    *pSub_System_StartupProgram,
    2328    *pSub_DebugSys_StartProc,
     
    5156
    5257// 動的メソッド
    53 UserProc
     58const UserProc
    5459    *pUserProc_System_CGarbageCollection_RegisterGlobalRoots;
    5560
     
    176181
    177182    //クラス名を取得(詳細情報はGetAllClassInfoで取得)
    178     //   GetSubInfo関数の中で参照されるオブジェクト名を事前に取得する。
     183    //   CollectUserProcs関数の中で参照されるオブジェクト名を事前に取得する。
    179184    //     ※オブジェクトの内容までは取得しない
    180185    compiler.GetMeta().GetClasses().CollectClassesForNameOnly( Smoothie::Lexical::source );
     
    186191    GetConstInfo();
    187192
    188     //サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得
    189     Smoothie::Temp::pCompilingClass=0;
    190     GetSubInfo();
    191 
    192     //クラス情報を取得(※注 - GetSubInfoの後に呼び出す)
     193    // サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得
     194    compiler.pCompilingClass=0;
     195    UserProcs::CollectUserProcs( Smoothie::Lexical::source, compiler.GetMeta().GetUserProcs() );
     196
     197    // クラス情報を取得(※注 - CollectUserProcsの後に呼び出す)
    193198    compiler.GetMeta().GetClasses().GetAllClassInfo();
     199
     200    // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備
     201    compiler.GetMeta().GetUserProcs().Iterator_Init();
    194202
    195203    if( !compiler.GetMeta().Write( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) )
     
    197205        MessageBox(0,"XML書き込みに失敗","test",0);
    198206    }
    199     MetaImpl tempMeta;
    200     if( !tempMeta.Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) )
     207    MetaImpl *pTempMeta = new MetaImpl();
     208    if( !pTempMeta->Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) )
    201209    {
    202210        MessageBox(0,"XML読み込みに失敗","test",0);
    203211    }
     212    compiler.GetMeta() = (*pTempMeta);
    204213
    205214    //コードと行番号の関係
     
    401410        extern DWORD dwContinueAddress;
    402411        dwContinueAddress=-1;
     412
     413        trace_for_sourcecodestep( "★★★ グローバル領域のコンパイルを開始" );
    403414
    404415
     
    451462
    452463        //call _System_End
    453         extern UserProc *pSub_System_End;
     464        extern const UserProc *pSub_System_End;
    454465        op_call(pSub_System_End);
    455466
     
    593604        ExportNamesLength=lstrlen(lpExportNames)+1;
    594605
    595         extern GlobalProc **ppSubHash;
    596         GlobalProc *pUserProc,*psi2;
     606        UserProc *pUserProc,*psi2;
    597607        while(1){
    598608            //辞書順にサーチ
    599609            temporary[0]=0;
    600             for(i=0,psi2=0;i<MAX_HASH;i++){
    601                 pUserProc=ppSubHash[i];
    602                 while(pUserProc){
    603                     if(pUserProc->IsExport()){
    604                         if(temporary[0]=='\0'){
     610            compiler.GetMeta().GetUserProcs().Iterator_Reset();
     611            while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     612            {
     613                pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     614                if(pUserProc->IsExport()){
     615                    if(temporary[0]=='\0'){
     616                        lstrcpy(temporary,pUserProc->GetName().c_str());
     617                        psi2=pUserProc;
     618                    }
     619                    else{
     620                        i3=lstrlen(temporary);
     621                        i4=(int)pUserProc->GetName().size();
     622                        if(i3<i4) i3=i4;
     623                        if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){
    605624                            lstrcpy(temporary,pUserProc->GetName().c_str());
    606625                            psi2=pUserProc;
    607626                        }
    608                         else{
    609                             i3=lstrlen(temporary);
    610                             i4=(int)pUserProc->GetName().size();
    611                             if(i3<i4) i3=i4;
    612                             if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){
    613                                 lstrcpy(temporary,pUserProc->GetName().c_str());
    614                                 psi2=pUserProc;
    615                             }
    616                         }
    617627                    }
    618                     pUserProc=pUserProc->pNextData;
    619628                }
    620629            }
     
    625634
    626635            if( pUserProc->GetName() == "DllMain" ){
    627                 DllMain_EntryPoint=pUserProc->beginOpAddress;
     636                DllMain_EntryPoint=pUserProc->GetBeginOpAddress();
    628637            }
    629638
    630639            lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD));
    631             lpdwExportAddressTable[ExportNum]=pUserProc->beginOpAddress;
     640            lpdwExportAddressTable[ExportNum]=pUserProc->GetBeginOpAddress();
    632641
    633642            lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD));
     
    808817    //(デバッグ情報で利用される)
    809818    extern int AllInitGlobalVarSize;
    810     BOOST_FOREACH( Variable *pVar, globalVars ){
    811         if(pVar->offset&0x80000000){
    812             pVar->offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize;
     819    BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
     820        if(pVar->GetOffsetAddress()&0x80000000){
     821            pVar->SetOffsetAddress( (pVar->GetOffsetAddress()&0x7FFFFFFF)+AllInitGlobalVarSize );
    813822        }
    814823    }
     
    11101119    // プロシージャポインタスケジュール
    11111120    for(i=0;i<pobj_SubAddrSchedule->num;i++){
    1112         if(pobj_SubAddrSchedule->ppsi[i]->beginOpAddress==0
    1113             &&pobj_SubAddrSchedule->ppsi[i]->endOpAddress==0){
     1121        if(pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()==0
     1122            &&pobj_SubAddrSchedule->ppsi[i]->GetEndOpAddress()==0){
    11141123            SetError(300,NULL,-1);
    11151124        }
     
    11171126        if(pobj_SubAddrSchedule->pbCall[i]){
    11181127            *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=
    1119                 pobj_SubAddrSchedule->ppsi[i]->beginOpAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));
     1128                pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));
    11201129        }
    11211130        else{
    11221131            *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=
    1123                 pobj_SubAddrSchedule->ppsi[i]->beginOpAddress+ImageBase+MemPos_CodeSection;
     1132                pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()+ImageBase+MemPos_CodeSection;
    11241133        }
    11251134    }
  • trunk/abdev/BasicCompiler32/NumOpe.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    179181    // 動的メソッドを検索
    180182    ///////////////////////////////////////////////////////////////////
    181     vector<UserProc *> userProcs;
     183    vector<const UserProc *> userProcs;
    182184
    183185    char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1];
    184     CClass::RefType refType;
     186    ReferenceKind refType;
    185187    lstrcpy( methodName, member );
    186188    GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
    187189
    188190    objClass.GetMethods().Enum( methodName, userProcs );
    189     UserProc *pUserProc;
    190191    if(userProcs.size()){
    191192        //オーバーロードを解決
    192         pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     193        const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
    193194
    194195        if( pUserProc ){
     
    248249    // パース
    249250    char member[VN_SIZE];
    250     CClass::RefType refType;
    251     if( CClass::SplitName( termFull, termLeft, member, refType ) ){
     251    ReferenceKind refType;
     252    if( SplitMemberName( termFull, termLeft, member, refType ) ){
    252253        ///////////////////////////////////////////////////////////////////
    253254        // オブジェクトとメンバに分解できるとき
     
    312313    if(lstrcmpi(termFull,"This")==0 && isProcedureCallOnly == false ){
    313314        //Thisオブジェクト
    314         resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
     315        resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
    315316
    316317        SetThisPtrToReg( useReg );
     
    386387            return true;
    387388        }
    388         else if(GetConstCalcBuffer(procName,parameter,temporary)){
    389             /////////////////////////
    390             // マクロ関数
    391             /////////////////////////
    392 
    393             //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    394             if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
    395 
    396             //マクロ関数の場合
    397             NumOpe(useReg, temporary,Type(),resultType);
    398 
    399             if(!IS_LITERAL(resultType.GetIndex())){
    400                 //リテラル値ではなかったとき
    401                 isLiteral = false;
     389        ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( procName );
     390        if( pConstMacro )
     391        {
     392            if( pConstMacro->GetCalcBuffer( parameter, temporary ) )
     393            {
     394                /////////////////////////
     395                // マクロ関数
     396                /////////////////////////
     397
     398                //閉じカッコ")"に続く文字がNULLでないときはエラーにする
     399                if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
     400
     401                //マクロ関数の場合
     402                NumOpe(useReg, temporary,Type(),resultType);
     403
     404                if(!IS_LITERAL(resultType.GetIndex())){
     405                    //リテラル値ではなかったとき
     406                    isLiteral = false;
     407                }
     408
     409                return true;
    402410            }
    403 
    404             return true;
    405411        }
    406412    }
     
    855861                    //////////////
    856862
    857                     i3 = CDBConst::obj.GetBasicType(term);
     863                    i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(term);
    858864                    if(i3){
    859                         if( CDBConst::obj.IsStringPtr( term ) ){
     865                        if( compiler.GetMeta().GetGlobalConsts().IsStringPtr( term ) ){
    860866                            //リテラル文字列
    861867
    862                             double dbl = CDBConst::obj.GetDoubleData(term);
     868                            double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term);
    863869                            memcpy(&i64data,&dbl,sizeof(double));
    864870
     
    874880                        if(IsRealNumberType(i3)){
    875881                            //実数
    876                             double dbl = CDBConst::obj.GetDoubleData(term);
     882                            double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term);
    877883                            memcpy(&i64data,&dbl,sizeof(double));
    878884                            goto Literal;
     
    880886                        else if(IsWholeNumberType(i3)){
    881887                            //整数
    882                             i64data = CDBConst::obj.GetWholeData(term);
     888                            i64data = compiler.GetMeta().GetGlobalConsts().GetWholeData(term);
    883889                            goto Literal;
    884890                        }
  • trunk/abdev/BasicCompiler32/NumOpe_Arithmetic.cpp

    r75 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
     
    270272
    271273            //call _allmul
    272             extern UserProc *pSub_allmul;
     274            extern const UserProc *pSub_allmul;
    273275            op_call(pSub_allmul);
    274276
     
    460462
    461463            //call _aullrem
    462             extern UserProc *pSub_aullrem;
     464            extern const UserProc *pSub_aullrem;
    463465            op_call(pSub_aullrem);
    464466        }
     
    467469
    468470            //call _allrem
    469             extern UserProc *pSub_allrem;
     471            extern const UserProc *pSub_allrem;
    470472            op_call(pSub_allrem);
    471473        }
     
    720722
    721723            //call _aulldiv
    722             extern UserProc *pSub_aulldiv;
     724            extern const UserProc *pSub_aulldiv;
    723725            op_call(pSub_aulldiv);
    724726        }
     
    727729
    728730            //call _alldiv
    729             extern UserProc *pSub_alldiv;
     731            extern const UserProc *pSub_alldiv;
    730732            op_call(pSub_alldiv);
    731733        }
     
    10001002
    10011003    //call pow
    1002     extern UserProc *pSub_pow;
     1004    extern const UserProc *pSub_pow;
    10031005    op_call(pSub_pow);
    10041006
     
    11561158
    11571159        //call _allshl
    1158         extern UserProc *pSub_allshl;
     1160        extern const UserProc *pSub_allshl;
    11591161        op_call(pSub_allshl);
    11601162
     
    13611363
    13621364            //call _aullshr
    1363             extern UserProc *pSub_aullshr;
     1365            extern const UserProc *pSub_aullshr;
    13641366            op_call(pSub_aullshr);
    13651367        }
     
    13681370
    13691371            //call _allshr
    1370             extern UserProc *pSub_allshr;
     1372            extern const UserProc *pSub_allshr;
    13711373            op_call(pSub_allshr);
    13721374        }
  • trunk/abdev/BasicCompiler32/NumOpe_Logical.cpp

    r36 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler32/NumOpe_Relation.cpp

    r97 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler32/NumOpe_TypeOperation.cpp

    r183 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
  • trunk/abdev/BasicCompiler32/Opcode.h

    r142 r206  
    1 //Opcode.h
     1#pragma once
     2
     3#include <Type.h>
     4#include <Procedure.h>
     5
    26
    37//未定義の定数情報
     
    201205bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
    202206void SetThisPtrToReg(int reg);
    203 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = 0);
    204 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *InitBuf);
     207bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
     208bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf);
    205209#define DIMFLAG_INITDEBUGVAR            1
    206210#define DIMFLAG_NONCALL_CONSTRACTOR     2
    207211#define DIMFLAG_STATIC                  4
    208212#define DIMFLAG_CONST                   8
    209 void dim( char *VarName,int *SubScripts,Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
     213void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
    210214void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
    211215void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
     
    234238    bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
    235239public:
    236     UserProc *_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );
    237     UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );
     240    const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
     241    const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
    238242
    239243    void ApplyDefaultParameters( const Parameters &params );
     
    252256#define PROCFLAG_NEW    1
    253257bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
    254 bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
     258bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
    255259bool Opcode_CallDllProc( const char *lpszParms, DllProc *pDllProc );
    256260
     
    351355void fpu_cast_end();
    352356
    353 void op_call(UserProc *pUserProc);
     357void op_call(const UserProc *pUserProc);
    354358void op_ret();
  • trunk/abdev/BasicCompiler32/OperatorProc.cpp

    r135 r206  
     1#include "stdafx.h"
     2
     3#include <jenga/include/smoothie/LexicalAnalysis.h>
     4
    15#include "../BasicCompiler_Common/common.h"
    26#include "Opcode.h"
     
    1115
    1216        //call DestructorProcAddr
    13         op_call( method->pUserProc );
     17        op_call( &method->GetUserProc() );
    1418    }
    1519
     
    1822
    1923    //call free
    20     extern UserProc *pSub_free;
     24    extern const UserProc *pSub_free;
    2125    op_call(pSub_free);
    2226}
     
    2731    pobj_c=(CClass *)index_stack[sp-2];
    2832
    29     std::vector<UserProc *> subs;
     33    std::vector<const UserProc *> subs;
    3034    pobj_c->GetMethods().Enum( idCalc, subs );
    3135    if( subs.size() == 0 ){
     
    5357    if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
    5458    else GetCalcName(idCalc,temporary);
    55     UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
     59    const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
    5660
    5761    if(!pUserProc){
     
    107111
    108112        //call calloc
    109         extern UserProc *pSub_calloc;
     113        extern const UserProc *pSub_calloc;
    110114        op_call(pSub_calloc);
    111115
     
    249253}
    250254void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType){
    251     std::vector<UserProc *> subs;
     255    std::vector<const UserProc *> subs;
    252256    pobj_Class->GetMethods().Enum( CALC_ARRAY_GET, subs );
    253257    if( subs.size() == 0 ){
  • trunk/abdev/BasicCompiler32/increment.cpp

    r129 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler32/op32_main.cpp

    r142 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
     
    980982/////////////////////////////
    981983
    982 void op_call(UserProc *pUserProc){
     984void op_call(const UserProc *pUserProc){
    983985    OpBuffer[obp++]=(char)0xE8;
    984986    pobj_SubAddrSchedule->add(pUserProc,1);
  • trunk/abdev/BasicCompiler64/BasicCompiler.vcproj

    r198 r206  
    5555                RuntimeLibrary="1"
    5656                RuntimeTypeInfo="true"
    57                 UsePrecompiledHeader="0"
     57                UsePrecompiledHeader="2"
    5858                PrecompiledHeaderFile=".\Debug/BasicCompiler.pch"
    5959                AssemblerListingLocation=".\Debug/"
     
    167167                RuntimeLibrary="1"
    168168                RuntimeTypeInfo="true"
    169                 UsePrecompiledHeader="0"
     169                UsePrecompiledHeader="2"
    170170                PrecompiledHeaderFile=".\Release/BasicCompiler.pch"
    171171                AssemblerListingLocation=".\Release/"
     
    246246            </File>
    247247            <File
    248                 RelativePath="..\BasicCompiler_Common\BasicFixed.h"
    249                 >
    250             </File>
    251             <File
    252248                RelativePath="CommandValue.h"
    253249                >
     
    263259            <File
    264260                RelativePath="..\BasicCompiler_Common\include\option.h"
     261                >
     262            </File>
     263            <File
     264                RelativePath=".\stdafx.h"
    265265                >
    266266            </File>
     
    289289                >
    290290                <File
    291                     RelativePath="..\BasicCompiler_Common\include\ClassImpl.h"
     291                    RelativePath="..\BasicCompiler_Common\include\Class.h"
    292292                    >
    293293                </File>
     
    301301                </File>
    302302                <File
     303                    RelativePath="..\BasicCompiler_Common\include\Const.h"
     304                    >
     305                </File>
     306                <File
    303307                    RelativePath="..\BasicCompiler_Common\include\DataTable.h"
    304308                    >
     
    313317                </File>
    314318                <File
     319                    RelativePath="..\BasicCompiler_Common\include\Member.h"
     320                    >
     321                </File>
     322                <File
    315323                    RelativePath="..\BasicCompiler_Common\include\MetaImpl.h"
    316324                    >
    317325                </File>
    318326                <File
     327                    RelativePath="..\BasicCompiler_Common\include\Method.h"
     328                    >
     329                </File>
     330                <File
    319331                    RelativePath="..\BasicCompiler_Common\include\NamespaceSupporter.h"
    320332                    >
    321333                </File>
    322334                <File
    323                     RelativePath="..\BasicCompiler_Common\include\ProcedureImpl.h"
     335                    RelativePath="..\BasicCompiler_Common\include\Parameter.h"
     336                    >
     337                </File>
     338                <File
     339                    RelativePath="..\BasicCompiler_Common\include\Procedure.h"
    324340                    >
    325341                </File>
     
    329345                </File>
    330346                <File
     347                    RelativePath="..\BasicCompiler_Common\include\Prototype.h"
     348                    >
     349                </File>
     350                <File
    331351                    RelativePath="..\BasicCompiler_Common\include\SmoothieImpl.h"
    332352                    >
    333353                </File>
    334354                <File
     355                    RelativePath="..\BasicCompiler_Common\include\Symbol.h"
     356                    >
     357                </File>
     358                <File
     359                    RelativePath="..\BasicCompiler_Common\include\Type.h"
     360                    >
     361                </File>
     362                <File
    335363                    RelativePath="..\BasicCompiler_Common\include\TypeDef.h"
    336364                    >
    337365                </File>
    338366                <File
    339                     RelativePath="..\BasicCompiler_Common\include\VariableImpl.h"
     367                    RelativePath="..\BasicCompiler_Common\include\Variable.h"
    340368                    >
    341369                </File>
     
    396424                        Name="VCResourceCompilerTool"
    397425                        PreprocessorDefinitions="_DEBUG;JPN;$(NoInherit)"
     426                    />
     427                </FileConfiguration>
     428            </File>
     429            <File
     430                RelativePath=".\stdafx.cpp"
     431                >
     432                <FileConfiguration
     433                    Name="Debug|Win32"
     434                    >
     435                    <Tool
     436                        Name="VCCLCompilerTool"
     437                        UsePrecompiledHeader="1"
     438                    />
     439                </FileConfiguration>
     440                <FileConfiguration
     441                    Name="Release|Win32"
     442                    >
     443                    <Tool
     444                        Name="VCCLCompilerTool"
     445                        UsePrecompiledHeader="1"
    398446                    />
    399447                </FileConfiguration>
     
    9811029                </Filter>
    9821030                <Filter
    983                     Name="Constant"
    984                     >
    985                     <File
    986                         RelativePath="..\BasicCompiler_Common\Const.cpp"
    987                         >
    988                     </File>
    989                     <File
    990                         RelativePath="..\BasicCompiler_Common\Const.h"
    991                         >
    992                     </File>
    993                 </Filter>
    994                 <Filter
    9951031                    Name="Variable"
    9961032                    >
     
    10211057                >
    10221058                <File
    1023                     RelativePath="..\BasicCompiler_Common\src\ClassImpl.cpp"
     1059                    RelativePath="..\BasicCompiler_Common\src\Class.cpp"
    10241060                    >
    10251061                </File>
     
    10331069                </File>
    10341070                <File
     1071                    RelativePath="..\BasicCompiler_Common\src\Const.cpp"
     1072                    >
     1073                </File>
     1074                <File
    10351075                    RelativePath="..\BasicCompiler_Common\src\DataTable.cpp"
    10361076                    >
     
    10451085                </File>
    10461086                <File
     1087                    RelativePath="..\BasicCompiler_Common\src\Method.cpp"
     1088                    >
     1089                </File>
     1090                <File
    10471091                    RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp"
    10481092                    >
    10491093                </File>
    10501094                <File
    1051                     RelativePath="..\BasicCompiler_Common\src\ProcedureImpl.cpp"
     1095                    RelativePath="..\BasicCompiler_Common\src\Procedure.cpp"
    10521096                    >
    10531097                </File>
     
    10611105                </File>
    10621106                <File
     1107                    RelativePath="..\BasicCompiler_Common\src\Symbol.cpp"
     1108                    >
     1109                </File>
     1110                <File
     1111                    RelativePath="..\BasicCompiler_Common\src\Type.cpp"
     1112                    >
     1113                </File>
     1114                <File
    10631115                    RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp"
    10641116                    >
    10651117                </File>
    10661118                <File
    1067                     RelativePath="..\BasicCompiler_Common\src\VariableImpl.cpp"
     1119                    RelativePath="..\BasicCompiler_Common\src\Variable.cpp"
    10681120                    >
    10691121                </File>
  • trunk/abdev/BasicCompiler64/CLockParameter.cpp

    r3 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "opcode.h"
  • trunk/abdev/BasicCompiler64/CParameter.cpp

    r75 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "opcode.h"
     
    110112
    111113                //call free
    112                 extern UserProc *pSub_free;
     114                extern const UserProc *pSub_free;
    113115                op_call(pSub_free);
    114116            }
     
    133135
    134136        //call calloc
    135         extern UserProc *pSub_calloc;
     137        extern const UserProc *pSub_calloc;
    136138        op_call(pSub_calloc);
    137139
  • trunk/abdev/BasicCompiler64/Compile_Calc.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    9496            }
    9597            else{
    96                 if(GetConstHash(variable)){
     98                if( compiler.GetMeta().GetGlobalConsts().IsExist(variable)
     99                    || compiler.GetMeta().GetGlobalConstMacros().IsExist(variable) )
     100                {
    97101                    //定数リストに該当したとき
    98102                    SetError(1,NULL,cp);
     
    234238    if( varType.IsObject() && compiler.GetMeta().GetBlittableTypes().IsExist( calcType ) ){
    235239        // Blittable型をオブジェクトとして扱う
    236         vector<UserProc *> userProcs;
     240        vector<const UserProc *> userProcs;
    237241        compiler.GetMeta().GetBlittableTypes().GetClass( calcType ).GetStaticMethods().Enum( "_Create", userProcs );
    238242        if( userProcs.size() != 1 ){
     
    240244            return;
    241245        }
    242         UserProc *pUserProc = userProcs[0];
     246        const UserProc *pUserProc = userProcs[0];
    243247
    244248        // mov rcx, rax
  • trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp

    r66 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler64/Compile_CallProc.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    1214void Call_DebugSys_SaveContext(){
    1315    //call _System_GetEip
    14     extern UserProc *pSub_System_GetEip;
     16    extern const UserProc *pSub_System_GetEip;
    1517    op_call(pSub_System_GetEip);
    1618
     
    2224
    2325    //call _DebugSys_SaveContext
    24     extern UserProc *pSub_DebugSys_SaveContext;
     26    extern const UserProc *pSub_DebugSys_SaveContext;
    2527    op_call(pSub_DebugSys_SaveContext);
    2628}
     
    99101}
    100102
    101 bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){
     103bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){
    102104    // TODO: RefTypeは不必要なので削除する
    103105    int i2;
     
    128130            if(lstrcmpi(ObjectName,"Super")==0){
    129131                //クラスメンバ関数内から基底クラスの呼び出し
    130                 pobj_c=Smoothie::Temp::pCompilingClass;
     132                pobj_c=compiler.pCompilingClass;
    131133            }
    132134            else{
     
    153155            else{
    154156                //クラスメンバ関数内から同一クラスのメンバ関数の呼び出し
    155                 pobj_c=Smoothie::Temp::pCompilingClass;
     157                pobj_c=compiler.pCompilingClass;
    156158            }
    157159        }
     
    182184        if(ObjectName[0]){
    183185            //外部からの呼び出し
    184             if(pobj_c==Smoothie::Temp::pCompilingClass){
     186            if(pobj_c==compiler.pCompilingClass){
    185187                //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    186188                if( pMethod->IsNoneAccess() ){
     
    279281
    280282            //call calloc
    281             extern UserProc *pSub_calloc;
     283            extern const UserProc *pSub_calloc;
    282284            op_call(pSub_calloc);
    283285
  • trunk/abdev/BasicCompiler64/Compile_Func.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    4648    }
    4749
    48     int SubScripts[MAX_ARRAYDIM];
     50    Subscripts subscripts;
    4951    RELATIVE_VAR RelativeVar;
    50     if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,SubScripts)) return;
     52    if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,&subscripts)) return;
    5153
    5254    if(type.GetBasicType()&FLAG_PTR){
     
    5961    int typeSize = type.GetSize();
    6062
    61     if(bArrayHead) typeSize*=JumpSubScripts(SubScripts);
     63    if(bArrayHead) typeSize*=JumpSubScripts(subscripts);
    6264
    6365    //mov rax,TypeSize
     
    6870void Opcode_Func_AddressOf( const char *name ){
    6971    extern int cp;
    70     UserProc *pUserProc;
     72    const UserProc *pUserProc;
    7173
    7274    extern LONG_PTR ProcPtr_BaseIndex;
     
    7476        //左辺の型にのっとり、オーバーロードを解決
    7577
    76         std::vector<UserProc *> subs;
     78        std::vector<const UserProc *> subs;
    7779        GetOverloadSubHash( name, subs );
    7880        if( subs.size() == 0 ){
     
    131133            SetThisPtrToReg(REG_RCX);
    132134
    133             pobj_c=Smoothie::Temp::pCompilingClass;
     135            pobj_c=compiler.pCompilingClass;
    134136        }
    135137
  • trunk/abdev/BasicCompiler64/Compile_Interface.cpp

    r132 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "opcode.h"
  • trunk/abdev/BasicCompiler64/Compile_Object.cpp

    r140 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "opcode.h"
     
    3335    ////////////////////////
    3436
    35     std::vector<UserProc *> subs;
     37    std::vector<const UserProc *> subs;
    3638    pobj_c->GetMethods().Enum( pobj_c->GetName().c_str(), subs );
    3739
    38     UserProc *pUserProc;
     40    const UserProc *pUserProc;
    3941    if( subs.size() > 0 ){
    4042        //オーバーロードを解決
     
    142144
    143145        //call _System_GC_malloc_ForObject
    144         extern UserProc *pSub_System_GC_malloc_ForObject;
     146        extern const UserProc *pSub_System_GC_malloc_ForObject;
    145147        op_call(pSub_System_GC_malloc_ForObject);
    146148    }
     
    150152
    151153        //call _System_GC_malloc_ForObjectPtr
    152         extern UserProc *pSub_System_GC_malloc_ForObjectPtr;
     154        extern const UserProc *pSub_System_GC_malloc_ForObjectPtr;
    153155        op_call(pSub_System_GC_malloc_ForObjectPtr);
    154156    }
     
    185187    op_mov_RV(sizeof(_int64),REG_RCX,0);
    186188    obp-=sizeof(long);
    187     pobj_SubAddrSchedule->add(method->pUserProc,0);
    188     method->pUserProc->Using();
     189    pobj_SubAddrSchedule->add(&method->GetUserProc(),0);
     190    method->GetUserProc().Using();
    189191    obp+=sizeof(long);
    190192
     
    299301    if( isSweeping ){
    300302        //call _System_GC_free_for_SweepingDelete
    301         extern UserProc *pSub_System_GC_free_for_SweepingDelete;
     303        extern const UserProc *pSub_System_GC_free_for_SweepingDelete;
    302304        op_call(pSub_System_GC_free_for_SweepingDelete);
    303305    }
    304306    else{
    305307        //call free
    306         extern UserProc *pSub_free;
     308        extern const UserProc *pSub_free;
    307309        op_call(pSub_free);
    308310    }
  • trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp

    r204 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    57#include <Compiler.h>
    68#include <LexicalScopingImpl.h>
    7 #include <ClassImpl.h>
    8 #include <VariableImpl.h>
     9#include <Class.h>
    910
    1011#include "../BasicCompiler_Common/common.h"
     
    3132        }
    3233
    33         UserProc *pBackUserProc;
    34         pBackUserProc = &UserProc::CompilingUserProc();
     34        const UserProc *pBackUserProc = &UserProc::CompilingUserProc();
    3535        UserProc::CompileStartForGlobalArea();
    3636
     
    5454
    5555        //_System_StartupProgramの呼び出し
    56         extern UserProc *pSub_System_StartupProgram;
     56        extern const UserProc *pSub_System_StartupProgram;
    5757        op_call(pSub_System_StartupProgram);
    5858
     
    8282        StackFrameSchedule=obp-sizeof(long);
    8383
    84         BOOST_FOREACH( Variable *pVar, globalVars ){
     84        BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
    8585            if(memicmp(pVar->GetName().c_str(),"Static%",7)==0){
    8686                //コンストラクタ呼び出し
    87                 if( pVar->IsObject() ){
     87                if( pVar->GetType().IsObject() ){
    8888
    8989                    //エラー用
     
    9292                    CallConstructor(
    9393                        pVar->GetName().c_str(),
    94                         pVar->GetSubScriptsPtr(),
    95                         *pVar,
    96                         pVar->paramStrForConstructor.c_str());
     94                        pVar->GetSubscripts(),
     95                        pVar->GetType(),
     96                        pVar->GetParamStrForConstructor().c_str());
    9797                }
    9898            }
     
    113113
    114114
    115         UserProc *pBackUserProc;
    116         pBackUserProc = &UserProc::CompilingUserProc();
     115        const UserProc *pBackUserProc = &UserProc::CompilingUserProc();
    117116        UserProc::CompileStartForGlobalArea();
    118117
     
    212211    }
    213212}
    214 void AutoGeneration(UserProc &userProc){
     213void AutoGeneration(const UserProc &userProc){
    215214    if( userProc.GetName() == "InitializeUserTypes"
    216215        && userProc.HasParentClass()
     
    229228    }
    230229}
    231 void _compile_proc(UserProc *pUserProc){
     230void _compile_proc(const UserProc *pUserProc){
    232231    extern char *basbuf;
    233232    extern HANDLE hHeap;
    234     extern GlobalProc **ppSubHash;
    235233    extern BOOL bDebugCompile;
    236234    int i3,i4;
     
    239237    if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return;
    240238
    241     if( pUserProc->localVars.size() ){
     239    if( pUserProc->GetLocalVars().size() ){
    242240        SetError();
    243241        return;
    244242    }
     243
     244    trace_for_sourcecodestep( "★★★ " << pUserProc->GetFullName() << "のコンパイルを開始" );
    245245
    246246    pUserProc->CompleteCompile();
     
    259259    else bDebugSupportProc=0;
    260260
    261     pUserProc->beginOpAddress=obp;
     261    pUserProc->SetBeginOpAddress( obp );
    262262
    263263    //コンパイル中の関数が属するクラス
    264     Smoothie::Temp::pCompilingClass=pUserProc->GetParentClassPtr();
     264    compiler.pCompilingClass=pUserProc->GetParentClassPtr();
    265265
    266266    //コンパイルスタートをクラス管理クラスに追加
     
    294294        pobj_sf=0;
    295295
    296         pUserProc->endOpAddress=obp;
     296        pUserProc->SetEndOpAddress( obp );
    297297        return;
    298298    }
     
    360360        Parameter &param = *pUserProc->RealParams()[i3];
    361361
    362         Variable *pVar = new VariableImpl( param.GetVarName(), param, false, param.IsRef() );
     362        Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef(), "" );
    363363
    364364        if( param.IsArray() ){
    365             pVar->SetArray( param.GetSubScriptsPtr() );
     365            pVar->SetArray( param.GetSubscripts() );
    366366        }
    367367
     
    381381        }
    382382        AllLocalVarSize+=varSize;
    383         pVar->offset=AllLocalVarSize;
     383        pVar->SetOffsetAddress( AllLocalVarSize );
    384384
    385385        //レキシカルスコープ情報
    386         pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    387         pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     386        pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     387        pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    388388        pVar->bLiving=TRUE;
    389389
    390         pUserProc->localVars.push_back( pVar );
     390        pUserProc->GetLocalVars().push_back( pVar );
    391391    }
    392392
     
    507507
    508508        //call _DebugSys_StartProc
    509         extern UserProc *pSub_DebugSys_StartProc;
     509        extern const UserProc *pSub_DebugSys_StartProc;
    510510        op_call(pSub_DebugSys_StartProc);
    511511    }
    512512
    513     if(Smoothie::Temp::pCompilingClass){
    514         if( pUserProc->GetName() == Smoothie::Temp::pCompilingClass->GetName() ){
     513    if(compiler.pCompilingClass){
     514        if( pUserProc->GetName() == compiler.pCompilingClass->GetName() ){
    515515            ////////////////////////////////////
    516516            // コンストラクタをコンパイルするとき
     
    518518
    519519            //コンストラクタのコンパイル開始を通知
    520             Smoothie::Temp::pCompilingClass->NotifyStartConstructorCompile();
     520            compiler.pCompilingClass->NotifyStartConstructorCompile();
    521521
    522522            //基底クラスかどうかの識別
    523523            //(継承元がインターフェイスの場合も基底クラスと見なす)
    524524            BOOL bThisIsSuperClass;
    525             if( !Smoothie::Temp::pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1;
    526             else if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){
     525            if( !compiler.pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1;
     526            else if( compiler.pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){
    527527                //インターフェイスを継承したときはコンストラクタを持たない
    528528                bThisIsSuperClass=1;
     
    543543                    temporary[i4]=basbuf[i3];
    544544                }
    545                 if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetName() == temporary ){
     545                if( compiler.pCompilingClass->GetSuperClass().GetName() == temporary ){
    546546                    //基底クラスのコンストラクタを呼び出す
    547547                    cp=i3;
     
    560560                    Type dummyType;
    561561                    CallProc( PROC_DEFAULT
    562                         , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc
    563                         , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc->GetName().c_str()
     562                        , &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc()
     563                        , compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc().GetName().c_str()
    564564                        , temporary
    565565                        , dummyType );
     
    568568                    //基底クラスのコンストラクタを暗黙的に呼び出す
    569569                    Opcode_CallProc("",
    570                         Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc,
     570                        &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc(),
    571571                        0,
    572572                        "",
     
    576576
    577577            //仮想関数テーブルを初期化
    578             if( Smoothie::Temp::pCompilingClass->IsExistVirtualFunctions()
    579                 && !Smoothie::Temp::pCompilingClass->IsAbstract() ){
     578            if( compiler.pCompilingClass->IsExistVirtualFunctions()
     579                && !compiler.pCompilingClass->IsAbstract() ){
    580580                    //関数テーブルに値をセット
    581                     int offset = (int)Smoothie::Temp::pCompilingClass->GetVtblGlobalOffset();
     581                    int offset = (int)compiler.pCompilingClass->GetVtblGlobalOffset();
    582582
    583583                    //mov rax,offset
     
    598598
    599599            //デストラクタのコンパイル開始を通知
    600             Smoothie::Temp::pCompilingClass->NotifyStartDestructorCompile();
     600            compiler.pCompilingClass->NotifyStartDestructorCompile();
    601601        }
    602602    }
     
    624624    //////////////////////////////////////////
    625625
    626     if( Smoothie::Temp::pCompilingClass ){
    627 
    628         if( Smoothie::Temp::pCompilingClass->IsCompilingConstructor() ){
     626    if( compiler.pCompilingClass ){
     627
     628        if( compiler.pCompilingClass->IsCompilingConstructor() ){
    629629            // コンストラクタをコンパイルしていたとき
    630630
    631631            // コンストラクタのコンパイルが完了したことを通知
    632             Smoothie::Temp::pCompilingClass->NotifyFinishConstructorCompile();
     632            compiler.pCompilingClass->NotifyFinishConstructorCompile();
    633633        }
    634634        else if( pUserProc->IsDestructor() ){
     
    638638
    639639            // デストラクタのコンパイルが完了したことを通知
    640             Smoothie::Temp::pCompilingClass->NotifyFinishDestructorCompile();
    641 
    642             if( Smoothie::Temp::pCompilingClass->HasSuperClass() ){
     640            compiler.pCompilingClass->NotifyFinishDestructorCompile();
     641
     642            if( compiler.pCompilingClass->HasSuperClass() ){
    643643                /* サブクラスのデストラクタをコンパイルしているときは、
    644644                    基底クラスのデストラクタを呼び出す */
    645645
    646                 const CMethod *method = Smoothie::Temp::pCompilingClass->GetSuperClass().GetDestructorMethod();
     646                const CMethod *method = compiler.pCompilingClass->GetSuperClass().GetDestructorMethod();
    647647                if( method ){
    648648                    Opcode_CallProc("",
    649                         method->pUserProc,
     649                        &method->GetUserProc(),
    650650                        0,
    651651                        "",
     
    694694    if(bDebugCompile&&bDebugSupportProc==0){
    695695        //call _DebugSys_EndProc
    696         extern UserProc *pSub_DebugSys_EndProc;
     696        extern const UserProc *pSub_DebugSys_EndProc;
    697697        op_call(pSub_DebugSys_EndProc);
    698698    }
     
    745745    }
    746746    HeapDefaultFree(pLocalVarAddrSchedule);
    747     BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){
     747    BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
    748748        //後にデバッグで利用する
    749         pVar->offset = AllLocalVarSize + pobj_sf->GetFrameSize() - pVar->offset;
     749        pVar->SetOffsetAddress(
     750            AllLocalVarSize + pobj_sf->GetFrameSize() - pVar->GetOffsetAddress()
     751        );
    750752    }
    751753
     
    785787
    786788
    787     pUserProc->endOpAddress=obp;
     789    pUserProc->SetEndOpAddress( obp );
    788790
    789791
     
    793795}
    794796
    795 void CompileBufferInProcedure( UserProc &userProc ){
     797void CompileBufferInProcedure( const UserProc &userProc ){
    796798    if( userProc.IsUsing() == false || userProc.IsCompiled() ) return;
    797799
     
    809811}
    810812void CompileLocal(){
    811     extern GlobalProc **ppSubHash;
    812     int i2;
    813 
    814813    extern BOOL bDll;
    815814    if(bDll){
    816815        //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする
    817         UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");
     816        const UserProc *pUserProc = GetSubHash("_System_InitDllGlobalVariables");
    818817        if(pUserProc){
    819818            CompileBufferInProcedure( *pUserProc );
     
    823822
    824823    //_System_TypeBase_InitializeUserTypesは一番最後にコンパイル
    825     extern UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;
     824    extern const UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;
    826825    pSubStaticMethod_System_TypeBase_InitializeUserTypes->CompleteCompile();
    827826
    828827    //_System_InitStaticLocalVariablesは一番最後にコンパイル
    829828    //※一般関数内の静的変数オブジェクトをすべて収集しなければならない
    830     extern UserProc *pSub_System_InitStaticLocalVariables;
     829    extern const UserProc *pSub_System_InitStaticLocalVariables;
    831830    pSub_System_InitStaticLocalVariables->CompleteCompile();
    832831
    833832    //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル
    834     extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;
     833    extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject;
    835834    pSub_System_Call_Destructor_of_GlobalObject->CompleteCompile();
    836835
    837836repeat:
    838     GlobalProc *pGlobalProc;
    839     for(i2=0;i2<MAX_HASH;i2++){
    840         pGlobalProc=ppSubHash[i2];
    841         while(pGlobalProc){
    842             CompileBufferInProcedure( *pGlobalProc );
    843             pGlobalProc=pGlobalProc->pNextData;
    844         }
     837    compiler.GetMeta().GetUserProcs().Iterator_Reset();
     838    while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     839    {
     840        UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     841        CompileBufferInProcedure( *pUserProc );
    845842    }
    846843
     
    856853    if( IsNeedProcCompile() ){
    857854        //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合
    858         for(i2=0;i2<MAX_HASH;i2++){
    859             pGlobalProc=ppSubHash[i2];
    860             while(pGlobalProc){
    861                 CompileBufferInProcedure( *pGlobalProc );
    862                 pGlobalProc=pGlobalProc->pNextData;
    863             }
     855
     856        compiler.GetMeta().GetUserProcs().Iterator_Reset();
     857        while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     858        {
     859            UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     860            CompileBufferInProcedure( *pUserProc );
    864861        }
    865862    }
  • trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp

    r96 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
     
    7880
    7981                    //call free
    80                     extern UserProc *pSub_free;
     82                    extern const UserProc *pSub_free;
    8183                    op_call(pSub_free);
    8284                }
  • trunk/abdev/BasicCompiler64/Compile_Statement.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/LexicalAnalysis.h>
    24
     
    911void OpcodeOthers(const char *Command){
    1012    int i,i2;
    11     UserProc *pUserProc;
    1213
    1314    char leftTerm[8192];
     
    5960        //////////////////////////////
    6061
    61         pUserProc=GetSubHash(Command);
     62        const UserProc *pUserProc=GetSubHash(Command);
    6263
    6364        //GetSubHash内でエラー提示が行われた場合
     
    737738
    738739                if(type1.IsObject()){
    739                     std::vector<UserProc *> subs;
     740                    std::vector<const UserProc *> subs;
    740741                    type1.GetClass().GetMethods().Enum( CALC_EQUAL, subs );
    741742                    if( subs.size() == 0 ){
     
    747748
    748749                    //オーバーロードを解決
    749                     UserProc *pUserProc;
    750                     pUserProc=OverloadSolution("==",subs, params, NULL);
     750                    const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL);
    751751
    752752                    delete params[0];
     
    892892
    893893    //call _System_GetEip
    894     extern UserProc *pSub_System_GetEip;
     894    extern const UserProc *pSub_System_GetEip;
    895895    op_call(pSub_System_GetEip);
    896896
     
    953953        //戻り値をセット
    954954        if(Parameter[0]){
    955             UserProc &proc = UserProc::CompilingUserProc();
     955            const UserProc &proc = UserProc::CompilingUserProc();
    956956
    957957            const char *temp = "_System_ReturnValue";
  • trunk/abdev/BasicCompiler64/Compile_Var.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    57#include <CodeGenerator.h>
    68#include <Compiler.h>
    7 #include <VariableImpl.h>
     9#include <Variable.h>
    810
    911#include "../BasicCompiler_Common/common.h"
     
    1113
    1214//変数
    13 Variables globalVars;
     15// TODO: xml未完成
    1416int AllGlobalVarSize;
    1517int AllInitGlobalVarSize;
     
    8688    }
    8789}
    88 bool GetArrayOffset(const int *SubScripts,char *array, const Type &type){
     90bool GetArrayOffset(const Subscripts &subscripts,char *array, const Type &type){
    8991    extern HANDLE hHeap;
    9092    int i,i2,i3,i4;
     
    105107        }
    106108        if(array[i]==','||array[i]=='\0'){
    107             if(SubScripts[i3]==-1){
     109            if( i3 >= (int)subscripts.size() )
     110            {
    108111                for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
    109112                return false;
     
    118121
    119122            if(array[i]=='\0'){
    120                 if(SubScripts[i3]!=-1){
     123                if( i3 < (int)subscripts.size() )
     124                {
    121125                    for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
    122126                    return false;
     
    166170        pobj_sf->pop(REG_R12);
    167171
    168         for(i2=i+1,i4=1;i2<i3;i2++) i4*=SubScripts[i2]+1;
     172        for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1;
    169173
    170174        //imul reg,i4
     
    204208    char lpPtrOffset[VN_SIZE];  //第2次配列
    205209    char NestMember[VN_SIZE];   //入れ子メンバ
    206     CClass::RefType refType;
     210    ReferenceKind refType;
    207211    lstrcpy(VarName,member);
    208212    if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false;
     
    224228
    225229    //アクセシビリティをチェック
    226     if(&objClass==Smoothie::Temp::pCompilingClass){
     230    if(&objClass==compiler.pCompilingClass){
    227231        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    228232        if(pMember->IsNoneAccess()){
     
    257261    //ポインタ変数の場合
    258262    if( resultType.IsPointer() ){
    259         if(pMember->SubScripts[0]==-1){
     263        if( pMember->GetSubscripts().size() == 0 ){
    260264            lstrcpy(lpPtrOffset,array);
    261265            array[0]=0;
     
    280284    if(array[0]){
    281285        //配列オフセット
    282         if(!GetArrayOffset(pMember->SubScripts,array,pMember->GetType())){
     286        if(!GetArrayOffset(pMember->GetSubscripts(),array,pMember->GetType())){
    283287            if(isErrorEnabled) SetError(14,member,cp);
    284288        }
    285289    }
    286     else if(pMember->SubScripts[0]!=-1){
     290    else if( pMember->GetSubscripts().size() > 0 ){
    287291        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    288292    }
     
    292296
    293297        if( resultType.IsObject() || resultType.IsStruct() ){
    294             if( refType != CClass::Dot ){
     298            if( refType != RefDot ){
    295299                if(isErrorEnabled) SetError(104,member,cp);
    296300                return false;
     
    308312                //pObj[n].member
    309313                if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() )
    310                     && refType != CClass::Dot ){
     314                    && refType != RefDot ){
    311315                        if(isErrorEnabled) SetError(104,member,cp);
    312316                        return false;
     
    322326                //pObj->member
    323327                if( (resultType.IsObjectPtr() || resultType.IsStructPtr() )
    324                     && refType != CClass::Pointer ){
     328                    && refType != RefPointer ){
    325329                        if(isErrorEnabled) SetError(104,member,cp);
    326330                        return false;
     
    336340            if(lpPtrOffset[0]){
    337341                //ppObj[n]->member
    338                 if( refType != CClass::Pointer ){
     342                if( refType != RefPointer ){
    339343                    if(isErrorEnabled) SetError(104,member,cp);
    340344                    return false;
     
    385389    SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg);
    386390}
    387 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss){
     391bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){
    388392    char variable[VN_SIZE];
    389393
     
    399403
    400404    // 先頭オブジェクトまたはクラス名と入れ子メンバに分割
    401     CClass::RefType refType;
     405    ReferenceKind refType;
    402406    char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE];
    403407    GetVarFormatString(simpleName,array,lpPtrOffset,member,refType);
     
    412416    }
    413417
    414     const int *pSubScripts;
     418    const Subscripts *pSubscripts;
    415419    bool bConst = false;
    416420
     
    421425        //////////////////
    422426
    423         const Variable *pVar = UserProc::CompilingUserProc().localVars.BackSearch( VarName );
     427        const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) );
    424428        if( pVar ){
    425429            //ポインタ変数の場合
    426             if( pVar->IsPointer() ){
     430            if( pVar->GetType().IsPointer() ){
    427431                if( !pVar->IsArray() ){
    428432                    lstrcpy(lpPtrOffset,array);
     
    438442            }
    439443
    440             pRelativeVar->offset=-pVar->offset;
     444            pRelativeVar->offset=-pVar->GetOffsetAddress();
    441445            pRelativeVar->bOffsetOffset=0;
    442446            if( pVar->IsRef() ){
     
    445449            }
    446450            else pRelativeVar->dwKind=VAR_LOCAL;
    447             resultType = *pVar;
    448             pSubScripts=pVar->GetSubScriptsPtr();
     451            resultType = pVar->GetType();
     452            pSubscripts = &pVar->GetSubscripts();
    449453            bConst = pVar->IsConst();
    450454
     
    454458
    455459
    456     if(Smoothie::Temp::pCompilingClass){
     460    if(compiler.pCompilingClass){
    457461        //////////////////////
    458462        // クラスメンバの参照
     
    465469            pRelativeVar->dwKind=VAR_DIRECTMEM;
    466470
    467             resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
     471            resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
    468472            return true;
    469473        }
     
    478482
    479483            bool isFound = false;
    480             BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){
     484            BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){
    481485                if( pMember->GetName() == VarName ){
    482486                    isFound = true;
     
    492496        if( isWriteAccess &&
    493497            pMethod->IsConst() &&
    494             Smoothie::Temp::pCompilingClass->IsCompilingConstructor() == false &&
    495             Smoothie::Temp::pCompilingClass->IsCompilingDestructor() == false
     498            compiler.pCompilingClass->IsCompilingConstructor() == false &&
     499            compiler.pCompilingClass->IsCompilingDestructor() == false
    496500            ){
    497501                SetError(131, NULL, cp );
     
    505509            isErrorEnabled,
    506510            isWriteAccess,
    507             *Smoothie::Temp::pCompilingClass,
     511            *compiler.pCompilingClass,
    508512            variable,
    509513            pRelativeVar,
     
    526530            GetNowStaticVarFullName(VarName,temporary);
    527531
    528             pVar = globalVars.Find( temporary );
     532            pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) );
    529533            if( pVar ){
    530534                goto GlobalOk;
     
    545549            char tempArray[VN_SIZE];
    546550            {
    547                 CClass::RefType refType;
     551                ReferenceKind refType;
    548552                GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType );
    549553            }
     
    557561            char temp2[VN_SIZE];
    558562            sprintf(temp2,"%s.%s",VarName,temporary);
    559             pVar = globalVars.Find( temp2 );
     563            pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
    560564            if( pVar ){
    561565                lstrcpy(member,tempMember);
     
    565569        }
    566570
    567         if(Smoothie::Temp::pCompilingClass){
     571        if(compiler.pCompilingClass){
    568572            //自身のクラスから静的メンバを参照する場合
    569573            char temp2[VN_SIZE];
    570             sprintf(temp2,"%s.%s",Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);
    571             pVar = globalVars.Find( temp2 );
     574            sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName);
     575            pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
    572576            if( pVar ){
    573577                goto GlobalOk;
     
    579583        /////////////////////
    580584
    581         pVar = globalVars.BackSearch( VarName );
     585        pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) );
    582586        if( pVar ){
    583587            goto GlobalOk;
     
    592596GlobalOk:
    593597        //ポインタ変数の場合
    594         if( pVar->IsPointer() ){
     598        if( pVar->GetType().IsPointer() ){
    595599            if( !pVar->IsArray() ){
    596600                lstrcpy(lpPtrOffset,array);
     
    606610        }
    607611
    608         pRelativeVar->offset=pVar->offset;
     612        pRelativeVar->offset=pVar->GetOffsetAddress();
    609613        pRelativeVar->bOffsetOffset=0;
    610614        if( pVar->IsRef() ){
     
    613617        }
    614618        else pRelativeVar->dwKind=VAR_GLOBAL;
    615         resultType = *pVar;
    616         pSubScripts=pVar->GetSubScriptsPtr();
     619        resultType = pVar->GetType();
     620        pSubscripts=&pVar->GetSubscripts();
    617621        bConst = pVar->IsConst();
    618622    }
     
    634638    }
    635639
    636     if(array[0]==0&&pSubScripts[0]!=-1){
     640    if( array[0] == 0 && pSubscripts->size() > 0 ){
    637641        //配列の先頭ポインタを示す場合
    638642        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    639         if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM);
     643
     644        if( pResultSubscripts )
     645        {
     646            (*pResultSubscripts) = *pSubscripts;
     647        }
    640648        return true;
    641649    }
     
    649657    }
    650658    if(array[0]){
    651         if(!GetArrayOffset(pSubScripts,array,resultType)){
     659        if(!GetArrayOffset(*pSubscripts,array,resultType)){
    652660            SetError(14,variable,cp);
    653661            pRelativeVar->dwKind=NON_VAR;
     
    658666        if( resultType.IsObject() || resultType.IsStruct() ){
    659667            //実態オブジェクトのメンバを参照(obj.member)
    660             if( refType != CClass::Dot ){
     668            if( refType != RefDot ){
    661669                SetError(104,VarName,cp);
    662670                pRelativeVar->dwKind=NON_VAR;
     
    673681            if(lpPtrOffset[0]){
    674682                //pObj[n].member
    675                 if( refType != CClass::Dot ){
     683                if( refType != RefDot ){
    676684                    SetError(104,VarName,cp);
    677685                    pRelativeVar->dwKind=NON_VAR;
     
    683691            else{
    684692                //pObj->member
    685                 if( refType != CClass::Pointer ){
     693                if( refType != RefPointer ){
    686694                    SetError(104,VarName,cp);
    687695                    pRelativeVar->dwKind=NON_VAR;
     
    700708            if(lpPtrOffset[0]){
    701709                //ppObj[n]->member
    702                 if( refType != CClass::Pointer ){
     710                if( refType != RefPointer ){
    703711                    SetError(104,VarName,cp);
    704712                    pRelativeVar->dwKind=NON_VAR;
     
    744752}
    745753
    746 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){
     754bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){
    747755    extern BYTE *initGlobalBuf;
    748     int i,i2,i3;
     756    int i2,i3;
    749757    char temporary[VN_SIZE];
    750758    char InitBuf[VN_SIZE];
     
    757765        int typeSize = type.GetSize();
    758766
    759         if(SubScripts[0]!=-1){
    760             typeSize*=JumpSubScripts(SubScripts+1);
    761             i=0;
    762             i2=0;
    763             while(1){
    764                 if(SubScripts[0]<i2){
    765                     SetError(41,0,cp);
    766                     return 0;
    767                 }
    768                 i=GetOneParameter(InitBuf,i,temporary);
    769                 if(!SetInitGlobalData(
    770                     offset+i2*typeSize,
    771                     type,
    772                     SubScripts+1,
    773                     temporary)) return false;
    774                 i2++;
    775                 if(InitBuf[i]=='\0') break;
     767        if( subscripts.size() > 0 ){
     768            Subscripts nestSubscripts;
     769            for( int i=1; i<(int)subscripts.size(); i++ )
     770            {
     771                nestSubscripts.push_back( subscripts[i] );
     772            }
     773
     774            typeSize*=JumpSubScripts( nestSubscripts );
     775            {
     776                int i=0;
     777                i2=0;
     778                while(1){
     779                    if( subscripts[0] < i2 ){
     780                        SetError(41,0,cp);
     781                        return 0;
     782                    }
     783                    i=GetOneParameter(InitBuf,i,temporary);
     784                    if(!SetInitGlobalData(
     785                        offset+i2*typeSize,
     786                        type,
     787                        nestSubscripts,
     788                        temporary)) return false;
     789                    i2++;
     790                    if(InitBuf[i]=='\0') break;
     791                }
    776792            }
    777793            return true;
     
    794810                if(!SetInitGlobalData(offset+i3,
    795811                    pMember->GetType(),
    796                     pMember->SubScripts,
     812                    pMember->GetSubscripts(),
    797813                    temporary)) return false;
    798814            }
     
    815831    }
    816832
    817     if(SubScripts[0]!=-1){
     833    if( subscripts.size() > 0 ){
    818834        SetError(41,0,cp);
    819835        return false;
     
    883899    return true;
    884900}
    885 bool InitLocalVar(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){
    886     int i,i2,i3;
     901bool InitLocalVar(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){
     902    int i2,i3;
    887903    char temporary[VN_SIZE];
    888904    char InitBuf[VN_SIZE];
     
    895911        int typeSize = type.GetSize();
    896912
    897         if(SubScripts[0]!=-1){
    898             typeSize*=JumpSubScripts(SubScripts+1);
    899             i=0;
    900             i2=0;
    901             while(1){
    902                 if(SubScripts[0]<i2){
    903                     SetError(41,0,cp);
    904                     return false;
    905                 }
    906                 i=GetOneParameter(InitBuf,i,temporary);
    907                 if(!InitLocalVar(
    908                     offset+i2*typeSize,
    909                     type,
    910                     SubScripts+1,
    911                     temporary)) return false;
    912                 i2++;
    913                 if(InitBuf[i]=='\0') break;
     913        if( subscripts.size() > 0 ){
     914            Subscripts nestSubscripts;
     915            for( int i=1; i<(int)subscripts.size(); i++ )
     916            {
     917                nestSubscripts.push_back( subscripts[i] );
     918            }
     919
     920            typeSize*=JumpSubScripts( nestSubscripts );
     921            {
     922                int i=0;
     923                i2=0;
     924                while(1){
     925                    if( subscripts[0] < i2 ){
     926                        SetError(41,0,cp);
     927                        return 0;
     928                    }
     929                    i=GetOneParameter(InitBuf,i,temporary);
     930                    if(!InitLocalVar(
     931                        offset+i2*typeSize,
     932                        type,
     933                        nestSubscripts,
     934                        temporary)) return false;
     935                    i2++;
     936                    if(InitBuf[i]=='\0') break;
     937                }
    914938            }
    915939            return true;
     
    932956                if(!InitLocalVar(offset+i3,
    933957                    pMember->GetType(),
    934                     pMember->SubScripts,
     958                    pMember->GetSubscripts(),
    935959                    temporary)) return false;
    936960
     
    949973    ///////////////////////////////////////
    950974
    951     if(SubScripts[0]!=-1){
     975    if( subscripts.size() > 0 ){
    952976        SetError(41,0,cp);
    953977        return false;
     
    10611085}
    10621086
    1063 void dim( char *VarName,int *SubScripts,Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){
     1087void dim( char *VarName, const Subscripts &subscripts, Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){
    10641088    if( UserProc::IsGlobalAreaCompiling() ){
    10651089        /////////////////////////
     
    10671091        /////////////////////////
    10681092
    1069         //OpcodeOthers( ( (string)"OutputDebugString(Ex\"" + VarName + "\r\n\")" ).c_str() );
    1070         AddGlobalVariable(VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags);
     1093        AddGlobalVariable(VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags);
    10711094    }
    10721095    else{
     
    10751098        /////////////////
    10761099
    1077         if( UserProc::CompilingUserProc().localVars.DuplicateCheck( VarName ) ){
     1100        if( UserProc::CompilingUserProc().GetLocalVars().DuplicateCheck( VarName ) ){
    10781101            //2重定義のエラー
    10791102            SetError(15,VarName,cp);
     
    10831106        bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false;
    10841107
    1085         Variable *pVar = new VariableImpl( VarName, type, isConst );
    1086 
    1087         if( SubScripts[0] != -1 ){
     1108        Variable *pVar = new Variable( VarName, type, isConst, false, ConstractParameter );
     1109
     1110        if( subscripts.size() > 0 ){
    10881111            //配列あり
    1089             pVar->SetArray( SubScripts );
    1090         }
    1091 
    1092         //コンストラクタ用パラメータ
    1093         pVar->paramStrForConstructor = ConstractParameter;
     1112            pVar->SetArray( subscripts );
     1113        }
    10941114
    10951115        //レキシカルスコープ
    1096         pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    1097         pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     1116        pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     1117        pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    10981118        pVar->bLiving=TRUE;
    10991119
     
    11021122
    11031123        // 変数を追加
    1104         UserProc::CompilingUserProc().localVars.push_back( pVar );
     1124        UserProc::CompilingUserProc().GetLocalVars().push_back( pVar );
    11051125
    11061126        //アラインメントを考慮
    1107         if( pVar->IsStruct() ){
    1108             int alignment = pVar->GetClass().iAlign;
     1127        if( pVar->GetType().IsStruct() ){
     1128            int alignment = pVar->GetType().GetClass().iAlign;
    11091129
    11101130            if( alignment ){
     
    11261146
    11271147        AllLocalVarSize += pVar->GetMemorySize();
    1128         pVar->offset = AllLocalVarSize;
     1148        pVar->SetOffsetAddress( AllLocalVarSize );
    11291149
    11301150        //レキシカルスコープ
    1131         pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    1132         pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     1151        pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     1152        pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    11331153        pVar->bLiving=TRUE;
    11341154
     
    11401160
    11411161            int result = 0;
    1142             if( !pVar->IsObject() ){
    1143                 result = InitLocalVar(-pVar->offset,
    1144                     *pVar,
    1145                     pVar->GetSubScriptsPtr(),
     1162            if( !pVar->GetType().IsObject() ){
     1163                result = InitLocalVar(-pVar->GetOffsetAddress(),
     1164                    pVar->GetType(),
     1165                    pVar->GetSubscripts(),
    11461166                    InitBuf);
    11471167            }
     
    11711191
    11721192            //add rcx, offset
    1173             op_add_RV( REG_RCX, -pVar->offset );
     1193            op_add_RV( REG_RCX, -pVar->GetOffsetAddress() );
    11741194            obp-=sizeof(long);
    11751195            AddLocalVarAddrSchedule();
     
    11861206    if( type.IsObject() &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&&InitBuf[0]=='\0'){
    11871207        char objectSize[255];
    1188         if( SubScripts[0] == -1 ){
     1208        if( subscripts.size() == 0 ){
    11891209            objectSize[0] = 0;
    11901210        }
    11911211        else{
    1192             if( SubScripts[1] != -1 ){
     1212            if( subscripts.size() > 1 ){
    11931213                SetError(300,NULL,cp);
    11941214            }
    1195             sprintf( objectSize, "%d", SubScripts[0] );
     1215            sprintf( objectSize, "%d", subscripts[0] );
    11961216        }
    11971217        Operator_New( type.GetClass(), objectSize, ConstractParameter, type );
     
    13041324
    13051325bool Compile_AddGlobalRootsForGc(){
    1306     UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
     1326    const UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
    13071327    if( !pUserProc_AddGlobalRootPtr ){
    13081328        SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 );
     
    13101330    }
    13111331
    1312     BOOST_FOREACH( const Variable *pVar, globalVars ){
    1313         if( pVar->IsObject() || pVar->IsPointer() || pVar->IsStruct() ){
     1332    BOOST_FOREACH( const Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
     1333        if( pVar->GetType().IsObject() || pVar->GetType().IsPointer() || pVar->GetType().IsStruct() ){
    13141334            // オブジェクトまたはポインタだったとき
    13151335            // ※構造体も含む(暫定対応)
     
    13211341            // ルートポインタを引き渡す
    13221342            //mov rdx,offset
    1323             op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar->offset);
     1343            op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar->GetOffsetAddress());
    13241344            obp-=sizeof(long);
    13251345            pobj_GlobalVarSchedule->add();
  • trunk/abdev/BasicCompiler64/MakePeHdr.cpp

    r202 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/common/Environment.h>
    24
     
    46
    57#include <LexicalScopingImpl.h>
    6 #include <ClassImpl.h>
     8#include <Class.h>
    79#include <Compiler.h>
    810
     11#include <../Enum.h>
     12
    913#include "../BasicCompiler_Common/common.h"
     14#include "../BasicCompiler_Common/DebugSection.h"
    1015#include "Opcode.h"
    1116
     
    1621
    1722// グローバル関数、静的メソッド
    18 UserProc
     23const UserProc
    1924    *pSub_System_StartupProgram,
    2025    *pSub_DebugSys_StartProc,
     
    3641
    3742// 動的メソッド
    38 UserProc
     43const UserProc
    3944    *pUserProc_System_CGarbageCollection_RegisterGlobalRoots;
    4045
     
    160165
    161166    //クラス名を取得(詳細情報はGetAllClassInfoで取得)
    162     //   GetSubInfo関数の中で参照されるオブジェクト名を事前に取得する。
     167    //   CollectUserProcs関数の中で参照されるオブジェクト名を事前に取得する。
    163168    //     ※オブジェクトの内容までは取得しない
    164169    compiler.GetMeta().GetClasses().CollectClassesForNameOnly( Smoothie::Lexical::source );
     
    171176
    172177    //サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得
    173     Smoothie::Temp::pCompilingClass = NULL;
    174     GetSubInfo();
    175 
    176     //クラス情報を取得(※注 - GetSubInfoの後に呼び出す)
     178    compiler.pCompilingClass = NULL;
     179    UserProcs::CollectUserProcs( Smoothie::Lexical::source, compiler.GetMeta().GetUserProcs() );
     180
     181    // クラス情報を取得(※注 - CollectUserProcsの後に呼び出す)
    177182    compiler.GetMeta().GetClasses().GetAllClassInfo();
    178183
    179     compiler.GetMeta().AutoWrite( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" );
     184    // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備
     185    compiler.GetMeta().GetUserProcs().Iterator_Init();
     186
     187    /*
     188    if( !compiler.GetMeta().Write( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) )
     189    {
     190        MessageBox(0,"XML書き込みに失敗","test",0);
     191    }
     192    MetaImpl *pTempMeta = new MetaImpl();
     193    if( !pTempMeta->Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) )
     194    {
     195        MessageBox(0,"XML読み込みに失敗","test",0);
     196    }
     197    compiler.GetMeta() = (*pTempMeta);
     198    */
    180199
    181200    //コードと行番号の関係
     
    347366        extern CStackFrame *pobj_sf;
    348367        pobj_sf=new CStackFrame();
     368
     369        trace_for_sourcecodestep( "★★★ グローバル領域のコンパイルを開始" );
    349370
    350371
     
    399420
    400421        //call _System_Call_Destructor_of_GlobalObject
    401         extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;
     422        extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject;
    402423        op_call(pSub_System_Call_Destructor_of_GlobalObject);
    403424
     
    557578        ExportNamesLength=lstrlen(lpExportNames)+1;
    558579
    559         extern GlobalProc **ppSubHash;
    560         GlobalProc *pUserProc,*psi2;
     580        UserProc *pUserProc,*psi2;
    561581        while(1){
    562582            //辞書順にサーチ
    563583            temporary[0]=0;
    564             for(i=0,psi2=0;i<MAX_HASH;i++){
    565                 pUserProc=ppSubHash[i];
    566                 while(pUserProc){
    567                     if(pUserProc->IsExport()){
    568                         if(temporary[0]=='\0'){
     584            compiler.GetMeta().GetUserProcs().Iterator_Reset();
     585            while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     586            {
     587                pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     588                if(pUserProc->IsExport()){
     589                    if(temporary[0]=='\0'){
     590                        lstrcpy(temporary,pUserProc->GetName().c_str());
     591                        psi2=pUserProc;
     592                    }
     593                    else{
     594                        i3=lstrlen(temporary);
     595                        i4=(int)pUserProc->GetName().size();
     596                        if(i3<i4) i3=i4;
     597                        if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){
    569598                            lstrcpy(temporary,pUserProc->GetName().c_str());
    570599                            psi2=pUserProc;
    571600                        }
    572                         else{
    573                             i3=lstrlen(temporary);
    574                             i4=(int)pUserProc->GetName().size();
    575                             if(i3<i4) i3=i4;
    576                             if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){
    577                                 lstrcpy(temporary,pUserProc->GetName().c_str());
    578                                 psi2=pUserProc;
    579                             }
    580                         }
    581601                    }
    582                     pUserProc=pUserProc->pNextData;
    583602                }
    584603            }
     
    589608
    590609            if( pUserProc->GetName() == "DllMain" ){
    591                 DllMain_EntryPoint=pUserProc->beginOpAddress;
     610                DllMain_EntryPoint=pUserProc->GetBeginOpAddress();
    592611            }
    593612
    594613            lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD));
    595             lpdwExportAddressTable[ExportNum]=pUserProc->beginOpAddress;
     614            lpdwExportAddressTable[ExportNum]=pUserProc->GetBeginOpAddress();
    596615
    597616            lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD));
     
    800819    //(デバッグ情報で利用される)
    801820    extern int AllInitGlobalVarSize;
    802     BOOST_FOREACH( Variable *pVar, globalVars ){
    803         if(pVar->offset&0x80000000){
    804             pVar->offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize;
     821    BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
     822        if(pVar->GetOffsetAddress()&0x80000000){
     823            pVar->SetOffsetAddress(
     824                (pVar->GetOffsetAddress()&0x7FFFFFFF)+AllInitGlobalVarSize
     825            );
    805826        }
    806827    }
     
    10881109    // ※x86はRVAからのオフセット。x64はRPI(実行中アドレス)からのオフセット
    10891110    for(i=0;i<pobj_ImportAddrSchedule->num;i++){
    1090         DllProc *pDllProc;
    1091         pDllProc=pobj_ImportAddrSchedule->ppdi[i];
     1111        const DllProc *pDllProc = pobj_ImportAddrSchedule->ppdi[i];
    10921112        *((long *)(OpBuffer+pobj_ImportAddrSchedule->pObpValues[i]))=
    10931113            MemPos_ImportSection+
     
    11011121    // プロシージャポインタスケジュール
    11021122    for(i=0;i<pobj_SubAddrSchedule->num;i++){
    1103         if(pobj_SubAddrSchedule->ppsi[i]->beginOpAddress==0
    1104             &&pobj_SubAddrSchedule->ppsi[i]->endOpAddress==0){
     1123        if(pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()==0
     1124            &&pobj_SubAddrSchedule->ppsi[i]->GetEndOpAddress()==0){
    11051125            SetError(300,NULL,-1);
    11061126        }
     
    11081128        if(pobj_SubAddrSchedule->pbCall[i]){
    11091129            *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=
    1110                 pobj_SubAddrSchedule->ppsi[i]->beginOpAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));
     1130                pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));
    11111131        }
    11121132        else{
    11131133            *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=
    1114                 pobj_SubAddrSchedule->ppsi[i]->beginOpAddress+ImageBase+MemPos_CodeSection;
     1134                pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()+ImageBase+MemPos_CodeSection;
    11151135        }
    11161136    }
  • trunk/abdev/BasicCompiler64/NumOpe.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    164166    // 動的メソッドを検索
    165167    ///////////////////////////////////////////////////////////////////
    166     vector<UserProc *> userProcs;
     168    vector<const UserProc *> userProcs;
    167169
    168170    char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1];
    169     CClass::RefType refType;
     171    ReferenceKind refType;
    170172    lstrcpy( methodName, member );
    171173    GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
    172174
    173175    objClass.GetMethods().Enum( methodName, userProcs );
    174     UserProc *pUserProc;
    175176    if(userProcs.size()){
    176177        //オーバーロードを解決
    177         pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     178        const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
    178179
    179180        if( pUserProc ){
     
    245246    // パース
    246247    char member[VN_SIZE];
    247     CClass::RefType refType;
    248     if( CClass::SplitName( termFull, termLeft, member, refType ) ){
     248    ReferenceKind refType;
     249    if( SplitMemberName( termFull, termLeft, member, refType ) ){
    249250        ///////////////////////////////////////////////////////////////////
    250251        // オブジェクトとメンバに分解できるとき
     
    309310    if(lstrcmpi(termFull,"This")==0 && isProcedureCallOnly == false ){
    310311        //Thisオブジェクト
    311         resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
     312        resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
    312313
    313314        SetThisPtrToReg( UseReg );
     
    385386            return true;
    386387        }
    387         else if(GetConstCalcBuffer(procName,parameter,temporary)){
    388             /////////////////////////
    389             // マクロ関数
    390             /////////////////////////
    391 
    392             //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    393             if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
    394 
    395             //マクロ関数の場合
    396             NumOpe(&UseReg,temporary,Type(),resultType);
    397 
    398             if(!IS_LITERAL(resultType.GetIndex())){
    399                 //リテラル値ではなかったとき
    400                 isLiteral = false;
    401             }
    402 
    403             return true;
     388
     389        ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( procName );
     390        if( pConstMacro )
     391        {
     392            if( pConstMacro->GetCalcBuffer( parameter, temporary ) )
     393            {
     394                /////////////////////////
     395                // マクロ関数
     396                /////////////////////////
     397
     398                //閉じカッコ")"に続く文字がNULLでないときはエラーにする
     399                if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
     400
     401                //マクロ関数の場合
     402                NumOpe(&UseReg, temporary,Type(),resultType);
     403
     404                if(!IS_LITERAL(resultType.GetIndex())){
     405                    //リテラル値ではなかったとき
     406                    isLiteral = false;
     407                }
     408
     409                return true;
     410            }
    404411        }
    405412    }
     
    905912                    //////////////
    906913
    907                     i3 = CDBConst::obj.GetBasicType(term);
     914                    i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(term);
    908915                    if(i3){
    909                         if( CDBConst::obj.IsStringPtr( term ) ){
     916                        if( compiler.GetMeta().GetGlobalConsts().IsStringPtr( term ) ){
    910917                            //リテラル文字列
    911918
    912                             double dbl = CDBConst::obj.GetDoubleData(term);
     919                            double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term);
    913920                            memcpy(&i64data,&dbl,sizeof(double));
    914921
     
    924931                        if(IsRealNumberType(i3)){
    925932                            //実数
    926                             double dbl = CDBConst::obj.GetDoubleData(term);
     933                            double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term);
    927934                            memcpy(&i64data,&dbl,sizeof(double));
    928935                            goto Literal;
     
    930937                        else if(IsWholeNumberType(i3)){
    931938                            //整数
    932                             i64data = CDBConst::obj.GetWholeData(term);
     939                            i64data = compiler.GetMeta().GetGlobalConsts().GetWholeData(term);
    933940                            goto Literal;
    934941                        }
  • trunk/abdev/BasicCompiler64/NumOpe_Arithmetic.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <Compiler.h>
    24
     
    561563
    562564        //call pow
    563         extern UserProc *pSub_pow;
     565        extern const UserProc *pSub_pow;
    564566        op_call(pSub_pow);
    565567
  • trunk/abdev/BasicCompiler64/NumOpe_Logical.cpp

    r64 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler64/NumOpe_Relation.cpp

    r36 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
  • trunk/abdev/BasicCompiler64/Opcode.h

    r142 r206  
    1 //Opcode.h
     1#pragma once
     2
     3#include <Type.h>
     4#include <Procedure.h>
    25
    36
     
    323326bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
    324327void SetThisPtrToReg(int reg);
    325 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = NULL);
    326 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *InitBuf);
     328bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
     329bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf);
    327330#define DIMFLAG_INITDEBUGVAR            0x01
    328331#define DIMFLAG_NONCALL_CONSTRACTOR     0x02
    329332#define DIMFLAG_STATIC                  0x04
    330333#define DIMFLAG_CONST                   0x08
    331 void dim( char *VarName,int *SubScripts,Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
     334void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
    332335void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
    333336bool Compile_AddGlobalRootsForGc();
     
    356359
    357360public:
    358     UserProc *_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );
    359     UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );
     361    const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
     362    const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
    360363
    361364    void ApplyDefaultParameters( const Parameters &params );
     
    389392#define PROCFLAG_NEW    1
    390393bool Opcode_CallProcPtr(const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
    391 bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
     394bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
    392395bool Opcode_CallDllProc( const char *lpszParms,DllProc *pDllProc);
    393396
     
    401404//OperatorProc.cpp
    402405void FreeTempObject(int reg,const CClass *pobj_c);
    403 int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
     406int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
    404407void CallCastOperatorProc(int reg,Type &calcType,BOOL bCalcUseHeap,const Type &toType);
    405408void CallIndexerGetterProc(int reg,const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType);
     
    512515void op_fld_ptr_esp(int type);
    513516void op_zero_reg(int reg);
    514 void op_call( UserProc *pUserProc );
    515 void op_call( DllProc *pDllProc );
     517void op_call( const UserProc *pUserProc );
     518void op_call( const DllProc *pDllProc );
    516519void op_ret();
  • trunk/abdev/BasicCompiler64/OperatorProc.cpp

    r135 r206  
     1#include "stdafx.h"
     2
     3#include <jenga/include/smoothie/LexicalAnalysis.h>
     4
    15#include "../BasicCompiler_Common/common.h"
    26#include "Opcode.h"
     
    1620
    1721        //call DestructorProcAddr
    18         op_call( method->pUserProc );
     22        op_call( &method->GetUserProc() );
    1923    }
    2024
     
    2327
    2428    //call free
    25     extern UserProc *pSub_free;
     29    extern const UserProc *pSub_free;
    2630    op_call(pSub_free);
    2731}
    2832
    29 int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){
     33int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){
    3034    //オーバーロードされたオペレータ関数を呼び出す
    3135    CClass *pobj_c;
    3236    pobj_c=(CClass *)index_stack[sp-2];
    3337
    34     std::vector<UserProc *> subs;
     38    std::vector<const UserProc *> subs;
    3539    pobj_c->GetMethods().Enum( idCalc, subs );
    3640    if( subs.size() == 0 ){
     
    5862    if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
    5963    else GetCalcName(idCalc,temporary);
    60     UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
     64    const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
    6165
    6266    if(!pUserProc){
     
    118122
    119123            //call calloc
    120             extern UserProc *pSub_calloc;
     124            extern const UserProc *pSub_calloc;
    121125            op_call(pSub_calloc);
    122126
     
    319323void CallIndexerGetterProc(int reg,const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType ){
    320324
    321     std::vector<UserProc *> subs;
     325    std::vector<const UserProc *> subs;
    322326    pobj_Class->GetMethods().Enum( CALC_ARRAY_GET, subs );
    323327    if( subs.size() == 0 ){
  • trunk/abdev/BasicCompiler64/Register.cpp

    r131 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler64/amd64_main.cpp

    r142 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
     
    17911793/////////////////////////////
    17921794
    1793 void op_call( UserProc *pUserProc ){
     1795void op_call( const UserProc *pUserProc ){
    17941796    OpBuffer[obp++] = (char)0xE8;
    17951797    pobj_SubAddrSchedule->add( pUserProc, 1 );
     
    17971799    obp += sizeof(long);
    17981800}
    1799 void op_call( DllProc *pDllProc ){
     1801void op_call( const DllProc *pDllProc ){
    18001802    OpBuffer[obp++] = (char)0xFF;
    18011803    OpBuffer[obp++] = (char)0x15;
  • trunk/abdev/BasicCompiler64/increment.cpp

    r129 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler64/stack_frame.cpp

    r66 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24#include "Opcode.h"
  • trunk/abdev/BasicCompiler_Common/BasicCompiler.cpp

    r188 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    548550}
    549551
     552void _Test()
     553{
     554    Jenga::Common::LoggerSetting loggerSetting;
     555    bool result = loggerSetting.Read( Jenga::Common::Environment::GetAppDir() + "\\logger.setting.xml" );
     556
     557    MessageBeep(0);
     558}
     559
    550560int PASCAL WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd){
    551561    int i,i2;
    552562    char temporary[1024],temp2[MAX_PATH];
     563
     564    //_Test();
    553565
    554566    //MessageBox(0,"starting compiler/debugger","ActiveBasic",MB_OK);
  • trunk/abdev/BasicCompiler_Common/BasicCompiler.h

    r182 r206  
    2323DWORD ImageBase;
    2424INCLUDEFILEINFO IncludeFileInfo;
    25 GlobalProc **ppSubHash;
    26 int SubNum;
    27 char **ppMacroNames;
    28 int MacroNum;
    2925DllProc **ppDeclareHash;
    30 CONSTINFO **ppConstHash;
    3126
    3227ERRORINFO *pErrorInfo;
  • trunk/abdev/BasicCompiler_Common/BreakPoint.cpp

    r165 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/common/Environment.h>
     4#include <jenga/include/smoothie/Source.h>
    25
    36#include "common.h"
  • trunk/abdev/BasicCompiler_Common/CDebugThreadInfo.cpp

    r4 r206  
     1#include "stdafx.h"
     2
    13#include "common.h"
     4#include "DebugSection.h"
    25
    36
  • trunk/abdev/BasicCompiler_Common/CommandFormat.cpp

    r75 r206  
     1#include "stdafx.h"
     2
    13#include "common.h"
    24
  • trunk/abdev/BasicCompiler_Common/Compile.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    126128    int i,i2;
    127129
    128     if(Command[0]=='\0') return;
     130    if(Command[0]=='\0')
     131    {
     132        return;
     133    }
     134
     135    trace_for_sourcecodestep( FormatEscapeSequenceStringToDefaultString(Command) );
     136
    129137    if(Command[0]=='*'&&IsVariableTopChar(Command[1])){
    130138        //Goto先ラベル
  • trunk/abdev/BasicCompiler_Common/Debug.cpp

    r165 r206  
     1#include "stdafx.h"
     2
     3#include <Compiler.h>
     4
    15#include "../BasicCompiler_Common/common.h"
     6#include "../BasicCompiler_Common/DebugSection.h"
    27
    38//デバッグ用
     
    224229    SendDlgItemMessage(hMainDlg,IDC_DEBUGLIST,EM_REPLACESEL,0,(LPARAM)buffer);
    225230}
    226 GlobalProc *GetSubFromObp(ULONG_PTR pos){
    227     extern GlobalProc **ppSubHash;
    228     GlobalProc *pUserProc;
    229     int i2;
    230 
    231     for(i2=0;i2<MAX_HASH;i2++){
    232         pUserProc=ppSubHash[i2];
    233         while(pUserProc){
    234             if(rva_to_real(pUserProc->beginOpAddress) <= pos  &&
    235                 pos < rva_to_real(pUserProc->endOpAddress))
    236                 return pUserProc;
    237 
    238             pUserProc=pUserProc->pNextData;
    239         }
    240     }
    241     return 0;
     231UserProc *GetSubFromObp(ULONG_PTR pos){
     232    compiler.GetMeta().GetUserProcs().Iterator_Reset();
     233    while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     234    {
     235        UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     236
     237        if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pos  &&
     238            pos < rva_to_real(pUserProc->GetEndOpAddress()))
     239        {
     240            return pUserProc;
     241        }
     242    }
     243    return NULL;
    242244}
    243245void ReleaseSingleStep(DWORD dwBeforeStepRun,HANDLE hThread,CONTEXT *pContext){
     
    447449    pobj_dti=new CDebugThreadInfo();
    448450
    449     GlobalProc *pUserProc;
     451    UserProc *pUserProc;
    450452
    451453    extern DWORD dwStepRun;
     
    681683                        if(!bRet) MessageBox(hMainDlg,"プロセスメモリーの読み込みに失敗","error",MB_OK);
    682684
    683                         extern UserProc *pSub_DebugSys_EndProc;
     685                        extern const UserProc *pSub_DebugSys_EndProc;
    684686                        if((BYTE)temporary[0]==0xE8&&
    685                             *((long *)(temporary+1))+5==(long)rva_to_real(pSub_DebugSys_EndProc->beginOpAddress)-(long)EIP_RIP(Context)){
     687                            *((long *)(temporary+1))+5==(long)rva_to_real(pSub_DebugSys_EndProc->GetBeginOpAddress())-(long)EIP_RIP(Context)){
    686688                            //プロシージャの終端位置の場合はステップインを行う
    687689                            goto StepIn;
     
    704706                            //シングルステップON
    705707                            WriteProcessMemory(hDebugProcess,
    706                                 (void *)rva_to_real(pUserProc->beginOpAddress),
    707                                 pobj_DBDebugSection->pobj_now->SingleStepCodeBuffer+pUserProc->beginOpAddress,
    708                                 pUserProc->endOpAddress-pUserProc->beginOpAddress,
     708                                (void *)rva_to_real(pUserProc->GetBeginOpAddress()),
     709                                pobj_DBDebugSection->pobj_now->SingleStepCodeBuffer+pUserProc->GetBeginOpAddress(),
     710                                pUserProc->GetEndOpAddress()-pUserProc->GetBeginOpAddress(),
    709711                                &lpAccBytes);
    710712                        }
  • trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp

    r201 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
    35#include <Compiler.h>
    4 #include <ClassImpl.h>
    5 #include <VariableImpl.h>
     6#include <Class.h>
     7#include <Variable.h>
    68
    79#include "../BasicCompiler_Common/common.h"
     10#include "../BasicCompiler_Common/DebugSection.h"
    811
    912#ifdef _AMD64_
     
    4447
    4548
    46 CDebugSection::CDebugSection(){
    47     memset(this,0,sizeof(CDebugSection));
    48 }
    4949CDebugSection::~CDebugSection(){
    5050    if(pobj_DBClass) DeleteDebugInfo();
     
    5656void CDebugSection::make(void){
    5757    extern INCLUDEFILEINFO IncludeFileInfo;
    58     int i2,i3,i5,BufferSize;
     58    int i2,i3,BufferSize;
    5959
    6060    if(buffer){
     
    159159
    160160    //グローバル変数情報
    161     *(long *)(buffer+i2)=(int)::globalVars.size();
    162     i2+=sizeof(long);
    163     BOOST_FOREACH( Variable *pVar, ::globalVars ){
     161    *(long *)(buffer+i2)=(int)compiler.GetMeta().GetGlobalVars().size();
     162    i2+=sizeof(long);
     163    BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
    164164        //変数名
    165165        lstrcpy(buffer+i2,pVar->GetName().c_str());
     
    167167
    168168        //型
    169         *(long *)(buffer+i2)=pVar->GetBasicType();
     169        *(long *)(buffer+i2)=pVar->GetType().GetBasicType();
    170170        i2+=sizeof(long);
    171171
    172172        //型の拡張情報
    173         SetLpIndex_DebugFile(buffer,&i2,*pVar);
     173        SetLpIndex_DebugFile(buffer,&i2,pVar->GetType());
    174174
    175175        buffer[i2++] = pVar->IsRef() ? 1 : 0;
     
    178178
    179179        if(pVar->IsArray()){
    180             for(i5=0;;i5++){
    181                 *(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5];
     180            *(long *)(buffer+i2)=(int)pVar->GetSubscripts().size();
     181            i2+=sizeof(long);
     182            BOOST_FOREACH( int indexMax, pVar->GetSubscripts() )
     183            {
     184                *(long *)(buffer+i2)=indexMax;
    182185                i2+=sizeof(long);
    183                 if(pVar->GetSubScriptsPtr()[i5]==-1) break;
    184186            }
    185187        }
    186188
    187189        //レキシカルスコープ情報
    188         *(long *)(buffer+i2)=pVar->ScopeStartAddress;
    189         i2+=sizeof(long);
    190         *(long *)(buffer+i2)=pVar->ScopeEndAddress;
    191         i2+=sizeof(long);
    192         *(long *)(buffer+i2)=pVar->ScopeLevel;
     190        *(long *)(buffer+i2)=pVar->GetScopeStartAddress();
     191        i2+=sizeof(long);
     192        *(long *)(buffer+i2)=pVar->GetScopeEndAddress();
     193        i2+=sizeof(long);
     194        *(long *)(buffer+i2)=pVar->GetScopeLevel();
    193195        i2+=sizeof(long);
    194196
    195197        //メモリ位置
    196         *(long *)(buffer+i2)=pVar->offset;
     198        *(long *)(buffer+i2)=pVar->GetOffsetAddress();
    197199        i2+=sizeof(long);
    198200
     
    210212
    211213    //プロシージャ情報
    212     extern GlobalProc **ppSubHash;
    213     extern int SubNum;
    214     GlobalProc *pUserProc;
    215     *(long *)(buffer+i2)=SubNum;
    216     i2+=sizeof(long);
    217     for(i3=0;i3<MAX_HASH;i3++){
    218         pUserProc=ppSubHash[i3];
    219         while(pUserProc){
    220             if(pUserProc->GetParentClassPtr()){
    221                 lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str());
    222                 i2+=lstrlen(buffer+i2)+1;
    223             }
    224             else{
    225                 lstrcpy(buffer+i2,"");
    226                 i2+=lstrlen(buffer+i2)+1;
    227             }
    228 
    229             //ID
    230             *(long *)(buffer+i2)=pUserProc->id;
    231             i2+=sizeof(long);
    232 
    233             //関数名
    234             lstrcpy(buffer+i2,pUserProc->GetName().c_str());
     214    *(long *)(buffer+i2) = compiler.GetMeta().GetUserProcs().Iterator_GetMaxCount();
     215    i2+=sizeof(long);
     216    compiler.GetMeta().GetUserProcs().Iterator_Reset();
     217    while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     218    {
     219        UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     220
     221        if(pUserProc->GetParentClassPtr()){
     222            lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str());
    235223            i2+=lstrlen(buffer+i2)+1;
    236 
    237             *(long *)(buffer+i2)=pUserProc->beginOpAddress;
    238             i2+=sizeof(long);
    239             *(long *)(buffer+i2)=pUserProc->endOpAddress;
    240             i2+=sizeof(long);
    241 
    242             //ローカル変数情報
    243             *(long *)(buffer+i2)=(int)pUserProc->localVars.size();
    244             i2+=sizeof(long);
     224        }
     225        else{
     226            lstrcpy(buffer+i2,"");
     227            i2+=lstrlen(buffer+i2)+1;
     228        }
     229
     230        //ID
     231        *(long *)(buffer+i2)=pUserProc->GetId();
     232        i2+=sizeof(long);
     233
     234        //関数名
     235        lstrcpy(buffer+i2,pUserProc->GetName().c_str());
     236        i2+=lstrlen(buffer+i2)+1;
     237
     238        *(long *)(buffer+i2)=pUserProc->GetBeginOpAddress();
     239        i2+=sizeof(long);
     240        *(long *)(buffer+i2)=pUserProc->GetEndOpAddress();
     241        i2+=sizeof(long);
     242
     243        //ローカル変数情報
     244        *(long *)(buffer+i2)=(int)pUserProc->GetLocalVars().size();
     245        i2+=sizeof(long);
     246
     247        //バッファが足りない場合は再確保
     248        if(BufferSize<i2+32768){
     249            BufferSize+=32768;
     250            buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
     251        }
     252
     253        BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
     254            lstrcpy(buffer+i2,pVar->GetName().c_str());
     255            i2+=lstrlen(buffer+i2)+1;
     256
     257            //型
     258            *(long *)(buffer+i2)=pVar->GetType().GetBasicType();
     259            i2+=sizeof(long);
     260
     261            //型の拡張情報
     262            SetLpIndex_DebugFile(buffer,&i2,pVar->GetType());
     263
     264            //参照型パラメータかどうか
     265            buffer[i2++] = pVar->IsRef() ? 1 : 0;
     266
     267            //配列かどうか
     268            buffer[i2++] = pVar->IsArray() ? 1 : 0;
     269
     270            //配列要素
     271            if(pVar->IsArray()){
     272                *(long *)(buffer+i2)=(int)pVar->GetSubscripts().size();
     273                i2+=sizeof(long);
     274                BOOST_FOREACH( int indexMax, pVar->GetSubscripts() )
     275                {
     276                    *(long *)(buffer+i2)=indexMax;
     277                    i2+=sizeof(long);
     278                }
     279            }
     280
     281            //レキシカルスコープ情報
     282            *(long *)(buffer+i2)=pVar->GetScopeStartAddress();
     283            i2+=sizeof(long);
     284            *(long *)(buffer+i2)=pVar->GetScopeEndAddress();
     285            i2+=sizeof(long);
     286            *(long *)(buffer+i2)=pVar->GetScopeLevel();
     287            i2+=sizeof(long);
     288
     289            //メモリ位置
     290            *(long *)(buffer+i2)=pVar->GetOffsetAddress();
     291            i2+=sizeof(long);
     292
     293
     294
    245295
    246296            //バッファが足りない場合は再確保
     
    249299                buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
    250300            }
    251 
    252             BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){
    253                 lstrcpy(buffer+i2,pVar->GetName().c_str());
    254                 i2+=lstrlen(buffer+i2)+1;
    255 
    256                 //型
    257                 *(long *)(buffer+i2)=pVar->GetBasicType();
    258                 i2+=sizeof(long);
    259 
    260                 //型の拡張情報
    261                 SetLpIndex_DebugFile(buffer,&i2,*pVar);
    262 
    263                 //参照型パラメータかどうか
    264                 buffer[i2++] = pVar->IsRef() ? 1 : 0;
    265 
    266                 //配列かどうか
    267                 buffer[i2++] = pVar->IsArray() ? 1 : 0;
    268 
    269                 //配列要素
    270                 if(pVar->IsArray()){
    271                     for(i5=0;;i5++){
    272                         *(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5];
    273                         i2+=sizeof(long);
    274                         if(pVar->GetSubScriptsPtr()[i5]==-1) break;
    275                     }
    276                 }
    277 
    278                 //レキシカルスコープ情報
    279                 *(long *)(buffer+i2)=pVar->ScopeStartAddress;
    280                 i2+=sizeof(long);
    281                 *(long *)(buffer+i2)=pVar->ScopeEndAddress;
    282                 i2+=sizeof(long);
    283                 *(long *)(buffer+i2)=pVar->ScopeLevel;
    284                 i2+=sizeof(long);
    285 
    286                 //メモリ位置
    287                 *(long *)(buffer+i2)=pVar->offset;
    288                 i2+=sizeof(long);
    289 
    290 
    291 
    292 
    293                 //バッファが足りない場合は再確保
    294                 if(BufferSize<i2+32768){
    295                     BufferSize+=32768;
    296                     buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
    297                 }
    298             }
    299 
    300             pUserProc=pUserProc->pNextData;
    301301        }
    302302    }
     
    328328        i2+=sizeof(long);
    329329
    330         //メンバ
     330        // 動的メンバ
    331331        *(long *)(buffer+i2)=(int)pobj_c->GetDynamicMembers().size();
    332332        i2+=sizeof(long);
     
    347347            i2+=sizeof(Prototype::Accessibility);
    348348
    349             memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM);
    350             i2+=sizeof(int)*MAX_ARRAYDIM;
     349            *(long *)(buffer+i2)=(int)member->GetSubscripts().size();
     350            i2+=sizeof(long);
     351            BOOST_FOREACH( int indexMax, member->GetSubscripts() )
     352            {
     353                *(long *)(buffer+i2)=indexMax;
     354                i2+=sizeof(long);
     355            }
    351356
    352357            //バッファが足りない場合は再確保
     
    357362        }
    358363
    359         //メソッド
     364        // 動的メソッド
    360365        *(long *)(buffer+i2)=(long)pobj_c->GetMethods().size();
    361366        i2+=sizeof(long);
     
    371376                i2+=lstrlen(buffer+i2)+1;
    372377            }
    373             lstrcpy(buffer+i2,pMethod->pUserProc->GetName().c_str());
     378            lstrcpy(buffer+i2,pMethod->GetUserProc().GetName().c_str());
    374379            i2+=lstrlen(buffer+i2)+1;
    375380        }
     
    394399            i2+=sizeof(Prototype::Accessibility);
    395400
    396             memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM);
    397             i2+=sizeof(int)*MAX_ARRAYDIM;
     401            // 配列
     402            *(long *)(buffer+i2)=(int)member->GetSubscripts().size();
     403            i2+=sizeof(long);
     404            BOOST_FOREACH( int indexMax, member->GetSubscripts() )
     405            {
     406                *(long *)(buffer+i2)=indexMax;
     407                i2+=sizeof(long);
     408            }
    398409
    399410            //バッファが足りない場合は再確保
     
    434445}
    435446BOOL CDebugSection::__load(void){
    436     int i2,i3,i4,i5,num;
     447    int i2,i3,i4,num;
    437448    char temp2[MAX_PATH],*temp5;
    438449
    439     Smoothie::Temp::pCompilingClass = NULL;
     450    compiler.pCompilingClass = NULL;
    440451
    441452    i2=0;
     
    487498    ///////////////////////////////////////////
    488499
    489     this->pobj_DBClass=new ClassesImpl();
     500    this->pobj_DBClass=new Classes();
    490501
    491502    int iMaxClassCount;
     
    524535    //定数を取得
    525536    GetConstInfo();
    526     extern CONSTINFO **ppConstHash;
    527     this->ppConstHash=ppConstHash;
    528 
     537    this->globalConsts = compiler.GetMeta().GetGlobalConsts();
     538    this->globalConstMacros = compiler.GetMeta().GetGlobalConstMacros();
    529539
    530540    //グローバル変数情報
    531     globalVars.clear();
     541    compiler.GetMeta().GetGlobalVars().clear();
    532542    int maxGlobalVars=*(long *)(buffer+i2);
    533543    i2+=sizeof(long);
     
    548558        bool isArray = (buffer[i2++]) ? true:false;
    549559
    550         Variable *pVar = new VariableImpl( name, type, false, isRef );
     560        Variable *pVar = new Variable( name, type, false, isRef, "" );
    551561
    552562        if(isArray){
    553             int SubScripts[MAX_ARRAYDIM];
    554             for(i4=0;;i4++){
    555                 SubScripts[i4]=*(long *)(buffer+i2);
     563            Subscripts subscripts;
     564            int nSubScriptsNum = *(long *)(buffer+i2);
     565            i2+=sizeof(long);
     566            for( int i=0; i<nSubScriptsNum; i++ )
     567            {
     568                subscripts.push_back( *(long *)(buffer+i2) );
    556569                i2+=sizeof(long);
    557 
    558                 if(SubScripts[i4]==-1) break;
    559             }
    560 
    561             pVar->SetArray( SubScripts );
     570            }
     571
     572            pVar->SetArray( subscripts );
    562573        }
    563574
    564575        //レキシカルスコープ情報
    565         pVar->ScopeStartAddress=*(long *)(buffer+i2);
    566         i2+=sizeof(long);
    567         pVar->ScopeEndAddress=*(long *)(buffer+i2);
    568         i2+=sizeof(long);
    569         pVar->ScopeLevel=*(long *)(buffer+i2);
     576        pVar->SetScopeStartAddress( *(long *)(buffer+i2) );
     577        i2+=sizeof(long);
     578        pVar->SetScopeEndAddress( *(long *)(buffer+i2) );
     579        i2+=sizeof(long);
     580        pVar->SetScopeLevel( *(long *)(buffer+i2) );
    570581        i2+=sizeof(long);
    571582
    572583        //メモリ位置
    573         pVar->offset=*(long *)(buffer+i2);
     584        pVar->SetOffsetAddress( *(long *)(buffer+i2) );
    574585        i2+=sizeof(long);
    575586
    576587        //変数を追加
    577         globalVars.push_back( pVar );
     588        compiler.GetMeta().GetGlobalVars().push_back( pVar );
    578589    }
    579590
     
    583594
    584595    //プロシージャ情報
    585     GlobalProc *pUserProc;
    586     SubNum=*(long *)(buffer+i2);
    587     i2+=sizeof(long);
    588     ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *));
    589     for(int i6=0;i6<SubNum;i6++){
     596    userProcs.Clear();
     597    int subNum = *(long *)(buffer+i2);
     598    i2+=sizeof(long);
     599    for(int i6=0;i6<subNum;i6++){
    590600        char szParentClassName[VN_SIZE];
    591601        lstrcpy(szParentClassName,buffer+i2);
     
    607617        // オブジェクトを生成
    608618        // TODO: 名前空間が未完成
    609         pUserProc = new GlobalProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false );
    610         pUserProc->pNextData=0;
    611         pUserProc->id=id;
     619        UserProc *pUserProc = new UserProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false, id );
    612620        pUserProc->SetParentClass( pClass );
    613621
    614         pUserProc->beginOpAddress=*(long *)(buffer+i2);
    615         i2+=sizeof(long);
    616         pUserProc->endOpAddress=*(long *)(buffer+i2);
     622        pUserProc->SetBeginOpAddress( *(long *)(buffer+i2) );
     623        i2+=sizeof(long);
     624        pUserProc->SetEndOpAddress( *(long *)(buffer+i2) );
    617625        i2+=sizeof(long);
    618626
     
    620628
    621629        //ローカル変数情報
    622         pUserProc->localVars.clear();
     630        pUserProc->GetLocalVars().clear();
    623631        int maxLocalVar=*(long *)(buffer+i2);
    624632        i2+=sizeof(long);
     
    638646            bool isArray = (buffer[i2++]) ? true:false;
    639647
    640             Variable *pVar = new VariableImpl( name, type, false, isRef );
     648            Variable *pVar = new Variable( name, type, false, isRef, "" );
    641649
    642650            if(isArray){
    643                 int SubScripts[MAX_ARRAYDIM];
    644                 for(i4=0;;i4++){
    645                     SubScripts[i4]=*(long *)(buffer+i2);
     651                Subscripts subscripts;
     652                int nSubScriptsNum = *(long *)(buffer+i2);
     653                i2+=sizeof(long);
     654                for( int i=0; i<nSubScriptsNum; i++ )
     655                {
     656                    subscripts.push_back( *(long *)(buffer+i2) );
    646657                    i2+=sizeof(long);
    647 
    648                     if(SubScripts[i4]==-1) break;
    649658                }
    650659
    651                 pVar->SetArray( SubScripts );
     660                pVar->SetArray( subscripts );
    652661            }
    653662
    654663            //レキシカルスコープ情報
    655             pVar->ScopeStartAddress=*(long *)(buffer+i2);
    656             i2+=sizeof(long);
    657             pVar->ScopeEndAddress=*(long *)(buffer+i2);
    658             i2+=sizeof(long);
    659             pVar->ScopeLevel=*(long *)(buffer+i2);
     664            pVar->SetScopeStartAddress( *(long *)(buffer+i2) );
     665            i2+=sizeof(long);
     666            pVar->SetScopeEndAddress( *(long *)(buffer+i2) );
     667            i2+=sizeof(long);
     668            pVar->SetScopeLevel( *(long *)(buffer+i2) );
    660669            i2+=sizeof(long);
    661670
    662671            //メモリ位置
    663             pVar->offset=*(long *)(buffer+i2);
     672            pVar->SetOffsetAddress( *(long *)(buffer+i2) );
    664673            i2+=sizeof(long);
    665674
    666675            //変数を追加
    667             pUserProc->localVars.push_back( pVar );
     676            pUserProc->GetLocalVars().push_back( pVar );
    668677        }
    669678
     
    673682        /////////////////////////////////
    674683
    675         i4=hash_default(pUserProc->GetName().c_str());
    676 
    677         GlobalProc *psi2;
    678         if(ppSubHash[i4]){
    679             psi2=ppSubHash[i4];
    680             while(1){
    681                 if(psi2->pNextData==0){
    682                     psi2->pNextData=pUserProc;
    683                     break;
    684                 }
    685                 psi2=psi2->pNextData;
    686             }
    687         }
    688         else{
    689             ppSubHash[i4]=pUserProc;
    690         }
    691     }
     684        // ハッシュに追加
     685        if( !userProcs.Insert( pUserProc, -1 ) )
     686        {
     687            //return NULL;
     688        }
     689    }
     690    userProcs.Iterator_Init();
    692691
    693692    //クラス情報
     
    709708        i2+=sizeof(long);
    710709
    711         //的メンバ
     710        // 動的メンバ
    712711        int nDynamicMember = *(long *)(buffer+i2);
    713712        i2+=sizeof(long);
     
    728727            i2+=sizeof(Prototype::Accessibility);
    729728
    730             CMember *member=new CMember( accessibility, name, type, false, "", "" );
    731 
    732             memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
    733             i2+=sizeof(int)*MAX_ARRAYDIM;
     729            Subscripts subscripts;
     730            int nSubScriptsNum = *(long *)(buffer+i2);
     731            i2+=sizeof(long);
     732            for( int i=0; i<nSubScriptsNum; i++ )
     733            {
     734                subscripts.push_back( *(long *)(buffer+i2) );
     735                i2+=sizeof(long);
     736            }
     737
     738            CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" );
    734739
    735740            pobj_c->GetDynamicMembers().push_back( member );
    736741        }
    737742
    738         //メソッド
     743        // 動的メソッド
    739744        int nMethod = *(long *)(buffer+i2);
    740745        i2+=sizeof(long);
     
    759764            pobj_temp_c=pobj_InheritsClass;
    760765            if(pobj_temp_c==0) pobj_temp_c=pobj_c;
    761             i5=hash_default(temp2);
    762             pUserProc=ppSubHash[i5];
    763             while(1){
    764                 if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c) break;
    765                 pUserProc=pUserProc->pNextData;
     766
     767            UserProc *pUserProc = compiler.GetMeta().GetUserProcs().GetHashArrayElement( temp2 );
     768            while(pUserProc){
     769                if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c)
     770                {
     771                    break;
     772                }
     773
     774                pUserProc=pUserProc->GetChainNext();
    766775            }
    767776
     
    790799            i2+=sizeof(Prototype::Accessibility);
    791800
    792             CMember *member=new CMember( accessibility, name, type, false, "", "" );
    793 
    794             memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
    795             i2+=sizeof(int)*MAX_ARRAYDIM;
     801            // 配列
     802            Subscripts subscripts;
     803            int nSubScriptsNum = *(long *)(buffer+i2);
     804            i2+=sizeof(long);
     805            for( int i=0; i<nSubScriptsNum; i++ )
     806            {
     807                subscripts.push_back( *(long *)(buffer+i2) );
     808                i2+=sizeof(long);
     809            }
     810
     811            CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" );
    796812
    797813            pobj_c->GetStaticMembers().push_back( member );
     
    805821
    806822
    807     extern GlobalProc **ppSubHash;
    808     ppSubHash=this->ppSubHash;
     823    compiler.GetMeta().GetUserProcs() = userProcs;
    809824    pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc");
    810825
     
    950965
    951966    //定数を取得
    952     extern CONSTINFO **ppConstHash;
    953     ppConstHash=this->ppConstHash;
     967    compiler.GetMeta().GetGlobalConsts() = this->globalConsts;
     968    compiler.GetMeta().GetGlobalConstMacros() = this->globalConstMacros;
    954969
    955970    //グローバル実行領域のサイズ
     
    958973
    959974    //プロシージャ
    960     extern char **ppMacroNames;
    961     ppMacroNames=0;
    962     extern GlobalProc **ppSubHash;
    963     extern int SubNum;
    964     ppSubHash=this->ppSubHash;
    965     SubNum=this->SubNum;
    966 
    967     extern UserProc *pSub_DebugSys_EndProc;
     975    compiler.GetMeta().GetUserProcs() = userProcs;
     976
     977    extern const UserProc *pSub_DebugSys_EndProc;
    968978    pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc;
    969979
     
    986996    delete this->pobj_DBClass;
    987997    this->pobj_DBClass=0;
    988 
    989     //サブルーチン情報のメモリ解放
    990     DeleteSubInfo(ppSubHash,0,0);
    991 
    992     //定数に関する情報を解放
    993     DeleteConstInfo(ppConstHash);
    994998
    995999    //コードと行番号の関係を解放
  • trunk/abdev/BasicCompiler_Common/DebugSection.h

    r182 r206  
    22
    33#include <jenga/include/smoothie/Source.h>
    4 #include <jenga/include/smoothie/Class.h>
    54
    6 #include <ProcedureImpl.h>
     5#include <Class.h>
     6#include <Procedure.h>
     7#include <Const.h>
    78
    89
     
    4243
    4344    //定数を取得
    44     CONSTINFO **ppConstHash;
     45    Consts globalConsts;
     46    ConstMacros globalConstMacros;
    4547
    4648    //グローバル実行領域のサイズ
     
    4850
    4951    //プロシージャ
    50     GlobalProc **ppSubHash;
    51     int SubNum;
     52    UserProcs userProcs;
    5253
    53     UserProc *pSub_DebugSys_EndProc;
     54    const UserProc *pSub_DebugSys_EndProc;
    5455
    5556    //ネイティブコードバッファ
     
    6667
    6768
    68     CDebugSection();
     69    CDebugSection()
     70        : buffer( NULL )
     71        , length( 0 )
     72        , dwImageBase( 0 )
     73        , dwRVA_RWSection( 0 )
     74        , dwRVA_CodeSection( 0 )
     75        , SizeOf_CodeSection( 0 )
     76        , pobj_DBClass( NULL )
     77        , GlobalOpBufferSize( 0 )
     78        , pSub_DebugSys_EndProc( NULL )
     79        , OpBuffer( NULL )
     80        , SingleStepCodeBuffer( NULL )
     81        , BreakStepCodeBuffer( NULL )
     82    {
     83        szNowFilePath[0]=0;
     84    }
    6985    ~CDebugSection();
    7086
  • trunk/abdev/BasicCompiler_Common/Diagnose.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    3840        int codeSizeOfGlobalProc = 0;
    3941        int codeSizeOfClassMethod = 0;
    40         for(int i2=0;i2<MAX_HASH;i2++){
    41             extern GlobalProc **ppSubHash;
    42             GlobalProc *pUserProc = ppSubHash[i2];
    43             while(pUserProc){
    44                 if( pUserProc->IsCompiled() ){
    45                     if( pUserProc->HasParentClass() ){
    46                         codeSizeOfClassMethod += pUserProc->GetCodeSize();
    47                     }
    48                     else{
    49                         codeSizeOfGlobalProc += pUserProc->GetCodeSize();
    50                     }
     42        compiler.GetMeta().GetUserProcs().Iterator_Reset();
     43        while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     44        {
     45            UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     46            if( pUserProc->IsCompiled() ){
     47                if( pUserProc->HasParentClass() ){
     48                    codeSizeOfClassMethod += pUserProc->GetCodeSize();
    5149                }
    52 
    53                 pUserProc=pUserProc->pNextData;
     50                else{
     51                    codeSizeOfGlobalProc += pUserProc->GetCodeSize();
     52                }
    5453            }
    5554        }
     
    8382            // 動的メソッド
    8483            BOOST_FOREACH( const CMethod *pMethod, objClass.GetMethods() ){
    85                 if( pMethod->pUserProc->IsCompiled() ){
    86                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
     84                if( pMethod->GetUserProc().IsCompiled() ){
     85                    codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
    8786                }
    8887            }
     
    9089            // 静的メソッド
    9190            BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){
    92                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
     91                    codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
    9392            }
    9493
     
    118117            // 動的メソッド
    119118            BOOST_FOREACH( const CMethod *pMethod, objClass.GetMethods() ){
    120                 if( pMethod->pUserProc->IsCompiled() ){
    121                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
     119                if( pMethod->GetUserProc().IsCompiled() ){
     120                    codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
    122121                }
    123122            }
     
    125124            // 静的メソッド
    126125            BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){
    127                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
     126                    codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
    128127            }
    129128
  • trunk/abdev/BasicCompiler_Common/Enum.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/common/logger.h>
    24
     
    57
    68#include <Compiler.h>
     9#include <../Enum.h>
    710
    811#include "common.h"
     
    293296
    294297    // ログを生成
    295     Jenga::Common::Logger logger( Jenga::Common::Environment::GetAppDir() + "\\enum_generated.log" );
     298    Jenga::Common::Logger logger( Jenga::Common::Environment::GetAppDir() + "\\enum_generated.log", false );
    296299    logger << buffer << endl;
    297300
  • trunk/abdev/BasicCompiler_Common/Intermediate_Step1.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
  • trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    68#include "../BasicCompiler_Common/common.h"
    79
    8 CONSTINFO *GetNewConstHash(char *name){
    9     extern int cp;
    10     CONSTINFO *pci;
    11 
    12     int key;
    13     key=hash_default(name);
    14 
    15     extern CONSTINFO **ppConstHash;
    16     if(ppConstHash[key]){
    17         pci=ppConstHash[key];
    18         while(1){
    19             if(lstrcmp(pci->name,name)==0){
    20                 //重複エラー
    21                 SetError(15,name,cp);
    22                 return 0;
    23             }
    24 
    25             if(pci->pNextData==0){
    26                 pci->pNextData=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
    27                 break;
    28             }
    29             pci=pci->pNextData;
    30         }
    31         pci=pci->pNextData;
    32     }
    33     else{
    34         ppConstHash[key]=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
    35         pci=ppConstHash[key];
    36     }
    37 
    38     return pci;
    39 }
    40 
    41 // マクロ定数を追加するための関数
    42 void AddConstData(char *Command){
    43     extern HANDLE hHeap;
    44     extern int cp;
    45     int i,i2;
    46     char temporary[VN_SIZE];
    47 
    48     for(i=0;;i++){
    49         if(Command[i]=='\0'){
    50             SetError(10,"Const",cp);
    51             return;
    52         }
    53         if(Command[i]=='=' ||  Command[i] == 1 && Command[i+1] == ESC_AS ){
    54             //定数定義は新しいクラスモジュール(CDBConst)へ移行
    55             // ※この関数はマクロ定数のみを扱う
    56             return;
    57         }
    58         if(Command[i]=='('){
    59             temporary[i]=0;
    60             break;
    61         }
    62         temporary[i]=Command[i];
    63     }
    64 
    65 
    66     /////////////////////////////////
    67     // 格納位置を計算してpciにセット
    68     /////////////////////////////////
    69 
    70     CONSTINFO *pci;
    71     pci=GetNewConstHash(temporary);
    72     if(!pci) return;
    73 
    74 
    75 
    76     ////////////////////
    77     // 定数情報を取得
    78     ////////////////////
    79 
    80     //定数名
    81     pci->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    82     lstrcpy(pci->name,temporary);
    83 
    84     if(Command[i]=='('){
    85         pci->ppParm=(char **)HeapAlloc(hHeap,0,1);
    86         pci->ParmNum=0;
    87         for(i++,i2=0;;i++,i2++){
    88             if(Command[i]=='\0'){
    89                 SetError(1,NULL,cp);
    90                 return;
    91             }
    92             if(Command[i]==','||Command[i]==')'){
    93                 temporary[i2]=0;
    94                 pci->ppParm=(char **)HeapReAlloc(hHeap,0,pci->ppParm,(pci->ParmNum+1)*sizeof(char *));
    95                 pci->ppParm[pci->ParmNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    96                 lstrcpy(pci->ppParm[pci->ParmNum],temporary);
    97                 pci->ParmNum++;
    98                 if(Command[i]==')'){
    99                     i++;
    100                     if(Command[i]!='='){
    101                         SetError(1,NULL,cp);
    102                         return;
    103                     }
    104                     break;
    105                 }
    106 
    107                 i2=-1;
    108                 continue;
    109             }
    110             temporary[i2]=Command[i];
    111         }
    112     }
    113     else pci->ParmNum=0;
    114 
    115     //データ
    116     lstrcpy(temporary,Command+i+1);
    117     if(pci->ParmNum){
    118         pci->StrValue=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    119         lstrcpy(pci->StrValue,temporary);
    120     }
    121     else if(temporary[0]=='\"'){
    122         //文字列定数
    123         RemoveStringQuotes(temporary);
    124         i2=lstrlen(temporary);
    125 
    126         pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
    127         memcpy(pci->StrValue,temporary,i2);
    128         pci->StrValue[i2]=0;
    129 
    130         pci->DblValue=(double)i2;
    131 
    132         pci->type=DEF_STRING;
    133         pci->lpIndex=-1;
    134     }
    135     else if((temporary[0]=='e'||temporary[0]=='E')&&
    136         (temporary[1]=='x'||temporary[1]=='X')&&
    137         temporary[2]=='\"'){
    138         //文字列定数
    139         RemoveStringQuotes(temporary+2);
    140         i2=FormatString_EscapeSequence(temporary+2);
    141         pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
    142         memcpy(pci->StrValue,temporary+2,i2);
    143         pci->StrValue[i2]=0;
    144 
    145         pci->DblValue=(double)i2;
    146 
    147         pci->type=DEF_STRING;
    148         pci->lpIndex=-1;
    149     }
    150     else{
    151         //数値定数
    152         _int64 i64data;
    153         Type resultType;
    154         StaticCalculation(true, temporary,0,&i64data,resultType);
    155         pci->type=resultType.GetBasicType();
    156         if(IsRealNumberType(pci->type)){
    157             //実数型
    158             memcpy(&pci->DblValue,&i64data,sizeof(double));
    159         }
    160         else if(Is64Type(pci->type)){
    161             //64ビット型
    162             pci->i64Value=i64data;
    163         }
    164         else if(IsWholeNumberType(pci->type)){
    165             //その他整数型
    166             pci->DblValue=(double)i64data;
    167         }
    168 
    169         pci->StrValue=0;
    170     }
    171 }
     10
    17211void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){
    17312    extern int cp;
     
    24079
    24180        //定数を追加
    242         CDBConst::obj.AddConst( namespaceScopes, temporary, NextValue);
     81        compiler.GetMeta().GetGlobalConsts().Add( namespaceScopes, temporary, NextValue);
    24382    }
    24483}
     
    25594    namespaceScopes.clear();
    25695
    257     //定数に関する情報
    258     extern CONSTINFO **ppConstHash;
    259     ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));
     96    //定数に関する情報を初期化
     97    compiler.GetMeta().GetGlobalConsts().Clear();
     98    compiler.GetMeta().GetGlobalConstMacros().Clear();
    26099
    261100    extern char *basbuf;
     
    315154                    temporary[i2]=basbuf[i];
    316155                }
    317                 CDBConst::obj.Add( namespaceScopes, temporary);
     156                AddConst( namespaceScopes, temporary);
    318157                if(basbuf[i]=='\0') break;
    319158            }
     
    331170        }
    332171    }
     172
     173    // イテレータを初期化
     174    compiler.GetMeta().GetGlobalConsts().Iterator_Init();
     175    compiler.GetMeta().GetGlobalConstMacros().Iterator_Init();
     176
    333177    return true;
    334178}
  • trunk/abdev/BasicCompiler_Common/MakeExe.cpp

    r191 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
     4
     5#include <Compiler.h>
    26
    37#include "common.h"
     
    610    extern HWND hMainDlg;
    711    PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_STEPIT,0,0);
    8 }
    9 
    10 void Delete_ci(CONSTINFO *pci){
    11     int i;
    12 
    13     HeapDefaultFree(pci->name);
    14     if(pci->StrValue) HeapDefaultFree(pci->StrValue);
    15     if(pci->ParmNum){
    16         for(i=0;i<pci->ParmNum;i++)
    17             HeapDefaultFree(pci->ppParm[i]);
    18         HeapDefaultFree(pci->ppParm);
    19     }
    20 
    21     if(pci->pNextData){
    22         Delete_ci(pci->pNextData);
    23     }
    24 
    25     HeapDefaultFree(pci);
    26 }
    27 void DeleteConstInfo(CONSTINFO **ppConstHash){
    28     int i;
    29 
    30     for(i=0;i<MAX_HASH;i++){
    31         if(ppConstHash[i]){
    32             Delete_ci(ppConstHash[i]);
    33         }
    34     }
    35     HeapDefaultFree(ppConstHash);
    3612}
    3713
     
    128104    if(bError||bStopCompile) goto EndCompile;
    129105
    130     /*未完成
    131     //定数に関する情報
    132     extern CONSTINFO **ppConstHash;
    133     ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));
    134     */
    135 
    136106    //コンパイルダイアログのプログレスバーを上げる
    137107    StepCompileProgress();
     
    167137    extern int AllGlobalVarSize;
    168138    extern int AllInitGlobalVarSize;
    169     globalVars.clear();
     139    compiler.GetMeta().GetGlobalVars().clear();
    170140    AllGlobalVarSize=0;
    171141    AllInitGlobalVarSize=0;
     
    195165    HeapDefaultFree(pLineInfo);
    196166
    197     //サブルーチン(ユーザー定義)情報のメモリ解放
    198     extern GlobalProc **ppSubHash;
    199     extern char **ppMacroNames;
    200     extern int MacroNum;
    201     DeleteSubInfo(ppSubHash,ppMacroNames,MacroNum);
    202 
    203167    //Declare(DLL関数)情報のメモリ解放
    204168    DeleteDeclareInfo();
    205 
    206     //定数に関する情報を解放
    207     extern CONSTINFO **ppConstHash;
    208     DeleteConstInfo(ppConstHash);
    209169
    210170    //コンパイルダイアログのプログレスバーを上げる
  • trunk/abdev/BasicCompiler_Common/NonVolatile.cpp

    r165 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/common/Environment.h>
    24
  • trunk/abdev/BasicCompiler_Common/NumOpe_GetType.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    198200    pobj_c=(CClass *)index_stack[sp-2];
    199201
    200     std::vector<UserProc *> subs;
     202    std::vector<const UserProc *> subs;
    201203    pobj_c->GetMethods().Enum( idCalc, subs );
    202204    if( subs.size() == 0 ){
     
    228230    if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
    229231    else GetCalcName(idCalc,temporary);
    230     UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
     232    const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
    231233
    232234    if(bTwoTerm){
     
    315317    // パース
    316318    char member[VN_SIZE];
    317     CClass::RefType refType;
    318     if( CClass::SplitName( termFull, termLeft, member, refType ) ){
     319    ReferenceKind refType;
     320    if( SplitMemberName( termFull, termLeft, member, refType ) ){
    319321        ///////////////////////////////////////////////////////////////////
    320322        // オブジェクトとメンバに分解できるとき
     
    371373        // 動的メソッドを検索
    372374        ///////////////////////////////////////////////////////////////////
    373         vector<UserProc *> userProcs;
    374 
    375375        char methodName[VN_SIZE] ,lpPtrOffset[VN_SIZE];
    376376        lstrcpy( methodName, member );
    377377        GetVarFormatString(methodName,parameter,lpPtrOffset,member,refType);
    378378
     379        vector<const UserProc *> userProcs;
    379380        objClass.GetMethods().Enum( methodName, userProcs );
    380         UserProc *pUserProc;
    381381        if(userProcs.size()){
    382382            //オーバーロードを解決
    383             pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     383            const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
    384384
    385385            if( pUserProc ){
     
    413413    if(lstrcmpi(termFull,"This")==0){
    414414        //Thisオブジェクト
    415         resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
     415        resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
    416416        isLiteral = false;
    417417        return true;
     
    455455            return true;
    456456        }
    457         else if(GetConstCalcBuffer(procName,parameter,temporary)){
    458             /////////////////////////
    459             // マクロ関数
    460             /////////////////////////
    461 
    462             //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    463             if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
    464 
    465             //マクロ関数の場合
    466             if( !NumOpe_GetType(temporary,Type(),resultType) ){
    467                 return false;
    468             }
    469 
    470             if( !IS_LITERAL( resultType.GetIndex() ) ){
    471                 //リテラル値ではなかったとき
    472                 isLiteral = false;
    473             }
    474 
    475             return true;
     457        else
     458        {
     459            ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( procName );
     460            if( pConstMacro )
     461            {
     462                if( pConstMacro->GetCalcBuffer( parameter, temporary ) )
     463                {
     464                    /////////////////////////
     465                    // マクロ関数
     466                    /////////////////////////
     467
     468                    //閉じカッコ")"に続く文字がNULLでないときはエラーにする
     469                    if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
     470
     471                    //マクロ関数の場合
     472                    if( !NumOpe_GetType(temporary,Type(),resultType) ){
     473                        return false;
     474                    }
     475
     476                    if( !IS_LITERAL( resultType.GetIndex() ) ){
     477                        //リテラル値ではなかったとき
     478                        isLiteral = false;
     479                    }
     480
     481                    return true;
     482                }
     483            }
    476484        }
    477485    }
     
    732740                    //////////////
    733741
    734                     i3 = CDBConst::obj.GetBasicType(term);
     742                    i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(term);
    735743                    if(i3){
    736                         if( CDBConst::obj.IsStringPtr( term ) ){
     744                        if( compiler.GetMeta().GetGlobalConsts().IsStringPtr( term ) ){
    737745                            //リテラル文字列
    738746                            goto StrLiteral;
  • trunk/abdev/BasicCompiler_Common/Object.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <Compiler.h>
    24
     
    1113extern HANDLE hHeap;
    1214
    13 void CallConstructor( const char *ObjectName,const int *SubScripts,const Type &type,const char *Parameter){
     15void CallConstructor( const char *ObjectName,const Subscripts &subscripts,const Type &type,const char *Parameter){
    1416    if( !type.IsObject() ){
    1517        return;
     
    2123    /////////////////////////////////////
    2224
    23     UserProc *pUserProc;
    24     pUserProc=GetMethodHash(ObjectName,type.GetClass().GetName().c_str(),Parameter);
     25    const UserProc *pUserProc = GetMethodHash(ObjectName,type.GetClass().GetName().c_str(),Parameter);
    2526    if(!pUserProc){
    2627        if(Parameter[0]) SetError(113,type.GetClass().GetName().c_str(),cp);
     
    3132    char temporary[VN_SIZE];
    3233
    33     if(SubScripts[0]!=-1){
     34    if( subscripts.size() > 0 ){
    3435        int ss[MAX_ARRAYDIM];
    3536        memset(ss,0,MAX_ARRAYDIM*sizeof(int));
    3637        while(1){
    3738            int i3;
    38             for(i3=0;;i3++){
    39                 if(SubScripts[i3]==-1) break;
    40 
    41                 if(ss[i3]>SubScripts[i3]){
     39            for(i3=0; i3<(int)subscripts.size(); i3++){
     40                if(ss[i3]>subscripts[i3]){
    4241                    ss[i3]=0;
    4342                    ss[i3+1]++;
     
    4544                else break;
    4645            }
    47             if(SubScripts[i3]==-1) break;
     46            if( i3 == subscripts.size() )
     47            {
     48                break;
     49            }
    4850            sprintf(temporary,"%s[%d",ObjectName,ss[0]);
    49             for(i3=1;;i3++){
    50                 if(SubScripts[i3]==-1) break;
    51 
     51            for(i3=1; i3<(int)subscripts.size(); i3++){
    5252                sprintf(temporary+lstrlen(temporary),",%d",ss[i3]);
    5353            }
  • trunk/abdev/BasicCompiler_Common/OldStatement.cpp

    r97 r206  
     1#include "stdafx.h"
     2
    13#include "common.h"
    24
     
    116118    OpcodeCalc(temp2);
    117119
    118     UserProc *pUserProc;
     120    const UserProc *pUserProc;
    119121    if(bFile) pUserProc=GetSubHash("INPUT_FromFile");
    120122    else pUserProc=GetSubHash("INPUT_FromPrompt");
     
    218220    OpcodeCalc(temp2);
    219221
    220     UserProc *pUserProc;
     222    const UserProc *pUserProc;
    221223    if(bFile) pUserProc=GetSubHash("PRINTUSING_ToFile");
    222224    else pUserProc=GetSubHash("PRINTUSING_ToPrompt");
     
    322324    if(sw) lstrcat(buffer,"+Ex\"\\r\\n\"");
    323325
    324     UserProc *pUserProc;
     326    const UserProc *pUserProc;
    325327    if(bFile) pUserProc=GetSubHash("PRINT_ToFile");
    326328    else pUserProc=GetSubHash("PRINT_ToPrompt");
  • trunk/abdev/BasicCompiler_Common/Overload.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24
     
    79#endif
    810
    9 UserProc *OverloadSolutionWithStrParam(
     11const UserProc *OverloadSolutionWithStrParam(
    1012    const char *name,
    11     std::vector<UserProc *> &subs,
     13    std::vector<const UserProc *> &subs,
    1214    const char *Parameter,
    1315    const char *ObjectName){
     
    2628
    2729        char MethodName[VN_SIZE];
    28         if( !CClass::SplitName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );
     30        if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );
    2931/*
    3032        //メソッドの場合は静的かどうかを調べる
     
    3941
    4042
    41         UserProc *pUserProc;
    42         pUserProc=pobj_parameter->OverloadSolution(name,subs);
     43        const UserProc *pUserProc = pobj_parameter->OverloadSolution(name,subs);
    4344
    4445
     
    4950        return pUserProc;
    5051}
    51 UserProc *OverloadSolution(
     52const UserProc *OverloadSolution(
    5253    const char *name,
    53     std::vector<UserProc *> &subs,
     54    std::vector<const UserProc *> &subs,
    5455    const Parameters &params,
    5556    const Type &returnType ){
     
    6667        }
    6768
    68         UserProc *pUserProc;
    69         pUserProc=pobj_Parameter->OverloadSolution(name,subs);
     69        const UserProc *pUserProc = pobj_Parameter->OverloadSolution(name,subs);
    7070
    7171        delete pobj_Parameter;
  • trunk/abdev/BasicCompiler_Common/PESchedule.cpp

    r75 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24
     
    197199
    198200CImportAddrSchedule::CImportAddrSchedule(){
    199     ppdi=(DllProc **)HeapAlloc(hHeap,0,1);
     201    ppdi=(const DllProc **)HeapAlloc(hHeap,0,1);
    200202}
    201203CImportAddrSchedule::~CImportAddrSchedule(){
     
    203205}
    204206
    205 void CImportAddrSchedule::add(DllProc *pDllProc){
    206     ppdi=(DllProc **)HeapReAlloc(hHeap,0,ppdi,(num+1)*sizeof(DllProc *));
     207void CImportAddrSchedule::add(const DllProc *pDllProc){
     208    ppdi=(const DllProc **)HeapReAlloc(hHeap,0,ppdi,(num+1)*sizeof(DllProc *));
    207209    ppdi[num]=pDllProc;
    208210
     
    220222
    221223CSubAddrSchedule::CSubAddrSchedule(){
    222     ppsi=(UserProc **)HeapAlloc(hHeap,0,1);
     224    ppsi=(const UserProc **)HeapAlloc(hHeap,0,1);
    223225    pbCall=(BOOL *)HeapAlloc(hHeap,0,1);
    224226}
     
    228230}
    229231
    230 void CSubAddrSchedule::add(UserProc *pUserProc,BOOL bCall){
     232void CSubAddrSchedule::add(const UserProc *pUserProc,BOOL bCall){
    231233    if(!pUserProc) return;
    232234
    233     ppsi=(UserProc **)HeapReAlloc(hHeap,0,ppsi,(num+1)*sizeof(UserProc *));
     235    ppsi=(const UserProc **)HeapReAlloc(hHeap,0,ppsi,(num+1)*sizeof(UserProc *));
    234236    ppsi[num]=pUserProc;
    235237    pbCall=(BOOL *)HeapReAlloc(hHeap,0,pbCall,(num+1)*sizeof(BOOL));
  • trunk/abdev/BasicCompiler_Common/PESchedule.h

    r182 r206  
    11#pragma once
    22
    3 #include <jenga/include/smoothie/Procedure.h>
     3
     4class UserProc;
     5class DllProc;
     6
    47
    58///////////////////////
     
    6568class CImportAddrSchedule:public CSchedule{
    6669public:
    67     DllProc **ppdi;
     70    const DllProc **ppdi;
    6871
    6972    CImportAddrSchedule();
    7073    ~CImportAddrSchedule();
    7174
    72     void add(DllProc *pDllProc);
     75    void add(const DllProc *pDllProc);
    7376};
    7477extern CImportAddrSchedule *pobj_ImportAddrSchedule;
     
    8184class CSubAddrSchedule:public CSchedule{
    8285public:
    83     UserProc **ppsi;
     86    const UserProc **ppsi;
    8487    BOOL *pbCall;
    8588
     
    8790    ~CSubAddrSchedule();
    8891
    89     void add(UserProc *pUserProc,BOOL bCall);
     92    void add(const UserProc *pUserProc,BOOL bCall);
    9093};
    9194extern CSubAddrSchedule *pobj_SubAddrSchedule;
  • trunk/abdev/BasicCompiler_Common/ParamImpl.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include <Program.h>
    24
     
    197199}
    198200
    199 UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType ){
     201const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){
    200202    int sw=0;
    201     UserProc *pUserProc;
     203    const UserProc *pUserProc;
    202204    pUserProc=0;
    203205
    204206    for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
    205207
    206         BOOST_FOREACH( UserProc *pTempUserProc, subs ){
     208        BOOST_FOREACH( const UserProc *pTempUserProc, subs ){
    207209
    208210            if(EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type() )){
     
    237239
    238240    if(!sw){
    239         BOOST_FOREACH( UserProc *pTempUserProc, subs ){
     241        BOOST_FOREACH( const UserProc *pTempUserProc, subs ){
    240242
    241243            //エラーチェック
     
    261263    return pUserProc;
    262264}
    263 UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType ){
     265const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){
    264266    trace_for_overload( "" );
    265267    trace_for_overload( "■■■■■■■■■■■■■■■■■■" );
    266268    trace_for_overload( "■■■ オーバーロード解決(" << name << ")" );
    267269
    268     UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType );
     270    const UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType );
    269271
    270272    trace_for_overload( "■■■ ここまで" );
  • trunk/abdev/BasicCompiler_Common/RSrcSection.cpp

    r4 r206  
     1#include "stdafx.h"
     2
    13#include "../BasicCompiler_Common/common.h"
    24
  • trunk/abdev/BasicCompiler_Common/Resource.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/LexicalAnalysis.h>
     4
     5#include <Type.h>
    26
    37#include "common.h"
  • trunk/abdev/BasicCompiler_Common/StrOperation.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/LexicalAnalysis.h>
     4#include <jenga/include/smoothie/Source.h>
    25
    36#include "../BasicCompiler_Common/common.h"
     
    406409    }
    407410}
    408 void GetCalcName(int idCalc,char *name){
    409     switch(idCalc){
    410         case CALC_XOR:
    411             lstrcpy(name,"xor");
    412             break;
    413         case CALC_OR:
    414             lstrcpy(name,"or");
    415             break;
    416         case CALC_AND:
    417             lstrcpy(name,"and");
    418             break;
    419         case CALC_NOT:
    420             lstrcpy(name,"Not");
    421             break;
    422 
    423         case CALC_PE:
    424             lstrcpy(name,"<=");
    425             break;
    426         case CALC_QE:
    427             lstrcpy(name,">=");
    428             break;
    429         case CALC_NOTEQUAL:
    430             lstrcpy(name,"<>");
    431             break;
    432         case CALC_SUBSITUATION:
    433         case CALC_EQUAL:
    434             lstrcpy(name,"=");
    435             break;
    436         case CALC_P:
    437             lstrcpy(name,"<");
    438             break;
    439         case CALC_Q:
    440             lstrcpy(name,">");
    441             break;
    442 
    443         case CALC_SHL:
    444             lstrcpy(name,"<<");
    445             break;
    446         case CALC_SHR:
    447             lstrcpy(name,">>");
    448             break;
    449         case CALC_ADDITION:
    450             lstrcpy(name,"+");
    451             break;
    452         case CALC_SUBTRACTION:
    453             lstrcpy(name,"-");
    454             break;
    455         case CALC_MOD:
    456             lstrcpy(name,"mod");
    457             break;
    458         case CALC_PRODUCT:
    459             lstrcpy(name,"*");
    460             break;
    461         case CALC_QUOTIENT:
    462             lstrcpy(name,"/");
    463             break;
    464         case CALC_INTQUOTIENT:
    465             lstrcpy(name,"\\");
    466             break;
    467         case CALC_AS:
    468             lstrcpy(name,"As");
    469             break;
    470         case CALC_BYVAL:
    471             lstrcpy(name,"ByVal");
    472             break;
    473         case CALC_MINUSMARK:
    474             lstrcpy(name,"-");
    475             break;
    476         case CALC_POWER:
    477             lstrcpy(name,"^");
    478             break;
    479 
    480         case CALC_ARRAY_GET:
    481             lstrcpy(name,"[]");
    482             break;
    483         case CALC_ARRAY_SET:
    484             lstrcpy(name,"[]=");
    485             break;
    486     }
     411const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source )
     412{
     413    int maxLength = (int)source.size();
     414
     415    char *temporary = (char *)malloc( source.size() + 8192 );
     416    lstrcpy( temporary, source.c_str() );
     417
     418    for( int i=0; i<maxLength-1; i++ )
     419    {
     420        if( temporary[i] == 1 )
     421        {
     422            char temp2[255];
     423            GetDefaultNameFromES( temporary[i+1], temp2 );
     424            if( i>0 )
     425            {
     426                char temp3[255];
     427                wsprintf( temp3, " %s", temp2 );
     428                lstrcpy( temp2, temp3 );
     429            }
     430            if( i<maxLength-2 )
     431            {
     432                lstrcat( temp2, " " );
     433            }
     434
     435            int length = lstrlen( temp2 );
     436            SlideString( temporary + i+2, length-2 );
     437            memcpy( temporary + i, temp2, length );
     438            maxLength = lstrlen( temporary );
     439        }
     440    }
     441
     442    static std::string resultStr = "";
     443    resultStr = temporary;
     444
     445    free( temporary );
     446
     447    return resultStr;
    487448}
    488449
  • trunk/abdev/BasicCompiler_Common/Subroutine.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
    35
    46#include <Compiler.h>
    5 #include <ProcedureImpl.h>
     7#include <Procedure.h>
    68#include <NamespaceSupporter.h>
    79
     
    103105        /////////////////////
    104106
    105         UserProc *pUserProc = (UserProc *)pProc;
     107        const UserProc *pUserProc = (const UserProc *)pProc;
    106108
    107109        //オブジェクト名を取得
     
    115117        ////////////////////////
    116118
    117         std::vector<UserProc *> subs;
     119        std::vector<const UserProc *> subs;
    118120        GetOverloadSubHash(fullCallName,subs);
    119121        if(subs.size()){
     
    194196
    195197    //オーバーロード用の関数リストを作成
    196     std::vector<UserProc *> subs;
     198    std::vector<const UserProc *> subs;
    197199    GetOverloadSubHash(VarName,subs);
    198200    if(subs.size()==0){
     
    210212
    211213    //オーバーロードを解決
    212     UserProc *pUserProc;
    213     pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
     214    const UserProc *pUserProc = OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
    214215
    215216    if(pUserProc){
     
    238239
    239240    //オーバーロード用の関数リストを作成
    240     std::vector<UserProc *> subs;
     241    std::vector<const UserProc *> subs;
    241242    GetOverloadSubHash(VarName,subs);
    242243    if(subs.size()==0){
     
    254255
    255256    //オーバーロードを解決
    256     UserProc *pUserProc;
    257     pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
     257    const UserProc *pUserProc = OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName);
    258258
    259259    if(pUserProc){
     
    266266//インデクサ(getter)の戻り値を取得
    267267bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){
    268     vector<UserProc *> subs;
     268    vector<const UserProc *> subs;
    269269    objClass.GetMethods().Enum( CALC_ARRAY_GET, subs );
    270270    if( subs.size() == 0 ){
     
    369369
    370370    // オブジェクトを生成
    371     DllProc *pDllProc = new DllProcImpl( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );
     371    DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );
    372372
    373373    // パラメータを解析
     
    429429}
    430430
    431 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic){
    432     int i2,i3;
    433     char temporary[8192];
    434 
    435     int i=1;
    436 
    437     Procedure::Kind kind = Procedure::Sub;
    438     bool isMacro = false;
    439     if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
    440     if(buffer[i]==ESC_MACRO){
    441         isMacro = true;
    442     }
    443 
    444     i++;
    445 
    446     bool isCdecl = false;
    447     bool isExport = false;
    448     while(1){
    449         if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
    450             isCdecl = true;
    451 
    452             i+=2;
    453         }
    454         else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
    455             isExport = true;
    456 
    457             i+=2;
    458         }
    459         else break;
    460     }
    461 
    462     i2=0;
    463     if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
    464         if(!pobj_c){
    465             SetError(126,NULL,nowLine);
    466             return 0;
    467         }
    468 
    469         //オペレータの場合
    470         temporary[i2++]=buffer[i++];
    471         temporary[i2++]=buffer[i++];
    472 
    473         int iCalcId;
    474         if(buffer[i]=='='&&buffer[i+1]=='='){
    475             iCalcId=CALC_EQUAL;
    476             i3=2;
    477         }
    478         else if(buffer[i]=='='){
    479             iCalcId=CALC_SUBSITUATION;
    480             i3=1;
    481         }
    482         else if(buffer[i]=='('){
    483             iCalcId=CALC_AS;
    484             i3=0;
    485         }
    486         else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
    487             iCalcId=CALC_ARRAY_SET;
    488             i3=3;
    489         }
    490         else if(buffer[i]=='['&&buffer[i+1]==']'){
    491             iCalcId=CALC_ARRAY_GET;
    492             i3=2;
    493         }
    494         else{
    495             iCalcId=GetCalcId(buffer+i,&i3);
    496             i3++;
    497         }
    498         if(!iCalcId){
    499             SetError(1,NULL,nowLine);
    500             return 0;
    501         }
    502         temporary[i2++]=iCalcId;
    503         temporary[i2]=0;
    504 
    505         i+=i3;
    506     }
    507     else{
    508         if(pobj_c){
    509             //クラスメンバの場合、デストラクタには~が付くことを考慮
    510             if(buffer[i]=='~'){
    511                 temporary[i2]='~';
    512                 i++;
    513                 i2++;
    514             }
    515         }
    516 
    517         for(;;i++,i2++){
    518             if(!IsVariableChar(buffer[i])){
    519                 temporary[i2]=0;
    520                 break;
    521             }
    522             temporary[i2]=buffer[i];
    523         }
    524     }
    525 
    526     if( isMacro ){
    527         //大文字に変換
    528         CharUpper(temporary);
    529 
    530         //マクロ関数の場合は名前リストに追加
    531         extern char **ppMacroNames;
    532         extern int MacroNum;
    533         ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *));
    534         ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    535         lstrcpy(ppMacroNames[MacroNum],temporary);
    536         MacroNum++;
    537     }
    538 
    539     if(!pobj_c){
    540         //クラスメンバ以外の場合のみ
    541         //重複チェック
    542 
    543         if(GetDeclareHash(temporary)){
    544             SetError(15,temporary,nowLine);
    545             return 0;
    546         }
    547     }
    548 
    549     extern int SubNum;
    550     SubNum++;
    551 
    552     GlobalProc *pUserProc = new GlobalProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport );
    553     pUserProc->SetParentClass( pobj_c );
    554     if( Smoothie::isFullCompile ){
    555         // すべての関数・メソッドをコンパイルする
    556         pUserProc->Using();
    557     }
    558 
    559     //ID
    560     static int id_base=0;
    561     pUserProc->id = (id_base++);
    562 
    563     if(isExport){
    564         pUserProc->Using();
    565     }
    566 
    567     // パラメータを解析
    568     // ※第1パラメータにに指定するデータの例:"( s As String ) As String"
    569     pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
    570 
    571     pUserProc->_paramStr = buffer + i;
    572 
    573 
    574     /////////////////////////////////
    575     // ハッシュデータに追加
    576     /////////////////////////////////
    577 
    578     int key;
    579     key=hash_default(pUserProc->GetName().c_str());
    580 
    581     extern GlobalProc **ppSubHash;
    582     if(ppSubHash[key]){
    583         GlobalProc *psi2;
    584         psi2=ppSubHash[key];
    585         while(1){
    586             if(pobj_c==psi2->GetParentClassPtr()){
    587                 //重複エラーチェックを行う
    588                 if( pUserProc->IsEqualSymbol( *psi2 ) ){
    589                     if( psi2->Params().Equals( pUserProc->Params() ) ){
    590                         SetError(15,pUserProc->GetName().c_str(),nowLine);
    591                         return 0;
    592                     }
    593                 }
    594             }
    595 
    596             if(psi2->pNextData==0) break;
    597             psi2=psi2->pNextData;
    598         }
    599         psi2->pNextData=pUserProc;
    600     }
    601     else{
    602         ppSubHash[key]=pUserProc;
    603     }
    604 
    605     return pUserProc;
    606 }
    607 
    608 void GetSubInfo(void){  //サブルーチン情報を取得
     431void UserProcs::CollectUserProcs( const BasicSource &source, UserProcs &userProcs )
     432{
    609433    extern HANDLE hHeap;
    610     extern char *basbuf;
    611434    int i,i2,i3;
    612435    char temporary[8192];
     
    617440
    618441    //サブルーチン(ユーザー定義)情報を初期化
    619     extern GlobalProc **ppSubHash;
    620     extern int SubNum;
    621     ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *));
    622     SubNum=0;
    623 
    624     //マクロ関数の名前リストを初期化
    625     extern char **ppMacroNames;
    626     extern int MacroNum;
    627     ppMacroNames=(char **)HeapAlloc(hHeap,0,1);
    628     MacroNum=0;
     442    userProcs.Clear();
    629443
    630444    // 名前空間管理
     
    640454        i++;
    641455
    642         if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_INTERFACE)){
     456        if(source[i]==1&&(source[i+1]==ESC_CLASS||source[i+1]==ESC_INTERFACE)){
    643457            /*  Class ~ End Class
    644458                Interface ~ End Interface
    645459                を飛び越す           */
    646             i3=GetEndXXXCommand(basbuf[i+1]);
     460            i3=GetEndXXXCommand(source[i+1]);
    647461            for(i+=2,i2=0;;i++,i2++){
    648                 if(basbuf[i]=='\0') break;
    649                 if(basbuf[i]==1&&basbuf[i+1]==(char)i3){
     462                if(source[i]=='\0') break;
     463                if(source[i]==1&&source[i+1]==(char)i3){
    650464                    i++;
    651465                    break;
    652466                }
    653467            }
    654             if(basbuf[i]=='\0') break;
    655             continue;
    656         }
    657 
    658         if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
     468            if(source[i]=='\0') break;
     469            continue;
     470        }
     471
     472        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    659473            for(i+=2,i2=0;;i2++,i++){
    660                 if( IsCommandDelimitation( basbuf[i] ) ){
     474                if( IsCommandDelimitation( source[i] ) ){
    661475                    temporary[i2]=0;
    662476                    break;
    663477                }
    664                 temporary[i2]=basbuf[i];
     478                temporary[i2]=source[i];
    665479            }
    666480            namespaceScopes.push_back( temporary );
     
    668482            continue;
    669483        }
    670         else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
     484        else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
    671485            if( namespaceScopes.size() <= 0 ){
    672486                SetError(12, "End Namespace", i );
     
    679493            continue;
    680494        }
    681         else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){
     495        else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
    682496            for(i+=2,i2=0;;i2++,i++){
    683                 if( IsCommandDelimitation( basbuf[i] ) ){
     497                if( IsCommandDelimitation( source[i] ) ){
    684498                    temporary[i2]=0;
    685499                    break;
    686500                }
    687                 temporary[i2]=basbuf[i];
     501                temporary[i2]=source[i];
    688502            }
    689503            if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
     
    694508            continue;
    695509        }
    696         else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
     510        else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
    697511            importedNamespaces.clear();
    698512            continue;
    699513        }
    700514
    701         if(basbuf[i]==1&&basbuf[i+1]==ESC_DECLARE){
     515        if(source[i]==1&&source[i+1]==ESC_DECLARE){
    702516            for(i+=2,i2=0;;i2++,i++){
    703                 if(basbuf[i]=='\n'){
     517                if(source[i]=='\n'){
    704518                    temporary[i2]=0;
    705519                    break;
    706520                }
    707                 temporary[i2]=basbuf[i];
    708                 if(basbuf[i]=='\0') break;
     521                temporary[i2]=source[i];
     522                if(source[i]=='\0') break;
    709523            }
    710524            AddDeclareData(namespaceScopes,temporary,i);
     
    712526            continue;
    713527        }
    714         if(basbuf[i]==1&&(basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION||basbuf[i+1]==ESC_MACRO)){
    715             char statementChar = basbuf[i+1];
     528        if(source[i]==1&&(source[i+1]==ESC_SUB||source[i+1]==ESC_FUNCTION||source[i+1]==ESC_MACRO)){
     529            char statementChar = source[i+1];
    716530
    717531            for(i2=0;;i2++,i++){
    718                 if(IsCommandDelimitation(basbuf[i])){
     532                if(IsCommandDelimitation(source[i])){
    719533                    temporary[i2]=0;
    720534                    break;
    721535                }
    722                 temporary[i2]=basbuf[i];
    723                 if(basbuf[i]=='\0') break;
    724             }
    725             AddSubData(namespaceScopes, importedNamespaces, temporary,i,0,0);
     536                temporary[i2]=source[i];
     537                if(source[i]=='\0') break;
     538            }
     539            userProcs.Add(namespaceScopes, importedNamespaces, temporary,i,false,NULL,false);
    726540
    727541            /*  Sub ~ End Sub
     
    731545            char endStatementChar = GetEndXXXCommand( statementChar );
    732546            for(i2=0;;i++,i2++){
    733                 if( basbuf[i] == '\0' ) break;
    734                 if( basbuf[i] == 1 && basbuf[i+1] == endStatementChar ){
     547                if( source[i] == '\0' ) break;
     548                if( source[i] == 1 && source[i+1] == endStatementChar ){
    735549                    i++;
    736550                    break;
    737551                }
    738552            }
    739             if(basbuf[i]=='\0') break;
     553            if(source[i]=='\0') break;
    740554            continue;
    741555        }
     
    743557        //次の行
    744558        for(;;i++){
    745             if(IsCommandDelimitation(basbuf[i])) break;
    746         }
    747         if(basbuf[i]=='\0') break;
     559            if(IsCommandDelimitation(source[i])) break;
     560        }
     561        if(source[i]=='\0') break;
    748562    }
    749563
     
    755569
    756570    sprintf(temporary,"%c%c_allrem()",1,ESC_SUB);
    757     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     571    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    758572
    759573    sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB);
    760     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     574    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    761575
    762576    sprintf(temporary,"%c%c_allmul()",1,ESC_SUB);
    763     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     577    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    764578
    765579    sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB);
    766     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     580    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    767581
    768582    sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB);
    769     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     583    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    770584
    771585    sprintf(temporary,"%c%c_allshl()",1,ESC_SUB);
    772     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     586    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    773587
    774588    sprintf(temporary,"%c%c_allshr()",1,ESC_SUB);
    775     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     589    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    776590
    777591    sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB);
    778     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
     592    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    779593
    780594    sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB);
    781     AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    782 }
    783 void Delete_si(GlobalProc *pUserProc){
    784     if(pUserProc->pNextData) Delete_si(pUserProc->pNextData);
    785     delete pUserProc;
    786 }
    787 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum){    //サブルーチン情報のメモリ解放
    788     int i;
    789     for(i=0;i<MAX_HASH;i++){
    790         if(!ppSubHash[i]) continue;
    791 
    792         Delete_si(ppSubHash[i]);
    793     }
    794     HeapDefaultFree(ppSubHash);
    795 
    796     //マクロの名前リスト
    797     if(ppMacroNames){
    798         for(i=0;i<MacroNum;i++){
    799             HeapDefaultFree(ppMacroNames[i]);
    800         }
    801         HeapDefaultFree(ppMacroNames);
    802     }
     595    userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
    803596}
    804597void Delete_di(DllProc *pDllProc){
     
    820613
    821614bool IsNeedProcCompile(){
    822     for(int i2=0;i2<MAX_HASH;i2++){
    823         extern GlobalProc **ppSubHash;
    824         GlobalProc *pUserProc=ppSubHash[i2];
    825         while(pUserProc){
    826             if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
    827                 return true;
    828             }
    829 
    830             pUserProc=pUserProc->pNextData;
     615    compiler.GetMeta().GetUserProcs().Iterator_Reset();
     616    while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     617    {
     618        UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     619        if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
     620            return true;
    831621        }
    832622    }
  • trunk/abdev/BasicCompiler_Common/VarList.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
     4
     5#include <Compiler.h>
    26
    37#include "../BasicCompiler_Common/common.h"
     
    913HWND hVarTree_Global,hVarTree_Local,hVarTree_This;
    1014
    11 int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type,const int *SubScripts);
     15int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type,const Subscripts &subscripts);
    1216void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,const CClass &objClass,BOOL bPtr);
    1317void VarList_Insert(HWND hVarTree,TV_INSERTSTRUCT *lptv,const char *VarName,const Type &type,LONG_PTR offset){
     
    180184        offset=objClass.GetMemberOffset( pMember->GetName().c_str(), &i2 );
    181185
    182         if(pMember->SubScripts[0]!=-1){
     186        if( pMember->GetSubscripts().size() > 0 ){
    183187            //構造体内の配列
    184188            sprintf(VarData,"%s %s(&H%X)",VarName,STRING_ARRAY,pTopOffset+offset);
     
    187191            hParent=TreeView_InsertItem(hVarTree,&tv);
    188192
    189             VarList_Array(hVarTree,hParent,
    190                 pTopOffset+offset,
     193            VarList_Array(
     194                hVarTree,
     195                hParent,
     196                pTopOffset + offset,
    191197                pMember->GetType(),
    192                 pMember->SubScripts);
     198                pMember->GetSubscripts()
     199            );
    193200        }
    194201        else{
     
    202209    }
    203210}
    204 int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type,const int *SubScripts ){
     211int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type, const Subscripts &subscripts ){
    205212    int i,i2,i3,ElementNum,MemCounter,UseCount[255];
    206213    char temporary[VN_SIZE],temp2[DIGIT_SIZE];
     
    213220    tv.item.pszText=temporary;
    214221
    215     for(i=0;i<255;i++){
    216         if(SubScripts[i]==-1) break;
     222    for(i=0;i<(int)subscripts.size();i++){
    217223        UseCount[i]=0;
    218224    }
     
    221227    while(1){
    222228        UseCount[i]++;
    223         for(ElementNum=0;SubScripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){
     229        for(ElementNum=0;subscripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){
    224230            UseCount[i-ElementNum]=0;
    225231            if(i-ElementNum-1<0) return MemCounter;
     
    268274    extern int MemPos_RWSection;
    269275
    270     BOOST_FOREACH( Variable *pVar, globalVars ){
     276    BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
    271277
    272278        //スコープ外の場合は無視
    273         if(pVar->ScopeLevel!=0){
    274             if(rva_to_real(pVar->ScopeStartAddress) <= pobj_dti->lplpObp[0]  &&
    275                 pobj_dti->lplpObp[0] < rva_to_real(pVar->ScopeEndAddress)){
     279        if(pVar->GetScopeLevel()!=0){
     280            if(rva_to_real(pVar->GetScopeStartAddress()) <= pobj_dti->lplpObp[0]  &&
     281                pobj_dti->lplpObp[0] < rva_to_real(pVar->GetScopeEndAddress())){
    276282                //範囲内
    277283            }
     
    304310                pVar->GetName().c_str(),
    305311                STRING_ARRAY,
    306                 ImageBase+MemPos_RWSection+pVar->offset);
     312                ImageBase+MemPos_RWSection+pVar->GetOffsetAddress());
    307313            tv.item.iImage=0;
    308314            tv.item.iSelectedImage=0;
    309315            hParent=TreeView_InsertItem(hVarTree_Global,&tv);
    310316
    311             VarList_Array(hVarTree_Global,hParent,
    312                 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->offset),
    313                 *pVar,
    314                 pVar->GetSubScriptsPtr());
     317            VarList_Array(
     318                hVarTree_Global,
     319                hParent,
     320                (LONG_PTR)(ImageBase+MemPos_RWSection + pVar->GetOffsetAddress()),
     321                pVar->GetType(),
     322                pVar->GetSubscripts()
     323            );
    315324        }
    316325        else{
     
    318327                &tv,
    319328                pVar->GetName().c_str(),
    320                 *pVar,
    321                 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->offset));
     329                pVar->GetType(),
     330                (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->GetOffsetAddress()));
    322331        }
    323332    }
    324333}
    325334void RefreshLocalVar(void){
    326     int i2,i3,sw;
     335    int i2;
    327336    char temporary[VN_SIZE];
    328337    TV_INSERTSTRUCT tv;
     
    347356    if(pobj_dti->lplpSpBase[i2]==0) return;
    348357
    349     extern GlobalProc **ppSubHash;
    350     GlobalProc *pUserProc;
    351     for(i3=0,sw=0;i3<MAX_HASH;i3++){
    352         pUserProc=ppSubHash[i3];
    353         while(pUserProc){
    354             if(rva_to_real(pUserProc->beginOpAddress) <= pobj_dti->lplpObp[i2]  &&
    355                 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->endOpAddress)){
    356                 sw=1;
    357                 break;
    358             }
    359 
    360             pUserProc=pUserProc->pNextData;
    361         }
    362         if(sw) break;
     358    UserProc *pUserProc = NULL;
     359    compiler.GetMeta().GetUserProcs().Iterator_Reset();
     360    while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     361    {
     362        pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     363        if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2]  &&
     364            pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
     365            break;
     366        }
    363367    }
    364368    if(!pUserProc) return;
    365369
    366     BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){
     370    BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
    367371
    368372        //スコープ外の場合は無視
    369         if(pVar->ScopeLevel!=0){
    370             if(rva_to_real(pVar->ScopeStartAddress) <= pobj_dti->lplpObp[i2]  &&
    371                 pobj_dti->lplpObp[i2] < rva_to_real(pVar->ScopeEndAddress)){
     373        if(pVar->GetScopeLevel()!=0){
     374            if(rva_to_real(pVar->GetScopeStartAddress()) <= pobj_dti->lplpObp[i2]  &&
     375                pobj_dti->lplpObp[i2] < rva_to_real(pVar->GetScopeEndAddress())){
    372376                //範囲内
    373377            }
     
    382386                pVar->GetName().c_str(),
    383387                STRING_ARRAY,
    384                 pobj_dti->lplpSpBase[i2]+pVar->offset);
     388                pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress());
    385389            tv.item.iImage=0;
    386390            tv.item.iSelectedImage=0;
    387391            hParent=TreeView_InsertItem(hVarTree_Local,&tv);
    388392
    389             VarList_Array(hVarTree_Local,hParent,
    390                 pobj_dti->lplpSpBase[i2]+pVar->offset,
    391                 *pVar,
    392                 pVar->GetSubScriptsPtr());
     393            VarList_Array(
     394                hVarTree_Local,
     395                hParent,
     396                pobj_dti->lplpSpBase[i2] + pVar->GetOffsetAddress(),
     397                pVar->GetType(),
     398                pVar->GetSubscripts()
     399            );
    393400        }
    394401        else{
    395             offset=pobj_dti->lplpSpBase[i2]+pVar->offset;
     402            offset=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress();
    396403            if(pVar->IsRef()){
    397404                ReadProcessMemory(hDebugProcess,(void *)offset,&lpData,sizeof(LONG_PTR),&accessBytes);
     
    400407            VarList_Insert(hVarTree_Local,&tv,
    401408                pVar->GetName().c_str(),
    402                 *pVar,
     409                pVar->GetType(),
    403410                offset);
    404411        }
     
    416423    //Thisポインタを取得
    417424    LONG_PTR pThis;
    418     const Variable *pVar = pUserProc->localVars.Find( Symbol( "_System_LocalThis" ) );
     425    const Variable *pVar = pUserProc->GetLocalVars().Find( Symbol( "_System_LocalThis" ) );
    419426    if( !pVar ){
    420427        return;
    421428    }
    422     lpData=pobj_dti->lplpSpBase[i2]+pVar->offset;
     429    lpData=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress();
    423430    ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&accessBytes);
    424431
     
    426433        offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pMember->GetName().c_str(),&i2);
    427434
    428         if(pMember->SubScripts[0]!=-1){
     435        if( pMember->GetSubscripts().size() > 0 ){
    429436            //配列
    430437            sprintf(temporary,"%s %s(&H%X)",
     
    436443            hParent=TreeView_InsertItem(hVarTree_This,&tv);
    437444
    438             VarList_Array(hVarTree_This,hParent,
    439                 pThis+offset,
     445            VarList_Array(
     446                hVarTree_This,
     447                hParent,
     448                pThis + offset,
    440449                pMember->GetType(),
    441                 pMember->SubScripts);
     450                pMember->GetSubscripts()
     451            );
    442452        }
    443453        else{
     
    590600
    591601    //プロシージャ コンボボックス
    592     extern GlobalProc **ppSubHash;
    593     GlobalProc *pUserProc;
    594     int sw;
    595602    SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
    596603    for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
    597         for(i3=0,sw=0;i3<MAX_HASH;i3++){
    598             pUserProc=ppSubHash[i3];
    599             while(pUserProc){
    600                 if(rva_to_real(pUserProc->beginOpAddress) <= pobj_dti->lplpObp[i2]  &&
    601                     pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->endOpAddress)){
    602                         lstrcpy(temporary,pUserProc->GetName().c_str());
    603                         sw=1;
    604                         break;
    605                 }
    606                 pUserProc=pUserProc->pNextData;
    607             }
    608             if(sw) break;
     604
     605        UserProc *pUserProc = NULL;
     606        compiler.GetMeta().GetUserProcs().Iterator_Reset();
     607        while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     608        {
     609            pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     610
     611            if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2]  &&
     612                pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()))
     613            {
     614                lstrcpy(temporary,pUserProc->GetName().c_str());
     615                break;
     616            }
    609617        }
    610618        if(!pUserProc){
     
    675683void InitVarList(DWORD dwThreadId){
    676684    extern HWND hDebugWnd;
    677     int i2,i3,i5;
     685    int i2,i5;
    678686    char temporary[255];
    679687
     
    703711    ///////////////////////////////////////////////
    704712
    705     int sw;
    706 
    707713    i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
    708714    i2=pobj_dti->iProcLevel-i2;
    709715
    710716    if(pobj_dti->lplpSpBase[i2]){
    711         extern GlobalProc **ppSubHash;
    712         GlobalProc *pUserProc;
    713         for(i3=0,sw=0;i3<MAX_HASH;i3++){
    714             pUserProc=ppSubHash[i3];
    715             while(pUserProc){
    716                 if(rva_to_real(pUserProc->beginOpAddress) <= pobj_dti->lplpObp[i2]  &&
    717                     pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->endOpAddress)){
    718                     sw=1;
    719                     break;
    720                 }
    721 
    722                 pUserProc=pUserProc->pNextData;
    723             }
    724             if(sw) break;
    725         }
    726 
     717
     718        UserProc *pUserProc = NULL;
     719        compiler.GetMeta().GetUserProcs().Iterator_Reset();
     720        while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() )
     721        {
     722            pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext();
     723
     724            if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2]  &&
     725                pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
     726                break;
     727            }
     728        }
    727729
    728730        if(pUserProc){
    729             Smoothie::Temp::pCompilingClass = pUserProc->GetParentClassPtr();
     731            compiler.pCompilingClass = pUserProc->GetParentClassPtr();
    730732            UserProc::CompileStartForUserProc( pUserProc );
    731733        }
  • trunk/abdev/BasicCompiler_Common/VariableOpe.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24#include <jenga/include/smoothie/LexicalAnalysis.h>
     
    46#include <Compiler.h>
    57#include <LexicalScopingImpl.h>
    6 #include <VariableImpl.h>
     8#include <Variable.h>
    79#include <NamespaceSupporter.h>
    810
     
    247249
    248250
    249 void GetArrange(char *variable,char *variAnswer,int *SubScripts){
     251void GetArrange(char *variable,char *variAnswer, Subscripts &subscripts ){
    250252    extern int cp;
    251     int i,i2,i3,i4;
     253    int i,i2,i4;
    252254    double dbl;
    253255    _int64 i64data;
     
    261263
    262264            variAnswer[i]=0;
    263             for(i++,i2=0,i3=0;;i++,i2++){
     265            for(i++,i2=0;;i++,i2++){
    264266                if(variable[i]==','){
    265267                    temporary[i2]=0;
     
    274276                    }
    275277
    276                     if(i64data<0){
     278                    if(i64data<0)
     279                    {
    277280                        //error
    278                         SubScripts[i3]=0;
     281                        subscripts.push_back( 0 );
    279282                    }
    280                     else SubScripts[i3]=(int)i64data;
    281                     i3++;
     283                    else
     284                    {
     285                        subscripts.push_back( (int)i64data );
     286                    }
    282287                    i2=-1;
    283288                    continue;
     
    299304                    temporary[i2]=0;
    300305                    if(i2==0){
    301                         SubScripts[i3]=-2;
     306                        subscripts.push_back( -2 );
    302307                        break;
    303308                    }
     
    314319                    if(i64data<0){
    315320                        //error
    316                         SubScripts[i3]=0;
     321                        subscripts.push_back( 0 );
    317322                    }
    318                     else SubScripts[i3]=(int)i64data;
    319                     SubScripts[i3+1]=-1;
     323                    else
     324                    {
     325                        subscripts.push_back( (int)i64data );
     326                    }
    320327                    break;
    321328                }
     
    330337        variAnswer[i]=variable[i];
    331338        if(variable[i]=='\0'){
    332             SubScripts[0]=-1;
    333339            break;
    334340        }
     
    337343
    338344
    339 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember,CClass::RefType &refType){
     345BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember,ReferenceKind &refType){
    340346    extern int cp;
    341347    int i,i2,i3;
     
    403409        if(buffer[i]=='.'){
    404410            lstrcpy(NestMember,buffer+i+1);
    405             refType = CClass::Dot;
     411            refType = RefDot;
    406412            buffer[i]=0;
    407413            break;
     
    409415        if(buffer[i]==1&&buffer[i+1]==ESC_PSMEM){
    410416            lstrcpy(NestMember,buffer+i+2);
    411             refType = CClass::Pointer;
     417            refType = RefPointer;
    412418            buffer[i]=0;
    413419            break;
     
    459465}
    460466
    461 int JumpSubScripts(const int *ss){
     467int JumpSubScripts( const Subscripts &subscripts ){
    462468    //DIMで定義された並んだ配列の数だけアドレスを進める
    463     int i,i2;
    464     for(i=0,i2=1;i<255;i++){
    465         if(ss[i]==-1) break;
    466         i2*=ss[i]+1;
     469    int i, i2;
     470    for( i=0,i2=1; i<(int)subscripts.size(); i++ ){
     471        i2 *= subscripts[i] + 1;
    467472    }
    468473    return i2;
     
    478483    char lpPtrOffset[VN_SIZE];      //第2次配列
    479484    char NestMember[VN_SIZE];   //入れ子メンバ
    480     CClass::RefType refType = CClass::Non;
     485    ReferenceKind refType = RefNon;
    481486    lstrcpy(VarName,lpszMember);
    482487    if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false;
     
    496501
    497502    //アクセシビリティをチェック
    498     if( &objClass == Smoothie::Temp::pCompilingClass ){
     503    if( &objClass == compiler.pCompilingClass ){
    499504        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    500505        if( pMember->IsNoneAccess() ){
     
    519524    //ポインタ変数の場合
    520525    if( resultType.IsPointer() ){
    521         if(pMember->SubScripts[0]==-1){
     526        if( pMember->GetSubscripts().size() == 0 ){
    522527            lstrcpy(lpPtrOffset,array);
    523528            array[0]=0;
     
    531536    }
    532537
    533     if( refType != CClass::Non ){
     538    if( refType != RefNon ){
    534539        //入れ子構造の場合
    535540
     
    541546    }
    542547
    543     if(array[0]==0&&pMember->SubScripts[0]!=-1){
     548    if( array[0] == 0 && pMember->GetSubscripts().size() > 0 ){
    544549        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    545550        return true;
     
    573578
    574579    // 先頭オブジェクトまたはクラス名と入れ子メンバに分割
    575     CClass::RefType refType;
     580    ReferenceKind refType;
    576581    char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE];
    577582    GetVarFormatString(simpleName,array,lpPtrOffset,member,refType);
     
    587592
    588593    const Variable *pVar = NULL;
    589     const int *pSubScripts;
    590594
    591595    if( UserProc::IsLocalAreaCompiling() ){
     
    594598        /////////////////
    595599
    596         pVar = UserProc::CompilingUserProc().localVars.BackSearch( Symbol( VarName ) );
     600        pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) );
    597601        if( pVar ){
    598602            goto ok;
     
    600604    }
    601605
    602     if(Smoothie::Temp::pCompilingClass){
     606    if(compiler.pCompilingClass){
    603607        ///////////////////////
    604608        // クラスメンバの参照
     
    607611        if(lstrcmpi(variable,"This")==0){
    608612            //Thisオブジェクト
    609             resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );
     613            resultType.SetType( DEF_OBJECT, compiler.pCompilingClass );
    610614            return true;
    611615        }
     
    620624
    621625            bool isFound = false;
    622             BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){
     626            BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){
    623627                if( pMember->GetName() == VarName ){
    624628                    isFound = true;
     
    629633        }
    630634
    631         return GetMemberType(*Smoothie::Temp::pCompilingClass,variable,resultType,1,isErrorEnabled);
     635        return GetMemberType(*compiler.pCompilingClass,variable,resultType,1,isErrorEnabled);
    632636    }
    633637
     
    643647        GetNowStaticVarFullName(VarName,temporary);
    644648
    645         pVar = globalVars.Find( Symbol( temporary ) );
     649        pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) );
    646650        if( pVar ){
    647651            goto ok;
     
    659663        char tempArray[VN_SIZE];
    660664        {
    661             CClass::RefType refType;
     665            ReferenceKind refType;
    662666            GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember,refType);
    663667        }
     
    672676        sprintf(temp2,"%s.%s",VarName,temporary);
    673677
    674         pVar = globalVars.Find( Symbol( temp2 ) );
     678        pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
    675679        if( pVar ){
    676680            lstrcpy(member,tempMember);
     
    680684    }
    681685
    682     if(Smoothie::Temp::pCompilingClass){
     686    if(compiler.pCompilingClass){
    683687        //自身のクラスから静的メンバを参照する場合
    684688        char temp2[VN_SIZE];
    685         sprintf(temp2,"%s.%s",Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);
    686 
    687         pVar = globalVars.Find( Symbol( temp2 ) );
     689        sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName);
     690
     691        pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) );
    688692        if( pVar ){
    689693            goto ok;
     
    696700    ////////////////////
    697701
    698     pVar = globalVars.BackSearch( Symbol( VarName ) );
     702    pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) );
    699703    if( pVar ){
    700704        goto ok;
     
    708712
    709713    //ポインタ変数の場合
    710     if( pVar->IsPointer() ){
     714    if( pVar->GetType().IsPointer() ){
    711715        if( !pVar->IsArray() ){
    712716            lstrcpy(lpPtrOffset,array);
     
    721725    }
    722726
    723     resultType = (*pVar);
    724     pSubScripts=pVar->GetSubScriptsPtr();
    725 
     727    resultType = pVar->GetType();
    726728
    727729    if(member[0]){
     
    732734    }
    733735
    734     if(array[0]==0&&pSubScripts[0]!=-1){
     736    if( array[0] == 0 && pVar->GetSubscripts().size() > 0 ){
    735737        //配列の先頭ポインタを示す場合
    736738        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
     
    751753}
    752754
    753 bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss ){
     755bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){
    754756    //読み取り専用で変数へアクセス
    755757    return GetVarOffset(
     
    759761        pRelativeVar,
    760762        resultType,
    761         pss);
    762 }
    763 bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss ){
     763        pResultSubscripts
     764    );
     765}
     766bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){
    764767    //読み書き両用で変数へアクセス
    765768    return GetVarOffset(
     
    769772        pRelativeVar,
    770773        resultType,
    771         pss);
     774        pResultSubscripts
     775    );
    772776}
    773777
     
    776780bool GetDimentionFormat( const char *buffer,
    777781                        char *VarName,
    778                         int *SubScripts,
     782                        Subscripts &subscripts,
    779783                        Type &type,
    780784                        char *InitBuf,
     
    924928    }
    925929
    926     GetArrange(variable,VarName,SubScripts);
     930    GetArrange(variable,VarName,subscripts);
    927931    return true;
    928932}
     
    934938    }
    935939
    936     UserProc &proc = UserProc::CompilingUserProc();
     940    const UserProc &proc = UserProc::CompilingUserProc();
    937941
    938942    //Static識別
     
    940944
    941945    //クラス名
    942     if(Smoothie::Temp::pCompilingClass){
    943         lstrcat(FullName,Smoothie::Temp::pCompilingClass->GetName().c_str());
     946    if(compiler.pCompilingClass){
     947        lstrcat(FullName,compiler.pCompilingClass->GetName().c_str());
    944948        lstrcat(FullName,"%");
    945949    }
     
    951955    //ID
    952956    char temp[255];
    953     sprintf(temp,"%x",proc.id);
     957    sprintf(temp,"%x",proc.GetId());
    954958    lstrcat(FullName,temp);
    955959    lstrcat(FullName,"%");
     
    962966
    963967
    964 void AddGlobalVariable( const char *name,int *SubScripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag){
     968void AddGlobalVariable( const char *name, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag){
    965969    /////////////////////////
    966970    // グローバル変数を追加
     
    969973    extern int AllGlobalVarSize;
    970974
    971     if( globalVars.DuplicateCheck( Symbol( name ) ) ){
     975    if( compiler.GetMeta().GetGlobalVars().DuplicateCheck( Symbol( name ) ) ){
    972976        //2重定義のエラー
    973977        SetError(15,name,cp);
     
    977981    bool isConst = ( dwFlag & DIMFLAG_CONST ) ? true:false;
    978982
    979     Variable *pVar = new VariableImpl( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(), name, type, isConst );
    980 
    981     if( SubScripts[0] != -1 ){
     983    Variable *pVar = new Variable( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(), name, type, isConst, false, ConstractParameter );
     984
     985    if( subscripts.size() > 0 ){
    982986        //配列あり
    983         pVar->SetArray( SubScripts );
    984     }
    985 
    986     //コンストラクタ用パラメータ
    987     pVar->paramStrForConstructor = ConstractParameter;
     987        pVar->SetArray( subscripts );
     988    }
    988989
    989990    //レキシカルスコープ
    990     pVar->ScopeLevel=GetLexicalScopes().GetNowLevel();
    991     pVar->ScopeStartAddress=GetLexicalScopes().GetStartAddress();
     991    pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );
     992    pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );
    992993    pVar->bLiving=TRUE;
    993994
     
    996997
    997998    // 変数を追加
    998     globalVars.push_back( pVar );
     999    compiler.GetMeta().GetGlobalVars().push_back( pVar );
    9991000
    10001001    //アラインメントを考慮
    10011002    int alignment = 0;
    1002     if( pVar->IsStruct() ){
    1003         alignment = pVar->GetClass().iAlign;
     1003    if( pVar->GetType().IsStruct() ){
     1004        alignment = pVar->GetType().GetClass().iAlign;
    10041005    }
    10051006
     
    10131014        }
    10141015
    1015         pVar->offset=AllInitGlobalVarSize;
     1016        pVar->SetOffsetAddress( AllInitGlobalVarSize );
    10161017        AllInitGlobalVarSize += pVar->GetMemorySize();
    10171018    }
     
    10251026        }
    10261027
    1027         pVar->offset=AllGlobalVarSize | 0x80000000;
     1028        pVar->SetOffsetAddress( AllGlobalVarSize | 0x80000000 );
    10281029        AllGlobalVarSize += pVar->GetMemorySize();
    10291030    }
     
    10311032    if(InitBuf[0]){
    10321033        int result = 0;
    1033         if( !pVar->IsObject() ){
     1034        if( !pVar->GetType().IsObject() ){
    10341035            //初期バッファにデータをセット
    10351036            extern BYTE *initGlobalBuf;
     
    10391040                AllInitGlobalVarSize);
    10401041
    1041             result = SetInitGlobalData(pVar->offset,
    1042                 *pVar,
    1043                 pVar->GetSubScriptsPtr(),
     1042            result = SetInitGlobalData(pVar->GetOffsetAddress(),
     1043                pVar->GetType(),
     1044                pVar->GetSubscripts(),
    10441045                InitBuf);
    10451046        }
     
    10701071        const CMethod *method = type.GetClass().GetDestructorMethod();
    10711072        if( method ){
    1072             method->pUserProc->Using();
     1073            method->GetUserProc().Using();
    10731074        }
    10741075    }
     
    11041105
    11051106        //定数と2重定義されていないる場合は抜け出す
    1106         if(CDBConst::obj.GetBasicType(VarName)){
     1107        if(compiler.GetMeta().GetGlobalConsts().GetBasicType(VarName)){
    11071108            return;
    11081109        }
    11091110
    11101111        //定数マクロとして定義されている場合は抜け出す
    1111         if(GetConstHash(VarName)){
     1112        if( compiler.GetMeta().GetGlobalConstMacros().IsExist( VarName ) )
     1113        {
    11121114            return;
    11131115        }
     
    11151117
    11161118    //構文を解析
    1117     int SubScripts[MAX_ARRAYDIM];
    11181119    Type type;
    11191120    char InitBuf[8192];
    11201121    char ConstractParameter[VN_SIZE];
    1121     if(!GetDimentionFormat(Parameter, VarName,SubScripts,type,InitBuf,ConstractParameter))
     1122    Subscripts subscripts;
     1123    if(!GetDimentionFormat(Parameter, VarName,subscripts,type,InitBuf,ConstractParameter))
    11221124        return;
    11231125
    11241126
    11251127    //定数と2重定義されていないかを調べる
    1126     if(CDBConst::obj.GetBasicType(VarName)){
     1128    if(compiler.GetMeta().GetGlobalConsts().GetBasicType(VarName)){
    11271129        SetError(15,VarName,cp);
    11281130        return;
     
    11301132
    11311133    //定数マクロとして定義されている場合
    1132     if(GetConstHash(VarName)){
     1134    if( compiler.GetMeta().GetGlobalConstMacros().IsExist( VarName ) ){
    11331135        SetError(15,VarName,cp);
    11341136        return;
     
    11651167        GetNowStaticVarFullName(VarName,temporary);
    11661168
    1167         dim( temporary,SubScripts,type,InitBuf,ConstractParameter,dwFlags );
     1169        dim( temporary,subscripts,type,InitBuf,ConstractParameter,dwFlags );
    11681170
    11691171        /*
     
    11731175    }
    11741176    else{
    1175         dim( VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags );
     1177        dim( VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags );
    11761178    }
    11771179}
  • trunk/abdev/BasicCompiler_Common/VariableOpe.h

    r193 r206  
     1#pragma once
    12
     3#include <jenga/include/smoothie/LexicalAnalysis.h>
     4
     5class Type;
     6class CClass;
    27
    38BOOL IsPtrType(int type);
     
    1419Type GetStringTypeInfo();
    1520void GetWithName(char *buffer);
    16 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember, CClass::RefType &refType );
     21BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember, ReferenceKind &refType );
    1722void GetArrayElement( const char *buffer,char *variable,char *array_element);
    1823BOOL CheckVarNameError(char *name,int nowLine);
    19 int JumpSubScripts(const int *ss);
     24int JumpSubScripts( const Subscripts &subscripts );
    2025bool GetMemberType( const CClass &objClass, const char *lpszMember, Type &resultType, BOOL bPrivateAccess, bool isErrorEnabled);
    2126bool GetVarType( const char *nameBuffer, Type &resultType, bool isError);
    22 bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = NULL );
    23 bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = NULL );
     27bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
     28bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
    2429bool GetDimentionFormat( const char *buffer,
    2530                        char *VarName,
    26                         int *SubScripts,
     31                        Subscripts &subscripts,
    2732                        Type &type,
    2833                        char *InitBuf,
    2934                        char *ConstractParameter );
    3035BOOL GetNowStaticVarFullName(char *VarName,char *FullName);
    31 void AddGlobalVariable( const char *name,int *SubScripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag);
     36void AddGlobalVariable( const char *name, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag);
    3237void dim(char *Parameter,DWORD dwFlags);
    3338void OpcodeDim(char *Parameter,DWORD dwFlags);
  • trunk/abdev/BasicCompiler_Common/WatchList.cpp

    r182 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
     4
     5#include <Compiler.h>
    26
    37#include "common.h"
     
    1216#include "debug.h"
    1317
    14 int Debugging_GetArray( const int *SubScripts,char *array,const Type &type,LONG_PTR *plpOffset);
     18int Debugging_GetArray( const Subscripts &subscripts,char *array,const Type &type,LONG_PTR *plpOffset);
    1519
    1620ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar){
     
    117121    char lpPtrOffset[VN_SIZE];  //第2次配列
    118122    char NestMember[VN_SIZE];   //入れ子メンバ
    119     CClass::RefType refType;
     123    ReferenceKind refType;
    120124    lstrcpy(VarName,member);
    121125    if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember, refType ) ) return 0;
     
    145149    //ポインタ変数の場合
    146150    if( resultType.IsPointer() ){
    147         if(pMember->SubScripts[0]==-1){
     151        if( pMember->GetSubscripts().size() == 0 ){
    148152            lstrcpy(lpPtrOffset,array);
    149153            array[0]=0;
     
    159163        //配列オフセット
    160164        i2=Debugging_GetArray(
    161             pMember->SubScripts,
     165            pMember->GetSubscripts(),
    162166            array,
    163167            resultType,
     
    172176        }
    173177    }
    174     else if(pMember->SubScripts[0]!=-1){
     178    else if( pMember->GetSubscripts().size() > 0 ){
    175179        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    176180    }
     
    180184
    181185        if( resultType.IsObject() || resultType.IsStruct() ){
    182             if( refType != CClass::Dot ) return 0;
     186            if( refType != RefDot ) return 0;
    183187
    184188            if( resultType.IsObject() ){
     
    195199
    196200            if(lpPtrOffset[0]){
    197                 if( refType != CClass::Dot ) return 0;
     201                if( refType != RefDot ) return 0;
    198202
    199203                //直接参照に切り替え
     
    203207            }
    204208            else{
    205                 if( refType != CClass::Pointer ) return 0;
     209                if( refType != RefPointer ) return 0;
    206210
    207211                extern HANDLE hDebugProcess;
     
    235239    return 1;
    236240}
    237 int Debugging_GetArray( const int *SubScripts,char *array,const Type &type,LONG_PTR *plpOffset){
     241int Debugging_GetArray( const Subscripts &subscripts,char *array,const Type &type,LONG_PTR *plpOffset){
    238242    extern HANDLE hHeap;
    239243    int i,i2,i3,i4,i5,array_offset;
     
    254258        }
    255259        if(array[i]==','||array[i]=='\0'){
    256             if(SubScripts[i3]==-1){
     260            if( i3 >= (int)subscripts.size() )
     261            {
    257262                for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
    258263                return 0;
     
    267272
    268273            if(array[i]=='\0'){
    269                 if(SubScripts[i3]!=-1){
     274                if( i3 < (int)subscripts.size() )
     275                {
    270276                    for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
    271277                    return 0;
     
    302308        i5=(int)i64data;
    303309
    304         for(i2=i+1,i4=1;i2<i3;i2++) i4*=SubScripts[i2]+1;
     310        for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1;
    305311
    306312        array_offset+=i5*i4;
     
    316322}
    317323ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){
    318     GlobalProc *pUserProc = GetSubFromObp(obp_Rip);
    319 
    320     BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){
     324    UserProc *pUserProc = GetSubFromObp(obp_Rip);
     325
     326    BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
    321327        if( pVar->GetName() == "_System_LocalThis" ){
    322             return pVar->offset;
     328            return pVar->GetOffsetAddress();
    323329        }
    324330    }
    325331    return 0;
    326332}
    327 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, int *pss){
     333int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts){
    328334    extern HANDLE hDebugProcess;
    329335    int i2,i3;
     
    333339
    334340    lstrcpy(VarName,variable);
    335     CClass::RefType refType;
     341    ReferenceKind refType;
    336342    GetVarFormatString(VarName,array,lpPtrOffset,member,refType);
    337343
    338     const int *pSubScripts;
     344    const Subscripts *pSubscripts;
    339345    bool isArray;
    340346
     
    344350    /////////////////
    345351    if( UserProc::IsLocalAreaCompiling() ){
    346         const Variable *pVar = UserProc::CompilingUserProc().localVars.Find( Symbol( VarName ) );
     352        const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().Find( Symbol( VarName ) );
    347353
    348354        if( pVar ){
    349355            //ポインタ変数の場合
    350             if( pVar->IsPointer() ){
     356            if( pVar->GetType().IsPointer() ){
    351357                if( !pVar->IsArray() ){
    352358                    lstrcpy(lpPtrOffset,array);
     
    358364            }
    359365
    360             pRelativeVar->offset = pVar->offset;
     366            pRelativeVar->offset = pVar->GetOffsetAddress();
    361367            if( pVar->IsRef() ){
    362368                pRelativeVar->dwKind=VAR_REFLOCAL;
     
    365371                pRelativeVar->dwKind=VAR_LOCAL;
    366372            }
    367             resultType = *pVar;
     373            resultType = pVar->GetType();
    368374            isArray = pVar->IsArray();
    369             pSubScripts = pVar->GetSubScriptsPtr();
    370         }
    371     }
    372 
    373     if(Smoothie::Temp::pCompilingClass){
     375            pSubscripts = &pVar->GetSubscripts();
     376        }
     377    }
     378
     379    if(compiler.pCompilingClass){
    374380        ///////////////////////
    375381        // クラスメンバの参照
     
    385391
    386392            bool isFound = false;
    387             BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){
     393            BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){
    388394                if( pMember->GetName() == VarName ){
    389395                    isFound = true;
     
    414420        pRelativeVar->dwKind=VAR_DIRECTMEM;
    415421
    416         i3=Debugging_GetMember(*Smoothie::Temp::pCompilingClass,variable,pRelativeVar,resultType,1);
     422        i3=Debugging_GetMember(*compiler.pCompilingClass,variable,pRelativeVar,resultType,1);
    417423        if(i3==0){
    418424            //式エラー
     
    434440        ///////////////////
    435441
    436         const Variable *pVar = globalVars.Find( VarName );
     442        const Variable *pVar = compiler.GetMeta().GetGlobalVars().Find( VarName );
    437443        if( !pVar ){
    438444            //一致しないとき
     
    441447
    442448        //ポインタ変数の場合
    443         if( pVar->IsPointer() ){
     449        if( pVar->GetType().IsPointer() ){
    444450            if( !pVar->IsArray() ){
    445451                lstrcpy(lpPtrOffset,array);
     
    451457        }
    452458
    453         pRelativeVar->offset=pVar->offset;
     459        pRelativeVar->offset=pVar->GetOffsetAddress();
    454460        if(pVar->IsRef()) pRelativeVar->dwKind=VAR_REFGLOBAL;
    455461        else pRelativeVar->dwKind=VAR_GLOBAL;
    456         resultType = *pVar;
     462        resultType = pVar->GetType();
    457463        isArray = pVar->IsArray();
    458         pSubScripts=pVar->GetSubScriptsPtr();
     464        pSubscripts = &pVar->GetSubscripts();
    459465    }
    460466
     
    463469        //配列の先頭ポインタを示す場合
    464470        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    465         if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM*sizeof(int));
     471        if( pResultSubscripts )
     472        {
     473            (*pResultSubscripts) = *pSubscripts;
     474        }
    466475        return 1;
    467476    }
    468477
    469478    if(array[0]){
    470         i3=Debugging_GetArray(pSubScripts,array,resultType,&pRelativeVar->offset);
     479        i3=Debugging_GetArray( *pSubscripts, array,resultType,&pRelativeVar->offset);
    471480        if(i3==0){
    472481            //式エラー
     
    481490        if( resultType.IsObject() || resultType.IsStruct() ){
    482491            //実態オブジェクトのメンバを参照(obj.member)
    483             if( refType != CClass::Dot ){
     492            if( refType != RefDot ){
    484493                return 0;
    485494            }
     
    499508            if(lpPtrOffset[0]){
    500509                //pObj[n].member
    501                 if( refType != CClass::Dot ) return 0;
     510                if( refType != RefDot ) return 0;
    502511                Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset);
    503512
     
    514523            else{
    515524                //pObj->member
    516                 if( refType != CClass::Pointer ) return 0;
     525                if( refType != RefPointer ) return 0;
    517526
    518527                pRelativeVar->offset=Debugging_GetVarPtr(pRelativeVar);
  • trunk/abdev/BasicCompiler_Common/calculation.cpp

    r198 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/LexicalAnalysis.h>
    24
     
    498500                        //定数関数
    499501
    500                         if(!GetConstCalcBuffer(temporary,temp2,Parms)){
     502                        ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( temporary );
     503                        if( !pConstMacro )
     504                        {
     505                            if(enableerror) SetError(3,temporary,cp);
     506                            return false;
     507                        }
     508                        if( !pConstMacro->GetCalcBuffer( temp2, Parms ) )
     509                        {
    501510                            if(enableerror) SetError(3,temporary,cp);
    502511                            return false;
     
    554563
    555564                            RELATIVE_VAR RelativeVar;
    556                             int ss[MAX_ARRAYDIM];
    557565                            void *offset;
    558566                            DWORD dwData;
     
    563571
    564572                            Type tempType;
    565                             i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType,ss);
     573                            i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType);
    566574                            if(i3==0){
    567575                                //式エラー
     
    657665                        /////////
    658666                        StrPtr[pnum]=0;
    659                         type[pnum] = CDBConst::obj.GetBasicType(Parms);
     667                        type[pnum] = compiler.GetMeta().GetGlobalConsts().GetBasicType(Parms);
    660668                        if(type[pnum]){
    661669                            if(IsRealNumberType(type[pnum])){
    662670                                //実数型
    663                                 nums[pnum] = CDBConst::obj.GetDoubleData(Parms);
     671                                nums[pnum] = compiler.GetMeta().GetGlobalConsts().GetDoubleData(Parms);
    664672                            }
    665673                            else if(IsWholeNumberType(type[pnum])){
    666674                                //整数
    667                                 i64nums[pnum] = CDBConst::obj.GetWholeData(Parms);
     675                                i64nums[pnum] = compiler.GetMeta().GetGlobalConsts().GetWholeData(Parms);
    668676                            }
    669677/*                          else if(type[pnum]==DEF_STRING){
     
    11081116#pragma optimize("", on)
    11091117
    1110 BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer){
    1111     extern HANDLE hHeap;
    1112     int i2,i3,i4,num;
    1113     char temporary[VN_SIZE];
    1114     char *pParms[MAX_PARMS];
    1115 
    1116     CONSTINFO *pci;
    1117     pci=GetConstHash(name);
    1118     if(!pci) return 0;
    1119 
    1120     num=0;
    1121     i2=0;
    1122     while(1){
    1123         i2=GetOneParameter(Parameter,i2,temporary);
    1124 
    1125         pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    1126         lstrcpy(pParms[num],temporary);
    1127 
    1128         num++;
    1129         if(Parameter[i2]=='\0') break;
    1130     }
    1131     if(num!=pci->ParmNum){
    1132         extern int cp;
    1133         for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
    1134         SetError(10,name,cp);
    1135         lstrcpy(pCalcBuffer,"0");
    1136         return 1;
    1137     }
    1138 
    1139     i2=0;
    1140     i4=0;
    1141     while(1){
    1142 
    1143         //数式内の項を取得
    1144         for(i3=0;;i2++,i3++){
    1145             if(!IsVariableChar(pci->StrValue[i2])){
    1146                 temporary[i3]=0;
    1147                 break;
    1148             }
    1149             temporary[i3]=pci->StrValue[i2];
    1150         }
    1151 
    1152         //パラメータと照合する
    1153         for(i3=0;i3<pci->ParmNum;i3++){
    1154             if(lstrcmp(pci->ppParm[i3],temporary)==0) break;
    1155         }
    1156 
    1157         if(i3==pci->ParmNum){
    1158             //パラメータでないとき
    1159             lstrcpy(pCalcBuffer+i4,temporary);
    1160             i4+=lstrlen(temporary);
    1161         }
    1162         else{
    1163             //パラメータのとき
    1164             lstrcpy(pCalcBuffer+i4,pParms[i3]);
    1165             i4+=lstrlen(pParms[i3]);
    1166         }
    1167 
    1168         //演算子をコピー
    1169         for(;;i2++,i4++){
    1170             if(pci->StrValue[i2]==1){
    1171                 pCalcBuffer[i4++]=pci->StrValue[i2++];
    1172                 pCalcBuffer[i4]=pci->StrValue[i2];
    1173                 continue;
    1174             }
    1175             if(IsVariableTopChar(pci->StrValue[i2])) break;
    1176             pCalcBuffer[i4]=pci->StrValue[i2];
    1177             if(pci->StrValue[i2]=='\0') break;
    1178         }
    1179 
    1180         if(pci->StrValue[i2]=='\0') break;
    1181     }
    1182 
    1183     for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
    1184 
    1185     return 1;
    1186 }
    1187 DWORD GetConstValue(char *name,double *pDbl,char *buffer,LONG_PTR *plpIndex){
    1188     CONSTINFO *pci;
    1189     pci=GetConstHash(name);
    1190     if(pci){
    1191         //定数が見つかったとき
    1192 
    1193         if(pci->StrValue){
    1194             //文字列定数
    1195 
    1196             //バイト数
    1197             *pDbl=pci->DblValue;
    1198 
    1199             //データ
    1200             memcpy(buffer,pci->StrValue,(int)pci->DblValue);
    1201 
    1202             if(plpIndex) *plpIndex=pci->lpIndex;
    1203 
    1204             return DEF_STRING;
    1205         }
    1206         else{
    1207             if(pci->type==DEF_INT64){
    1208                 memcpy(pDbl,&pci->i64Value,sizeof(_int64));
    1209                 return DEF_INT64;
    1210             }
    1211 
    1212             if(plpIndex) *plpIndex=pci->lpIndex;
    1213 
    1214             *pDbl=pci->DblValue;
    1215             return pci->type;
    1216         }
    1217     }
    1218 
    1219     if(plpIndex) *plpIndex=-1;
    1220 
    1221     return -1;
    1222 }
    12231118int IsStrCalculation(char *Command){
    12241119    int i,i2,i3,i4,PareNum;
     
    12831178
    12841179                    //ユーザー定義関数
    1285                     UserProc *pUserProc;
    1286                     pUserProc=GetSubHash(temporary);
     1180                    const UserProc *pUserProc = GetSubHash(temporary);
    12871181                    if(pUserProc){
    12881182                        if( pUserProc->ReturnType().IsStringClass() ){
     
    13001194
    13011195                    //定数
    1302                     CONSTINFO *pci;
    1303                     pci=GetConstHash(temporary);
    1304                     if(pci){
    1305 
    1306                         if(pci->ParmNum){
    1307                             //マクロ関数の場合
    1308                             GetStringInPare_RemovePare(temporary,Command+i2+i3+1);
    1309                             GetConstCalcBuffer(pci->name,temporary,temp2);
    1310                             return IsStrCalculation(temp2);
    1311                         }
    1312 
    1313                         if(pci->type==DEF_STRING) return 1;
    1314                         else return 0;
     1196                    ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( temporary );
     1197                    if(pConstMacro){
     1198                        //マクロ関数の場合
     1199                        GetStringInPare_RemovePare(temporary,Command+i2+i3+1);
     1200                        pConstMacro->GetCalcBuffer( temporary, temp2 );
     1201                        return IsStrCalculation(temp2);
    13151202                    }
    13161203                }
    13171204
    13181205                //定数
    1319                 i3 = CDBConst::obj.GetBasicType(Command+i2);
     1206                i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(Command+i2);
    13201207                if(i3==DEF_STRING) return 1;    //文字列
    13211208                if(i3) return 0;            //数値
  • trunk/abdev/BasicCompiler_Common/common.h

    r182 r206  
     1#pragma once
     2
    13//#define _CRT_SECURE_NO_DEPRECATE
    24#pragma warning(disable : 4996)
    35
    46#include <option.h>
    5 
    6 #include <windows.h>
    7 #include <stdio.h>
    8 #include <string.h>
    9 #include <math.h>
    10 #include <commctrl.h>
    11 #include <time.h>
    12 #include <limits.h>
    13 #include <shlobj.h>
    14 #include <vector>
    15 #include <string>
    16 #include <fstream>
    17 
    18 //boost libraries
    19 #include <boost/foreach.hpp>
    207
    218using namespace std;
     
    3320#endif
    3421
    35 #include "../BasicCompiler_Common/BasicFixed.h"
     22#include <jenga/include/smoothie/BasicFixed.h>
    3623#include "../BasicCompiler_Common/NonVolatile.h"
    3724#include "../BasicCompiler_Common/psapi.h"
     
    139126
    140127
    141 // 列挙体管理用のクラス
    142 #include "Enum.h"
    143 
    144 // 定数管理用のクラス
    145 #include "Const.h"
    146 
    147 
    148128
    149129struct ERRORINFO{
     
    157137    LONG_PTR offset;
    158138    BOOL bOffsetOffset;
    159 };
    160 
    161 struct CONSTINFO{
    162     char *name;
    163     char *StrValue;
    164 
    165     double DblValue;
    166     _int64 i64Value;
    167     int type;
    168     LONG_PTR lpIndex;
    169 
    170     int ParmNum;
    171     char **ppParm;
    172 
    173     CONSTINFO *pNextData;
    174139};
    175140
     
    245210
    246211#include "../BasicCompiler_Common/PESchedule.h"
    247 #include "../BasicCompiler_Common/DebugSection.h"
    248212#include "../BasicCompiler_Common/VariableOpe.h"
    249213
     
    268232//hash.cpp
    269233int hash_default(const char *name);
    270 CONSTINFO *GetConstHash(const char *name);
    271234DllProc *GetDeclareHash(char *name);
    272 void GetOverloadSubHash( const char *lpszName, std::vector<UserProc *> &subs );
    273 UserProc *GetSubHash(const char *name,BOOL bError=0);
    274 UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
    275 UserProc *GetClassMethod( const char *className, const char *methodName );
     235void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
     236const UserProc *GetSubHash(const char *name,BOOL bError=0);
     237const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
     238const UserProc *GetClassMethod( const char *className, const char *methodName );
    276239
    277240//Object.cpp
    278 void CallConstructor( const char *ObjectName,const int *SubScripts, const Type &type,const char *Parameter);
     241void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
    279242bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
    280243
    281244//Overload.sbp
    282 UserProc *OverloadSolutionWithStrParam(
     245class Parameters;
     246const UserProc *OverloadSolutionWithStrParam(
    283247    const char *name,
    284     std::vector<UserProc *> &subs,
     248    std::vector<const UserProc *> &subs,
    285249    const char *Parameter,
    286250    const char *ObjectName);
    287 UserProc *OverloadSolution(
     251const UserProc *OverloadSolution(
    288252    const char *name,
    289     std::vector<UserProc *> &subs,
     253    std::vector<const UserProc *> &subs,
    290254    const Parameters &params,
    291255    const Type &returnType );
     
    298262void Debugger_Pause(void);
    299263ULONG_PTR rva_to_real(DWORD p);
    300 GlobalProc *GetSubFromObp(ULONG_PTR pos);
     264UserProc *GetSubFromObp(ULONG_PTR pos);
    301265void ReadOpBuffer();
    302266void DebugProgram(void);
     
    310274ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
    311275ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
    312 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, int *pss);
     276int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
    313277
    314278//MakeExe.cpp
    315279void StepCompileProgress(void);
    316 void DeleteConstInfo(CONSTINFO **ppConstHash);
    317280void DeleteDeclareInfo(void);
    318281void AddSourceCode(char *buffer);
     
    366329char GetEndXXXCommand(char es);
    367330void GetDefaultNameFromES(char es,char *name);
    368 void GetCalcName(int idCalc,char *name);
     331const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
    369332BOOL IsFile(char *path);
    370333BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
     
    382345int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
    383346DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType);
    384 BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer);
    385 DWORD GetConstValue(char *name,double *dbl,char *buffer,LONG_PTR *plpIndex);
    386347int IsStrCalculation(char *Command);
    387348BYTE GetCalcId(const char *Command,int *pi);
     
    403364bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
    404365bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType );
    405 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic = false );
    406 void GetSubInfo(void);
    407 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum);
    408366void DeleteDeclareInfo(void);
    409367int AddProcPtrInfo( const string &typeExpression, int nowLine );
  • trunk/abdev/BasicCompiler_Common/error.cpp

    r204 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/LexicalAnalysis.h>
    24
    35#include <Program.h>
     6#include <Class.h>
    47
    58#include "../BasicCompiler_Common/common.h"
     
    301304        if(num>-100){
    302305            //エラーのみ
     306
    303307            i2=0;
    304308        }
  • trunk/abdev/BasicCompiler_Common/gc.cpp

    r75 r206  
     1#include "stdafx.h"
     2
    13#include "common.h"
    24
  • trunk/abdev/BasicCompiler_Common/hash.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
     
    2123}
    2224
    23 CONSTINFO *GetConstHash(const char *name){
    24     //ハッシュ値を取得
    25     int key;
    26     key=hash_default(name);
    27 
    28     //格納位置を取得
    29     extern CONSTINFO **ppConstHash;
    30     CONSTINFO *pci;
    31     pci=ppConstHash[key];
    32     while(pci){
    33         if(lstrcmp(pci->name,name)==0) break;
    34 
    35         pci=pci->pNextData;
    36     }
    37 
    38     return pci;
    39 }
    40 
    4125DllProc *GetDeclareHash(char *fullName){
    4226    char ObjName[VN_SIZE];      //オブジェクト変数
    4327    char NestMember[VN_SIZE];   //入れ子メンバ
    44     bool isObjectMember = CClass::SplitName( fullName, ObjName, NestMember );
     28    bool isObjectMember = SplitMemberName( fullName, ObjName, NestMember );
    4529
    4630    //ハッシュ値を取得
     
    6448}
    6549
    66 void GetOverloadSubHash( const char *lpszName, std::vector<UserProc *> &subs ){
     50void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs ){
    6751    char name[VN_SIZE];
    6852
     
    7559    char ObjName[VN_SIZE];      //オブジェクト変数
    7660    char NestMember[VN_SIZE];   //入れ子メンバ
    77     bool isObjectMember = CClass::SplitName( name, ObjName, NestMember );
     61    bool isObjectMember = SplitMemberName( name, ObjName, NestMember );
    7862
    7963    if(isObjectMember){
     
    8468        if(lstrcmpi(ObjName,"Super")==0){
    8569            //クラスメンバ関数内から基底クラスの呼び出し
    86             pobj_c=Smoothie::Temp::pCompilingClass;
     70            pobj_c=compiler.pCompilingClass;
    8771        }
    8872        else{
     
    11498
    11599
    116     if(Smoothie::Temp::pCompilingClass){
     100    if(compiler.pCompilingClass){
    117101        //自身のオブジェクトのメンバ関数を検索
    118102
    119103        // 静的メソッド
    120         Smoothie::Temp::pCompilingClass->GetStaticMethods().Enum( name, subs );
     104        compiler.pCompilingClass->GetStaticMethods().Enum( name, subs );
    121105
    122106        // 動的メソッド
    123         Smoothie::Temp::pCompilingClass->GetMethods().Enum( name, subs );
     107        compiler.pCompilingClass->GetMethods().Enum( name, subs );
    124108    }
    125109
    126110
    127     ///////////////////////////
    128111    // グローバル関数を検索
    129     ///////////////////////////
    130 
    131     //ハッシュ値を取得
    132     int key;
    133     key=hash_default(NestMember);
    134 
    135     //格納位置を取得
    136     extern GlobalProc **ppSubHash;
    137     GlobalProc *pUserProc;
    138     pUserProc=ppSubHash[key];
    139     while(pUserProc){
    140         if(!pUserProc->GetParentClassPtr()){
    141             if( pUserProc->IsEqualSymbol( name ) ){
    142                 subs.push_back( pUserProc );
    143             }
    144         }
    145 
    146         pUserProc=pUserProc->pNextData;
    147     }
     112    compiler.GetMeta().GetUserProcs().EnumGlobalProcs( NestMember, name, subs );
    148113}
    149114
    150115//オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持)
    151 UserProc *GetSubHash(const char *lpszName,BOOL bError){
    152     std::vector<UserProc *> subs;
     116const UserProc *GetSubHash(const char *lpszName,BOOL bError){
     117    std::vector<const UserProc *> subs;
    153118    GetOverloadSubHash(lpszName,subs);
    154119
     
    166131    }
    167132
    168     UserProc *pUserProc;
    169     pUserProc = subs[0];
     133    const UserProc *pUserProc = subs[0];
    170134
    171135    return pUserProc;
    172136}
    173 UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError){
     137const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError){
    174138    char temporary[VN_SIZE];
    175139    sprintf(temporary,"%s.%s",ObjectName,MethodName);
    176140
    177     std::vector<UserProc *> subs;
    178     UserProc *pUserProc;
     141    std::vector<const UserProc *> subs;
    179142    GetOverloadSubHash(temporary,subs);
    180143
     
    185148
    186149    //オーバーロードを解決
    187     pUserProc=OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName);
     150    const UserProc *pUserProc = OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName);
    188151
    189152    return pUserProc;
    190153}
    191154
    192 UserProc *GetClassMethod( const char *className, const char *methodName ){
     155const UserProc *GetClassMethod( const char *className, const char *methodName ){
    193156    const CClass *pClass = compiler.GetMeta().GetClasses().Find( className );
    194157    if( pClass ){
    195         vector<UserProc *> userProcs;
     158        vector<const UserProc *> userProcs;
    196159        pClass->GetMethods().Enum( methodName, userProcs );
    197160        if( userProcs.size() == 1 ){
  • trunk/abdev/BasicCompiler_Common/include/Class.h

    r201 r206  
    11#pragma once
    22
    3 #include <jenga/include/smoothie/Class.h>
    4 
    5 class ClassImpl: public CClass
     3#include <option.h>
     4#include <Program.h>
     5#include <Prototype.h>
     6#include <Method.h>
     7#include <Member.h>
     8
     9class UserProc;
     10
     11class InheritedInterface
    612{
    7 public:
    8     ClassImpl( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name )
    9         : CClass( namespaceScopes, importedNamespaces, name )
    10     {
    11     }
    12     ClassImpl()
    13         : CClass()
    14     {
    15     }
    16 
    17     virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
     13    CClass *pInterfaceClass;
     14    int vtblOffset;
     15public:
     16    InheritedInterface( CClass *pInterfaceClass, int vtblOffset )
     17        : pInterfaceClass( pInterfaceClass )
     18        , vtblOffset( vtblOffset )
     19    {
     20    }
     21
     22    CClass &GetInterfaceClass() const{
     23        return *pInterfaceClass;
     24    }
     25    int GetVtblOffset() const
     26    {
     27        return vtblOffset;
     28    }
     29};
     30typedef vector<InheritedInterface> Interfaces;
     31
     32class CClass: public Prototype
     33{
     34public:
     35    // 型の種類
     36    enum ClassType{
     37        Class,
     38        Interface,
     39        Enum,
     40        Delegate,
     41        Structure,
     42    };
     43
     44private:
     45    ClassType classType;
     46
     47    // importされている名前空間
     48    NamespaceScopesCollection importedNamespaces;
     49   
     50    // 継承クラス
     51    const CClass *pSuperClass;
     52
     53    // Blittable型情報
     54    Type blittableType;
     55
     56    // 実装するインターフェイス
     57    Interfaces interfaces;
     58
     59    // 動的メンバ
     60    Members dynamicMembers;
     61
     62    // 静的メンバ
     63    Members staticMembers;
     64
     65    // 動的メソッド
     66    Methods methods;
     67    int ConstructorMemberSubIndex;
     68    int DestructorMemberSubIndex;
     69    int vtblNum;                    // 仮想関数の数
     70
     71    // 静的メソッド
     72    Methods staticMethods;
     73
     74    // XMLシリアライズ用
     75private:
     76    friend class boost::serialization::access;
     77    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     78    {
     79        trace_for_serialize( "serializing - CClass" );
     80
     81        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Prototype );
     82        ar & BOOST_SERIALIZATION_NVP( classType );
     83        ar & BOOST_SERIALIZATION_NVP( importedNamespaces );
     84        ar & boost::serialization::make_nvp( "pSuperClass", const_cast<CClass *&>(pSuperClass) );
     85        ar & BOOST_SERIALIZATION_NVP( blittableType );
     86        //ar & BOOST_SERIALIZATION_NVP( interfaces );
     87        ar & BOOST_SERIALIZATION_NVP( dynamicMembers );
     88        ar & BOOST_SERIALIZATION_NVP( staticMembers );
     89        ar & BOOST_SERIALIZATION_NVP( methods );
     90        ar & BOOST_SERIALIZATION_NVP( ConstructorMemberSubIndex );
     91        ar & BOOST_SERIALIZATION_NVP( DestructorMemberSubIndex );
     92        ar & BOOST_SERIALIZATION_NVP( vtblNum );
     93        ar & BOOST_SERIALIZATION_NVP( staticMethods );
     94    }
     95
     96    bool isReady;
     97public:
     98
     99    //アラインメント値
     100    int iAlign;
     101
     102    CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name )
     103        : Prototype( namespaceScopes, name )
     104        , importedNamespaces( importedNamespaces )
     105        , classType( Class )
     106        , pSuperClass( NULL )
     107        , isReady( false )
     108        , iAlign( 0 )
     109        , ConstructorMemberSubIndex( -1 )
     110        , DestructorMemberSubIndex( -1 )
     111        , vtblNum( 0 )
     112        , vtbl_offset( -1 )
     113        , isCompilingConstructor( false )
     114        , isCompilingDestructor( false )
     115        , pobj_NextClass( NULL )
     116    {
     117    }
     118    CClass()
     119        : Prototype()
     120        , importedNamespaces()
     121        , classType()
     122        , pSuperClass( NULL )
     123        , isReady( false )
     124        , iAlign( 0 )
     125        , ConstructorMemberSubIndex( -1 )
     126        , DestructorMemberSubIndex( -1 )
     127        , vtblNum( 0 )
     128        , vtbl_offset( -1 )
     129        , isCompilingConstructor( false )
     130        , isCompilingDestructor( false )
     131        , pobj_NextClass( NULL )
     132    {
     133    }
     134    ~CClass()
     135    {
     136        // 動的メンバ
     137        BOOST_FOREACH( CMember *member, dynamicMembers ){
     138            delete member;
     139        }
     140
     141        // 静的メンバ
     142        BOOST_FOREACH( CMember *member, staticMembers ){
     143            delete member;
     144        }
     145    }
     146
     147    void Readed(){
     148        isReady = true;
     149    }
     150    bool IsReady() const{
     151        return isReady;
     152    }
     153
     154    const NamespaceScopesCollection &GetImportedNamespaces() const
     155    {
     156        return importedNamespaces;
     157    }
     158
     159    // 継承元クラス
     160    bool HasSuperClass() const
     161    {
     162        return ( pSuperClass != NULL );
     163    }
     164    const CClass &GetSuperClass() const
     165    {
     166        return *pSuperClass;
     167    }
     168    void SetSuperClass( const CClass *pSuperClass )
     169    {
     170        this->pSuperClass = pSuperClass;
     171    }
     172
     173    // Blittable型
     174    bool IsBlittableType() const
     175    {
     176        return !blittableType.IsNull();
     177    }
     178    const Type &GetBlittableType() const
     179    {
     180        return blittableType;
     181    }
     182    void SetBlittableType( const Type &type ){
     183        blittableType = type;
     184    }
     185
     186    bool IsClass() const;
     187    bool IsInterface() const;
     188    bool IsEnum() const;
     189    bool IsDelegate() const;
     190    bool IsStructure() const;
     191    void SetClassType( ClassType classType )
     192    {
     193        this->classType = classType;
     194    }
     195
     196
     197    //コンストラクタをコンパイルしているかどうかのチェックフラグ
     198private:
     199    mutable bool isCompilingConstructor;
     200public:
     201    void NotifyStartConstructorCompile() const;
     202    void NotifyFinishConstructorCompile() const;
     203    bool IsCompilingConstructor() const;
     204
     205    //デストラクタをコンパイルしているかどうかのチェックフラグ
     206private:
     207    mutable bool isCompilingDestructor;
     208public:
     209    void NotifyStartDestructorCompile() const;
     210    void NotifyFinishDestructorCompile() const;
     211    bool IsCompilingDestructor() const;
     212
     213
     214    //自身の派生クラスかどうかを確認
     215    bool IsSubClass( const CClass *pClass ) const;
     216
     217    //自身と等しいまたは派生クラスかどうかを確認
     218    bool IsEqualsOrSubClass( const CClass *pClass ) const;
     219
     220    // 自身と等しいまたは派生クラス、基底クラスかどうかを確認
     221    bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const;
     222
     223    // インターフェイス
     224    bool HasInterfaces() const
     225    {
     226        return ( interfaces.size() != 0 );
     227    }
     228    bool IsInheritsInterface( const CClass *pInterfaceClass ) const;
    18229
    19230    //継承させる
    20     virtual bool Inherits( const char *inheritNames, int nowLine );
    21     virtual bool InheritsClass( const CClass &inheritsClass, int nowLine );
    22     virtual bool InheritsInterface( const CClass &inheritsClass, int nowLine );
     231    bool Inherits( const char *inheritNames, int nowLine );
     232    bool InheritsClass( const CClass &inheritsClass, int nowLine );
     233    bool InheritsInterface( const CClass &inheritsClass, int nowLine );
    23234
    24235    //メンバ、メソッドの追加
    25236    CMember *CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine );
    26     virtual void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine );
    27     virtual void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine );
    28 
    29     virtual void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
     237    void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine );
     238    void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine );
     239
     240    void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
    30241        bool isVirtual, bool isOverride, char *buffer, int nowLine);
    31242
    32     virtual LONG_PTR GetVtblGlobalOffset(void) const;
    33     virtual void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
    34 
    35 
    36     // XMLシリアライズ用
    37 private:
    38     friend class boost::serialization::access;
    39     template<class Archive> void serialize(Archive& ar, const unsigned int version)
    40     {
    41         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CClass );
    42     }
     243    //重複チェック
     244    bool DupliCheckAll(const char *name);
     245    bool DupliCheckMember(const char *name);
     246
     247    const Members &GetDynamicMembers() const
     248    {
     249        return dynamicMembers;
     250    }
     251    const Members &GetStaticMembers() const
     252    {
     253        return staticMembers;
     254    }
     255    Members &GetDynamicMembers()
     256    {
     257        return dynamicMembers;
     258    }
     259    Members &GetStaticMembers()
     260    {
     261        return staticMembers;
     262    }
     263
     264    const Methods &GetMethods() const
     265    {
     266        return methods;
     267    }
     268    const Methods &GetStaticMethods() const
     269    {
     270        return staticMethods;
     271    }
     272    Methods &GetMethods()
     273    {
     274        return methods;
     275    }
     276    Methods &GetStaticMethods()
     277    {
     278        return staticMethods;
     279    }
     280
     281    //デフォルト コンストラクタ
     282    const CMethod *GetConstructorMethod() const
     283    {
     284        if( ConstructorMemberSubIndex == -1 ) return NULL;
     285        return methods[ConstructorMemberSubIndex];
     286    }
     287    void SetConstructorMemberSubIndex( int constructorMemberSubIndex )
     288    {
     289        this->ConstructorMemberSubIndex = constructorMemberSubIndex;
     290    }
     291
     292    //デストラクタ メソッドを取得
     293    const CMethod *GetDestructorMethod() const
     294    {
     295        if( DestructorMemberSubIndex == -1 ) return NULL;
     296        return methods[DestructorMemberSubIndex];
     297    }
     298    void SetDestructorMemberSubIndex( int destructorMemberSubIndex )
     299    {
     300        this->DestructorMemberSubIndex = destructorMemberSubIndex;
     301    }
     302
     303    // vtblに存在する仮想関数の数
     304    int GetVtblNum() const
     305    {
     306        return vtblNum;
     307    }
     308    void SetVtblNum( int vtblNum )
     309    {
     310        this->vtblNum = vtblNum;
     311    }
     312    void AddVtblNum( int vtblNum )
     313    {
     314        this->vtblNum += vtblNum;
     315    }
     316    bool IsExistVirtualFunctions() const
     317    {
     318        return ( vtblNum > 0 );
     319    }
     320
     321    // メンバの総合サイズを取得
     322    int GetSize() const;
     323
     324    // メンバのオフセットを取得
     325    int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const;
     326private:
     327    // アラインメント値を取得
     328    int GetAlignment() const;
     329
     330    //vtbl
     331protected:
     332    mutable long vtbl_offset;
     333public:
     334    int GetFuncNumInVtbl( const UserProc *pUserProc ) const;
     335    LONG_PTR GetVtblGlobalOffset(void) const;
     336    void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
     337    bool IsAbstract() const;
     338
     339
     340    //線形リスト用
     341    CClass *pobj_NextClass;
    43342};
    44 BOOST_IS_ABSTRACT( CClass );
    45 
    46 class ClassesImpl : public Classes
     343
     344#define MAX_CLASS_HASH 65535
     345class Classes
    47346{
    48 public:
    49     ClassesImpl()
    50         : Classes()
    51     {
    52     }
    53 
    54     virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name);
    55     virtual void CollectClassesForNameOnly( const BasicSource &source );
    56 
    57     virtual void InitStaticMember();
    58 
    59 private:
    60     bool MemberVar_LoopRefCheck(const CClass &objClass);
    61 public:
    62     virtual void GetClass_recur(const char *lpszInheritsClass);
    63     virtual void GetAllClassInfo();
    64     virtual void Compile_System_InitializeUserTypes();
    65 
    66     virtual const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;
    67 
     347    CClass *pobj_ClassHash[MAX_CLASS_HASH];
     348    int GetHashCode(const char *name) const;
    68349
    69350    // XMLシリアライズ用
     
    73354    template<class Archive> void load(Archive& ar, const unsigned int version)
    74355    {
    75         std::vector<ClassImpl *> vectorClasses;
     356        trace_for_serialize( "serializing(load) - Classes" );
     357
     358        std::vector<CClass *> vectorClasses;
    76359        ar & BOOST_SERIALIZATION_NVP( vectorClasses );
    77360
     
    82365            Insert( pClass );
    83366        }
     367        Iterator_Init();
    84368    }
    85369    template<class Archive> void save(Archive& ar, const unsigned int version) const
    86370    {
     371        trace_for_serialize( "serializing(save) - Classes" );
     372
    87373        // 保存準備
    88         std::vector<ClassImpl *> vectorClasses;
     374        std::vector<CClass *> vectorClasses;
    89375        vectorClasses.clear();
    90376        Iterator_Reset();
    91377        while( Iterator_HasNext() )
    92378        {
    93             vectorClasses.push_back( dynamic_cast<ClassImpl *>(Iterator_GetNext()) );
     379            vectorClasses.push_back( dynamic_cast<CClass *>(Iterator_GetNext()) );
    94380        }
    95381
    96382        ar & BOOST_SERIALIZATION_NVP( vectorClasses );
    97383    }
     384
     385public:
     386    Classes()
     387        : pCompilingMethod( NULL )
     388        , pStringClass( NULL )
     389        , pObjectClass( NULL )
     390        , ppobj_IteClass( NULL )
     391        , iIteMaxNum( 0 )
     392        , iIteNextNum( 0 )
     393    {
     394        memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) );
     395    }
     396    ~Classes()
     397    {
     398        for(int i=0;i<MAX_CLASS_HASH;i++){
     399            if(pobj_ClassHash[i]) DestroyClass(pobj_ClassHash[i]);
     400        }
     401    }
     402    void DestroyClass(CClass *pobj_c)
     403    {
     404        if(pobj_c->pobj_NextClass){
     405            DestroyClass(pobj_c->pobj_NextClass);
     406        }
     407
     408        delete pobj_c;
     409    }
     410    void Clear()
     411    {
     412        if(ppobj_IteClass)
     413        {
     414            free(ppobj_IteClass);
     415            ppobj_IteClass = NULL;
     416        }
     417        // TODO: ここはこれでいいのか…
     418        memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) );
     419    }
     420
     421    virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name);
     422    bool Insert( CClass *pClass );
     423    CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
     424    virtual void CollectClassesForNameOnly( const BasicSource &source );
     425
     426    void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
     427
     428    virtual void InitStaticMember();
     429
     430private:
     431    bool MemberVar_LoopRefCheck(const CClass &objClass);
     432public:
     433    virtual void GetClass_recur(const char *lpszInheritsClass);
     434    virtual void GetAllClassInfo();
     435    virtual void Compile_System_InitializeUserTypes();
     436
     437    const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;
     438    const CClass *Find( const string &fullName ) const;
     439
     440
     441    /////////////////////////////
     442    // 現在コンパイル中の情報
     443    /////////////////////////////
     444private:
     445    const CMethod *pCompilingMethod;
     446public:
     447    void StartCompile( const UserProc *pUserProc );
     448
     449    //現在コンパイル中のメソッド情報を取得
     450    const CMethod *GetNowCompilingMethodInfo(){
     451        return pCompilingMethod;
     452    }
     453
     454
     455    /////////////////////////////
     456    // 特殊クラス
     457    /////////////////////////////
     458    CClass *pStringClass;
     459    CClass *pObjectClass;
     460    CClass *GetStringClassPtr() const;
     461    CClass *GetObjectClassPtr() const;
     462
     463
     464    /////////////////////
     465    // イテレータ
     466    /////////////////////
     467private:
     468    mutable CClass **ppobj_IteClass;
     469    mutable int iIteMaxNum;
     470    mutable int iIteNextNum;
     471public:
     472    void Iterator_Init() const;
     473    void Iterator_Reset() const;
     474    BOOL Iterator_HasNext() const;
     475    CClass *Iterator_GetNext() const;
     476    int Iterator_GetMaxCount() const;
    98477};
    99 BOOST_IS_ABSTRACT( Classes );
  • trunk/abdev/BasicCompiler_Common/include/Compiler.h

    r199 r206  
    3434    static bool StringToType( const std::string &typeName, Type &type );
    3535    static const std::string TypeToString( const Type &type );
     36
     37    // コンパイル中のクラス
     38    const CClass *pCompilingClass;
    3639};
    3740
  • trunk/abdev/BasicCompiler_Common/include/Const.h

    r201 r206  
    11#pragma once
    22
    3 #include <jenga/include/smoothie/Type.h>
     3#include <Type.h>
     4#include <Symbol.h>
    45
    5 //定数の基底クラス
    6 class ConstBase{
    7     const string name;
    8     const NamespaceScopes namespaceScopes;
     6
     7void AddConst( const NamespaceScopes &namespaceScopes, char *buffer );
     8
     9//定数
     10class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst>
     11{
     12    Type type;
     13    _int64 i64data;
     14
     15    // XMLシリアライズ用
     16private:
     17    friend class boost::serialization::access;
     18    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     19    {
     20        trace_for_serialize( "serializing - CConst" );
     21
     22        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
     23        ar & BOOST_SERIALIZATION_NVP( type );
     24        ar & BOOST_SERIALIZATION_NVP( i64data );
     25    }
    926
    1027public:
    1128
    12     ConstBase( const NamespaceScopes &namespaceScopes, const string &name )
    13         : namespaceScopes( namespaceScopes )
    14         , name( name )
     29    CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data)
     30        : Symbol( namespaceScopes, name )
     31        , type( newType )
     32        , i64data( i64data )
    1533    {
    1634    }
    17     ~ConstBase()
     35    CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value)
     36        : Symbol( namespaceScopes, name )
     37        , type( Type(DEF_LONG) )
     38        , i64data( value )
     39    {
     40    }
     41    CConst()
     42    {
     43    }
     44    ~CConst()
    1845    {
    1946    }
    2047
    21     const string &GetName() const
     48    virtual const std::string &GetKeyName() const
    2249    {
    23         return name;
     50        return GetName();
    2451    }
    2552
    26     bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
    27     bool IsEqualSymbol( const string &name ) const;
    28 };
    29 
    30 //定数
    31 class CConst:public ConstBase{
    32     Type type;
    33     _int64 i64data;
    34 
    35 public:
    36     CConst *pNext;
    37 
    38     CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &newType, _int64 i64data);
    39     CConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
    40     ~CConst();
    41 
    42     Type GetType();
    43     _int64 GetWholeData();
     53    Type GetType()
     54    {
     55        return type;
     56    }
     57    _int64 GetWholeData()
     58    {
     59        return i64data;
     60    }
    4461    double GetDoubleData();
    4562};
     63class Consts : public Jenga::Common::Hashmap<CConst>
     64{
     65    // XMLシリアライズ用
     66private:
     67    friend class boost::serialization::access;
     68    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     69    {
     70        trace_for_serialize( "serializing - Consts" );
    4671
    47 //定数マクロ
    48 class CConstMacro:public ConstBase{
    49     int ParmNum;
    50     char **ppParm;
    51 public:
    52 
    53     CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
    54     ~CConstMacro();
    55 };
    56 
    57 //定数管理クラス
    58 class CDBConst{
    59     CConst **ppHash;
    60 
    61     CConstMacro **ppobj_Macro;
    62     int NumOfMacro;
    63 
    64     //シングルトンクラスなので、プライベートに置く
    65     CDBConst();
    66     ~CDBConst();
    67     void _free();
    68     void Free();
     72        ar & boost::serialization::make_nvp("Hashmap_CConst",
     73            boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this));
     74    }
    6975
    7076public:
    7177
    72     void Init();
    73 
    7478    void Add( const NamespaceScopes &namespaceScopes, char *buffer);
    75 private:
    76     void AddConst( const string &name, CConst *newconst);
    77 public:
    78     void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
    79     void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
     79    void Add( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
     80    void Add( const NamespaceScopes &namespaceScopes, const string &name, int value);
    8081
    8182private:
     
    8788    double GetDoubleData(char *Name);
    8889    bool IsStringPtr(char *Name);
     90};
    8991
     92//定数マクロ
     93class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro>
     94{
     95    std::vector<std::string> parameters;
     96    std::string expression;
    9097
    91     //シングルトンオブジェクト
    92     static CDBConst obj;
     98    // XMLシリアライズ用
     99private:
     100    friend class boost::serialization::access;
     101    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     102    {
     103        trace_for_serialize( "serializing - ConstMacro" );
     104
     105        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
     106        ar & BOOST_SERIALIZATION_NVP( parameters );
     107        ar & BOOST_SERIALIZATION_NVP( expression );
     108    }
     109
     110public:
     111    ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> &parameters, const string &expression )
     112        : Symbol( namespaceScopes, name )
     113        , parameters( parameters )
     114        , expression( expression )
     115    {
     116    }
     117    ConstMacro()
     118    {
     119    }
     120    ~ConstMacro()
     121    {
     122    }
     123
     124    virtual const std::string &GetKeyName() const
     125    {
     126        return GetName();
     127    }
     128
     129    const std::vector<std::string> &GetParameters() const
     130    {
     131        return parameters;
     132    }
     133    const std::string &GetExpression() const
     134    {
     135        return expression;
     136    }
     137
     138    bool GetCalcBuffer( const char *parameterStr, char *dest ) const;
    93139};
     140class ConstMacros : public Jenga::Common::Hashmap<ConstMacro>
     141{
     142    // XMLシリアライズ用
     143private:
     144    friend class boost::serialization::access;
     145    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     146    {
     147        trace_for_serialize( "serializing - ConstMacros" );
     148
     149        ar & boost::serialization::make_nvp("Hashmap_ConstMacro",
     150            boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this));
     151    }
     152
     153public:
     154    void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
     155    ConstMacro *Find( const std::string &name );
     156};
  • trunk/abdev/BasicCompiler_Common/include/LexicalScopingImpl.h

    r184 r206  
    2626public:
    2727
     28    virtual void End();
     29
    2830    //スコープ終了時のデストラクタ呼び出し
    2931    virtual void CallDestructorsOfScopeEnd();
  • trunk/abdev/BasicCompiler_Common/include/MetaImpl.h

    r201 r206  
    33#include <jenga/include/common/BoostXmlSupport.h>
    44
    5 #include <jenga/include/smoothie/ObjectModule.h>
     5#include <option.h>
     6#include <Program.h>
     7#include <Class.h>
     8#include <Procedure.h>
     9#include <TypeDef.h>
     10#include <Variable.h>
     11#include <Const.h>
    612
    7 #include <ClassImpl.h>
    8 #include <ProcedureImpl.h>
    9 #include <TypeDef.h>
    10 
    11 class MetaImpl : public Meta, public Jenga::Common::BoostXmlSupport<MetaImpl>
     13class MetaImpl : public Jenga::Common::BoostXmlSupport<MetaImpl>
    1214{
    1315    // 名前空間
    1416    NamespaceScopesCollection namespaceScopesCollection;
    1517
     18    // 関数・メソッド
     19    UserProcs userProcs;
     20
    1621    // クラス
    17     ClassesImpl classesImpl;
    18     Classes *pNowClassesForDebugger;
     22    Classes classesImpl;
     23
     24    // グローバル変数
     25    Variables globalVars;
     26
     27    // グローバル定数
     28    Consts globalConsts;
     29
     30    // グローバル定数マクロ
     31    ConstMacros globalConstMacros;
    1932
    2033    // blittable型
     
    2437    TypeDefCollection typeDefs;
    2538
     39    // 関数ポインタ
     40    ProcPointers procPointers;
     41
     42    // XMLシリアライズ用
     43private:
     44    virtual const char *RootTagName() const
     45    {
     46        return "metaImpl";
     47    }
     48    friend class boost::serialization::access;
     49    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     50    {
     51        trace_for_serialize( "serializing - MetaImpl" );
     52
     53        ar & BOOST_SERIALIZATION_NVP( namespaceScopesCollection );
     54        ar & BOOST_SERIALIZATION_NVP( userProcs );
     55        ar & BOOST_SERIALIZATION_NVP( classesImpl );
     56        ar & BOOST_SERIALIZATION_NVP( globalVars );
     57        ar & BOOST_SERIALIZATION_NVP( globalConsts );
     58        ar & BOOST_SERIALIZATION_NVP( globalConstMacros );
     59        ar & BOOST_SERIALIZATION_NVP( blittableTypes );
     60        ar & BOOST_SERIALIZATION_NVP( typeDefs );
     61        ar & BOOST_SERIALIZATION_NVP( procPointers );
     62    }
     63
     64    Classes *pNowClassesForDebugger;
     65
    2666public:
    2767    MetaImpl()
    28         : Meta( new ProcPointersImpl() )
    29         , classesImpl()
     68        : classesImpl()
    3069        , pNowClassesForDebugger( &classesImpl )
    3170    {
     
    4180    }
    4281
    43     virtual Classes &GetClasses()
     82    const UserProcs &GetUserProcs() const
     83    {
     84        return userProcs;
     85    }
     86    UserProcs &GetUserProcs()
     87    {
     88        return userProcs;
     89    }
     90
     91    Classes &GetClasses()
    4492    {
    4593        return *pNowClassesForDebugger;
    4694    }
    47     virtual void SetClasses( Classes *pClasses )
     95    void SetClasses( Classes *pClasses )
    4896    {
    4997        this->pNowClassesForDebugger = pClasses;
     98    }
     99
     100    const Variables &GetGlobalVars() const
     101    {
     102        return globalVars;
     103    }
     104    Variables &GetGlobalVars()
     105    {
     106        return globalVars;
     107    }
     108
     109    const Consts &GetGlobalConsts() const
     110    {
     111        return globalConsts;
     112    }
     113    Consts &GetGlobalConsts()
     114    {
     115        return globalConsts;
     116    }
     117
     118    const ConstMacros &GetGlobalConstMacros() const
     119    {
     120        return globalConstMacros;
     121    }
     122    ConstMacros &GetGlobalConstMacros()
     123    {
     124        return globalConstMacros;
    50125    }
    51126
     
    60135    }
    61136
    62     virtual bool AutoWrite( const std::string &filePath )
     137    // 関数ポインタ
     138    ProcPointers &GetProcPointers()
     139    {
     140        return procPointers;
     141    }
     142
     143    bool AutoWrite( const std::string &filePath )
    63144    {
    64145        std::ofstream ofs( filePath.c_str() );
     
    82163        return isSuccessful;
    83164    }
    84 
    85 
    86     // XMLシリアライズ用
    87 private:
    88     virtual const char *RootTagName() const
    89     {
    90         return "metaImpl";
    91     }
    92     friend class boost::serialization::access;
    93     template<class Archive> void serialize(Archive& ar, const unsigned int version)
    94     {
    95         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Meta );
    96         ar & BOOST_SERIALIZATION_NVP( classesImpl );
    97     }
    98165};
    99 BOOST_IS_ABSTRACT( Meta );
  • trunk/abdev/BasicCompiler_Common/include/Procedure.h

    r201 r206  
    11#pragma once
    22
    3 #include <jenga/include/smoothie/Procedure.h>
    4 
    5 
    6 class UserProcImpl : public UserProc
     3#include <jenga/include/common/Hashmap.h>
     4#include <jenga/include/smoothie/Source.h>
     5#include <jenga/include/smoothie/LexicalAnalysis.h>
     6
     7#include <option.h>
     8#include <Program.h>
     9#include <Class.h>
     10#include <Method.h>
     11#include <Procedure.h>
     12#include <Parameter.h>
     13#include <Variable.h>
     14
     15class CClass;
     16class CMethod;
     17
     18class Procedure
    719{
    820public:
    9     UserProcImpl( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport )
    10         : UserProc( name, kind, isMacro, isCdecl, isExport )
    11     {
    12     }
    13     virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic );
     21    // 種類
     22    enum Kind{
     23        Sub,
     24        Function,
     25    };
     26
     27private:
     28    string name;                        // プロシージャ名
     29
     30    Kind kind;
     31
     32    bool isCdecl;
     33    mutable bool isUsing;
     34
     35protected:
     36
     37    // パラメータ
     38    Parameters params;
     39
     40    // 戻り値の型
     41    Type returnType;
     42
     43    // ソースコードの位置
     44    int codePos;
     45
     46    // XMLシリアライズ用
     47private:
     48private:
     49    friend class boost::serialization::access;
     50    BOOST_SERIALIZATION_SPLIT_MEMBER();
     51    template<class Archive> void load(Archive& ar, const unsigned int version)
     52    {
     53        trace_for_serialize( "serializing - Procedure" );
     54
     55        std::string _name;
     56        ar & BOOST_SERIALIZATION_NVP( _name );
     57        this->name = Operator_NaturalStringToCalcMarkString( _name );
     58
     59        ar & BOOST_SERIALIZATION_NVP( kind );
     60        ar & BOOST_SERIALIZATION_NVP( isCdecl );
     61        ar & BOOST_SERIALIZATION_NVP( isUsing );
     62        ar & BOOST_SERIALIZATION_NVP( params );
     63        ar & BOOST_SERIALIZATION_NVP( returnType );
     64        ar & BOOST_SERIALIZATION_NVP( codePos );
     65    }
     66    template<class Archive> void save(Archive& ar, const unsigned int version) const
     67    {
     68        trace_for_serialize( "serializing - Procedure" );
     69
     70        std::string _name = Operator_CalcMarkStringToNaturalString( name );
     71        ar & BOOST_SERIALIZATION_NVP( _name );
     72
     73        ar & BOOST_SERIALIZATION_NVP( kind );
     74        ar & BOOST_SERIALIZATION_NVP( isCdecl );
     75        ar & BOOST_SERIALIZATION_NVP( isUsing );
     76        ar & BOOST_SERIALIZATION_NVP( params );
     77        ar & BOOST_SERIALIZATION_NVP( returnType );
     78        ar & BOOST_SERIALIZATION_NVP( codePos );
     79    }
     80
     81public:
     82    Procedure( const string &name, Kind kind, bool isCdecl )
     83        : name( name )
     84        , kind( kind )
     85        , isCdecl( isCdecl )
     86        , isUsing( false )
     87        , codePos( -1 )
     88    {
     89    }
     90    Procedure()
     91    {
     92    }
     93    ~Procedure(){
     94        BOOST_FOREACH( Parameter *pParam, params ){
     95            delete pParam;
     96        }
     97    }
     98
     99    const string &GetName() const
     100    {
     101        return name;
     102    }
     103
     104    bool IsSub() const
     105    {
     106        return ( kind == Sub );
     107    }
     108    bool IsFunction() const
     109    {
     110        return ( kind == Function );
     111    }
     112
     113    bool IsCdecl() const
     114    {
     115        return isCdecl;
     116    }
     117    void Using() const
     118    {
     119        isUsing = true;
     120    }
     121    bool IsUsing() const
     122    {
     123        return isUsing;
     124    }
     125
     126    int GetCodePos() const
     127    {
     128        return codePos;
     129    }
     130
     131    const Parameters &Params() const
     132    {
     133        return params;
     134    }
     135    const Type &ReturnType() const
     136    {
     137        return returnType;
     138    }
    14139};
    15140
    16 class GlobalProc : public UserProcImpl
     141class UserProc : public Procedure, public Jenga::Common::ObjectInHashmap<UserProc>
    17142{
    18     const NamespaceScopes namespaceScopes;
    19     const NamespaceScopesCollection importedNamespaces;
     143public:
     144    string _paramStr;
     145
     146private:
     147    NamespaceScopes namespaceScopes;
     148    NamespaceScopesCollection importedNamespaces;
     149
     150    // 親クラスと対応するメソッド
     151    const CClass *pParentClass;
     152    CMethod *pMethod;
     153
     154    bool isMacro;
     155
     156    // パラメータの追加情報
     157    int secondParmNum;
     158    Parameters realParams;
     159    int realSecondParmNum;
     160
     161    // 各種フラグ
     162    bool isExport;
     163    mutable bool isSystem;
     164    mutable bool isAutoGeneration;
     165    mutable bool isCompiled;
     166
     167    mutable DWORD beginOpAddress;
     168    mutable DWORD endOpAddress;
     169
     170    // ローカル変数
     171    mutable Variables localVars;
     172
     173    // 識別ID
     174    int id;
     175
     176    // XMLシリアライズ用
     177private:
     178    friend class boost::serialization::access;
     179    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     180    {
     181        trace_for_serialize( "serializing - UserProc" );
     182
     183        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
     184        ar & BOOST_SERIALIZATION_NVP( _paramStr );
     185        ar & BOOST_SERIALIZATION_NVP( namespaceScopes );
     186        ar & BOOST_SERIALIZATION_NVP( importedNamespaces );
     187        ar & boost::serialization::make_nvp("pParentClass", const_cast<CClass *&>(pParentClass) );
     188        ar & BOOST_SERIALIZATION_NVP( pMethod );
     189        ar & BOOST_SERIALIZATION_NVP( isMacro );
     190        ar & BOOST_SERIALIZATION_NVP( secondParmNum );
     191        ar & BOOST_SERIALIZATION_NVP( realParams );
     192        ar & BOOST_SERIALIZATION_NVP( realSecondParmNum );
     193        ar & BOOST_SERIALIZATION_NVP( isExport );
     194        ar & BOOST_SERIALIZATION_NVP( isSystem );
     195        ar & BOOST_SERIALIZATION_NVP( isAutoGeneration );
     196        ar & BOOST_SERIALIZATION_NVP( isCompiled );
     197        ar & BOOST_SERIALIZATION_NVP( beginOpAddress );
     198        ar & BOOST_SERIALIZATION_NVP( endOpAddress );
     199        ar & BOOST_SERIALIZATION_NVP( localVars );
     200        ar & BOOST_SERIALIZATION_NVP( id );
     201    }
     202
     203public:
     204
     205    UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport, int id )
     206        : Procedure( name, kind, isCdecl )
     207        , namespaceScopes( namespaceScopes )
     208        , importedNamespaces( importedNamespaces )
     209        , pParentClass( NULL )
     210        , pMethod( NULL )
     211        , isMacro( isMacro )
     212        , isExport( isExport )
     213        , isSystem( false )
     214        , isAutoGeneration( false )
     215        , isCompiled( false )
     216        , beginOpAddress( 0 )
     217        , endOpAddress( 0 )
     218        , id( id )
     219    {
     220    }
     221    UserProc()
     222    {
     223    }
     224    ~UserProc()
     225    {
     226        BOOST_FOREACH( Parameter *pParam, realParams ){
     227            delete pParam;
     228        }
     229    }
     230
     231    virtual const std::string &GetKeyName() const
     232    {
     233        return GetName();
     234    }
     235
     236    bool IsMacro() const
     237    {
     238        return isMacro;
     239    }
     240
     241    int GetSecondParmNum() const
     242    {
     243        return secondParmNum;
     244    }
     245    const Parameters &RealParams() const
     246    {
     247        return realParams;
     248    }
     249    int GetRealSecondParmNum() const
     250    {
     251        return realSecondParmNum;
     252    }
     253
     254    void ExportOff(){
     255        isExport = false;
     256    }
     257    bool IsExport() const
     258    {
     259        return isExport;
     260    }
     261    void ThisIsSystemProc() const
     262    {
     263        isSystem = true;
     264    }
     265    bool IsSystem() const
     266    {
     267        return isSystem;
     268    }
     269    void ThisIsAutoGenerationProc() const
     270    {
     271        isAutoGeneration = true;
     272    }
     273    bool IsAutoGeneration() const
     274    {
     275        return isAutoGeneration;
     276    }
     277    void CompleteCompile() const
     278    {
     279        isCompiled = true;
     280    }
     281    void KillCompileStatus() const
     282    {
     283        isCompiled = false;
     284    }
     285    bool IsCompiled() const
     286    {
     287        return isCompiled;
     288    }
     289    bool IsDestructor() const
     290    {
     291        return ( GetName()[0] == '~' );
     292    }
     293
     294    // バイナリコード位置とサイズ
     295    DWORD GetBeginOpAddress() const
     296    {
     297        return beginOpAddress;
     298    }
     299    void SetBeginOpAddress( DWORD beginOpAddress ) const
     300    {
     301        this->beginOpAddress = beginOpAddress;
     302    }
     303    DWORD GetEndOpAddress() const
     304    {
     305        return endOpAddress;
     306    }
     307    void SetEndOpAddress( DWORD endOpAddress ) const
     308    {
     309        this->endOpAddress = endOpAddress;
     310    }
     311    int GetCodeSize() const
     312    {
     313        return endOpAddress - beginOpAddress;
     314    }
     315
     316    const NamespaceScopes &GetNamespaceScopes() const;
     317    const NamespaceScopesCollection &GetImportedNamespaces() const;
     318
     319    Variables &GetLocalVars() const
     320    {
     321        return localVars;
     322    }
     323
     324    int GetId() const
     325    {
     326        return id;
     327    }
     328
     329    std::string GetFullName() const;
     330
     331    virtual bool IsDuplication( const UserProc *pUserProc ) const
     332    {
     333        if( this->GetParentClassPtr() == pUserProc->GetParentClassPtr()
     334            && pUserProc->IsEqualSymbol( *this )
     335            && this->Params().Equals( pUserProc->Params() ) )
     336        {
     337            return true;
     338        }
     339        return false;
     340    }
     341
     342    bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
     343    bool IsEqualSymbol( const UserProc &globalProc ) const;
     344    bool IsEqualSymbol( const string &name ) const;
     345
     346    bool IsVirtual() const;
     347
     348    void SetParentClass( const CClass *pParentClass ){
     349        this->pParentClass = pParentClass;
     350    }
     351    const CClass *GetParentClassPtr() const
     352    {
     353        return pParentClass;
     354    }
     355    const CClass &GetParentClass() const
     356    {
     357        return *pParentClass;
     358    }
     359    bool HasParentClass() const
     360    {
     361        return ( pParentClass != NULL );
     362    }
     363    void SetMethod( CMethod *pMethod ){
     364        this->pMethod = pMethod;
     365    }
     366
     367    bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic );
     368
     369
     370
     371    /////////////////////////////////////////////////////////////////
     372    // コンパイル中の関数を管理
     373    /////////////////////////////////////////////////////////////////
     374private:
     375    static const UserProc *pCompilingUserProc;
     376public:
     377    static void CompileStartForGlobalArea(){
     378        pCompilingUserProc = NULL;
     379    }
     380    static void CompileStartForUserProc( const UserProc *pUserProc ){
     381        pCompilingUserProc = pUserProc;
     382    }
     383    static bool IsGlobalAreaCompiling(){
     384        return ( pCompilingUserProc == NULL );
     385    }
     386    static bool IsLocalAreaCompiling(){
     387        return ( pCompilingUserProc != NULL );
     388    }
     389    static const UserProc &CompilingUserProc(){
     390        return *pCompilingUserProc;
     391    }
     392};
     393
     394class UserProcs : public Jenga::Common::Hashmap<UserProc>
     395{
     396    std::vector<std::string> macroNames;
     397
     398    // XMLシリアライズ用
     399private:
     400    friend class boost::serialization::access;
     401    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     402    {
     403        trace_for_serialize( "serializing - UserProcs" );
     404
     405        ar & boost::serialization::make_nvp("Hashmap_UserProcImpl",
     406            boost::serialization::base_object<Jenga::Common::Hashmap<UserProc>>(*this));
     407        ar & BOOST_SERIALIZATION_NVP( macroNames );
     408    }
     409
     410
     411public:
     412    UserProcs()
     413    {
     414    }
     415    ~UserProcs()
     416    {
     417    }
     418
     419    bool Insert( UserProc *pUserProc, int nowLine );
     420
     421    UserProc *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic);
     422
     423    void EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs );
     424
     425    static void CollectUserProcs( const BasicSource &source, UserProcs &userProcs );
     426};
     427
     428class DllProc : public Procedure
     429{
     430    NamespaceScopes namespaceScopes;
     431
     432    string dllFileName;
     433    string alias;
     434    int lookupAddress;
     435
     436    // XMLシリアライズ用
     437private:
     438    friend class boost::serialization::access;
     439    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     440    {
     441        trace_for_serialize( "serializing - DllProc" );
     442
     443        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
     444        ar & BOOST_SERIALIZATION_NVP( namespaceScopes );
     445        ar & BOOST_SERIALIZATION_NVP( dllFileName );
     446        ar & BOOST_SERIALIZATION_NVP( alias );
     447        ar & BOOST_SERIALIZATION_NVP( lookupAddress );
     448    }
     449
    20450public:
    21451    // ハッシュリスト用
    22     GlobalProc *pNextData;
    23 
    24     GlobalProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):
    25       UserProcImpl( name, kind, isMacro, isCdecl, isExport ),
     452    DllProc *pNextData;
     453
     454    DllProc( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ):
     455      Procedure( name, kind, isCdecl ),
    26456      namespaceScopes( namespaceScopes ),
    27       importedNamespaces( importedNamespaces ),
     457      dllFileName( dllFileName ),
     458      alias( alias ),
     459      lookupAddress( 0 ),
    28460      pNextData( NULL )
    29     {}
    30     ~GlobalProc(){}
    31 
    32     virtual const NamespaceScopes &GetNamespaceScopes() const;
    33     virtual const NamespaceScopesCollection &GetImportedNamespaces() const
    34     {
    35         return importedNamespaces;
    36     }
     461    {
     462    }
     463    ~DllProc(){}
    37464
    38465    virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
    39     virtual bool IsEqualSymbol( const GlobalProc &globalProc ) const;
    40     virtual bool IsEqualSymbol( const string &name ) const;
     466    bool IsEqualSymbol( const string &name ) const;
     467
     468    const NamespaceScopes &GetNamespaceScopes() const
     469    {
     470        return namespaceScopes;
     471    }
     472
     473    const string &GetDllFileName() const
     474    {
     475        return dllFileName;
     476    }
     477    const string &GetAlias() const
     478    {
     479        return alias;
     480    }
     481
     482    void SetLookupAddress( int lookupAddress ){
     483        this->lookupAddress = lookupAddress;
     484    }
     485    int GetLookupAddress() const
     486    {
     487        return lookupAddress;
     488    }
     489
     490    bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
    41491};
    42492
    43 class DllProcImpl : public DllProc
     493class ProcPointer : public Procedure
    44494{
    45 public:
    46     DllProcImpl( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias )
    47         : DllProc( namespaceScopes, name, kind, isCdecl, dllFileName, alias )
    48     {
    49     }
    50 
    51     virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
     495    // XMLシリアライズ用
     496private:
     497    friend class boost::serialization::access;
     498    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     499    {
     500        trace_for_serialize( "serializing - ProcPointer" );
     501
     502        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
     503    }
     504
     505public:
     506    ProcPointer( Kind kind )
     507        : Procedure( "", kind, false )
     508    {
     509    }
     510    ProcPointer()
     511    {
     512    }
     513    ~ProcPointer(){}
    52514
    53515    virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
    54516};
    55517
    56 class ProcPointerImpl : public ProcPointer
     518class ProcPointers : public vector<ProcPointer *>
    57519{
    58 public:
    59     ProcPointerImpl( Kind kind ):
    60       ProcPointer( kind )
    61     {
    62     }
    63 
    64     virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine );
    65 };
    66 
    67 class ProcPointersImpl : public ProcPointers
    68 {
    69 public:
    70     ProcPointersImpl()
    71     {
    72     }
    73     ~ProcPointersImpl()
     520    // XMLシリアライズ用
     521private:
     522    friend class boost::serialization::access;
     523    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     524    {
     525        trace_for_serialize( "serializing - ProcPointers" );
     526
     527        ar & boost::serialization::make_nvp("vector_ProcPointer",
     528            boost::serialization::base_object<vector<ProcPointer *>>(*this));
     529    }
     530
     531public:
     532    ProcPointers()
     533    {
     534    }
     535    ~ProcPointers()
    74536    {
    75537        Clear();
  • trunk/abdev/BasicCompiler_Common/include/SmoothieImpl.h

    r193 r206  
    22
    33#include <jenga/include/smoothie/Smoothie.h>
    4 #include <jenga/include/smoothie/ObjectModule.h>
    54
    65#include <MetaImpl.h>
  • trunk/abdev/BasicCompiler_Common/include/TypeDef.h

    r193 r206  
    44#include <string>
    55
    6 #include <jenga/include/smoothie/Type.h>
    76#include <jenga/include/smoothie/Namespace.h>
     7
     8#include <Type.h>
     9#include <Symbol.h>
    810
    911using namespace std;
     
    1113class TypeDefCollection;
    1214
    13 class TypeDef{
     15class TypeDef : public Symbol
     16{
    1417    friend TypeDefCollection;
    1518
    16     NamespaceScopes namespaceScopes;
    17 
    18     string name;
    1919    string baseName;
    2020    Type baseType;
     21
     22    // XMLシリアライズ用
     23private:
     24    friend class boost::serialization::access;
     25    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     26    {
     27        trace_for_serialize( "serializing - TypeDef" );
     28
     29        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
     30        ar & BOOST_SERIALIZATION_NVP( baseName );
     31        ar & BOOST_SERIALIZATION_NVP( baseType );
     32    }
     33
    2134public:
    2235    TypeDef( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName, int nowLine );
    23     ~TypeDef();
     36    TypeDef()
     37    {
     38    }
     39    ~TypeDef()
     40    {
     41    }
    2442
    25     const string &GetName() const
    26     {
    27         return name;
    28     }
    2943    const string &GetBaseName() const
    3044    {
     
    3549        return baseType;
    3650    }
    37 
    38     bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
    39     bool IsEqualSymbol( const string &name ) const;
    4051};
    4152
    42 class TypeDefCollection : public vector<TypeDef>
     53class TypeDefCollection : public std::vector<TypeDef>
    4354{
     55    // XMLシリアライズ用
     56private:
     57    friend class boost::serialization::access;
     58    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     59    {
     60        trace_for_serialize( "serializing - TypeDefCollection" );
     61
     62        ar & boost::serialization::make_nvp("vector_TypeDef",
     63            boost::serialization::base_object<std::vector<TypeDef>>(*this));
     64    }
     65
    4466public:
    4567    TypeDefCollection();
  • trunk/abdev/BasicCompiler_Common/include/option.h

    r182 r206  
    2323
    2424// ログ生成しない場合はこの下の行をコメントアウトする
    25 //#define USE_TRACE
     25#define USE_TRACE
    2626
    2727// オーバーロードに関するログを生成する
    28 #define USE_TRACE_FOR_OVERLOAD
     28//#define USE_TRACE_FOR_OVERLOAD
    2929
    3030// モジュールサイズに関するログを生成する
    31 #define USE_TRACE_FOR_SIZE
     31//#define USE_TRACE_FOR_SIZE
     32
     33// XMLシリアライズに関するログを生成する
     34#define USE_TRACE_FOR_SERIALIZE
     35
     36// ソースコードステップに関するログを生成する
     37#define USE_TRACE_FOR_SOURCECODESTEP
    3238
    3339
     
    5359#define trace_for_size(s)
    5460#endif
     61
     62#ifdef USE_TRACE_FOR_SERIALIZE
     63#define trace_for_serialize(s) trace(s)
     64#else
     65#define trace_for_serialize(s)
     66#endif
     67
     68#ifdef USE_TRACE_FOR_SOURCECODESTEP
     69#define trace_for_sourcecodestep(s) trace( "[source code step] " << s)
     70#else
     71#define trace_for_sourcecodestep(s)
     72#endif
  • trunk/abdev/BasicCompiler_Common/src/Class.cpp

    r204 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    2 #include <jenga/include/smoothie/Class.h>
    34#include <jenga/include/smoothie/Source.h>
    45#include <jenga/include/smoothie/SmoothieException.h>
    56#include <jenga/include/smoothie/LexicalAnalysis.h>
    67
    7 #include <ClassImpl.h>
     8#include <Class.h>
    89#include <Compiler.h>
    910#include <NamespaceSupporter.h>
     
    1516#include "../../BasicCompiler32/opcode.h"
    1617#endif
    17 
    18 
    1918
    2019
     
    7776
    7877
    79 bool ClassImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    80 {
    81     if( GetName() != name ){
     78bool CClass::IsClass() const
     79{
     80    return classType == CClass::Class;
     81}
     82bool CClass::IsInterface() const
     83{
     84    return classType == CClass::Interface;
     85}
     86bool CClass::IsEnum() const
     87{
     88    return classType == CClass::Enum;
     89}
     90bool CClass::IsDelegate() const
     91{
     92    return classType == CClass::Delegate;
     93}
     94bool CClass::IsStructure() const
     95{
     96    return classType == CClass::Structure;
     97}
     98
     99
     100// コンストラクタのコンパイルを開始
     101void CClass::NotifyStartConstructorCompile() const
     102{
     103    isCompilingConstructor = true;
     104}
     105
     106//コンストラクタのコンパイルを終了
     107void CClass::NotifyFinishConstructorCompile() const
     108{
     109    isCompilingConstructor = false;
     110}
     111
     112//コンストラクタをコンパイル中かどうかを判別
     113bool CClass::IsCompilingConstructor() const
     114{
     115    return isCompilingConstructor;
     116}
     117
     118//デストラクタのコンパイルを開始
     119void CClass::NotifyStartDestructorCompile() const{
     120    isCompilingDestructor = true;
     121}
     122
     123//デストラクタのコンパイルを終了
     124void CClass::NotifyFinishDestructorCompile() const{
     125    isCompilingDestructor = false;
     126}
     127
     128//デストラクタをコンパイル中かどうかを判別
     129bool CClass::IsCompilingDestructor() const
     130{
     131    return isCompilingDestructor;
     132}
     133
     134//自身の派生クラスかどうかを確認
     135bool CClass::IsSubClass( const CClass *pClass ) const
     136{
     137    if( !pClass->HasSuperClass() )
     138    {
    82139        return false;
    83140    }
    84141
    85     return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes );
    86 }
    87 
    88 bool ClassImpl::Inherits( const char *inheritNames, int nowLine ){
     142    const CClass *pTempClass = &pClass->GetSuperClass();
     143    while( pTempClass ){
     144        if( this == pTempClass ) return true;
     145        pTempClass = &pTempClass->GetSuperClass();
     146    }
     147    return false;
     148}
     149
     150//自身と等しいまたは派生クラスかどうかを確認
     151bool CClass::IsEqualsOrSubClass( const CClass *pClass ) const
     152{
     153    if( IsEquals( pClass ) ) return true;
     154    return IsSubClass( pClass );
     155}
     156
     157// 自身と等しいまたは派生クラス、基底クラスかどうかを確認
     158bool CClass::IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const
     159{
     160    if( IsEquals( &objClass ) ) return true;
     161    if( IsSubClass( &objClass ) ) return true;
     162    if( objClass.IsSubClass( this ) ) return true;
     163    return false;
     164}
     165
     166bool CClass::IsInheritsInterface( const CClass *pInterfaceClass ) const
     167{
     168    BOOST_FOREACH( const InheritedInterface &objInterface, interfaces ){
     169        if( pInterfaceClass == &objInterface.GetInterfaceClass() ){
     170            return true;
     171        }
     172    }
     173    return false;
     174}
     175
     176bool CClass::Inherits( const char *inheritNames, int nowLine ){
    89177    int i = 0;
    90178    bool isInheritsClass = false;
     
    183271    return true;
    184272}
    185 bool ClassImpl::InheritsClass( const CClass &inheritsClass, int nowLine ){
     273bool CClass::InheritsClass( const CClass &inheritsClass, int nowLine ){
    186274
    187275    //ループ継承でないかをチェック
     
    245333    return true;
    246334}
    247 bool ClassImpl::InheritsInterface( const CClass &inheritsInterface, int nowLine ){
     335bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){
    248336
    249337    //ループ継承でないかをチェック
     
    291379    return true;
    292380}
    293 CMember *ClassImpl::CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine )
     381CMember *CClass::CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine )
    294382{
    295383    extern int cp;
     
    299387    char initBuffer[VN_SIZE];
    300388    char lpszConstructParameter[VN_SIZE];
    301     int SubScripts[MAX_ARRAYDIM];
     389    Subscripts subscripts;
    302390    Type type;
    303     GetDimentionFormat(buffer,VarName,SubScripts,type,initBuffer,lpszConstructParameter);
     391    GetDimentionFormat(buffer,VarName,subscripts,type,initBuffer,lpszConstructParameter);
    304392
    305393    //重複チェック
     
    308396    }
    309397
    310     CMember *pMember = new CMember( accessibility, VarName, type, isConst, initBuffer, lpszConstructParameter );
     398    CMember *pMember = new CMember( accessibility, VarName, type, isConst, subscripts, initBuffer, lpszConstructParameter );
    311399    pMember->source_code_address = nowLine;
    312     memcpy( pMember->SubScripts, SubScripts, MAX_ARRAYDIM * sizeof(int) );
    313400    return pMember;
    314401}
    315 void ClassImpl::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){
     402void CClass::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){
    316403    dynamicMembers.push_back(
    317404        CreateMember( accessibility, isConst, isRef, buffer, nowLine )
    318405    );
    319406}
    320 void ClassImpl::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){
     407void CClass::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){
    321408    staticMembers.push_back(
    322409        CreateMember( accessibility, isConst, isRef, buffer, nowLine )
     
    324411}
    325412
    326 void ClassImpl::AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
     413void CClass::AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
    327414                         bool isVirtual, bool isOverride, char *buffer, int nowLine){
    328415    int i,i2;
     
    340427
    341428    //関数ハッシュへ登録
    342     GlobalProc *pUserProc;
    343     pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0) );
     429    UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Add( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0) );
    344430    if(!pUserProc) return;
    345431
     
    394480        if( pMethod->GetInheritsClassPtr() ) continue;
    395481
    396         if( pMethod->pUserProc->GetName() == temporary ){
    397             if( pMethod->pUserProc->Params().Equals( pUserProc->Params() ) ){
     482        if( pMethod->GetUserProc().GetName() == temporary ){
     483            if( pMethod->GetUserProc().Params().Equals( pUserProc->Params() ) ){
    398484                //関数名、パラメータ属性が合致したとき
    399485                SetError(15,pUserProc->GetName().c_str(),nowLine);
     
    408494    //メソッドのオーバーライド
    409495    BOOST_FOREACH( CMethod *pMethod, pobj_c->GetMethods() ){
    410         if( pMethod->pUserProc->GetName() == temporary ){
    411             if( pMethod->pUserProc->Params().Equals( pUserProc->Params() ) ){
     496        if( pMethod->GetUserProc().GetName() == temporary ){
     497            if( pMethod->GetUserProc().Params().Equals( pUserProc->Params() ) ){
    412498
    413499                if(pMethod->IsVirtual()){
    414500                    //メンバ関数を上書き
    415                     pMethod->pUserProc=pUserProc;
     501                    pMethod->SetUserProcPtr( pUserProc );
    416502                    pMethod->Override();
    417503
     
    446532}
    447533
    448 LONG_PTR ClassImpl::GetVtblGlobalOffset(void) const
     534bool CClass::DupliCheckAll(const char *name){
     535    //重複チェック
     536
     537    //メンバ
     538    if(DupliCheckMember(name)) return 1;
     539
     540    //メソッド
     541    BOOST_FOREACH( const CMethod *pMethod, methods ){
     542        if( lstrcmp( name, pMethod->GetUserProc().GetName().c_str() ) == 0 ){
     543            return 1;
     544        }
     545    }
     546
     547    return 0;
     548}
     549bool CClass::DupliCheckMember(const char *name){
     550    //重複チェック
     551
     552    // 動的メンバ
     553    BOOST_FOREACH( CMember *pMember, dynamicMembers ){
     554        if( GetName() == pMember->GetName() ){
     555            return 1;
     556        }
     557    }
     558
     559    // 静的メンバ
     560    BOOST_FOREACH( CMember *pMember, staticMembers ){
     561        if( GetName() == pMember->GetName() ){
     562            return 1;
     563        }
     564    }
     565
     566    return 0;
     567}
     568
     569//サイズを取得
     570int CClass::GetSize() const
     571{
     572    return GetMemberOffset( NULL, NULL );
     573}
     574
     575//メンバのオフセットを取得
     576int CClass::GetMemberOffset( const char *memberName, int *pMemberNum ) const
     577{
     578    int i2;
     579
     580    //仮想関数が存在する場合は関数リストへのポインタのサイズを追加
     581    int offset = IsExistVirtualFunctions() ? PTR_SIZE : 0;
     582
     583    int alignment;
     584    if(iAlign) alignment=iAlign;
     585    else alignment=1;
     586
     587    int iMaxAlign=0;
     588    int i = -1;
     589    BOOST_FOREACH( CMember *pMember, dynamicMembers ){
     590        i++;
     591
     592        i2 = pMember->GetType().GetSize();
     593
     594        //アラインメントを算出
     595        int member_size;
     596        if( pMember->GetType().IsStruct() ){
     597            //メンバクラスのアラインメントを取得
     598            member_size=pMember->GetType().GetClass().GetAlignment();
     599        }
     600        else{
     601            //メンバサイズを取得
     602            member_size=i2;
     603        }
     604        if(iMaxAlign<member_size) iMaxAlign=member_size;
     605
     606        //アラインメントを考慮
     607        if(iAlign&&iAlign<member_size){
     608            if(offset%alignment) offset+=alignment-(offset%alignment);
     609        }
     610        else{
     611            if(alignment<member_size) alignment=member_size;
     612
     613            if(member_size==0){
     614                //メンバを持たないクラス
     615                //※何もしない(オフセットの計算をしない)
     616            }
     617            else{
     618                if(offset%member_size) offset+=member_size-(offset%member_size);
     619            }
     620        }
     621
     622        if(memberName){
     623            //メンバ指定がある場合は、オフセットを返す
     624            if( pMember->GetName() == memberName ){
     625                if(pMemberNum) *pMemberNum=i;
     626                return offset;
     627            }
     628        }
     629
     630        //配列を考慮したメンバサイズを取得
     631        member_size = i2 * Variable::GetSubScriptCounts( pMember->GetSubscripts() );
     632
     633        //メンバサイズを加算
     634        offset+= member_size;
     635    }
     636
     637    if(iMaxAlign<alignment) alignment=iMaxAlign;
     638
     639    //アラインメントを考慮
     640    if(alignment){
     641        if(offset%alignment) offset+=alignment-(offset%alignment);
     642    }
     643
     644    if(pMemberNum) *pMemberNum=i;
     645    return offset;
     646}
     647int CClass::GetAlignment() const
     648{
     649    //仮想関数が存在する場合は関数リストへのポインタのサイズを追加
     650    int alignment = IsExistVirtualFunctions() ? PTR_SIZE : 0;
     651
     652    BOOST_FOREACH( CMember *pMember, dynamicMembers ){
     653        int member_size;
     654        if(pMember->GetType().IsStruct()){
     655            //メンバクラスのアラインメントを取得
     656            member_size=pMember->GetType().GetClass().GetAlignment();
     657        }
     658        else{
     659            //メンバサイズを取得
     660            member_size = pMember->GetType().GetSize();
     661        }
     662
     663        //アラインメントをセット
     664        if(alignment<member_size) alignment=member_size;
     665    }
     666
     667    if(alignment==0) return 0;
     668
     669    if(iAlign) alignment=iAlign;
     670
     671    return alignment;
     672}
     673int CClass::GetFuncNumInVtbl( const UserProc *pUserProc ) const
     674{
     675    int n = 0;
     676    BOOST_FOREACH( const CMethod *pMethod, methods ){
     677        if( &pMethod->GetUserProc() == pUserProc ) break;
     678        if( pMethod->IsVirtual() ) n++;
     679    }
     680    return n;
     681}
     682LONG_PTR CClass::GetVtblGlobalOffset(void) const
    449683{
    450684
     
    458692    //////////////////////////////////////
    459693
    460     UserProc **ppsi;
    461     ppsi=(UserProc **)malloc(GetVtblNum()*sizeof(UserProc *));
     694    const UserProc **ppsi;
     695    ppsi=(const UserProc **)malloc(GetVtblNum()*sizeof(UserProc *));
    462696
    463697    //関数テーブルに値をセット
     
    465699    BOOST_FOREACH( const CMethod *pMethod, methods ){
    466700        if(pMethod->IsVirtual()){
    467             pMethod->pUserProc->Using();
     701            pMethod->GetUserProc().Using();
    468702
    469703            if(pMethod->IsAbstract()){
     
    474708            }
    475709            else{
    476                 ppsi[i2]=pMethod->pUserProc;
     710                ppsi[i2]=&pMethod->GetUserProc();
    477711            }
    478712            i2++;
     
    490724    return vtbl_offset;
    491725}
    492 void ClassImpl::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){
     726void CClass::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){
    493727    if(vtbl_offset==-1) return;
    494728
     
    501735        pUserProc=(UserProc *)pVtbl[i];
    502736        if(!pUserProc) continue;
    503         pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection;
    504     }
    505 }
    506 
    507 CClass *ClassesImpl::Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name){
    508     return new ClassImpl(namespaceScopes, importedNamespaces, name);
    509 }
    510 
    511 void ClassesImpl::CollectClassesForNameOnly( const BasicSource &source )
     737        pVtbl[i]=pUserProc->GetBeginOpAddress()+ImageBase+MemPos_CodeSection;
     738    }
     739}
     740bool CClass::IsAbstract() const
     741{
     742    // 未実装(abstract)の仮想関数を持つ場合はtrueを返す
     743
     744    BOOST_FOREACH( const CMethod *pMethod, methods ){
     745        if(pMethod->IsVirtual()){
     746            if(pMethod->IsAbstract()){
     747                return true;
     748            }
     749        }
     750    }
     751
     752    return false;
     753}
     754
     755
     756int Classes::GetHashCode(const char *name) const
     757{
     758    int key;
     759
     760    for(key=0;*name!='\0';name++){
     761        key=((key<<8)+ *name )%MAX_CLASS_HASH;
     762    }
     763
     764    return key;
     765}
     766
     767CClass *Classes::Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name){
     768    return new CClass(namespaceScopes, importedNamespaces, name);
     769}
     770bool Classes::Insert( CClass *pClass )
     771{
     772    // キャッシュしておくクラス
     773    if( pClass->GetName() == "String" )
     774    {
     775        pStringClass=pClass;
     776    }
     777    else if( pClass->GetName() == "Object" )
     778    {
     779        pObjectClass = pClass;
     780    }
     781
     782    /////////////////////////////////
     783    // ハッシュデータに追加
     784    /////////////////////////////////
     785
     786    int key;
     787    key=GetHashCode( pClass->GetName().c_str() );
     788
     789    if(pobj_ClassHash[key]){
     790        CClass *pobj_c2;
     791        pobj_c2=pobj_ClassHash[key];
     792        while(1){
     793            if( ((const Prototype *)pobj_c2)->IsEqualSymbol( *(const Prototype *)pClass ) ){
     794                //名前空間及びクラス名が重複した場合
     795                SmoothieException::Throw(15,pClass->GetName());
     796                return false;
     797            }
     798
     799            if(pobj_c2->pobj_NextClass==0) break;
     800            pobj_c2=pobj_c2->pobj_NextClass;
     801        }
     802        pobj_c2->pobj_NextClass=pClass;
     803    }
     804    else{
     805        pobj_ClassHash[key]=pClass;
     806    }
     807    return true;
     808}
     809CClass *Classes::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){
     810    //////////////////////////////////////////////////////////////////////////
     811    // クラスを追加
     812    // ※名前のみを登録。その他の情報はSetClassメソッドで!
     813    //////////////////////////////////////////////////////////////////////////
     814
     815    CClass *pClass = Create(namespaceScopes, importedNamespaces, name);
     816
     817    if( !Insert( pClass ) )
     818    {
     819        return NULL;
     820    }
     821
     822    return pClass; 
     823}
     824
     825void Classes::CollectClassesForNameOnly( const BasicSource &source )
    512826{
    513827    int i, i2;
     
    641955}
    642956
    643 void ClassesImpl::InitStaticMember(){
     957void Classes::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){
     958    int i;
     959    for(i=0;i<MAX_CLASS_HASH;i++){
     960        if(pobj_ClassHash[i]){
     961            CClass *pobj_c;
     962            pobj_c=pobj_ClassHash[i];
     963            while(1){
     964                pobj_c->ActionVtblSchedule(ImageBase,MemPos_CodeSection);
     965
     966                if(pobj_c->pobj_NextClass==0) break;
     967                pobj_c=pobj_c->pobj_NextClass;
     968            }
     969        }
     970    }
     971}
     972
     973
     974void Classes::InitStaticMember(){
    644975    //静的メンバをグローバル領域に作成
    645976
     
    662993            dim(
    663994                temporary,
    664                 member->SubScripts,
     995                member->GetSubscripts(),
    665996                member->GetType(),
    666997                member->GetInitializeExpression().c_str(),
     
    6791010    cp=back_cp;
    6801011}
    681 bool ClassesImpl::MemberVar_LoopRefCheck(const CClass &objClass){
     1012bool Classes::MemberVar_LoopRefCheck(const CClass &objClass){
    6821013    bool result = true;
    6831014    BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){
     
    7041035    return result;
    7051036}
    706 void ClassesImpl::GetClass_recur(const char *lpszInheritsClass){
     1037void Classes::GetClass_recur(const char *lpszInheritsClass){
    7071038    extern char *basbuf;
    7081039    int i,i2,i3,sub_address,top_pos;
     
    11561487    compiler.GetNamespaceSupporter().GetLivingNamespaceScopes() = backupNamespaceScopes;
    11571488}
    1158 void ClassesImpl::GetAllClassInfo(void){
     1489void Classes::GetAllClassInfo(void){
    11591490    //ループ継承チェック用のクラス
    11601491    pobj_LoopRefCheck=new CLoopRefCheck();
     
    11691500    this->Iterator_Init();
    11701501}
    1171 void ClassesImpl::Compile_System_InitializeUserTypes(){
     1502void Classes::Compile_System_InitializeUserTypes(){
    11721503    char temporary[VN_SIZE];
    11731504
     
    12961627}
    12971628
    1298 const CClass *ClassesImpl::Find( const NamespaceScopes &namespaceScopes, const string &name ) const
     1629const CClass *Classes::Find( const NamespaceScopes &namespaceScopes, const string &name ) const
    12991630{
    13001631    int key;
     
    13331664    return NULL;
    13341665}
     1666const CClass *Classes::Find( const string &fullName ) const
     1667{
     1668    char AreaName[VN_SIZE] = "";        //オブジェクト変数
     1669    char NestName[VN_SIZE] = "";        //入れ子メンバ
     1670    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
     1671
     1672    return Find( NamespaceScopes( AreaName ), NestName );
     1673}
     1674void Classes::StartCompile( const UserProc *pUserProc ){
     1675    const CClass *pParentClass = pUserProc->GetParentClassPtr();
     1676    if( pParentClass ){
     1677        pParentClass->Using();
     1678
     1679        pCompilingMethod = pParentClass->GetMethods().GetMethodPtr( pUserProc );
     1680        if( !pCompilingMethod ){
     1681            pCompilingMethod = pParentClass->GetStaticMethods().GetMethodPtr( pUserProc );
     1682            if( !pCompilingMethod ){
     1683                SmoothieException::Throw(300);
     1684            }
     1685        }
     1686    }
     1687    else{
     1688        pCompilingMethod = NULL;
     1689    }
     1690}
     1691
     1692CClass *Classes::GetStringClassPtr() const
     1693{
     1694    if( !pStringClass ){
     1695        SmoothieException::Throw();
     1696        return NULL;
     1697    }
     1698    return pStringClass;
     1699}
     1700CClass *Classes::GetObjectClassPtr() const
     1701{
     1702    if( !pObjectClass ){
     1703        SmoothieException::Throw();
     1704        return NULL;
     1705    }
     1706    return pObjectClass;
     1707}
     1708
     1709
     1710//////////////////////
     1711// イテレータ
     1712//////////////////////
     1713
     1714void Classes::Iterator_Init() const
     1715{
     1716    if(ppobj_IteClass) free(ppobj_IteClass);
     1717
     1718    iIteMaxNum=0;
     1719    iIteNextNum=0;
     1720    ppobj_IteClass=(CClass **)malloc(1);
     1721
     1722    int i;
     1723    for(i=0;i<MAX_CLASS_HASH;i++){
     1724        if(pobj_ClassHash[i]){
     1725            CClass *pobj_c;
     1726            pobj_c=pobj_ClassHash[i];
     1727            while(1){
     1728                ppobj_IteClass=(CClass **)realloc(ppobj_IteClass,(iIteMaxNum+1)*sizeof(CClass *));
     1729                ppobj_IteClass[iIteMaxNum]=pobj_c;
     1730                iIteMaxNum++;
     1731
     1732                if(pobj_c->pobj_NextClass==0) break;
     1733                pobj_c=pobj_c->pobj_NextClass;
     1734            }
     1735        }
     1736    }
     1737}
     1738void Classes::Iterator_Reset() const
     1739{
     1740    iIteNextNum = 0;
     1741}
     1742BOOL Classes::Iterator_HasNext() const
     1743{
     1744    if(iIteNextNum<iIteMaxNum) return 1;
     1745    return 0;
     1746}
     1747CClass *Classes::Iterator_GetNext() const
     1748{
     1749    CClass *pobj_c = ppobj_IteClass[iIteNextNum];
     1750    iIteNextNum++;
     1751    return pobj_c;
     1752}
     1753int Classes::Iterator_GetMaxCount() const
     1754{
     1755    return iIteMaxNum;
     1756}
  • trunk/abdev/BasicCompiler_Common/src/CodeGenerator.cpp

    r184 r206  
     1#include "stdafx.h"
     2
    13#include <windows.h>
    24#include <stdlib.h>
  • trunk/abdev/BasicCompiler_Common/src/Compiler.cpp

    r196 r206  
    1 #include <jenga/include/smoothie/Type.h>
     1#include "stdafx.h"
     2
    23#include <jenga/include/smoothie/SmoothieException.h>
    34
    45#include <Compiler.h>
     6#include <Type.h>
    57
    68Compiler compiler;
  • trunk/abdev/BasicCompiler_Common/src/Const.cpp

    r201 r206  
     1#include "stdafx.h"
     2
    13#include <Compiler.h>
    2 #include <NamespaceSupporter.h>
    3 
    4 #include "common.h"
    5 #include OPCODE_H_PATH  //opcode.h
    6 
    7 
    8 //シングルトンオブジェクト
    9 CDBConst CDBConst::obj;
    10 
    11 
    12 bool ConstBase::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    13 {
    14     if( GetName() != name ){
    15         return false;
    16     }
    17     return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->namespaceScopes, namespaceScopes );
    18 }
    19 bool ConstBase::IsEqualSymbol( const string &fullName ) const
    20 {
    21     char AreaName[VN_SIZE] = "";        //オブジェクト変数
    22     char NestName[VN_SIZE] = "";        //入れ子メンバ
    23     bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );
    24 
    25     return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
    26 }
    27 
    28 
    29 
    30 
    31 CConst::CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &newType, _int64 i64data)
    32     : ConstBase( namespaceScopes, name )
    33     , type( newType )
    34     , i64data( i64data )
    35     , pNext( NULL )
    36 {
    37 }
    38 CConst::CConst( const NamespaceScopes &namespaceScopes, const string &name, int value)
    39     : ConstBase( namespaceScopes, name )
    40     , type( Type(DEF_LONG) )
    41     , i64data( value )
    42     , pNext( NULL )
    43 {
    44 }
    45 CConst::~CConst(){
    46     //連結先のオブジェクトを破棄
    47     if(pNext){
    48         delete pNext;
    49         pNext = 0;
    50     }
    51 }
    52 
    53 Type CConst::GetType(){
    54     return type;
    55 }
    56 _int64 CConst::GetWholeData(){
    57     return i64data;
    58 }
     4
     5
    596double CConst::GetDoubleData(){
    607    double dbl;
     
    6310}
    6411
    65 
    66 
    67 CConstMacro::CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression)
    68     : ConstBase( namespaceScopes, name )
    69 {
    70 }
    71 CConstMacro::~CConstMacro(){
    72 }
    73 
    74 
    75 
    76 
    77 
    78 CDBConst::CDBConst(){
    79     memset(this,0,sizeof(CDBConst));
    80 
    81     ppHash = (CConst **)calloc(MAX_HASH*sizeof(CConst *),1);
    82     Init();
    83 }
    84 CDBConst::~CDBConst(){
    85     Free();
    86 
    87     free(ppHash);
    88 }
    89 
    90 //解放
    91 void CDBConst::Free(){
     12void AddConst( const NamespaceScopes &namespaceScopes, char *buffer ){
    9213    int i;
    93     for(i=0; i<MAX_HASH; i++){
    94         if(ppHash[i]){
    95             delete ppHash[i];
    96             ppHash[i] = 0;
    97         }
    98     }
    99 }
    100 
    101 //初期化
    102 void CDBConst::Init(){
    103     Free();
    104 }
    105 
    106 void AddConstData(char *Command);
    107 void CDBConst::Add( const NamespaceScopes &namespaceScopes, char *buffer ){
    108     int i;
    10914
    11015    //名前を取得
    111     char Name[VN_SIZE];
     16    char name[VN_SIZE];
    11217    for(i=0;;i++){
    11318        if(buffer[i]=='\0'){
     
    11621        }
    11722        if(buffer[i]=='='||buffer[i]=='('){
    118             Name[i]=0;
     23            name[i]=0;
    11924            break;
    12025        }
    121         Name[i]=buffer[i];
     26        name[i]=buffer[i];
    12227    }
    12328
    12429    //重複チェック
    125     if(GetBasicType(Name)){
    126         SetError(15,Name,cp);
     30    if( compiler.GetMeta().GetGlobalConstMacros().IsExist( name )
     31        || compiler.GetMeta().GetGlobalConsts().IsExist( name ) )
     32    {
     33        SetError(15,name,cp);
    12734        return;
    12835    }
     
    13138        //定数マクロ
    13239
    133         //未完成
    134         AddConstData(buffer);
     40        compiler.GetMeta().GetGlobalConstMacros().Add( namespaceScopes, name, buffer + i );
    13541    }
    13642    else{
    13743        //一般の定数
    138         char *Expression = buffer + i + 1;
    139 
    140         AddConst( namespaceScopes, Name,Expression);
    141     }
    142 }
    143 
    144 void CDBConst::AddConst( const string &name, CConst *newconst){
    145     int key = hash_default(name.c_str());
    146 
    147     //ハッシュリストに追加
    148     if(ppHash[key]){
    149         CConst *pConst = ppHash[key];
    150         while(pConst->pNext){
    151             pConst = pConst->pNext;
    152         }
    153 
    154         pConst->pNext = newconst;
    155     }
    156     else{
    157         ppHash[key] = newconst;
    158     }
    159 }
    160 void CDBConst::AddConst( const NamespaceScopes &namespaceScopes, const string &name , char *Expression){
     44        char *expression = buffer + i + 1;
     45
     46        compiler.GetMeta().GetGlobalConsts().Add( namespaceScopes, name, expression );
     47    }
     48}
     49
     50void Consts::Add( const NamespaceScopes &namespaceScopes, const string &name , char *Expression)
     51{
    16152    _int64 i64data;
    16253    Type resultType;
     
    17263    CConst *newconst = new CConst(namespaceScopes, name, resultType, i64data);
    17364
    174     AddConst( name, newconst);
    175 }
    176 void CDBConst::AddConst(const NamespaceScopes &namespaceScopes, const string &name, int value){
     65    //ハッシュリストに追加
     66    Put( newconst );
     67}
     68void Consts::Add(const NamespaceScopes &namespaceScopes, const string &name, int value){
    17769    CConst *newconst = new CConst( namespaceScopes, name, value);
    17870
    179     AddConst(name, newconst);
    180 }
    181 
    182 CConst *CDBConst::GetObjectPtr( const string &name ){
     71    //ハッシュリストに追加
     72    Put( newconst );
     73}
     74
     75CConst *Consts::GetObjectPtr( const string &name ){
    18376    char ObjName[VN_SIZE];      //オブジェクト変数
    18477    char NestMember[VN_SIZE];   //入れ子メンバ
    185     bool isObjectMember = CClass::SplitName( name.c_str(), ObjName, NestMember );
    186 
    187     //ハッシュ値を取得
    188     int key;
    189     key=hash_default( NestMember );
    190 
    191     //格納位置を取得
    192     CConst *pConst;
    193     pConst=ppHash[key];
    194     while(pConst){
    195         if( pConst->IsEqualSymbol( name ) ) break;
    196 
    197         pConst=pConst->pNext;
     78    bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember );
     79
     80    CConst *pConst = GetHashArrayElement( NestMember );
     81    while( pConst )
     82    {
     83        if( pConst->IsEqualSymbol( name ) )
     84        {
     85            break;
     86        }
     87        pConst = pConst->GetChainNext();
    19888    }
    19989
     
    20292
    20393
    204 int CDBConst::GetBasicType(char *Name){
     94int Consts::GetBasicType(char *Name){
    20595    CConst *pConst = GetObjectPtr(Name);
    20696
     
    20999    return pConst->GetType().GetBasicType();
    210100}
    211 _int64 CDBConst::GetWholeData(char *Name){
     101_int64 Consts::GetWholeData(char *Name){
    212102    CConst *pConst = GetObjectPtr(Name);
    213103
     
    216106    return pConst->GetWholeData();
    217107}
    218 double CDBConst::GetDoubleData(char *Name){
     108double Consts::GetDoubleData(char *Name){
    219109    CConst *pConst = GetObjectPtr(Name);
    220110
     
    223113    return pConst->GetDoubleData();
    224114}
    225 bool CDBConst::IsStringPtr( char *Name ){
     115bool Consts::IsStringPtr( char *Name ){
    226116    CConst *pConst = GetObjectPtr(Name);
    227117
     
    232122    return ( type.GetBasicType() == typeOfPtrChar && type.GetIndex() == LITERAL_STRING );
    233123}
     124
     125
     126bool ConstMacro::GetCalcBuffer( const char *parameterStr, char *dest ) const
     127{
     128    extern HANDLE hHeap;
     129    int i2,i3,i4,num;
     130    char temporary[VN_SIZE];
     131    char *pParms[MAX_PARMS];
     132    num=0;
     133    i2=0;
     134    while(1){
     135        i2=GetOneParameter(parameterStr,i2,temporary);
     136
     137        pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
     138        lstrcpy(pParms[num],temporary);
     139
     140        num++;
     141        if(parameterStr[i2]=='\0') break;
     142    }
     143    if( num != this->GetParameters().size() ){
     144        extern int cp;
     145        for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
     146        SetError(10,GetName().c_str(),cp);
     147        lstrcpy(dest,"0");
     148        return 1;
     149    }
     150
     151    i2=0;
     152    i4=0;
     153    while(1){
     154
     155        //数式内の項を取得
     156        for(i3=0;;i2++,i3++){
     157            if(!IsVariableChar( this->GetExpression()[i2] )){
     158                temporary[i3]=0;
     159                break;
     160            }
     161            temporary[i3] = this->GetExpression()[i2];
     162        }
     163
     164        //パラメータと照合する
     165        for( i3=0; i3<(int)this->GetParameters().size(); i3++ ){
     166            if( this->GetParameters()[i3] == temporary ) break;
     167        }
     168
     169        if( i3 == (int)this->GetParameters().size() ){
     170            //パラメータでないとき
     171            lstrcpy(dest+i4,temporary);
     172            i4+=lstrlen(temporary);
     173        }
     174        else{
     175            //パラメータのとき
     176            lstrcpy(dest+i4,pParms[i3]);
     177            i4+=lstrlen(pParms[i3]);
     178        }
     179
     180        //演算子をコピー
     181        for(;;i2++,i4++){
     182            if( this->GetExpression()[i2] == 1 ){
     183                dest[i4++] = this->GetExpression()[i2++];
     184                dest[i4] = this->GetExpression()[i2];
     185                continue;
     186            }
     187            if(IsVariableTopChar( this->GetExpression()[i2] )) break;
     188            dest[i4] = this->GetExpression()[i2];
     189            if( this->GetExpression()[i2] == '\0' ) break;
     190        }
     191
     192        if( this->GetExpression()[i2] == '\0' ) break;
     193    }
     194
     195    for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
     196
     197    return 1;
     198}
     199
     200// マクロ定数を追加するための関数
     201void ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr )
     202{
     203    std::vector<std::string> parameters;
     204
     205    int i = 0;
     206    if(parameterStr[i]!='(')
     207    {
     208        SetError();
     209        return;
     210    }
     211
     212    char temporary[VN_SIZE];
     213    int i2;
     214    for(i++,i2=0;;i++,i2++){
     215        if(parameterStr[i]=='\0'){
     216            SetError(1,NULL,cp);
     217            return;
     218        }
     219        if(parameterStr[i]==','||parameterStr[i]==')'){
     220            temporary[i2]=0;
     221
     222            parameters.push_back( temporary );
     223
     224            if(parameterStr[i]==')'){
     225                i++;
     226                if(parameterStr[i]!='='){
     227                    extern int cp;
     228                    SetError(1,NULL,cp);
     229                    return;
     230                }
     231                break;
     232            }
     233
     234            i2=-1;
     235            continue;
     236        }
     237        temporary[i2]=parameterStr[i];
     238    }
     239
     240    //データ
     241    lstrcpy(temporary,parameterStr+i+1);
     242
     243    Put( new ConstMacro( namespaceScopes, name, parameters, temporary ) );
     244}
     245ConstMacro *ConstMacros::Find( const std::string &name ){
     246    char ObjName[VN_SIZE];      //オブジェクト変数
     247    char NestMember[VN_SIZE];   //入れ子メンバ
     248    bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember );
     249
     250    ConstMacro *pConstMacro = GetHashArrayElement( NestMember );
     251    while( pConstMacro )
     252    {
     253        if( pConstMacro->IsEqualSymbol( name ) )
     254        {
     255            break;
     256        }
     257        pConstMacro = pConstMacro->GetChainNext();
     258    }
     259
     260    return pConstMacro;
     261}
  • trunk/abdev/BasicCompiler_Common/src/DataTable.cpp

    r184 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
  • trunk/abdev/BasicCompiler_Common/src/Exception.cpp

    r125 r206  
     1#include "stdafx.h"
     2
    13#include <Exception.h>
    24
  • trunk/abdev/BasicCompiler_Common/src/LexicalScopingImpl.cpp

    r184 r206  
     1#include "stdafx.h"
     2
    13#include <LexicalScopingImpl.h>
     4#include <Compiler.h>
    25
    36#include "../common.h"
     
    2932}
    3033
     34void LexicalScopesImpl::End(){
     35    if( level <= 0 ){
     36        SetError();
     37        return;
     38    }
     39
     40    //デストラクタを呼ぶ
     41    CallDestructorsOfScopeEnd();
     42
     43    Variables &vars = UserProc::IsGlobalAreaCompiling() ?
     44        compiler.GetMeta().GetGlobalVars() :
     45        UserProc::CompilingUserProc().GetLocalVars();
     46
     47    //使用済みローカル変数の生存チェックを外す
     48    BOOST_FOREACH( Variable *pVar, vars ){
     49        if(pVar->bLiving&&pVar->GetScopeLevel()==level){
     50            pVar->bLiving=0;
     51            extern int obp;
     52            pVar->SetScopeEndAddress( obp );
     53        }
     54    }
     55
     56
     57    //スコープ抜け出しスケジュール
     58    ppScopes[level]->RunScheduleOfBreak();
     59
     60
     61    //スコープレベルを下げる
     62    delete ppScopes[level];
     63    level--;
     64}
     65
    3166// スコープ終了時のデストラクタ呼び出し
    3267void LexicalScopesImpl::CallDestructorsOfScopeEnd(){
    3368
    34     Variables &vars = UserProc::IsGlobalAreaCompiling()?
    35         globalVars :
    36         UserProc::CompilingUserProc().localVars;
     69    Variables &vars = UserProc::IsGlobalAreaCompiling() ?
     70        compiler.GetMeta().GetGlobalVars() :
     71        UserProc::CompilingUserProc().GetLocalVars();
    3772
    3873
     
    5287        //同一レベルのレキシカルスコープのみを検知
    5388        if(!pVar->bLiving) continue;
    54         if( pVar->ScopeLevel != GetNowLevel() ) continue;
     89        if( pVar->GetScopeLevel() != GetNowLevel() ) continue;
    5590
    56         if( pVar->IsStruct() && pVar->IsParameter() ){
     91        if( pVar->GetType().IsStruct() && pVar->IsParameter() ){
    5792            //構造体パラメータを持つとき
    5893
     
    6499            //mov rcx,qword ptr[rsp+offset]
    65100            op_mov_RM(sizeof(_int64),REG_RCX,REG_RSP,
    66                 -pVar->offset,
     101                -pVar->GetOffsetAddress(),
    67102                MOD_BASE_DISP32);
    68103            obp-=sizeof(long);
     
    73108
    74109            //mov ecx,dword ptr[ebp+offset]
    75             op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->offset,MOD_BASE_DISP32);
     110            op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32);
    76111            obp-=sizeof(long);
    77112            AddLocalVarAddrSchedule();
     
    83118
    84119            //call free
    85             extern UserProc *pSub_free;
     120            extern const UserProc *pSub_free;
    86121            op_call(pSub_free);
    87122
     
    96131    if(indexSystemGC!=-1){
    97132        //_System_GCオブジェクトのデストラクタの呼び出し処理
    98         const CMethod *method = vars[indexSystemGC]->GetClass().GetDestructorMethod();
     133        const CMethod *method = vars[indexSystemGC]->GetType().GetClass().GetDestructorMethod();
    99134        if( method ){
    100             Opcode_CallProc("",method->pUserProc,0,vars[indexSystemGC]->GetName().c_str(),DEF_OBJECT);
     135            Opcode_CallProc("",&method->GetUserProc(),0,vars[indexSystemGC]->GetName().c_str(),DEF_OBJECT);
    101136        }
    102137    }
  • trunk/abdev/BasicCompiler_Common/src/NamespaceSupporter.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/SmoothieException.h>
     4#include <jenga/include/smoothie/LexicalAnalysis.h>
    25
    36#include <Compiler.h>
  • trunk/abdev/BasicCompiler_Common/src/Procedure.cpp

    r201 r206  
     1#include "stdafx.h"
     2
     3#include <jenga/include/smoothie/Smoothie.h>
    14#include <jenga/include/smoothie/SmoothieException.h>
    25#include <jenga/include/smoothie/LexicalAnalysis.h>
    36
    47#include <Compiler.h>
    5 #include <ProcedureImpl.h>
     8#include <Procedure.h>
    69#include <NamespaceSupporter.h>
    710
     
    1316#endif
    1417
    15 bool UserProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){
     18
     19std::string UserProc::GetFullName() const
     20{
     21    if( HasParentClass() ){
     22        return GetParentClass().GetName() + "." + GetName();
     23    }
     24
     25    return GetName();
     26}
     27const NamespaceScopes &UserProc::GetNamespaceScopes() const
     28{
     29    if( HasParentClass() ){
     30        return GetParentClassPtr()->GetNamespaceScopes();
     31    }
     32    return namespaceScopes;
     33}
     34const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
     35{
     36    return importedNamespaces;
     37}
     38bool UserProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
     39{
     40    if( GetName() != name ){
     41        return false;
     42    }
     43
     44    return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes );
     45}
     46bool UserProc::IsEqualSymbol( const UserProc &globalProc ) const
     47{
     48    return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );
     49}
     50bool UserProc::IsEqualSymbol( const string &fullName ) const
     51{
     52    char AreaName[VN_SIZE] = "";        //オブジェクト変数
     53    char NestName[VN_SIZE] = "";        //入れ子メンバ
     54    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
     55
     56    return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
     57}
     58bool UserProc::IsVirtual() const
     59{
     60    if( pMethod == NULL ){
     61        return false;
     62    }
     63    return ( pMethod->IsVirtual() != 0 );
     64}
     65
     66bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){
    1667    int i = 0;
    1768    int i2,i3,sw;
     
    51102        //パラメータ名
    52103        bool isArray = false;
    53         int subScripts[MAX_ARRAYDIM];
     104        Subscripts subscripts;
    54105        char name[VN_SIZE];
    55106        sw=0;
     
    83134
    84135            if((name[i2-2]=='('&&name[i2-1]==')')||
    85                 (name[i2-2]=='['&&name[i2-1]==']')){
    86                 subScripts[0]=LONG_MAX;
    87                 subScripts[1]=-1;
     136                (name[i2-2]=='['&&name[i2-1]==']'))
     137            {
     138                subscripts.push_back( LONG_MAX );
    88139
    89140                name[i2-2]=0;
    90141            }
    91142            else{
    92                 GetArrange(name,temp2,subScripts);
     143                GetArrange(name,temp2,subscripts);
    93144                lstrcpy(name,temp2);
    94145            }
     
    152203        Parameter *pParam = new Parameter( name, type, isRef, initValue );
    153204        if( isArray ){
    154             pParam->SetArray( subScripts );
     205            pParam->SetArray( subscripts );
    155206        }
    156207
     
    189240            //パラメータ名
    190241            bool isArray = false;
    191             int subScripts[MAX_ARRAYDIM];
     242            Subscripts subscripts;
    192243            char name[VN_SIZE];
    193244            sw=0;
     
    221272
    222273                if((name[i2-2]=='('&&name[i2-1]==')')||
    223                     (name[i2-2]=='['&&name[i2-1]==']')){
    224                     subScripts[0]=LONG_MAX;
    225                     subScripts[1]=-1;
     274                    (name[i2-2]=='['&&name[i2-1]==']'))
     275                {
     276                    subscripts.push_back( LONG_MAX );
    226277
    227278                    name[i2-2]=0;
    228279                }
    229280                else{
    230                     GetArrange(name,temp2,subScripts);
     281                    GetArrange(name,temp2,subscripts);
    231282                    lstrcpy(name,temp2);
    232283                }
     
    273324            Parameter *pParam = new Parameter( name, type, isRef );
    274325            if( isArray ){
    275                 pParam->SetArray( subScripts );
     326                pParam->SetArray( subscripts );
    276327            }
    277328
     
    376427}
    377428
    378 const NamespaceScopes &GlobalProc::GetNamespaceScopes() const
    379 {
    380     if( HasParentClass() ){
    381         return GetParentClassPtr()->GetNamespaceScopes();
    382     }
    383     return namespaceScopes;
    384 }
    385 bool GlobalProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
     429const UserProc *UserProc::pCompilingUserProc = NULL;
     430
     431
     432bool UserProcs::Insert( UserProc *pUserProc, int nowLine )
     433{
     434    /////////////////////////////////
     435    // ハッシュデータに追加
     436    /////////////////////////////////
     437
     438    if( !Put( pUserProc ) )
     439    {
     440        // 重複しているため、失敗
     441        SetError(15,pUserProc->GetName().c_str(),nowLine);
     442        return false;
     443    }
     444
     445    return true;
     446}
     447UserProc *UserProcs::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic)
     448{
     449    int i2,i3;
     450    char temporary[8192];
     451
     452    int i=1;
     453
     454    Procedure::Kind kind = Procedure::Sub;
     455    bool isMacro = false;
     456    if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
     457    if(buffer[i]==ESC_MACRO){
     458        isMacro = true;
     459    }
     460
     461    i++;
     462
     463    bool isCdecl = false;
     464    bool isExport = false;
     465    while(1){
     466        if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
     467            isCdecl = true;
     468
     469            i+=2;
     470        }
     471        else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
     472            isExport = true;
     473
     474            i+=2;
     475        }
     476        else break;
     477    }
     478
     479    i2=0;
     480    if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
     481        if(!pobj_c){
     482            SetError(126,NULL,nowLine);
     483            return 0;
     484        }
     485
     486        //オペレータの場合
     487        temporary[i2++]=buffer[i++];
     488        temporary[i2++]=buffer[i++];
     489
     490        int iCalcId;
     491        if(buffer[i]=='='&&buffer[i+1]=='='){
     492            iCalcId=CALC_EQUAL;
     493            i3=2;
     494        }
     495        else if(buffer[i]=='='){
     496            iCalcId=CALC_SUBSITUATION;
     497            i3=1;
     498        }
     499        else if(buffer[i]=='('){
     500            iCalcId=CALC_AS;
     501            i3=0;
     502        }
     503        else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
     504            iCalcId=CALC_ARRAY_SET;
     505            i3=3;
     506        }
     507        else if(buffer[i]=='['&&buffer[i+1]==']'){
     508            iCalcId=CALC_ARRAY_GET;
     509            i3=2;
     510        }
     511        else{
     512            iCalcId=GetCalcId(buffer+i,&i3);
     513            i3++;
     514        }
     515        if(!iCalcId){
     516            SetError(1,NULL,nowLine);
     517            return 0;
     518        }
     519        temporary[i2++]=iCalcId;
     520        temporary[i2]=0;
     521
     522        i+=i3;
     523    }
     524    else{
     525        if(pobj_c){
     526            //クラスメンバの場合、デストラクタには~が付くことを考慮
     527            if(buffer[i]=='~'){
     528                temporary[i2]='~';
     529                i++;
     530                i2++;
     531            }
     532        }
     533
     534        for(;;i++,i2++){
     535            if(!IsVariableChar(buffer[i])){
     536                temporary[i2]=0;
     537                break;
     538            }
     539            temporary[i2]=buffer[i];
     540        }
     541    }
     542
     543    if( isMacro ){
     544        //大文字に変換
     545        CharUpper(temporary);
     546
     547        //マクロ関数の場合は名前リストに追加
     548        macroNames.push_back( temporary );
     549    }
     550
     551    if(!pobj_c){
     552        //クラスメンバ以外の場合のみ
     553        //重複チェック
     554
     555        if(GetDeclareHash(temporary)){
     556            SetError(15,temporary,nowLine);
     557            return 0;
     558        }
     559    }
     560
     561    // 識別ID
     562    static int id_base=0;
     563
     564    UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport, (id_base++) );
     565    pUserProc->SetParentClass( pobj_c );
     566    if( Smoothie::isFullCompile ){
     567        // すべての関数・メソッドをコンパイルする
     568        pUserProc->Using();
     569    }
     570
     571    if(isExport){
     572        pUserProc->Using();
     573    }
     574
     575    // パラメータを解析
     576    // ※第1パラメータにに指定するデータの例:"( s As String ) As String"
     577    pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
     578
     579    pUserProc->_paramStr = buffer + i;
     580
     581    // ハッシュに追加
     582    if( !Insert( pUserProc, nowLine ) )
     583    {
     584        return NULL;
     585    }
     586
     587    return pUserProc;
     588}
     589void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs )
     590{
     591    ///////////////////////////
     592    // グローバル関数を検索
     593    ///////////////////////////
     594
     595    // ハッシュ値を取得
     596    UserProc *pUserProc = GetHashArrayElement( simpleName );
     597    while(pUserProc){
     598        if(!pUserProc->GetParentClassPtr()){
     599            if( pUserProc->IsEqualSymbol( localName ) ){
     600                subs.push_back( pUserProc );
     601            }
     602        }
     603
     604        pUserProc=pUserProc->GetChainNext();
     605    }
     606}
     607
     608
     609bool DllProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    386610{
    387611    if( GetName() != name ){
    388612        return false;
    389613    }
    390 
    391     return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes );
    392 }
    393 bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const
    394 {
    395     return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );
    396 }
    397 bool GlobalProc::IsEqualSymbol( const string &fullName ) const
     614    return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes );
     615}
     616bool DllProc::IsEqualSymbol( const string &fullName ) const
    398617{
    399618    char AreaName[VN_SIZE] = "";        //オブジェクト変数
    400619    char NestName[VN_SIZE] = "";        //入れ子メンバ
    401     bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );
    402 
    403     return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
    404 }
    405 
    406 bool DllProcImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    407 {
    408     if( GetName() != name ){
    409         return false;
    410     }
    411     return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes );
    412 }
    413 bool DllProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
     620    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
     621
     622    if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){
     623        return true;
     624    }
     625
     626    if( isNest ){
     627        // 静的メンバを考慮
     628
     629        char AreaName2[VN_SIZE] = "";       //オブジェクト変数
     630        char NestName2[VN_SIZE] = "";       //入れ子メンバ
     631        bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 );
     632        lstrcat( NestName2, "." );
     633        lstrcat( NestName2, NestName );
     634
     635        return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 );
     636    }
     637
     638    return false;
     639}
     640bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
    414641    int i = 0;
    415642    int i2,i3,sw;
     
    443670        //パラメータ名
    444671        bool isArray = false;
    445         int subScripts[MAX_ARRAYDIM];
     672        Subscripts subscripts;
    446673        char name[VN_SIZE];
    447674        sw=0;
     
    475702
    476703            if((name[i2-2]=='('&&name[i2-1]==')')||
    477                 (name[i2-2]=='['&&name[i2-1]==']')){
    478                 subScripts[0]=LONG_MAX;
    479                 subScripts[1]=-1;
     704                (name[i2-2]=='['&&name[i2-1]==']'))
     705            {
     706                subscripts.push_back( LONG_MAX );
    480707
    481708                name[i2-2]=0;
    482709            }
    483710            else{
    484                 GetArrange(name,temp2,subScripts);
     711                GetArrange(name,temp2,subscripts);
    485712                lstrcpy(name,temp2);
    486713            }
     
    528755        Parameter *pParam = new Parameter( name, type, isRef );
    529756        if( isArray ){
    530             pParam->SetArray( subScripts );
     757            pParam->SetArray( subscripts );
    531758        }
    532759
     
    584811}
    585812
    586 bool ProcPointerImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
     813bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
    587814    int i = 0;
    588815    int i2,i3,sw;
     
    615842        //パラメータ名
    616843        bool isArray = false;
    617         int subScripts[MAX_ARRAYDIM];
     844        Subscripts subscripts;
    618845        char name[VN_SIZE];
    619846        sw=0;
     
    647874
    648875            if((name[i2-2]=='('&&name[i2-1]==')')||
    649                 (name[i2-2]=='['&&name[i2-1]==']')){
    650                 subScripts[0]=LONG_MAX;
    651                 subScripts[1]=-1;
     876                (name[i2-2]=='['&&name[i2-1]==']'))
     877            {
     878                subscripts.push_back( LONG_MAX );
    652879
    653880                name[i2-2]=0;
    654881            }
    655882            else{
    656                 GetArrange(name,temp2,subScripts);
     883                GetArrange(name,temp2,subscripts);
    657884                lstrcpy(name,temp2);
    658885            }
     
    699926        Parameter *pParam = new Parameter( name, type, isRef );
    700927        if( isArray ){
    701             pParam->SetArray( subScripts );
     928            pParam->SetArray( subscripts );
    702929        }
    703930
     
    771998}
    772999
    773 int ProcPointersImpl::Add( const string &typeExpression )
     1000int ProcPointers::Add( const string &typeExpression )
    7741001{
    7751002    DWORD dwProcType = (DWORD)typeExpression[2];
     
    7811008    }
    7821009
    783     ProcPointer *pProcPointer = new ProcPointerImpl( kind );
     1010    ProcPointer *pProcPointer = new ProcPointer( kind );
    7841011
    7851012    //buffer[0]は'('となっている
     
    7921019}
    7931020
    794 void ProcPointersImpl::Clear()
    795 {
    796     ProcPointersImpl &procPointers = *this;
     1021void ProcPointers::Clear()
     1022{
     1023    ProcPointers &procPointers = *this;
    7971024    BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
    7981025        delete pProcPointer;
  • trunk/abdev/BasicCompiler_Common/src/Program.cpp

    r168 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/common/Environment.h>
    24
    35#include <Program.h>
    46
    5 Jenga::Common::Logger Program::logger( Jenga::Common::Environment::GetAppDir() + "\\logger.log" );
     7Jenga::Common::Logger Program::logger( Jenga::Common::Environment::GetAppDir() + "\\logger.log", true );
  • trunk/abdev/BasicCompiler_Common/src/SmoothieImpl.cpp

    r193 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    24
    35#include <SmoothieImpl.h>
    4 #include <ClassImpl.h>
    5 #include <ProcedureImpl.h>
     6#include <Class.h>
     7#include <Procedure.h>
    68#include <LexicalScopingImpl.h>
    79
  • trunk/abdev/BasicCompiler_Common/src/TypeDef.cpp

    r199 r206  
     1#include "stdafx.h"
     2
    13#include <jenga/include/smoothie/Smoothie.h>
    2 #include <jenga/include/smoothie/Class.h>
    34#include <jenga/include/smoothie/SmoothieException.h>
     5#include <jenga/include/smoothie/LexicalAnalysis.h>
    46
    57#include <TypeDef.h>
     
    810
    911TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName, int nowLine )
    10     : namespaceScopes( namespaceScopes )
    11     , name( name )
     12    : Symbol( namespaceScopes, name )
    1213    , baseName( baseName )
    1314{
     
    1718    }
    1819}
    19 TypeDef::~TypeDef(){
    20 }
    21 
     20/*
    2221bool TypeDef::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    2322{
     
    3130    char AreaName[VN_SIZE] = "";        //オブジェクト変数
    3231    char NestName[VN_SIZE] = "";        //入れ子メンバ
    33     bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );
     32    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
    3433
    3534    if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){
     
    4241        char AreaName2[VN_SIZE] = "";       //オブジェクト変数
    4342        char NestName2[VN_SIZE] = "";       //入れ子メンバ
    44         bool isNest = CClass::SplitName( AreaName, AreaName2, NestName2 );
     43        bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 );
    4544        lstrcat( NestName2, "." );
    4645        lstrcat( NestName2, NestName );
     
    5049
    5150    return false;
    52 }
     51}*/
    5352
    5453
     
    7473    char AreaName[VN_SIZE] = "";        //オブジェクト変数
    7574    char NestName[VN_SIZE] = "";        //入れ子メンバ
    76     bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );
     75    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
    7776
    7877    return GetIndex( NamespaceScopes( AreaName ), NestName );
Note: See TracChangeset for help on using the changeset viewer.