Example #1
0
        private IteratorFinallyMethodSymbol MakeSynthesizedFinally(int state)
        {
            var stateMachineType = (IteratorStateMachine)F.CurrentType;
            var finallyMethod    = new IteratorFinallyMethodSymbol(stateMachineType, GeneratedNames.MakeIteratorFinallyMethodName(state));

            F.ModuleBuilderOpt.AddSynthesizedDefinition(stateMachineType, finallyMethod);
            return(finallyMethod);
        }
            public IteratorFinallyFrame(
                IteratorFinallyFrame parent,
                int finalizeState,
                IteratorFinallyMethodSymbol handler,
                HashSet<LabelSymbol> labels)
            {
                Debug.Assert(parent != null, "non root frame must have a parent");
                Debug.Assert((object)handler != null, "non root frame must have a handler");

                this.parent = parent;
                this.finalizeState = finalizeState;
                this.handler = handler;
                this.labels = labels;
            }
            public IteratorFinallyFrame(
                IteratorFinallyFrame parent,
                int finalizeState,
                IteratorFinallyMethodSymbol handler,
                HashSet <LabelSymbol> labels)
            {
                Debug.Assert(parent != null, "non root frame must have a parent");
                Debug.Assert((object)handler != null, "non root frame must have a handler");

                this.parent        = parent;
                this.finalizeState = finalizeState;
                this.handler       = handler;
                this.labels        = labels;
            }
        private IteratorFinallyMethodSymbol MakeSynthesizedFinally(int state)
        {
            // we can pick any name, but we will try to do
            // <>m__Finally1
            // <>m__Finally2
            // <>m__Finally3
            // . . .
            // that will roughly match native naming scheme and may also be easier when need to debug.
            string name = "<>m__Finally" + Math.Abs(state + 2);

            var stateMachineType = (IteratorStateMachine)F.CurrentClass;

            Debug.Assert(stateMachineType != null);

            var finallyMethod = new IteratorFinallyMethodSymbol(stateMachineType, name);

            F.ModuleBuilderOpt.AddSynthesizedDefinition(stateMachineType, finallyMethod);

            return(finallyMethod);
        }
        private IteratorFinallyMethodSymbol MakeSynthesizedFinally(int state)
        {
            var stateMachineType = (IteratorStateMachine)F.CurrentType;
            var finallyMethod = new IteratorFinallyMethodSymbol(stateMachineType, GeneratedNames.MakeIteratorFinallyMethodName(state));

            F.ModuleBuilderOpt.AddSynthesizedDefinition(stateMachineType, finallyMethod);
            return finallyMethod;
        }
        private IteratorFinallyMethodSymbol MakeSynthesizedFinally(int state)
        {
            // we can pick any name, but we will try to do
            // <>m__Finally1
            // <>m__Finally2
            // <>m__Finally3
            // . . . 
            // that will roughly match native naming scheme and may also be easier when need to debug.
            string name = "<>m__Finally" + Math.Abs(state + 2);

            var stateMachineType = (IteratorStateMachine)F.CurrentClass;
            Debug.Assert(stateMachineType != null);

            var finallyMethod = new IteratorFinallyMethodSymbol(stateMachineType, name);

            F.ModuleBuilderOpt.AddSynthesizedDefinition(stateMachineType, finallyMethod);

            return finallyMethod;
        }