Exemplo n.º 1
0
        public object EvaluateExpression(Expression expression)
        {
            switch (expression.Type)
            {
            case SyntaxNodes.AssignmentExpression:
                return(_expressions.EvaluateAssignmentExpression(expression.As <AssignmentExpression>()));

            case SyntaxNodes.ArrayExpression:
                return(_expressions.EvaluateArrayExpression(expression.As <ArrayExpression>()));

            case SyntaxNodes.BinaryExpression:
                return(_expressions.EvaluateBinaryExpression(expression.As <BinaryExpression>()));

            case SyntaxNodes.CallExpression:
                return(_expressions.EvaluateCallExpression(expression.As <CallExpression>()));

            case SyntaxNodes.ConditionalExpression:
                return(_expressions.EvaluateConditionalExpression(expression.As <ConditionalExpression>()));

            case SyntaxNodes.FunctionExpression:
                return(_expressions.EvaluateFunctionExpression(expression.As <FunctionExpression>()));

            case SyntaxNodes.Identifier:
                return(_expressions.EvaluateIdentifier(expression.As <Identifier>()));

            case SyntaxNodes.Literal:
                return(_expressions.EvaluateLiteral(expression.As <Literal>()));

            case SyntaxNodes.RegularExpressionLiteral:
                return(_expressions.EvaluateLiteral(expression.As <Literal>()));

            case SyntaxNodes.LogicalExpression:
                return(_expressions.EvaluateLogicalExpression(expression.As <LogicalExpression>()));

            case SyntaxNodes.MemberExpression:
                return(_expressions.EvaluateMemberExpression(expression.As <MemberExpression>()));

            case SyntaxNodes.NewExpression:
                return(_expressions.EvaluateNewExpression(expression.As <NewExpression>()));

            case SyntaxNodes.ObjectExpression:
                return(_expressions.EvaluateObjectExpression(expression.As <ObjectExpression>()));

            case SyntaxNodes.SequenceExpression:
                return(_expressions.EvaluateSequenceExpression(expression.As <SequenceExpression>()));

            case SyntaxNodes.ThisExpression:
                return(_expressions.EvaluateThisExpression(expression.As <ThisExpression>()));

            case SyntaxNodes.UpdateExpression:
                return(_expressions.EvaluateUpdateExpression(expression.As <UpdateExpression>()));

            case SyntaxNodes.UnaryExpression:
                return(_expressions.EvaluateUnaryExpression(expression.As <UnaryExpression>()));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }