private VB.Syntax.StatementSyntax VisitGotoStatementWorker(CS.Syntax.GotoStatementSyntax node) { switch (node.Kind()) { case CS.SyntaxKind.GotoStatement: return(VB.SyntaxFactory.GoToStatement( VB.SyntaxFactory.IdentifierLabel(nodeVisitor.ConvertIdentifier((CS.Syntax.IdentifierNameSyntax)node.Expression)))); case CS.SyntaxKind.GotoDefaultStatement: return(VB.SyntaxFactory.GoToStatement( VB.SyntaxFactory.IdentifierLabel(VB.SyntaxFactory.Identifier("Else")))); case CS.SyntaxKind.GotoCaseStatement: string text = node.Expression.ToString(); return(VB.SyntaxFactory.GoToStatement( VB.SyntaxFactory.IdentifierLabel(VB.SyntaxFactory.Identifier(text)))); } throw new NotImplementedException(); }
public override SyntaxList <StatementSyntax> VisitGotoStatement(CSS.GotoStatementSyntax node) { LabelSyntax label; if (node.IsKind(CS.SyntaxKind.GotoCaseStatement, CS.SyntaxKind.GotoDefaultStatement)) { if (_blockInfo.Count == 0) { throw new InvalidOperationException("goto case/goto default outside switch is illegal!"); } var labelExpression = node.Expression?.Accept(_nodesVisitor) ?? SyntaxFactory.ElseCaseClause(); _blockInfo.Peek().GotoCaseExpressions.Add(labelExpression); label = SyntaxFactory.Label(SyntaxKind.IdentifierLabel, MakeGotoSwitchLabel(labelExpression)); } else { label = SyntaxFactory.Label(SyntaxKind.IdentifierLabel, _commonConversions.ConvertIdentifier(((CSS.IdentifierNameSyntax)node.Expression).Identifier)); } return(SyntaxFactory.SingletonList <StatementSyntax>(SyntaxFactory.GoToStatement(label))); }
public override SyntaxNode VisitGotoStatement(CSS.GotoStatementSyntax node) { if (node.Ancestors().FirstOrDefault(_ => _.IsKind(CS.SyntaxKind.SwitchStatement)) == _csSwitch) { bool isGotoCase = node.CaseOrDefaultKeyword.IsKind(CS.SyntaxKind.CaseKeyword); bool isGotoDefault = node.CaseOrDefaultKeyword.IsKind(CS.SyntaxKind.DefaultKeyword); // bool isGotoCaseOrDefault = isGotoCase | isGotoDefault; if (isGotoCase || isGotoDefault) { if (!HasGotoTop && !HasGotoDefault) { string sNumber = CreateLabelNumber().ToString(); VariantName = "__SELECT_VALUE_" + sNumber; LabelTop = "__RETRY_SELECT_" + sNumber; LabelDefault = "__GOTO_DEFALUT_" + sNumber; } HasGotoTop |= isGotoCase; HasGotoDefault |= isGotoDefault; if (isGotoCase) { // "goto case EXPERESSION;" --> " { VariantName = EXPERESSION; Goto LabelTop; }" var csVariant = CS.SyntaxFactory.IdentifierName(VariantName); var csAssignExp = CS.SyntaxFactory.AssignmentExpression(CS.SyntaxKind.SimpleAssignmentExpression, csVariant, node.Expression); var csAssignStatement = CS.SyntaxFactory.ExpressionStatement(csAssignExp); var csGotoTop = CS.SyntaxFactory.GotoStatement(CS.SyntaxKind.GotoStatement, CS.SyntaxFactory.IdentifierName(LabelTop)); return(CS.SyntaxFactory.Block().AddStatements(csAssignStatement, csGotoTop)); } else { // "goto default;" --> "goto LABEL_DEFAULT;" return(CS.SyntaxFactory.GotoStatement(CS.SyntaxKind.GotoStatement, CS.SyntaxFactory.IdentifierName(LabelDefault))); } } } return(base.VisitGotoStatement(node)); }
public override SyntaxList <VB.Syntax.StatementSyntax> VisitGotoStatement(CS.Syntax.GotoStatementSyntax node) { return(List(VisitGotoStatementWorker(node))); }