Beispiel #1
0
        private void WriteTryCatchBlockBody(ILWriter writer, IImmutableQueue <Type> exceptionTypes)
        {
            var currentExecutionAttempt = writer.DeclareLocal <int>();
            var shouldRetry             = writer.DeclareLocal <bool>();

            var retryLabel = writer.DefineLabel();

            writer.MarkLabel(retryLabel);

            writer.WriteIncrement(currentExecutionAttempt, 1);

            writer.TryCatch(
                endOfTryCatch =>
            {
                writer.LoadFalse();
                writer.SetLocal(shouldRetry);

                var method = KnownMetadata.Methods.IExceptionAwareAction_Do;
                writer.LoadFirstParameter();
                writer.InstanceMethodCall(method);
            },
                WriteUnrolledCatchBlocks(writer, exceptionTypes, shouldRetry, currentExecutionAttempt)
                );

            writer.LoadLocal(shouldRetry);
            var shouldNotRetry = writer.IfTrueThen();

            writer.GoTo(retryLabel);

            writer.MarkLabel(shouldNotRetry);

            writer.Return();
        }