Changeset 373 for trunk


Ignore:
Timestamp:
Nov 6, 2007, 2:35:38 AM (17 years ago)
Author:
dai
Message:

Try-Catchを試験的に実装。
(まだ下記の動作しか実装していません)
・Try
・Catch(パラメータ無し)
・Throw(パラメータ無し)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/system/exception.ab

    r372 r373  
    66    Const basePtr As LONG_PTR
    77    Const stackPtr As LONG_PTR
    8     context As CONTEXT
    98    Const debugProcNum As DWord
    109   
     
    1312        This.basePtr = basePtr
    1413        This.stackPtr = stackPtr
    15 
    16         Dim tempContext As CONTEXT
    17 
    18         tempContext.ContextFlags = CONTEXT_CONTROL or CONTEXT_INTEGER
    19         If Thread.CurrentThread().__GetContext(tempContext) = 0 Then
    20             ' TODO: エラー処理
    21             debug
    22         End If
    23         context = tempContext
    2414
    2515#ifdef _DEBUG
     
    5848
    5949    'Try
    60     Function BeginTryScope( addressOfCatch As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer
     50    Function _BeginTryScope( addressOfCatch As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer
    6151        ppTryLayers = _System_realloc( ppTryLayers, ( nTryLayers + 1 ) * SizeOf( *TryLayer ) )
    6252        ppTryLayers[nTryLayers] = New TryLayer( addressOfCatch, basePtr, stackPtr )
     
    6454
    6555        Return ByVal ppTryLayers[nTryLayers-1]
     56    End Function
     57
     58    Static Function BeginTryScope( addressOfCatch As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer
     59        Return _System_pobj_AllThreads->GetCurrentException()->_BeginTryScope( addressOfCatch, basePtr, stackPtr )
    6660    End Function
    6761
     
    9286        '--------------------------------------------------
    9387
    94         'レジスタ情報を取得
    95         Dim context = ppTryLayers[nTryLayers - 1]->context
     88        Dim context As CONTEXT
     89        context.ContextFlags = CONTEXT_CONTROL or CONTEXT_INTEGER
     90        If GetThreadContext( GetCurrentThread(), context ) = 0 Then
     91            ' TODO: エラー処理
     92            debug
     93        End If
    9694
    97         'カレント スレッドを取得
    98         Dim thread = Thread.CurrentThread
    99 
    100         '新しいip, spをセット
     95        '新しいip, sp, bpをセット
    10196#ifdef _WIN64
    10297        context.Rip = ppTryLayers[nTryLayers - 1]->addressOfCatch As QWord
     
    116111        End If
    117112#endif
    118 debug
    119         If thread.__SetContext( context ) = 0 Then
     113
     114        If SetThreadContext( GetCurrentThread(), context ) = 0 Then
    120115            OutputDebugString(Ex"レジスタ情報の設定に失敗しました。\r\n")
    121116            Return
    122117        End If
    123         debug
    124118    End Sub
    125119
     
    127121        _Throw()
    128122    End Sub
    129 
    130     Static Sub AllocateObject( pObj As VoidPtr )
    131         Dim thread = Thread.CurrentThread
    132         'TODO: ローカルオブジェクトを登録
    133     End Sub
    134 
    135     Static Sub DeallocateObject( pObj As VoidPtr )
    136         'TODO: ローカルオブジェクトを破棄
    137     End Sub
    138123End Class
    139124
  • trunk/Include/system/gc.sbp

    r370 r373  
    88Dim _System_gc_StackRoot_StartPtr As VoidPtr
    99*/
    10 
    11 Function _System_GetSp() As LONG_PTR                    'dummy
    12 End Function
    13 
    1410
    1511Const _System_GC_FLAG_ATOMIC = 1
Note: See TracChangeset for help on using the changeset viewer.