public override void Visit(TryStatement node) { VisitNode(node.Statement); VisitNode(node.Catch); VisitNode(node.Finally); Visit((Statement)node); }
public override void Visit(TryStatement node) { ///we may have an exception anywhere in the try block ///so stack may be at its max when entering the catch block ///one option is to clear up the stack before starting (we chose this one) ///the other optios is to make sure there is enough room on the stack PushLocation(node); _ilGen.BeginExceptionBlock(); _labelInfos.PushProtectedRegion(node); VisitNode(node.Statement); _labelInfos.PopProtectedRegion(node); VisitNode(node.Catch); VisitNode(node.Finally); _ilGen.EndExceptionBlock(); PopLocation(); }
public override void Visit(TryStatement node) { Visit((Statement)node); }
public override void Visit(TryStatement node) { ///In case we ever use a StackPointer variable that is changed at runtime, we have to consider the following: ///we may have an exception anywhere in the try block ///so stack may be at its max when entering the catch block ///one option is to clear up the stack before starting (we chose this one) ///the other optios is to make sure there is enough room on the stack PushLocation(node); var tryICIndex = ReserveNewICIndex(); var tryBeginIndex = GetCurrentICIndex() + 1; VisitNode(node.Statement); var tryEndIndex = GetCurrentICIndex(); var exceptionVariableIndex = -1; var catchBeginIndex = int.MaxValue; var catchEndIndex = int.MinValue; if (node.Catch != null) { var symbol = node.Catch.Identifier.Symbol; Debug.Assert(symbol != null, new JSSourceLocation(_currFuncMetadata, node.Catch), string.Format("Cannot find symbol for identifier {0} in catch clause", node.Catch.Identifier)); var originalSymbolType = symbol.SymbolType; symbol.SymbolType = JSSymbol.SymbolTypes.Local; //This symbols is defined only in the catch scope. exceptionVariableIndex = GetIndex(symbol); catchBeginIndex = GetCurrentICIndex() + 1; VisitNode(node.Catch); catchEndIndex = GetCurrentICIndex(); symbol.SymbolType = originalSymbolType; } var finallyBeginIndex = int.MaxValue; var finallyEndIndex = int.MinValue; if (node.Finally != null) { finallyBeginIndex = GetCurrentICIndex() + 1; VisitNode(node.Finally); finallyEndIndex = GetCurrentICIndex(); } BeginICMethod(node); _ilGen.Ldarg_CallFrame(); _ilGen.Ldc_I4(tryBeginIndex); _ilGen.Ldc_I4(tryEndIndex); _ilGen.Ldc_I4(catchBeginIndex); _ilGen.Ldc_I4(catchEndIndex); _ilGen.Ldc_I4(finallyBeginIndex); _ilGen.Ldc_I4(finallyEndIndex); _ilGen.Ldc_I4(exceptionVariableIndex); _ilGen.Call(Types.Operations.ICMethods.TryCatchFinally); EndICMethod(tryICIndex, GetCurrentICIndex() + 1); PopLocation(); }
public abstract void Visit(TryStatement node);
public override void Visit(TryStatement node) { throw new NotImplementedException(); }