Ignore:
Timestamp:
Mar 19, 2012, 1:59:48 AM (12 years ago)
Author:
イグトランス (egtra)
Message:

egtraブランチの内容をマージ。

Location:
trunk
Files:
39 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ab5.0/abdev

    • Property svn:ignore set to
      *.opensdf
      *.sdf
      *.suo
      *.user
      int
      ipch
      out
  • trunk/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp

    r773 r828  
    253253}
    254254
    255 BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen){
     255BOOL GetFilePathDialog(HWND hwnd,char *filename,LPCSTR Filter,LPCSTR Title,BOOL bOpen){
    256256    OPENFILENAME ofstr;
    257257    filename[0]=0;
     
    325325        //生成するファイルの相対パスを取得
    326326        char relationalPath[MAX_PATH];
    327         lstrcpy( relationalPath, program.GetOutputFilePath().c_str() );
     327        strcpy( relationalPath, program.GetOutputFilePath().c_str() );
    328328        GetRelationalPath( relationalPath, BasicCurDir );
    329329
     
    375375    SetWindowPos(hwnd,0,x,y,0,0,SWP_NOSIZE);
    376376}
    377 BOOL CALLBACK DlgCompile(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
     377INT_PTR CALLBACK DlgCompile(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
    378378    extern HANDLE hDebugProcess;
     379    extern DWORD processIdDebug;
    379380    char temporary[MAX_PATH];
    380381    RECT rect;
     
    444445                            TerminateProcess(hDebugProcess,0);
    445446                            hDebugProcess=0;
     447                            processIdDebug = 0;
    446448
    447449                            //デバッグダイアログを終了
     
    475477                        TerminateProcess(hDebugProcess,0);
    476478                        hDebugProcess=0;
     479                        processIdDebug = 0;
    477480
    478481                        //デバッグダイアログを終了
     
    587590
    588591    // グローバルローケルを日本語にする
    589     std::locale::global(std::locale("japanese"));
    590     _setmode(_fileno(stdout), _O_BINARY);
     592    //std::locale::global(std::locale("japanese"));
     593    //_setmode(_fileno(stdout), _O_BINARY);
    591594
    592595    //_Test();
     
    642645            if( program.IsDebugRun() || compiler.IsDebug() )
    643646            {
    644                 lstrcat(tempOutputFileName,"_debug.abobj");
     647                strcat(tempOutputFileName,"_debug.abobj");
    645648            }
    646649            else
    647650            {
    648                 lstrcat(tempOutputFileName,".abobj");
     651                strcat(tempOutputFileName,".abobj");
    649652            }
    650653        }
     
    653656            if( program.IsDebugRun() || compiler.IsDebug() )
    654657            {
    655                 lstrcat(tempOutputFileName,"_debug.exe");
     658                strcat(tempOutputFileName,"_debug.exe");
    656659            }
    657660            else
    658661            {
    659                 lstrcat(tempOutputFileName,".exe");
     662                strcat(tempOutputFileName,".exe");
    660663            }
    661664        }
     
    719722        }
    720723        if(temporary[i]){
    721             lstrcpy(szDebugCmdLine,temporary+i+2);
     724            strcpy(szDebugCmdLine,temporary+i+2);
    722725        }
    723726    }
    724727
    725728    _splitpath( program.GetSourceFilePath().c_str(), BasicCurDir,temporary,NULL,NULL);
    726     lstrcat(BasicCurDir,temporary);
     729    strcat(BasicCurDir,temporary);
    727730
    728731    if( program.IsClipCompileView() ){
    729732        //ProjectEditor埋め込み型インターフェイス
    730         hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_CLIPMAIN),hOwnerEditor,(DLGPROC)DlgCompile);
     733        hMainDlg=CreateDialog(hInst, MAKEINTRESOURCE(IDD_CLIPMAIN), hOwnerEditor, DlgCompile);
    731734        ShowWindow(hMainDlg,SW_SHOW);
    732735        SendMessage(hOwnerEditor,WM_SETCOMPILEVIEW,0,(LPARAM)hMainDlg);
     
    759762            trace("Complete ActiveBasic Compiler!");
    760763
    761             ExitProcess( program.GetExitCode() );
    762             return 0;
     764            return program.GetExitCode();
    763765        }
    764766        else
     
    770772
    771773    //エラーリストをサブクラス化
    772     OldErrorListProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hMainDlg,IDC_ERRORLIST),GWLP_WNDPROC);
    773     SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_ERRORLIST),GWLP_WNDPROC,(LONG_PTR)ErrorListProc);
     774    OldErrorListProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(GetDlgItem(hMainDlg, IDC_ERRORLIST), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ErrorListProc)));
    774775
    775776    //デバッグリストをサブクラス化
    776     OldDebugListProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC);
    777     SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC,(LONG_PTR)DebugListProc);
     777    OldDebugListProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(GetDlgItem(hMainDlg, IDC_DEBUGLIST), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(DebugListProc)));
    778778
    779779    if( program.IsKickedFromEditor() )
     
    804804    trace("Complete ActiveBasic Compiler!");
    805805
    806     ExitProcess( program.GetExitCode() );
    807 
    808     return 0;
    809 }
     806    return program.GetExitCode();
     807}
  • trunk/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.h

    r641 r828  
    11#include "../BasicCompiler_Common/common.h"
    22
    3 LPSTR BasicFileFilter="プログラム ファイル(*.ab;*.bas;*.abp;*.sbp)\0*.ab;*.bas;*.abp;*sbp\0テキスト ファイル(*.txt)\0*.txt\0すべてのファイル(*.*)\0*\0\0";
    4 LPSTR ExeFileFilter="実行可能ファイル(*.exe)\0*.exe\0すべてのファイル(*.*)\0*\0\0";
     3extern const LPCSTR BasicFileFilter = "プログラム ファイル(*.ab;*.bas;*.abp;*.sbp)\0*.ab;*.bas;*.abp;*sbp\0テキスト ファイル(*.txt)\0*.txt\0すべてのファイル(*.*)\0*\0\0";
     4extern const LPCSTR ExeFileFilter = "実行可能ファイル(*.exe)\0*.exe\0すべてのファイル(*.*)\0*\0\0";
    55
    66HINSTANCE hInst;
  • trunk/ab5.0/abdev/BasicCompiler_Common/CDebugThreadInfo.cpp

    r741 r828  
    44#include "DebugSection.h"
    55
     6#include <ProcessAndModule.h>
    67
    78//デバッグ用
     
    1011
    1112extern HANDLE hDebugProcess;
     13extern DWORD processIdDebug;
    1214extern DebugSectionCollection debugSectionCollection;
    1315
     
    6769
    6870    //マッピングされているモジュールのイメージベースを取得
    69     HMODULE array_hModule[1024];
    70     DWORD cbReturned;
    71     if(!EnumProcessModules( hDebugProcess, array_hModule, sizeof(HMODULE)*1024, &cbReturned )) return 0;
     71    //HMODULE array_hModule[1024];
     72    //DWORD cbReturned;
     73    //if(!EnumProcessModules( hDebugProcess, array_hModule, sizeof(HMODULE)*1024, &cbReturned )) return 0;
     74    auto modules = ActiveBasic::Common::GetModules(processIdDebug);
    7275
    73     int i;
    7476    HMODULE hTargetModule=0;
    75     for(i=0;i<(int)(cbReturned/sizeof(HMODULE));i++){
    76         if((LONG_PTR)array_hModule[i]<=(LONG_PTR)EIP_RIP(Context)){
    77             if(hTargetModule<array_hModule[i]) hTargetModule=array_hModule[i];
     77    for (std::size_t i = 0; i < modules.size(); ++i)
     78    {
     79        if ((LONG_PTR)modules[i]<=(LONG_PTR)EIP_RIP(Context))
     80        {
     81            if (hTargetModule<modules[i])
     82            {
     83                hTargetModule=modules[i];
     84            }
    7885        }
    7986    }
     
    8188    extern DWORD ImageBase;
    8289    if((HMODULE)(ULONG_PTR)ImageBase!=hTargetModule){
    83         for(i=0;i<debugSectionCollection.debugSections.size();i++){
     90        for(std::size_t i=0;i<debugSectionCollection.debugSections.size();i++){
    8491            if((HMODULE)(ULONG_PTR)debugSectionCollection.debugSections[i]->dwImageBase==hTargetModule){
    8592                debugSectionCollection.choice(i);
  • trunk/ab5.0/abdev/BasicCompiler_Common/Debug.cpp

    r750 r828  
    99#include "../BasicCompiler_Common/debug.h"
    1010
     11#include <Path.h>
     12#include <ProcessAndModule.h>
     13
    1114char *OpBuffer;
    1215
     
    1417
    1518HANDLE hDebugProcess;
     19DWORD processIdDebug;
    1620
    1721DWORD _DebugSys_dwThreadID[MAX_DEBUG_THREAD];
     
    155159    TerminateProcess(hDebugProcess,0);
    156160    hDebugProcess=0;
     161    processIdDebug = 0;
    157162
    158163    //デバッグダイアログを終了
     
    271276UserProc *GetSubFromObp(ULONG_PTR pos)
    272277{
    273     compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    274     while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     278    foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs())
    275279    {
    276         UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    277 
    278280        if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pos  &&
    279281            pos < rva_to_real(pUserProc->GetEndOpAddress()))
     
    406408            //ユーザーに実行ファイルを選択させる
    407409            extern HWND hOwnerEditor;
    408             extern LPSTR ExeFileFilter;
     410            extern const LPCSTR ExeFileFilter;
    409411            if(!GetFilePathDialog(hOwnerEditor,ExeFilePathForDll,ExeFileFilter,"デバッグ用の実行可能ファイルを指定してください。",1)) return;
    410412        }
     
    435437    if( program.IsAttach() )
    436438    {
    437         //プロセスIDを元にハンドルを取得
    438         HANDLE hProcess;
    439         hProcess=OpenProcess(PROCESS_ALL_ACCESS,0, program.GetAttachProcessId() );
    440         if(!hProcess) goto AttachError;
    441 
    442         //そのプロセスにおける実行モジュールのインスタンスハンドルを取得
    443         HINSTANCE hModule;
    444         DWORD cbReturned;
    445         if(!EnumProcessModules( hProcess, &hModule, sizeof(HINSTANCE), &cbReturned )) goto AttachError;
     439        ////プロセスIDを元にハンドルを取得
     440        //HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,0, program.GetAttachProcessId() );
     441        //if(!hProcess)
     442        //{
     443        //  DebugMessage("アタッチに失敗しました。");
     444        //  return;
     445        //}
     446
     447        ////そのプロセスにおける実行モジュールのインスタンスハンドルを取得
     448        //HINSTANCE hModule;
     449        //DWORD cbReturned;
     450        //if(!EnumProcessModules( hProcess, &hModule, sizeof(HINSTANCE), &cbReturned ))
     451        //{
     452        //  DebugMessage("アタッチに失敗しました。");
     453        //  return;
     454        //}
    446455
    447456        //実行ファイル名を取得
    448         char tempOutputFileName[MAX_PATH];
    449         GetModuleFileNameEx(hProcess,hModule,tempOutputFileName,MAX_PATH);
    450         program.SetOutputFilePath( tempOutputFileName );
    451 
    452         CloseHandle(hProcess);
     457        auto tempOutputFilePath = ActiveBasic::Common::GetExecutableModulePath(program.GetAttachProcessId());
     458        program.SetOutputFilePath( tempOutputFilePath.string().c_str() );
     459
     460        //CloseHandle(hProcess);
    453461
    454462/*
     
    456464        pobj_DebugSection->load(program.GetOutputFilePath().c_str());*/
    457465
    458         if(!DebugActiveProcess( program.GetAttachProcessId() )){
    459 AttachError:
     466        if(!DebugActiveProcess( program.GetAttachProcessId() ))
     467        {
    460468            DebugMessage("アタッチに失敗しました。");
    461469            return;
     
    532540            else{
    533541Attach_DllLoad:
    534                 //アタッチした場合
    535                 GetModuleFileNameEx(hDebugProcess,(HINSTANCE)de.u.LoadDll.lpBaseOfDll,temporary,MAX_PATH);
     542                {
     543                    //アタッチした場合
     544                    auto path = ActiveBasic::Common::GetModuleFilePath(hDebugProcess, reinterpret_cast<HINSTANCE>(de.u.LoadDll.lpBaseOfDll));
     545                    strncpy_s(temporary, path.string().c_str(), _TRUNCATE);
     546                }
    536547            }
    537548
     
    562573            hDebugProcess=de.u.CreateProcessInfo.hProcess;
    563574            hMainThread=de.u.CreateProcessInfo.hThread;
     575            processIdDebug = de.dwProcessId;
    564576
    565577            if(debugSectionCollection.add((HMODULE)de.u.CreateProcessInfo.lpBaseOfImage)){
  • trunk/ab5.0/abdev/BasicCompiler_Common/Diagnose.cpp

    r750 r828  
    3434        int codeSizeOfGlobalProc = 0;
    3535        int codeSizeOfClassMethod = 0;
    36         compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    37         while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     36        foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs())
    3837        {
    39             UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    4038            if( pUserProc->IsCompiled() ){
    4139                if( pUserProc->HasParentClass() ){
     
    6058        int codeSizeOfEnum = 0;
    6159
    62         // イテレータをリセット
    63         compiler.GetObjectModule().meta.GetClasses().Iterator_Reset();
    64 
    65         while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){
     60        foreach (auto pClass, compiler.GetObjectModule().meta.GetClasses())
     61        {
    6662            int codeSizeOfClass = 0;
    6763
    68             CClass &objClass = *compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();
     64            CClass &objClass = *pClass;
    6965
    7066            if( !objClass.IsEnum() ){
     
    8278            // 静的メソッド
    8379            foreach( const CMethod *pMethod, objClass.GetStaticMethods() ){
    84                     codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
     80                codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
    8581            }
    8682
     
    9995        ///////////////////////////////////////////////////////////////////
    10096
    101         // イテレータをリセット
    102         compiler.GetObjectModule().meta.GetClasses().Iterator_Reset();
    103 
    104         while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){
     97        foreach (auto pClass, compiler.GetObjectModule().meta.GetClasses())
     98        {
    10599            int codeSizeOfClass = 0;
    106100
    107             CClass &objClass = *compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();
     101            CClass &objClass = *pClass;
    108102
    109103            // 動的メソッド
     
    116110            // 静的メソッド
    117111            foreach( const CMethod *pMethod, objClass.GetStaticMethods() ){
    118                     codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
     112                codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
    119113            }
    120114
    121             if( codeSizeOfClass ){
    122                 temporary[0]=0;
    123                 lstrcat( temporary, "------------------------------------------------------------------\n" );
    124                 sprintf( temporary + lstrlen(temporary), "【 %s クラスのコード情報】\n", objClass.GetName().c_str() );
    125                 sprintf( temporary + lstrlen(temporary), "class code size: %d bytes\n", codeSizeOfClass );
    126                 lstrcat( temporary, "------------------------------------------------------------------\n" );
    127                 lstrcat( temporary, "\n" );
     115            if( codeSizeOfClass )
     116            {
     117                sprintf(temporary,
     118                    "------------------------------------------------------------------\n"
     119                    "【 %s クラスのコード情報】\n"
     120                    "class code size: %d bytes\n"
     121                    "------------------------------------------------------------------\n"
     122                    "\n",
     123                    objClass.GetName().c_str(), codeSizeOfClass);
    128124                trace_for_size( temporary );
    129125            }
  • trunk/ab5.0/abdev/BasicCompiler_Common/MakeExe.cpp

    r750 r828  
    2626}
    2727
    28 void AddSourceCode(const char *buffer){
    29     char *temp=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)+8192);
    30     lstrcpy(temp,buffer);
    31 
    32     MakeMiddleCode( temp );
     28void AddSourceCode(const char *buffer)
     29{
     30    std::size_t size = std::strlen(buffer) + 8192;
     31    std::unique_ptr<char[]> temp(new char[size]);
     32    strcpy_s(temp.get(), size, buffer);
     33
     34    MakeMiddleCode(temp.get());
    3335
    3436    //最後尾に貼り付け
    35     compiler.GetObjectModule().GetSource().Addition( temp );
    36 
    37     HeapDefaultFree(temp);
     37    compiler.GetObjectModule().GetSource().Addition(temp.get());
    3838}
    3939
  • trunk/ab5.0/abdev/BasicCompiler_Common/NonVolatile.h

    r523 r828  
    3939    void load();
    4040    void save();
     41
     42private:
     43    CNonVolatile(CNonVolatile const&);
     44    CNonVolatile& operator =(CNonVolatile const&);
    4145};
    4246extern CNonVolatile *pobj_nv;
  • trunk/ab5.0/abdev/BasicCompiler_Common/StrOperation.cpp

    r736 r828  
    11#include "stdafx.h"
    2 
    3 void KillSpaces(char *str1,char *str2){
     2#include <abdev/ab_common/include/ab_common.h>
     3#include "StrOperation.h"
     4#include "common.h"
     5
     6void KillSpaces(char const *str1,char *str2){
    47    int i,i2,i3,IsStr;
    58    for(i=0,i2=0,IsStr=0;;i++,i2++){
     
    3033    }
    3134}
    32 void KillStringSpaces(char *str){
    33     char *s2;
    34 
    35     extern HANDLE hHeap;
    36     s2=(char *)HeapAlloc(hHeap,0,lstrlen(str)+1);
    37     lstrcpy(s2,str);
    38     KillSpaces(s2,str);
    39     HeapDefaultFree(s2);
    40     return;
     35void KillStringSpaces(char *str)
     36{
     37    std::string s2(str);
     38    KillSpaces(s2.c_str(), str);
    4139}
    4240BOOL RemoveStringQuotes(char *str){
     
    362360    }
    363361}
    364 const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source )
     362std::string FormatEscapeSequenceStringToDefaultString( const std::string &source )
    365363{
    366364    int maxLength = (int)source.size();
  • trunk/ab5.0/abdev/BasicCompiler_Common/StrOperation.h

    r603 r828  
     1#pragma once
    12
    23enum ReferenceKind
  • trunk/ab5.0/abdev/BasicCompiler_Common/Subroutine.cpp

    r751 r828  
    319319
    320320bool IsNeedProcCompile(){
    321     compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    322     while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
    323     {
    324         UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
     321    foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs())
     322    {
    325323        if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
    326324            return true;
     
    385383
    386384repeat:
    387     compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    388     while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
    389     {
    390         UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
     385    foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs())
     386    {
    391387        CompileBufferInProcedure( *pUserProc );
    392388    }
     
    410406            //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合
    411407
    412             compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    413             while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     408            foreach(auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs())
    414409            {
    415                 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    416410                CompileBufferInProcedure( *pUserProc );
    417411            }
  • trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp

    r763 r828  
    11#include "stdafx.h"
    22
     3#include <boost/range/algorithm.hpp>
    34#include <Compiler.h>
    45
     
    411412    if(pobj_dti->lplpSpBase[i2]==0) return;
    412413
    413     UserProc *pUserProc = NULL;
    414     compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    415     while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     414    auto const& t = compiler.GetObjectModule().meta.GetUserProcs();
     415    auto it = boost::find_if<boost::return_found>(t, [&](UserProc *pUserProc) -> bool {
     416        return rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
     417            pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress());
     418    });
     419    if (it == boost::end(t))
    416420    {
    417         pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    418         if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2]  &&
    419             pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
    420             break;
    421         }
    422     }
    423     if(!pUserProc) return;
     421        return;
     422    }
     423    UserProc *pUserProc = *it;
    424424
    425425    foreach( Variable *pVar, pUserProc->GetLocalVars() ){
     
    696696    //プロシージャ コンボボックス
    697697    SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
    698     for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
    699 
     698    for(i2=pobj_dti->iProcLevel;i2>=0;i2--)
     699    {
     700        auto const& t = compiler.GetObjectModule().meta.GetUserProcs();
     701        auto it = boost::find_if<boost::return_found>(t, [&](UserProc* p) {
     702            return rva_to_real(p->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
     703                pobj_dti->lplpObp[i2] < rva_to_real(p->GetEndOpAddress());
     704        });
    700705        UserProc *pUserProc = NULL;
    701         compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    702         while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     706        if (it != boost::end(t))
    703707        {
    704             pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    705 
    706             if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2]  &&
    707                 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()))
    708             {
    709                 lstrcpy(temporary,pUserProc->GetName().c_str());
    710                 break;
    711             }
     708            pUserProc = *it;
     709            lstrcpy(temporary, pUserProc->GetName().c_str());
    712710        }
    713711        if(!pUserProc){
     
    811809    i2=pobj_dti->iProcLevel-i2;
    812810
    813     if(pobj_dti->lplpSpBase[i2]){
    814 
    815         UserProc *pUserProc = NULL;
    816         compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
    817         while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
     811    if(pobj_dti->lplpSpBase[i2])
     812    {
     813        auto const& t = compiler.GetObjectModule().meta.GetUserProcs();
     814        auto it = boost::find_if<boost::return_found>(t, [&](UserProc* p) {
     815            return rva_to_real(p->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
     816                pobj_dti->lplpObp[i2] < rva_to_real(p->GetEndOpAddress());
     817        });
     818
     819        if (it != boost::end(t))
    818820        {
    819             pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
    820 
    821             if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2]  &&
    822                 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
    823                 break;
    824             }
    825         }
    826 
    827         if(pUserProc){
    828             compiler.StartProcedureCompile( pUserProc );
     821            compiler.StartProcedureCompile(*it);
    829822        }
    830823    }
  • trunk/ab5.0/abdev/BasicCompiler_Common/common.h

    r824 r828  
    11#pragma once
    22
    3 //#define _CRT_SECURE_NO_DEPRECATE
    4 #pragma warning(disable : 4996)
     3
     4#include <psapi.h>
    55
    66#include <option.h>
     
    1717
    1818#include "../BasicCompiler_Common/NonVolatile.h"
    19 #include <psapi.h>
    2019
    2120
     
    3635#define MAX_PARMS       64
    3736#define MAX_ARRAYDIM    16
    38 #define MAX_HASH        32761
    3937
    4038
     
    4240    #define PLATFORM    64
    4341#else
    44 #define PLATFORM    32
    45     #ifndef LONG_PTR
    46         typedef long LONG_PTR;
    47         typedef DWORD ULONG_PTR;
    48     #endif
     42    #define PLATFORM    32
    4943#endif
    5044
     
    217211void GetFullPath( char *path, const std::string &baseDirPath );
    218212void ShowErrorLine(int LineNum,const char *FileName);
    219 BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
     213BOOL GetFilePathDialog(HWND hwnd,char *filename,LPCSTR Filter,LPCSTR Title,BOOL bOpen);
    220214void MakeMessageText(char *buffer,char *msg,int flag);
    221215
    222216//hash.cpp
    223 int hash_default(const char *name);
    224217DllProc *GetDeclareHash(const char *name);
    225218void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
     
    303296
    304297// StrOperation.cpp
    305 void KillSpaces(char *str1,char *str2);
     298void KillSpaces(const char *str1,char *str2);
    306299void KillStringSpaces(char *str);
    307300BOOL RemoveStringQuotes(char *str);
     
    316309char GetEndXXXCommand(char es);
    317310void GetDefaultNameFromES(char es,char *name);
    318 const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
     311std::string FormatEscapeSequenceStringToDefaultString( const std::string &source );
    319312bool IsFileExist(const char *path);
    320313BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
     
    370363void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
    371364int JumpStatement(const char *source, int &pos);
     365
     366//MakePeHdr.cpp
    372367void MakeExe();
    373368
  • trunk/ab5.0/abdev/BasicCompiler_Common/error.cpp

    r562 r828  
    44
    55#define STRING_SYSTEM_DECLAREHANDLE "*_System_DeclareHandle_"
    6 void DifferentTypeError( const Type &varType, const Type &calcFormalType, const int iWarning,const char *pszFuncName,const int ParmNum){
     6void DifferentTypeError(const Type &varType, const Type &calcFormalType, const int iWarning, const char *pszFuncName, const int ParmNum)
     7{
    78    //////////////////////////
    89    // キャストに関する警告
    910    //////////////////////////
    10     char temporary[255];
    11     Type calcType( calcFormalType );
    12 
    13     if(IS_LITERAL(calcType.GetIndex()))
     11    std::ostringstream s;
     12    Type calcType(calcFormalType);
     13
     14    if (IS_LITERAL(calcType.GetIndex()))
    1415    {
    1516        calcType.SetIndex( -1 );
    1617    }
    1718
    18     if(pszFuncName)
    19         sprintf(temporary,"\"%s\"の第%dパラメータが、",pszFuncName,ParmNum+1);
    20     else temporary[0]=0;
    21 
    22     std::string varTypeName = compiler.TypeToString( varType );
    23     if(memcmp( varTypeName.c_str(),STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0)
    24     {
    25         varTypeName = varTypeName.substr( lstrlen(STRING_SYSTEM_DECLAREHANDLE) );
    26     }
    27 
    28     std::string calcTypeName = compiler.TypeToString( calcType );
    29     if(memcmp( calcTypeName.c_str(),STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0)
    30     {
    31         calcTypeName = calcTypeName.substr( lstrlen(STRING_SYSTEM_DECLAREHANDLE) );
    32     }
    33     sprintf(temporary+lstrlen(temporary),"%sから%s",calcTypeName.c_str(),varTypeName.c_str());
     19    if (pszFuncName)
     20    {
     21        s << boost::format("\"%s\"の第%dパラメータが、") % pszFuncName % (ParmNum + 1);
     22    }
     23
     24    std::string varTypeName = compiler.TypeToString(varType);
     25    if (memcmp(varTypeName.c_str(), STRING_SYSTEM_DECLAREHANDLE, lstrlen(STRING_SYSTEM_DECLAREHANDLE)) == 0)
     26    {
     27        varTypeName = varTypeName.substr(strlen(STRING_SYSTEM_DECLAREHANDLE));
     28    }
     29
     30    std::string calcTypeName = compiler.TypeToString(calcType);
     31    if (memcmp(calcTypeName.c_str(), STRING_SYSTEM_DECLAREHANDLE, strlen(STRING_SYSTEM_DECLAREHANDLE)) == 0)
     32    {
     33        calcTypeName = calcTypeName.substr(strlen(STRING_SYSTEM_DECLAREHANDLE));
     34    }
     35    s << boost::format("%sから%s") % calcTypeName % varTypeName;
    3436
    3537    extern int cp;
    36     if(iWarning==1) compiler.errorMessenger.Output(-101,temporary,cp);
    37     else if(iWarning==2) compiler.errorMessenger.Output(-102,temporary,cp);
    38     else if(iWarning==3) compiler.errorMessenger.Output(50,temporary,cp);
     38    int errorCode;
     39    switch (iWarning)
     40    {
     41        case 1: errorCode = -101; break;
     42        case 2: errorCode = -102; break;
     43        case 3: errorCode = 50; break;
     44    }
     45    compiler.errorMessenger.Output(errorCode, s.str().c_str(), cp);
    3946}
    4047
  • trunk/ab5.0/abdev/BasicCompiler_Common/hash.cpp

    r598 r828  
    1313using namespace ActiveBasic::Compiler;
    1414
    15 int hash_default(const char *name){
    16     int key;
    17 
    18     for(key=0;*name!='\0';name++){
    19         key=((key<<8)+ *name )%MAX_HASH;
    20     }
    21 
    22     return key;
    23 }
    24 
    2515DllProc *GetDeclareHash(const char *fullName){
    2616    char namespaceStr[VN_SIZE];     //オブジェクト変数
     
    3222    ///////////////////////////
    3323
     24    auto const s = LexicalAnalyzer::FullNameToSymbol( fullName );
     25
    3426    // ハッシュ値を取得
    35     DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().GetHashArrayElement( simpleName );
    36     while(pDllProc){
    37         if( pDllProc->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( fullName ) ) ){
     27    foreach (auto pDllProc, compiler.GetObjectModule().meta.GetDllProcs().GetHashArrayElement(simpleName))
     28    {
     29        if( pDllProc->IsEqualSymbol( s ) )
     30        {
    3831            return pDllProc;
    3932        }
    40 
    41         pDllProc=pDllProc->GetChainNext();
    4233    }
    4334
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/BreakPoint.h

    r743 r828  
    99    BreakPointsPerFile(const char *lpszFileName,int iLineNum);
    1010
     11    BreakPointsPerFile(BreakPointsPerFile&& y)
     12        : filename(std::move(y.filename))
     13        , lines(std::move(y.lines))
     14    {
     15    }
     16
     17    BreakPointsPerFile(BreakPointsPerFile const& y)
     18        : filename(y.filename)
     19        , lines(y.lines)
     20    {
     21    }
     22
     23    BreakPointsPerFile& operator =(BreakPointsPerFile&& y)
     24    {
     25        filename = std::move(y.filename);
     26        lines = std::move(y.lines);
     27        return *this;
     28    }
     29
     30    BreakPointsPerFile& operator =(BreakPointsPerFile const& y)
     31    {
     32        return *this = std::move(BreakPointsPerFile(y));
     33    }
     34
    1135    void add(int iLineNum);
    1236    void remove(int iLineNum);
    1337
    1438    void update( char *nativeCodeBuffer, const SourceLines &sourceLines );
     39
    1540};
    1641typedef std::vector<BreakPointsPerFile> BreakPointsPerFiles;
     
    2752
    2853    char *update( char *nativeCodeBuffer, int SizeOf_CodeSection, const SourceLines &sourceLines );
     54
     55private:
     56    BreakPointManager(BreakPointManager const&);
     57    BreakPointManager& operator =(BreakPointManager const&);
    2958};
    3059
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/CodeGenerator.h

    r641 r828  
    3333        return typeSize;
    3434    }
     35
     36private:
     37    PertialSchedule(PertialSchedule const&);
     38    PertialSchedule& operator =(PertialSchedule const&);
    3539};
    3640typedef std::vector<const PertialSchedule *> PertialSchedules;
     
    6872        return sourceCodePos;
    6973    }
     74
     75private:
     76    GotoLabelSchedule(GotoLabelSchedule const&);
     77    GotoLabelSchedule& operator =(GotoLabelSchedule const&);
    7078};
    7179typedef std::vector<const GotoLabelSchedule *> GotoLabelSchedules;
     
    9098        , address( nativeCodePos )
    9199    {
     100    }
     101
     102    GotoLabel(GotoLabel&& y)
     103        : name(std::move(y.name))
     104        , line(std::move(y.line))
     105        , address(std::move(y.address))
     106    {
     107    }
     108
     109    GotoLabel(GotoLabel const& y)
     110        : name(y.name)
     111        , line(y.line)
     112        , address(y.address)
     113    {
     114    }
     115
     116    GotoLabel& operator =(GotoLabel&& y)
     117    {
     118        name = std::move(y.name);
     119        line = std::move(y.line);
     120        address = std::move(y.address);
     121        return *this;
     122    }
     123
     124    GotoLabel& operator =(GotoLabel const& y)
     125    {
     126        return *this = std::move(GotoLabel(y));
    92127    }
    93128};
     
    147182    void Break();
    148183    void RunScheduleOfBreak();
     184
     185private:
     186    LexicalScope(LexicalScope const&);
     187    LexicalScope& operator =(LexicalScope const&);
    149188};
    150189
     
    184223    //Returnステートメント用のデストラクタ呼び出し
    185224    void CallDestructorsOfReturn( int BaseLevel = 0 );
     225
     226private:
     227    LexicalScopes(LexicalScopes const&);
     228    LexicalScopes& operator =(LexicalScopes const&);
    186229};
    187230
     
    534577        pNativeCode->Put( c6 );
    535578    }
     579
     580private:
     581    CodeGenerator(CodeGenerator const&);
     582    CodeGenerator& operator =(CodeGenerator const&);
    536583};
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Compiler.h

    r745 r828  
     1#include "Messenger.h"
     2#include "CodeGenerator.h"
     3#include "Linker.h"
     4#include "Enum.h"
     5#include "ErrorCode.h"
     6
    17#pragma once
    28
     
    209215    bool IsCompilingClass();
    210216    const CClass &GetCompilingClass();
     217
     218private:
     219    Compiler(Compiler const&);
     220    Compiler& operator =(Compiler const&);
    211221};
    212222
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Configuration.h

    r477 r828  
    2727        ar & BOOST_SERIALIZATION_NVP( abdevRootRelativePath );
    2828    }
     29
     30    Configuration(Configuration const&);
     31    Configuration& operator =(Configuration const&);
    2932};
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/DataTableGenerator.h

    r589 r828  
    1717    }
    1818
     19private:
     20    DataTableGenerator();
     21    DataTableGenerator(DataTableGenerator const&);
     22    DataTableGenerator& operator =(DataTableGenerator const&);
    1923};
    2024
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Debugger.h

    r467 r828  
    2424        return isRunning;
    2525    }
     26
     27private:
     28    Debugger(Debugger const&);
     29    Debugger& operator =(Debugger const&);
    2630};
    2731
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Enum.h

    r750 r828  
    66    std::string value;
    77    int sourceIndex;
     8
    89public:
    910    EnumMember( const std::string &name, const std::string &value, int sourceIndex )
     
    1314    {
    1415    }
     16
     17    EnumMember(EnumMember&& y)
     18        : name(std::move(y.name))
     19        , value(std::move(y.value))
     20        , sourceIndex(std::move(y.sourceIndex))
     21    {
     22    }
     23
     24    EnumMember(EnumMember const& y)
     25        : name(y.name)
     26        , value(y.value)
     27        , sourceIndex(y.sourceIndex)
     28    {
     29    }
     30
     31    EnumMember& operator =(EnumMember&& y)
     32    {
     33        name = std::move(y.name);
     34        value = std::move(y.value);
     35        sourceIndex = std::move(y.sourceIndex);
     36        return *this;
     37    }
     38
     39    EnumMember& operator =(EnumMember const& y)
     40    {
     41        return *this = std::move(EnumMember(y));
     42    }
     43
    1544    const std::string &GetName() const
    1645    {
     
    3968        : Symbol( namespaceScopes, name )
    4069    {
     70    }
     71
     72    EnumInfo(EnumInfo&& y)
     73        : Symbol(std::move(y))
     74        , bConst(std::move(y.bConst))
     75        , members(std::move(y.members))
     76    {
     77    }
     78
     79    EnumInfo(EnumInfo const& y)
     80        : Symbol(y)
     81        , bConst(y.bConst)
     82        , members(y.members)
     83    {
     84    }
     85
     86    EnumInfo& operator =(EnumInfo&& y)
     87    {
     88        Symbol::operator =(std::move(y));
     89        bConst = std::move(y.bConst);
     90        members = std::move(y.members);
     91        return *this;
     92    }
     93
     94    EnumInfo& operator =(EnumInfo const& y)
     95    {
     96        return *this = std::move(EnumInfo(y));
    4197    }
    4298
     
    80136        return NULL;
    81137    };
     138
     139    EnumInfoCollection() {}
     140
     141private:
     142    EnumInfoCollection(EnumInfoCollection const&);
     143    EnumInfoCollection& operator =(EnumInfoCollection const&);
    82144};
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h

    r728 r828  
     1#include <string>
     2
    13#pragma once
     4
     5class EnumInfo;
     6class EnumInfoCollection;
    27
    38namespace ActiveBasic{ namespace Compiler{
     
    2429
    2530    // TypeDefを収集する
    26     static void AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const std::string &expression, int nowLine );
     31    static void AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const boost::iterator_range<char const*> &expression, int nowLine );
    2732    static void CollectTypeDefs( const char *source, TypeDefCollection &typeDefs );
    2833
     
    3035    static void AddConstEnum( Consts &consts, const NamespaceScopes &namespaceScopes, const char *buffer );
    3136    static void CollectConsts( const char *source, Consts &consts, ConstMacros &constMacros );
    32     static bool ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest );
     37    static bool ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, std::string& dest );
     38    static bool ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest, std::size_t destSize );
     39    template<std::size_t N>
     40    static bool ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char (&dest)[N] )
     41    {
     42        return ConstMacroToExpression(constMacro, parameterStr, dest, N);
     43    }
    3344
    3445    // クラスを収集する
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Linker.h

    r357 r828  
    5454    // データテーブルをセット
    5555    void SetDataTable( DataTable &dataTable );
     56
     57private:
     58    Linker(Linker const&);
     59    Linker& operator =(Linker const&);
    5660};
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Messenger.h

    r541 r828  
     1#pragma once
    12
    23class Messenger
     
    2324    {
    2425    }
     26
    2527    ErrorInfo( int errorCode, const std::string &keyword, int sourceIndex );
     28
     29    ErrorInfo(ErrorInfo&& y)
     30        : errorCode(std::move(y.errorCode))
     31        , keyword(std::move(y.keyword))
     32        , sourceFilePath(std::move(y.sourceFilePath))
     33        , sourceLineNum(std::move(y.sourceLineNum))
     34        , errorLineNum(std::move(y.errorLineNum))
     35    {
     36    }
     37
     38    ErrorInfo(ErrorInfo const& y)
     39        : errorCode(y.errorCode)
     40        , keyword(y.keyword)
     41        , sourceFilePath(y.sourceFilePath)
     42        , sourceLineNum(y.sourceLineNum)
     43        , errorLineNum(y.errorLineNum)
     44    {
     45    }
     46
     47    ErrorInfo& operator =(ErrorInfo&& y)
     48    {
     49        errorCode = std::move(y.errorCode);
     50        keyword = std::move(y.keyword);
     51        sourceFilePath = std::move(y.sourceFilePath);
     52        sourceLineNum = std::move(y.sourceLineNum);
     53        errorLineNum = std::move(y.errorLineNum);
     54        return *this;
     55    }
     56
     57    ErrorInfo& operator =(ErrorInfo const& y)
     58    {
     59        return *this = std::move(ErrorInfo(y));
     60    }
    2661
    2762    int GetErrorCode() const
     
    6297
    6398public:
     99    ErrorMessenger() {}
     100
    64101    void Output( const ErrorInfo &errorInfo );
    65102    void Output( int errorCode, const std::string &keyword, int sourceIndex = -1 );
     
    74111
    75112    void ShowErrorLine( int errorLineNum );
     113
     114private:
     115    ErrorMessenger(ErrorMessenger const&);
     116    ErrorMessenger& operator =(ErrorMessenger const&);
    76117};
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Program.h

    r719 r828  
    9696
    9797    int GetExitCode() const;
     98
     99private:
     100    Program(Program const&);
     101    Program& operator =(Program const&);
    98102};
    99103
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/logger.h

    r523 r828  
    2828        ar & BOOST_SERIALIZATION_NVP( stopStep );
    2929    }
     30
     31    LoggerSetting(LoggerSetting const&);
     32    LoggerSetting operator =(LoggerSetting const&);
    3033};
    3134
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp

    r751 r828  
    1 #pragma warning(disable : 4996)
    2 
    31#include <map>
    42#include <string>
     
    1917#include <limits.h>
    2018#include <shlobj.h>
    21 #include <process.h>
    22 #include <fcntl.h>
    23 #include <io.h>
    2419#include <shlwapi.h>
    2520#include <tchar.h>
    26 #include <stdarg.h>
    2721
    2822//boost libraries
    2923#include <boost/foreach.hpp>
    30 
     24#include <boost/cast.hpp>
     25
     26#pragma warning(push)
     27#pragma warning(disable: 4244 6326)
    3128#include <boost/archive/xml_oarchive.hpp>
    3229#include <boost/archive/xml_iarchive.hpp>
     
    4138#include <boost/serialization/map.hpp>
    4239#include <boost/serialization/version.hpp>
    43 #include <boost/serialization/is_abstract.hpp>
     40#pragma warning(pop)
    4441
    4542#include <jenga/include/jenga.h>
     
    4946using namespace Jenga::Common;
    5047
     48using boost::polymorphic_downcast;
     49
    5150template<class T_xml_schema> void BoostSerializationSupport<T_xml_schema>::echo( const char *msg ) const
    5251{
    53     MessageBox( NULL, msg, "XMLシリアライズの例外", MB_OK );
     52    MessageBox( NULL, msg, "シリアライズの例外", MB_OK );
    5453}
    5554template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXml( std::istream& ifs, bool isShowExceptionMessage )
     
    6160
    6261        // ファイルから読込
    63         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    64 
    65         isSuccessful = true;
    66     }
    67     catch( boost::archive::archive_exception e )
     62        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     63
     64        isSuccessful = true;
     65    }
     66    catch( boost::archive::archive_exception const& e )
    6867    {
    6968        if( isShowExceptionMessage )
     
    9493
    9594        // ファイルに書き出し
    96         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    97 
    98         isSuccessful = true;
    99     }
    100     catch( boost::archive::archive_exception e )
     95        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     96
     97        isSuccessful = true;
     98    }
     99    catch( boost::archive::archive_exception const& e )
    101100    {
    102101        if( isShowExceptionMessage )
     
    154153
    155154        // 文字列ストリームから読込
    156         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
     155        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
    157156
    158157        isSuccessful = true;
     
    179178
    180179        // 文字列ストリームに書き出し
    181         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    182 
    183         isSuccessful = true;
    184     }
    185     catch( boost::archive::archive_exception e )
     180        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     181
     182        isSuccessful = true;
     183    }
     184    catch( boost::archive::archive_exception const& e )
    186185    {
    187186        echo( e.what() );
     
    211210
    212211        // ファイルから読込
    213         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    214 
    215         isSuccessful = true;
    216     }
    217     catch( boost::archive::archive_exception e )
     212        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     213
     214        isSuccessful = true;
     215    }
     216    catch( boost::archive::archive_exception const& e )
    218217    {
    219218        if( isShowExceptionMessage )
     
    249248
    250249        // ファイルに書き出し
    251         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    252 
    253         isSuccessful = true;
    254     }
    255     catch( boost::archive::archive_exception e )
     250        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     251
     252        isSuccessful = true;
     253    }
     254    catch( boost::archive::archive_exception const& e )
    256255    {
    257256        if( isShowExceptionMessage )
     
    289288
    290289        // 文字列ストリームから読込
    291         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    292 
    293         isSuccessful = true;
    294     }
    295     catch( boost::archive::archive_exception e )
     290        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     291
     292        isSuccessful = true;
     293    }
     294    catch( boost::archive::archive_exception const& e )
    296295    {
    297296        echo( e.what() );
     
    313312
    314313        // 文字列ストリームに書き出し
    315         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    316 
    317         isSuccessful = true;
    318     }
    319     catch( boost::archive::archive_exception e )
     314        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     315
     316        isSuccessful = true;
     317    }
     318    catch( boost::archive::archive_exception const& e )
    320319    {
    321320        echo( e.what() );
     
    342341
    343342        // ファイルから読込
    344         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    345 
    346         isSuccessful = true;
    347     }
    348     catch( boost::archive::archive_exception e )
     343        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     344
     345        isSuccessful = true;
     346    }
     347    catch( boost::archive::archive_exception const& e )
    349348    {
    350349        if( isShowExceptionMessage )
     
    380379
    381380        // ファイルに書き出し
    382         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    383 
    384         isSuccessful = true;
    385     }
    386     catch( boost::archive::archive_exception e )
     381        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     382
     383        isSuccessful = true;
     384    }
     385    catch( boost::archive::archive_exception const& e )
    387386    {
    388387        if( isShowExceptionMessage )
     
    420419
    421420        // 文字列ストリームから読込
    422         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
     421        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
    423422
    424423        isSuccessful = true;
     
    445444
    446445        // 文字列ストリームに書き出し
    447         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    448 
    449         isSuccessful = true;
    450     }
    451     catch( boost::archive::archive_exception e )
     446        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     447
     448        isSuccessful = true;
     449    }
     450    catch( boost::archive::archive_exception const& e )
    452451    {
    453452        echo( e.what() );
     
    478477
    479478        // 文字列ストリームから読込
    480         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
     479        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
    481480
    482481        isSuccessful = true;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp

    r750 r828  
    353353const std::string Compiler::TypeToString( const Type &type )
    354354{
    355     if( PTR_LEVEL( type.GetBasicType() ) ){
     355    if(type.GetBasicType() != DEF_NON && PTR_LEVEL( type.GetBasicType() ) ){
    356356        //ポインタレベルが1以上の場合
    357357        Type tempType( type );
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp

    r625 r828  
    33using namespace ActiveBasic::Compiler;
    44
    5 bool LexicalAnalyzer::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection )
     5using boost::numeric_cast;
     6
     7bool LexicalAnalyzer::CollectNamespaces(char const* source, NamespaceScopesCollection &namespaceScopesCollection)
    68{
    7     int i, i2;
    8     char temporary[1024];
    9 
    109    bool isSuccessful = true;
    1110
     
    1312    NamespaceScopes namespaceScopes;
    1413
    15     for(i=0;;i++){
     14    for (int i = 0; ; i++)
     15    {
    1616        if(source[i]=='\0') break;
    1717
    1818        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    19             for(i+=2,i2=0;;i2++,i++){
    20                 if( IsCommandDelimitation( source[i] ) ){
    21                     temporary[i2]=0;
    22                     break;
    23                 }
    24                 temporary[i2]=source[i];
     19            i+=2;
     20            char const* p = &source[i];
     21            while (!IsCommandDelimitation(source[i]))
     22            {
     23                ++i;
    2524            }
    26             namespaceScopes.push_back( temporary );
     25            namespaceScopes.push_back(std::string(p, &source[i]));
    2726
    2827            if( !namespaceScopesCollection.IsExist( namespaceScopes ) ){
     
    4645    }
    4746
    48     if( namespaceScopes.size() > 0 ){
     47    if( !namespaceScopes.empty() ){
    4948        compiler.errorMessenger.Output( 63, NULL, cp );
    5049        isSuccessful = false;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp

    r750 r828  
    1515void LexicalAnalyzer::CollectClassesForNameOnly( const char *source, Classes &classes )
    1616{
    17     int i, i2;
     17    int i2;
    1818    char temporary[VN_SIZE];
    1919
     
    2525    compiler.GetNamespaceSupporter().ClearImportedNamespaces();
    2626
    27     for(i=0;;i++){
     27    for(int i=0;;i++){
    2828        if(source[i]=='\0') break;
    2929
    3030        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    31             for(i+=2,i2=0;;i2++,i++){
    32                 if( IsCommandDelimitation( source[i] ) ){
    33                     temporary[i2]=0;
    34                     break;
    35                 }
    36                 temporary[i2]=source[i];
    37             }
    38             namespaceScopes.push_back( temporary );
     31            i+=2;
     32            char const* p = &source[i];
     33            while (!IsCommandDelimitation(source[i]))
     34            {
     35                ++i;
     36            }
     37            namespaceScopes.push_back(std::string(p, &source[i]));
    3938
    4039            continue;
     
    5251        }
    5352        else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
    54             for(i+=2,i2=0;;i2++,i++){
    55                 if( IsCommandDelimitation( source[i] ) ){
    56                     temporary[i2]=0;
    57                     break;
    58                 }
    59                 temporary[i2]=source[i];
    60             }
    61             if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
    62             {
    63                 compiler.errorMessenger.Output(64,temporary,i );
     53            i+=2;
     54            char const* p = &source[i];
     55            while (!IsCommandDelimitation(source[i]))
     56            {
     57                ++i;
     58            }
     59            std::string s(p, &source[i]);
     60            if (!compiler.GetNamespaceSupporter().ImportsNamespace(s))
     61            {
     62                compiler.errorMessenger.Output(64, s.c_str(), i);
    6463            }
    6564
     
    13481347    delete pobj_LoopRefCheck;
    13491348    pobj_LoopRefCheck=0;
    1350 
    1351     // イテレータの準備
    1352     classes.Iterator_Init();
    13531349}
    13541350
     
    14121408
    14131409    compiler.GetObjectModule().meta.GetUserProcs().Put( pUserProc );
    1414     compiler.GetObjectModule().meta.GetUserProcs().Iterator_Init();
    14151410
    14161411    LexicalAnalyzer::AddMethod(
     
    15221517        else
    15231518        {
    1524             for( int i=0; i<pInterface->GetDynamicMethods().size(); i++ )
     1519            for( std::size_t i=0; i<pInterface->GetDynamicMethods().size(); i++ )
    15251520            {
    15261521                if( pInterface->GetDynamicMethods()[i]->IsAbstract() != pExpandedInterface->GetDynamicMethods()[i]->IsAbstract() )
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp

    r637 r828  
    8585
    8686    int i2;
    87     char temporary[1024];
    8887
    8988    // 名前空間管理
     
    9190    namespaceScopes.clear();
    9291
    93     for(int i=0;;i++){
     92    for (int i = 0; ; ++i)
     93    {
    9494        if( source[i] == '\0' ) break;
    9595
    9696        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    97             for(i+=2,i2=0;;i2++,i++){
    98                 if( IsCommandDelimitation( source[i] ) ){
    99                     temporary[i2]=0;
    100                     break;
    101                 }
    102                 temporary[i2]=source[i];
    103             }
    104             namespaceScopes.push_back( temporary );
     97            i+=2;
     98            char const* p = &source[i];
     99            while (!IsCommandDelimitation(source[i]))
     100            {
     101                ++i;
     102            }
     103            namespaceScopes.push_back(std::string(p, &source[i]));
    105104
    106105            continue;
     
    131130                }
    132131
     132                char const* beginTemp = &source[i];
     133                char const* endTemp = &source[i];
     134
    133135                for(i2=0;;i++,i2++){
    134136                    if(source[i]=='\"'){
    135                         temporary[i2]=source[i];
    136137                        for(i++,i2++;;i++,i2++){
    137                             temporary[i2]=source[i];
    138138                            if(source[i]=='\"') break;
    139139                        }
     
    141141                    }
    142142                    if(IsCommandDelimitation(source[i])){
    143                         temporary[i2]=0;
     143                        endTemp = beginTemp + i2;
    144144                        break;
    145145                    }
    146                     temporary[i2]=source[i];
    147146                }
    148147
    149148                //名前を取得
    150                 char name[VN_SIZE];
     149                char const* nameEnd;
    151150                for(i2=0;;i2++){
    152                     if(temporary[i2]=='\0'){
     151                    if(beginTemp[i2]=='\0'){
    153152                        compiler.errorMessenger.Output(10,"Const",cp);
    154153                        return;
    155154                    }
    156                     if(temporary[i2]=='='||temporary[i2]=='('){
    157                         name[i2]=0;
     155                    if(beginTemp[i2]=='='||beginTemp[i2]=='('){
     156                        nameEnd = beginTemp + i2;
    158157                        break;
    159158                    }
    160                     name[i2]=temporary[i2];
    161                 }
     159                }
     160                std::string name(beginTemp, nameEnd);
    162161
    163162                //重複チェック
     
    165164                    || compiler.GetObjectModule().meta.GetGlobalConsts().IsExistDuplicationKeyName( name ) )
    166165                {
    167                     compiler.errorMessenger.Output(15,name,cp);
     166                    compiler.errorMessenger.Output(15, name, cp);
    168167                    return;
    169168                }
    170169
    171                 if( temporary[i2] == '=' )
     170                if( beginTemp[i2] == '=' )
    172171                {
    173172                    // 定数
    174                     const char *expression = temporary + i2 + 1;
     173                    std::string expression(beginTemp + i2 + 1, endTemp);
    175174
    176175                    _int64 i64data;
    177176                    Type resultType;
    178                     if( StaticCalculation(false, expression, 0, &i64data, resultType) )
     177                    if( StaticCalculation(false, expression.c_str(), 0, &i64data, resultType) )
    179178                    {
    180179                        consts.Add( Symbol( namespaceScopes, name ), i64data, resultType );
     
    184183                {
    185184                    // 定数マクロ
    186                     const char *params = temporary + i2;
    187                     if( !constMacros.Add( Symbol( namespaceScopes, name ), params ) )
     185                    std::string params(beginTemp + i2, endTemp);
     186                    if( !constMacros.Add( Symbol( namespaceScopes, name ), params.c_str() ) )
    188187                    {
    189188                        compiler.errorMessenger.Output( 1, NULL, i );
     
    206205        }
    207206    }
    208 
    209     // イテレータを初期化
    210     compiler.GetObjectModule().meta.GetGlobalConsts().Iterator_Init();
    211     compiler.GetObjectModule().meta.GetGlobalConstMacros().Iterator_Init();
    212 }
    213 
    214 bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest )
    215 {
    216     extern HANDLE hHeap;
    217     int i2,i3,i4,num;
     207}
     208
     209bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest, std::size_t destSize )
     210{
     211    std::string s;
     212    auto ret = ConstMacroToExpression(constMacro, parameterStr, s);
     213    strcpy_s(dest, destSize, s.c_str());
     214    return ret;
     215}
     216
     217bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, std::string& dest )
     218{
     219    int i2,i3;
    218220    char temporary[VN_SIZE];
    219     char *pParms[MAX_PARMS];
    220     num=0;
     221    std::vector<std::string> Parms;
     222    dest.reserve(8192);
    221223    i2=0;
    222224    while(1){
    223225        i2=GetOneParameter(parameterStr,i2,temporary);
    224226
    225         pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
    226         lstrcpy(pParms[num],temporary);
    227 
    228         num++;
     227        Parms.push_back(temporary);
     228
    229229        if(parameterStr[i2]=='\0') break;
    230230    }
    231     if( num != constMacro.GetParameters().size() ){
     231    if( Parms.size() != constMacro.GetParameters().size() ){
    232232        extern int cp;
    233         for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
    234233        compiler.errorMessenger.Output(10,constMacro.GetName().c_str(),cp);
    235         lstrcpy(dest,"0");
     234        dest = '0';
    236235        return true;
    237236    }
    238237
    239238    i2=0;
    240     i4=0;
    241239    while(1){
    242240
     
    257255        if( i3 == (int)constMacro.GetParameters().size() ){
    258256            //パラメータでないとき
    259             lstrcpy(dest+i4,temporary);
    260             i4+=lstrlen(temporary);
     257            dest += temporary;
    261258        }
    262259        else{
    263260            //パラメータのとき
    264             lstrcpy(dest+i4,pParms[i3]);
    265             i4+=lstrlen(pParms[i3]);
     261            dest += Parms[i3];
    266262        }
    267263
    268264        //演算子をコピー
    269         for(;;i2++,i4++){
     265        for(;;i2++){
    270266            if( constMacro.GetExpression()[i2] == 1 ){
    271                 dest[i4++] = constMacro.GetExpression()[i2++];
    272                 dest[i4] = constMacro.GetExpression()[i2];
     267                dest += constMacro.GetExpression()[i2++];
     268                dest += constMacro.GetExpression()[i2];
    273269                continue;
    274270            }
    275271            if(IsVariableTopChar( constMacro.GetExpression()[i2] )) break;
    276             dest[i4] = constMacro.GetExpression()[i2];
     272            dest += constMacro.GetExpression()[i2];
    277273            if( constMacro.GetExpression()[i2] == '\0' ) break;
    278274        }
     
    281277    }
    282278
    283     for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);
    284 
    285279    return true;
    286280}
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp

    r750 r828  
    55void LexicalAnalyzer::CollectDelegates( const char *source, Delegates &delegates )
    66{
    7     int i2;
    8     char temporary[VN_SIZE];
    9 
    107    // 名前空間管理
    118    NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
     
    1512    compiler.GetNamespaceSupporter().ClearImportedNamespaces();
    1613
    17     int length = lstrlen( source );
    18     for( int i=0; i<length; i++ )
     14    for (int i=0; source[i] != '\0'; i++)
    1915    {
    2016        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    21             for(i+=2,i2=0;;i2++,i++){
    22                 if( IsCommandDelimitation( source[i] ) ){
    23                     temporary[i2]=0;
    24                     break;
    25                 }
    26                 temporary[i2]=source[i];
    27             }
    28             namespaceScopes.push_back( temporary );
     17            i+=2;
     18            char const* p = &source[i];
     19            while (!IsCommandDelimitation(source[i]))
     20            {
     21                ++i;
     22            }
     23            namespaceScopes.push_back(std::string(p, &source[i]));
    2924
    3025            continue;
     
    4237        }
    4338        else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
    44             for(i+=2,i2=0;;i2++,i++){
    45                 if( IsCommandDelimitation( source[i] ) ){
    46                     temporary[i2]=0;
    47                     break;
    48                 }
    49                 temporary[i2]=source[i];
    50             }
    51             if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
    52             {
    53                 compiler.errorMessenger.Output(64,temporary,i );
     39            i+=2;
     40            char const* p = &source[i];
     41            while (!IsCommandDelimitation(source[i]))
     42            {
     43                ++i;
     44            }
     45            std::string s(p, &source[i]);
     46            if (!compiler.GetNamespaceSupporter().ImportsNamespace(s))
     47            {
     48                compiler.errorMessenger.Output(64, s.c_str(), i);
    5449            }
    5550
     
    112107                {
    113108                    compiler.errorMessenger.Output(-104,name,nowLine);
    114                     lstrcpy( returnTypeName, "Double" );
     109                    strcpy( returnTypeName, "Double" );
    115110                }
    116111            }
     
    127122    Jenga::Common::SourceTemplate sourceTemplate( ActiveBasic::Common::Environment::GetAbdevSystemDirPath() + "\\templates\\delegate_class.tab" );
    128123
    129     delegates.Iterator_Reset();
    130     while( delegates.Iterator_HasNext() )
    131     {
    132         const Delegate &dg = *delegates.Iterator_GetNext();
     124    foreach (auto pDelegate, delegates)
     125    {
     126        const Delegate &dg = *pDelegate;
    133127
    134128        if( dg.IsExternal() )
     
    263257void LexicalAnalyzer::RefleshDelegatesParameterAndReturnType( Delegates &delegates )
    264258{
    265     delegates.Iterator_Reset();
    266     while( delegates.Iterator_HasNext() )
    267     {
    268         Delegate &dg = *delegates.Iterator_GetNext();
    269         RefleshDelegateParameterAndReturnType( dg );
    270     }
    271 }
     259    foreach (auto *pDelegate, delegates)
     260    {
     261        RefleshDelegateParameterAndReturnType(*pDelegate);
     262    }
     263}
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Procedure.cpp

    r750 r828  
    913913
    914914        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    915             for(i+=2,i2=0;;i2++,i++){
    916                 if( IsCommandDelimitation( source[i] ) ){
    917                     temporary[i2]=0;
    918                     break;
    919                 }
    920                 temporary[i2]=source[i];
    921             }
    922             namespaceScopes.push_back( temporary );
     915            i+=2;
     916            char const* p = &source[i];
     917            while (!IsCommandDelimitation(source[i]))
     918            {
     919                ++i;
     920            }
     921            namespaceScopes.push_back(std::string(p, &source[i]));
    923922
    924923            continue;
     
    936935        }
    937936        else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
    938             for(i+=2,i2=0;;i2++,i++){
    939                 if( IsCommandDelimitation( source[i] ) ){
    940                     temporary[i2]=0;
    941                     break;
    942                 }
    943                 temporary[i2]=source[i];
    944             }
    945             if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
    946             {
    947                 compiler.errorMessenger.Output(64,temporary,cp );
     937            i+=2;
     938            char const* p = &source[i];
     939            while (!IsCommandDelimitation(source[i]))
     940            {
     941                ++i;
     942            }
     943            std::string s(p, &source[i]);
     944            if (!compiler.GetNamespaceSupporter().ImportsNamespace(s))
     945            {
     946                compiler.errorMessenger.Output(64, s.c_str(), i);
    948947            }
    949948
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_TypeDef.cpp

    r668 r828  
    11#include "stdafx.h"
     2#include <abdev/ab_common/include/ab_common.h>
     3#include "LexicalAnalyzer.h"
     4#include "Compiler.h"
     5#include "StrOperation.h"
     6#include <boost/algorithm/string/predicate.hpp>
    27
    38using namespace ActiveBasic::Compiler;
    49
    5 void LexicalAnalyzer::AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const std::string &expression, int nowLine )
     10void LexicalAnalyzer::AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const boost::iterator_range<char const*> &expression, int nowLine )
    611{
    7     int i;
    8     char temporary[VN_SIZE];
     12    auto name = boost::find<boost::return_begin_found>(expression, '=');
    913
    10     for(i=0;;i++){
    11         if(expression[i]=='='||expression[i]=='\0'){
    12             temporary[i]=0;
    13             break;
    14         }
    15         temporary[i]=expression[i];
    16     }
    17 
    18     if(expression[i]!='='){
    19         compiler.errorMessenger.Output(10,"TypeDef",nowLine);
     14    if (boost::end(name) == boost::end(expression))
     15    {
     16        compiler.errorMessenger.Output(10, "TypeDef", nowLine);
    2017        return;
    2118    }
    2219
    23     const char *pTemp=expression.c_str()+i+1;
     20    const char *pTemp = expression.begin() + boost::size(name) + 1;
    2421
    2522    //識別文字のエラーチェック(新しい型)
    26     i=0;
    27     for(;;i++){
    28         if(temporary[i]=='\0') break;
    29         if( !( IsVariableChar( temporary[i], true) ) ){
    30             compiler.errorMessenger.Output(10,"TypeDef",nowLine);
    31             return;
    32         }
     23    if (!boost::algorithm::all(name, [](char c) {return IsVariableChar(c, true);}))
     24    {
     25        compiler.errorMessenger.Output(10, "TypeDef", nowLine);
     26        return;
    3327    }
    3428
     
    4135        }
    4236    }
    43     else{
    44         i=0;
     37    else
     38    {
     39        int i=0;
    4540        while(pTemp[i]=='*') i++;
    46         for(;;i++){
    47             if(pTemp[i]=='\0') break;
    48             if( !( IsVariableChar( pTemp[i], true) ) )
    49             {
    50                 compiler.errorMessenger.Output(10,"TypeDef",nowLine);
    51                 return;
    52             }
     41        if (!boost::algorithm::all(name, [](char c) {return IsVariableChar(c, true);}))
     42        {
     43            compiler.errorMessenger.Output(10,"TypeDef",nowLine);
     44            return;
    5345        }
    5446    }
    5547
     48    std::string baseName(pTemp, expression.end());
     49
    5650    //識別子が重複している場合はエラーにする
    57     if(lstrcmp(temporary,pTemp)==0){
     51    if (boost::algorithm::equals(name, baseName))
     52    {
    5853        compiler.errorMessenger.Output(1,NULL,nowLine);
    5954        return;
     
    6762
    6863    Type baseType;
    69     if( !compiler.StringToType( pTemp, baseType ) )
     64    if( !compiler.StringToType( baseName, baseType ) )
    7065    {
    71         compiler.errorMessenger.Output(3, pTemp, nowLine );
     66        compiler.errorMessenger.Output(3, baseName, nowLine );
    7267        return;
    7368    }
     
    7570    typeDefs.push_back(
    7671        TypeDef(
    77             Symbol( namespaceScopes, temporary ),
    78             pTemp,
     72            Symbol(namespaceScopes, boost::copy_range<std::string>(name)),
     73            baseName,
    7974            baseType
    8075        )
     
    9085    compiler.GetNamespaceSupporter().ClearImportedNamespaces();
    9186
    92     int i=-1, i2;
    93     char temporary[VN_SIZE];
    94     while(1){
    95 
    96         i++;
    97 
     87    for (int i = 0; ; ++i)
     88    {
    9889        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
    99             for(i+=2,i2=0;;i2++,i++){
    100                 if( IsCommandDelimitation( source[i] ) ){
    101                     temporary[i2]=0;
    102                     break;
    103                 }
    104                 temporary[i2]=source[i];
     90            i+=2;
     91            char const* p = &source[i];
     92            while (!IsCommandDelimitation(source[i]))
     93            {
     94                ++i;
    10595            }
    106             namespaceScopes.push_back( temporary );
     96            namespaceScopes.push_back(std::string(p, &source[i]));
    10797
    10898            continue;
     
    120110        }
    121111        else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
    122             for(i+=2,i2=0;;i2++,i++){
    123                 if( IsCommandDelimitation( source[i] ) ){
    124                     temporary[i2]=0;
    125                     break;
    126                 }
    127                 temporary[i2]=source[i];
     112            i+=2;
     113            char const* p = &source[i];
     114            while (!IsCommandDelimitation(source[i]))
     115            {
     116                ++i;
    128117            }
    129             if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
     118            std::string s(p, &source[i]);
     119            if (!compiler.GetNamespaceSupporter().ImportsNamespace(s))
    130120            {
    131                 compiler.errorMessenger.Output(64,temporary,i );
     121                compiler.errorMessenger.Output(64, s.c_str(), i);
    132122            }
    133123
     
    144134            char temporary[VN_SIZE];
    145135            if(source[i+1]==ESC_TYPEDEF){
    146                 int i2 = 0;
    147                 for(i+=2;;i2++,i++){
    148                     if(source[i]=='\n'){
    149                         temporary[i2]=0;
    150                         break;
    151                     }
    152                     temporary[i2]=source[i];
    153                     if(source[i]=='\0') break;
     136                i+=2;
     137                char const* p = &source[i];
     138                while (!IsCommandDelimitation(source[i]))
     139                {
     140                    ++i;
    154141                }
    155                 AddTypeDef( typeDefs, namespaceScopes, temporary, i );
    156 
     142                AddTypeDef(typeDefs, namespaceScopes, boost::make_iterator_range(p, &source[i]), i);
    157143                continue;
    158144            }
     
    168154                }
    169155
    170                 Type baseType;
    171                 if( !compiler.StringToType( "Long", baseType ) )
    172                 {
    173                     throw;
    174                 }
    175 
    176156                typeDefs.push_back(
    177157                    TypeDef(
    178158                        Symbol( namespaceScopes, temporary ),
    179159                        "Long",
    180                         baseType
     160                        Type(DEF_LONG)
    181161                    )
    182162                );
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Linker.cpp

    r750 r828  
    257257    nativeCode.PutEx( masterObjectModule.globalNativeCode );
    258258
    259     masterObjectModule.meta.GetUserProcs().Iterator_Reset();
    260     while( masterObjectModule.meta.GetUserProcs().Iterator_HasNext() )
    261     {
    262         const UserProc *pUserProc = masterObjectModule.meta.GetUserProcs().Iterator_GetNext();
    263 
     259    foreach (auto pUserProc, masterObjectModule.meta.GetUserProcs())
     260    {
    264261        if( pUserProc->GetNativeCode().GetSize() > 0 )
    265262        {
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/ProcedureGenerator.cpp

    r750 r828  
    1818    int back_cp=cp;
    1919
    20     classes.Iterator_Reset();
    21     while(classes.Iterator_HasNext()){
    22         CClass &objClass = *classes.Iterator_GetNext();
     20    foreach(auto pClass, classes)
     21    {
     22        CClass &objClass = *pClass;
    2323        if( objClass.IsExternal() )
    2424        {
     
    8383    ////////////////////////////////////////////////////////////////////
    8484
    85     // イテレータをリセット
    86     classes.Iterator_Reset();
    87 
    88     while( classes.Iterator_HasNext() ){
    89         const CClass &objClass = *classes.Iterator_GetNext();
     85    foreach (auto pClass, classes)
     86    {
     87        const CClass &objClass = *pClass;
    9088
    9189        if( !objClass.IsUsing() ){
     
    152150    ChangeOpcode( temporary );
    153151
    154     // イテレータをリセット
    155     classes.Iterator_Reset();
    156 
    157     while( classes.Iterator_HasNext() ){
    158         const CClass &objClass = *classes.Iterator_GetNext();
     152    foreach (auto pClass, classes)
     153    {
     154        const CClass &objClass = *pClass;
    159155
    160156        if( !objClass.IsUsing() ){
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp

    r750 r828  
    9393void VtblGenerator::GenerateVTablesForAllClasses( Classes &classes )
    9494{
    95     classes.Iterator_Reset();
    96     while( classes.Iterator_HasNext() )
     95    foreach (auto pClass, classes)
    9796    {
    98         CClass *pClass = classes.Iterator_GetNext();
    9997        GenerateFullVTables( *pClass );
    10098
     
    177175void VtblGenerator::ActionVtblScheduleForAllClasses( Classes &classes, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection )
    178176{
    179     classes.Iterator_Reset();
    180     while( classes.Iterator_HasNext() )
     177    foreach(auto pClass, classes)
    181178    {
    182         CClass *pClass = classes.Iterator_GetNext();
    183179        ActionVtblSchedule( *pClass, ImageBase, MemPos_CodeSection, MemPos_DataSection );
    184180
Note: See TracChangeset for help on using the changeset viewer.