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()); } }
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; }
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())); }