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());
            }
        }
Ejemplo n.º 2
0
        public override void VisitYieldStatement(YieldStatementSyntax node)
        {
            var nextState = GetNextState(node);

            if (node.ReturnOrBreakKeyword.IsKind(SyntaxKind.BreakKeyword))
            {
                currentState.Add(ChangeState(nextState));
                currentState.Add(Cs.Return(Cs.False()));
            }
            else
            {
                currentState.Add(ChangeState(nextState));
                currentState.Add(Cs.Express(Cs.This().Member("Current").Assign(YieldThisFixer.Fix(node.Expression))));
                currentState.Add(Cs.Return(Cs.True()));
            }
            SetClosed(currentState);

            currentState = nextState;
        }
Ejemplo n.º 3
0
        public InvocationExpressionSyntax Object(AnonymousObjectCreationExpressionSyntax obj, bool compact = false)
        {
            var method = context.JsniType.GetMembers("object").OfType <IMethodSymbol>().Single();

            return(method.Invoke(obj, compact ? Cs.True() : Cs.False()));
        }