val firstPushScopeIndex = bytecode.ops.indexWhere( x => x ~== PushScope()) // insert try after first pushScope call
var op = bytecode.ops(firstPushScopeIndex + 1)
val markerStart = bytecode.markers.mark(op)
val markerCatch = bytecode.markers.mark(op)
val markerEnd = bytecode.markers.mark(bytecode.ops(bytecode.ops.length - 2))
val typeName = AbcQName('Error, AbcNamespace(22, Symbol("")))
val varName = AbcQName('e, AbcNamespace(22, Symbol("")))
val newExceptionHandler = new BytecodeExceptionHandler(markerStart, markerEnd, markerCatch, typeName, varName)
bytecode.exceptions = Array(newExceptionHandler) //:: bytecode.exceptions
privatefunction exceptionNoReturn():void
{
try
{
trace("trying")
}
catch(e:Error)
{
}
}
The ABC looks different, i.e. there are Jump's, more markers, etc....
Bytecode:
operandStack: 3
scopeStack: 3
localCount: 2
1 exception(s):
(L0, L1) => L2, AbcQName('Error,AbcNamespace(22,')), AbcQName('e,AbcNamespace(22,'))
24 operation(s):
+0|-0 DebugFile('/Users/alenbalja/Projects/BBC/code2/ActionScriptTestCases/src;;SimpleException.as)
+0|-0 DebugLine(12)
+1|-0 GetLocal(0)
+0|-1 PushScope()
try {
L0: +0|-0 DebugLine(16)
+1|-0 FindPropStrict(AbcQName('trace,AbcNamespace(22,')))
+1|-0 PushString('trying)
+1|-2 CallProperty(AbcQName('trace,AbcNamespace(22,')),1)
+0|-1 Pop()
} catch {
(AbcQName('e,AbcNamespace(22,')), AbcQName('Error,AbcNamespace(22,'))) => L2
}
L1: +0|-0 DebugLine(18)
+0|-0 Jump(L3)
L2: +1|-0 GetLocal(0)
+0|-1 PushScope()
+1|-0 NewCatch((L0, L1) => L2, AbcQName('Error,AbcNamespace(22,')), AbcQName('e,AbcNamespace(22,')))
+2|-1 Dup()
+0|-1 SetLocal(1)
+2|-1 Dup()
+0|-1 PushScope()
+2|-2 Swap()
+0|-2 SetSlot(1)
+0|-0 PopScope()
+0|-0 Kill(1)
L3: +0|-0 DebugLine(21)
+0|-0 ReturnVoid()
SimpleException/private:exceptionNoReturn
ops len: 24
markers: apparat.bytecode.MarkerManager@30d1e7c2
exceptions len: 1
(L0, L1) => L2, AbcQName('Error,AbcNamespace(22,')), AbcQName('e,AbcNamespace(22,'))
trace("trying....");
;
trace("cathed");
return;
}