Babel.Compiler.CodeGeneratingVisitor.VisitProtect C# (CSharp) Method

VisitProtect() public method

public VisitProtect ( ProtectStatement protect ) : void
protect ProtectStatement
return void
        public override void VisitProtect(ProtectStatement protect)
        {
            exceptionLevel++;
            ilGenerator.BeginExceptionBlock();
            protect.StatementList.Accept(this);
            foreach (ProtectWhen when in protect.WhenPartList) {
                ilGenerator.BeginCatchBlock(when.TypeSpecifier.RawType);
                LocalBuilder prevException = currentException;
                currentException =
                    ilGenerator.DeclareLocal(when.TypeSpecifier.RawType);
                ilGenerator.Emit(OpCodes.Stloc, currentException);
                when.ThenPart.Accept(this);
                currentException = prevException;
            }
            if (protect.ElsePart != null) {
                ilGenerator.BeginCatchBlock(typeof(Exception));
                LocalBuilder prevException = currentException;
                currentException =
                    ilGenerator.DeclareLocal(typeof(Exception));
                ilGenerator.Emit(OpCodes.Stloc, currentException);
                protect.ElsePart.Accept(this);
                currentException = prevException;
            }
            ilGenerator.EndExceptionBlock();
            exceptionLevel--;
        }