Ejemplo n.º 1
0
        public void GenerateStates()
        {
            var lastState = new State(this);

            lastState.Statements.Add(Cs.Return(Cs.False()));

            currentState = new State(this)
            {
                NextState = lastState
            };
            node.Accept(this);

            // Post-process goto statements
            if (labelStates.Any())
            {
                var gotoSubstituter = new GotoSubstituter(compilation, labelStates);
                foreach (var state in states)
                {
                    state.Statements = state.Statements.Select(x => (StatementSyntax)x.Accept(gotoSubstituter)).ToList();
                }
            }

            if (!states.Last().Statements.Any())
            {
                states.Last().Statements.Add(Cs.Break());
            }
        }