public StatementInterpreterHandler(MethodDeclarationSyntax declarationSyntax, SemanticModel semanticModel)
        {
            this.declarationSyntax = declarationSyntax;
            this.semanticModel     = semanticModel;

            parameterInterpreter = new ParameterInterpreter(declarationSyntax, semanticModel);

            scopedLocalVariableDeclarations = new List <LocalVariableDeclaration>();
        }
Exemple #2
0
        public Statement GetStatement(CSharpSyntaxNode syntax)
        {
            Statement statement = null;

            switch (syntax)
            {
            case LocalDeclarationStatementSyntax localDeclarationStatementSyntax:
                statement = new LocalVariableStatementIntrepreter(this,
                                                                  localDeclarationStatementSyntax).GetStatement();
                return(statement);

            case VariableDeclarationSyntax variableDeclarationSyntax:
                statement = new VariableDeclarationStatementInterpreter(this, semanticModel, scopedLocalVariableDeclarations,
                                                                        variableDeclarationSyntax).GetStatement();
                return(statement);

            case ExpressionStatementSyntax expressionStatementSyntax:
                statement = new ExpressionStatementIntrepreter(this, expressionStatementSyntax).GetStatement();
                return(statement);

            case InvocationExpressionSyntax ies:
                statement = new InvocationStatementIntrepreter(this, semanticModel, ies).GetStatement();
                return(statement);

            case AssignmentExpressionSyntax aes:
                statement = new AssignmentStatementInterpreter(this, aes).GetStatement();
                return(statement);

            case LiteralExpressionSyntax les:
                statement = new LiteralStatementInterpreter(les, semanticModel).GetStatement();
                return(statement);

            case IdentifierNameSyntax ins:
                statement = new IdentifierNameStatementInterpreter(ins, semanticModel,
                                                                   parameters).GetStatement();
                return(statement);

            case EqualsValueClauseSyntax evcs:
                statement = new EqualsClauseStatementInterpreter(evcs, this).GetStatement();
                return(statement);

            case ObjectCreationExpressionSyntax oces:
                statement = new ObjectCreationStatementInterpreter(this, semanticModel, oces).GetStatement();
                return(statement);

            case ArgumentSyntax argumentSyntax:
                statement = new ArgumentStatementInterpreter(this, argumentSyntax).GetStatement();
                return(statement);

            case MemberAccessExpressionSyntax memberAccessExpressionSyntax:
                statement = new MemberAccessStatementInterpreter(this, memberAccessExpressionSyntax).GetStatement();
                return(statement);

            case ThisExpressionSyntax thisExpressionSyntax:
                statement = new ThisStatementInterpreter(thisExpressionSyntax, semanticModel).GetStatement();
                return(statement);

            case BinaryExpressionSyntax binaryExpressionSyntax:
                statement = new BinaryStatementInterpreter(this, semanticModel, binaryExpressionSyntax).GetStatement();
                return(statement);

            case ConditionalExpressionSyntax conditionalExpressionSyntax:
                statement = new ConditionalStatementInterpreter(this, conditionalExpressionSyntax).GetStatement();
                return(statement);

            case IfStatementSyntax ifStatementSyntax:
                statement = new IfStatementInterpreter(this, ifStatementSyntax).GetStatement();
                return(statement);

            case ElseClauseSyntax elseClauseSyntax:
                statement = new ElseClauseStatementInterpreter(this, elseClauseSyntax).GetStatement();
                return(statement);

            case BlockSyntax blockSyntax:
                statement = new BlockStatementInterpreter(this, blockSyntax).GetStatement();
                return(statement);

            case ArrowExpressionClauseSyntax arrowExpression:
                statement = new ArrowStatementInterpreter(this, arrowExpression).GetStatement();
                return(statement);

            case DefaultExpressionSyntax defaultExpressionSyntax:
                statement = new DefaultStatementInterpreter(semanticModel, defaultExpressionSyntax).GetStatement();
                return(statement);

            case TypeOfExpressionSyntax typeOfExpressionSyntax:
                statement = new TypeOfStatementInterpreter(semanticModel, typeOfExpressionSyntax).GetStatement();
                return(statement);

            case IsPatternExpressionSyntax patternExpressionSyntax:
                statement = new IsPatternStatementInterpreter(this, patternExpressionSyntax).GetStatement();
                return(statement);

            case SwitchStatementSyntax switchStatementSyntax:
                statement = new SwitchStatementInterpreter(this, switchStatementSyntax).GetStatement();
                return(statement);

            case BreakStatementSyntax breakStatementSyntax:
                statement = new BreakStatementInterpreter(breakStatementSyntax).GetStatement();
                return(statement);

            case ContinueStatementSyntax continueStatementSyntax:
                statement = new ContinueStatementInterpreter().GetStatement();
                return(statement);

            case AwaitExpressionSyntax awaitExpressionSyntax:
                statement = new AwaitStatementInterpreter(this, awaitExpressionSyntax).GetStatement();
                return(statement);

            case ReturnStatementSyntax returnStatementSyntax:
                statement = new ReturnStatementInterpreter(this, returnStatementSyntax).GetStatement();
                return(statement);

            case PostfixUnaryExpressionSyntax postfixUnaryExpressionSyntax:
                statement = new PostfixUnaryStatementInterpreter(this, postfixUnaryExpressionSyntax).GetStatement();
                return(statement);

            case PrefixUnaryExpressionSyntax prefixUnaryExpressionSyntax:
                statement = new PrefixUnaryStatementInterpreter(this, prefixUnaryExpressionSyntax).GetStatement();
                return(statement);

            case CastExpressionSyntax castExpressionSyntax:
                statement = new CastStatementInterpreter(this, castExpressionSyntax, semanticModel).GetStatement();
                return(statement);

            case ArrayCreationExpressionSyntax arrayCreationExpressionSyntax:
                statement = new ArrayCreationStatementInterpreter(this, arrayCreationExpressionSyntax, semanticModel).GetStatement();
                return(statement);

            case InitializerExpressionSyntax initializerExpressionSyntax:
                statement = new InitializerStatementInterpreter(this, initializerExpressionSyntax, semanticModel).GetStatement();
                return(statement);

            case ElementAccessExpressionSyntax elementAccessExpressionSyntax:
                statement = new ElementAccessStatementInterpreter(this, elementAccessExpressionSyntax, semanticModel).GetStatement();
                return(statement);

            case WhileStatementSyntax whileStatementSyntax:
                statement = new WhileStatementInterpreter(this, whileStatementSyntax).GetStatement();
                return(statement);

            case DoStatementSyntax doStatementSyntax:
                statement = new DoStatementInterpreter(this, doStatementSyntax).GetStatement();
                return(statement);

            case ForStatementSyntax forStatementSyntax:
                statement = new ForStatementInterpreter(this, forStatementSyntax).GetStatement();
                return(statement);

            case ForEachStatementSyntax forEachStatementSyntax:
                statement = new ForEachStatementInterpreter(this, forEachStatementSyntax, semanticModel).GetStatement();
                return(statement);

            case UsingStatementSyntax usingStatementSyntax:
                statement = new UsingStatementInterpreter(this, usingStatementSyntax).GetStatement();
                return(statement);

            case BaseExpressionSyntax baseExpressionSyntax:
                statement = new BaseStatementInterpreter(baseExpressionSyntax).GetStatement();
                return(statement);

            case ParenthesizedExpressionSyntax parenthesizedExpressionSyntax:
                statement = new ParenthesizedStatementInterpreter(this, parenthesizedExpressionSyntax).GetStatement();
                return(statement);

            case InterpolatedStringExpressionSyntax interpolatedStringExpressionSyntax:
                statement = new InterpolatedStringStatementInterpreter(this, interpolatedStringExpressionSyntax).GetStatement();
                return(statement);

            case TryStatementSyntax tryStatementSyntax:
                statement = new TryStatementInterpreter(this, tryStatementSyntax).GetStatement();
                return(statement);

            case CatchClauseSyntax catchClauseSyntax:
                statement = new CatchStatementInterpreter(this, catchClauseSyntax, semanticModel).GetStatement();
                return(statement);

            case ThrowStatementSyntax throwStatementSyntax:
                statement = new ThrowStatementInterpreter(this, throwStatementSyntax).GetStatement();
                return(statement);

            case FinallyClauseSyntax finallyClauseSyntax:
                statement = new FinallyStatementInterpreter(this, finallyClauseSyntax).GetStatement();
                return(statement);

            case ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpressionSyntax:
                statement = new LamdaStatementInterpreter(this, parenthesizedLambdaExpressionSyntax, semanticModel).GetStatement();
                return(statement);

            case ParameterSyntax parameterSyntax:
                statement = new ParameterInterpreter(parameterSyntax, semanticModel).GetStatement();
                return(statement);

            case AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax:
                statement = new AnonymousMethodStatementInterpreter(this,
                                                                    anonymousMethodExpressionSyntax,
                                                                    semanticModel).GetStatement();
                return(statement);

            case ConditionalAccessExpressionSyntax conditionalAccessExpressionSyntax:
                statement = new ConditionalAccessStatementInterpreter(this, conditionalAccessExpressionSyntax)
                            .GetStatement();
                return(statement);

            case MemberBindingExpressionSyntax memberBindingExpression:
                statement = new MemberBindingStatementInterpreter(this, memberBindingExpression)
                            .GetStatement();
                return(statement);

            case ElementBindingExpressionSyntax elementBindingExpression:
                statement = new ElementbindingStatementInterpreter(this, elementBindingExpression, semanticModel)
                            .GetStatement();
                return(statement);

            default:
                throw new NotImplementedException(syntax.GetType() + " is not supported yet");
            }
        }