Changeset 374 for trunk/Include/system
- Timestamp:
- Nov 10, 2007, 11:20:01 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/system/exception.ab
r373 r374 3 3 Class TryLayer 4 4 Public 5 Const addressOfCatch As VoidPtr 5 Const catchTable As *LONG_PTR 6 Const addressOfFinally As VoidPtr 6 7 Const basePtr As LONG_PTR 7 8 Const stackPtr As LONG_PTR 9 8 10 Const debugProcNum As DWord 9 11 10 Sub TryLayer( addressOfCatch As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) 11 This.addressOfCatch = addressOfCatch 12 Sub TryLayer( catchTable As *LONG_PTR, addressOfFinally As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) 13 This.catchTable = catchTable 14 This.addressOfFinally = addressOfFinally 12 15 This.basePtr = basePtr 13 16 This.stackPtr = stackPtr … … 23 26 Sub ~TryLayer() 24 27 End Sub 28 29 Sub FinishFinally() 30 If Thread.CurrentThread().__IsThrowing() Then 31 Throw Thread.CurrentThread().__GetThrowintParamObject() 32 End If 33 End Sub 34 35 Function ResolveCatchesOverload( ex As Object ) As LONG_PTR 36 Dim defaultCatchCodePos = 0 As LONG_PTR 37 Dim pos = 0 As Long 38 While catchTable[pos] 39 ' パラメータのクラス名 40 Dim paramName = catchTable[pos] As *Char 41 pos ++ 42 43 ' コード位置 44 Dim codePos = catchTable[pos] As LONG_PTR 45 pos ++ 46 47 If paramName[0] = 0 Then 48 ' Default Catch 49 defaultCatchCodePos = codePos 50 End If 51 52 If Object.ReferenceEquals( ex, Nothing ) Then 53 ' パラメータなしのとき 54 If paramName[0] = 0 Then 55 ' マッチしたとき 56 Return codePos 57 End If 58 Else 59 If lstrcmp( paramName, ex.GetType().FullName ) = 0 Then 60 ' マッチしたとき 61 Return codePos 62 End If 63 End If 64 Wend 65 Return defaultCatchCodePos 66 End Function 25 67 End Class 26 68 … … 48 90 49 91 'Try 50 Function _BeginTryScope( addressOfCatchAs VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer92 Function _BeginTryScope( catchTable As *LONG_PTR, addressOfFinally As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer 51 93 ppTryLayers = _System_realloc( ppTryLayers, ( nTryLayers + 1 ) * SizeOf( *TryLayer ) ) 52 ppTryLayers[nTryLayers] = New TryLayer( addressOfCatch, basePtr, stackPtr )94 ppTryLayers[nTryLayers] = New TryLayer( catchTable, addressOfFinally, basePtr, stackPtr ) 53 95 nTryLayers++ 54 96 … … 56 98 End Function 57 99 58 Static Function BeginTryScope( addressOfCatchAs VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer59 Return _System_pobj_AllThreads->GetCurrentException()->_BeginTryScope( addressOfCatch, basePtr, stackPtr )100 Static Function BeginTryScope( catchTable As *LONG_PTR, addressOfFinally As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer 101 Return _System_pobj_AllThreads->GetCurrentException()->_BeginTryScope( catchTable, addressOfFinally, basePtr, stackPtr ) 60 102 End Function 61 103 … … 67 109 68 110 'Throw 69 Sub _Throw( )111 Sub _Throw( ex As Object ) 70 112 If nTryLayers <= 0 then 71 113 '例外処理スコープ制御が無効なとき … … 77 119 End If 78 120 121 ' スレッドへThrow処理を開始したことを通知 122 Thread.CurrentThread().__Throw( ex ) 123 79 124 '未解放なローカルオブジェクトを解放する 80 125 FreeLocalObjects() 81 126 127 Dim pTryLayer = ppTryLayers[nTryLayers - 1] As *TryLayer 128 129 Dim addressOfCatch = pTryLayer->ResolveCatchesOverload( ex ) As LONG_PTR 130 If addressOfCatch Then 131 ' スレッドへThrow処理が終了した(Catchされた)ことを通知 132 Thread.CurrentThread().__Catched() 133 Else 134 ' Catchが定義されていないときはFinallyへ誘導 135 addressOfCatch = pTryLayer->addressOfFinally As LONG_PTR 136 End If 82 137 83 138 … … 95 150 '新しいip, sp, bpをセット 96 151 #ifdef _WIN64 97 context.Rip = ppTryLayers[nTryLayers - 1]->addressOfCatch As QWord98 context.Rbp = p pTryLayers[nTryLayers - 1]->basePtr99 context.Rsp = p pTryLayers[nTryLayers - 1]->stackPtr152 context.Rip = addressOfCatch As QWord 153 context.Rbp = pTryLayer->basePtr 154 context.Rsp = pTryLayer->stackPtr 100 155 #else 101 context.Eip = ppTryLayers[nTryLayers - 1]->addressOfCatch As DWord102 context.Ebp = p pTryLayers[nTryLayers - 1]->basePtr103 context.Esp = p pTryLayers[nTryLayers - 1]->stackPtr156 context.Eip = addressOfCatch As DWord 157 context.Ebp = pTryLayer->basePtr 158 context.Esp = pTryLayer->stackPtr 104 159 #endif 105 160 … … 108 163 ThreadNum=_DebugSys_GetThread() 109 164 If ThreadNum <> -1 Then 110 _DebugSys_ProcNum[ThreadNum] = p pTryLayers[nTryLayers - 1]->debugProcNum-1165 _DebugSys_ProcNum[ThreadNum] = pTryLayer->debugProcNum-1 111 166 End If 112 167 #endif … … 118 173 End Sub 119 174 120 Sub _Throw( msg As String ) 121 _Throw() 175 Sub _ThrowWithParam( ex As Object ) 176 _Throw( ex ) 177 End Sub 178 179 Sub _ThrowNoneParam() 180 _Throw( Nothing ) 181 End Sub 182 183 Sub FinishFinally() 184 Dim pTryLayer = ppTryLayers[nTryLayers - 1] As *TryLayer 185 pTryLayer->FinishFinally() 122 186 End Sub 123 187 End Class
Note:
See TracChangeset
for help on using the changeset viewer.