Exemplo n.º 1
0
 public static PhpSourceItems GetKind(PhpSourceBase x)
 {
     if (x == null)
     {
         throw new ArgumentNullException();
     }
     if (x.GetType() == typeof(PhpCodeBlock))
     {
         return(PhpSourceItems.PhpCodeBlock);
     }
     if (x.GetType() == typeof(PhpArrayCreateExpression))
     {
         return(PhpSourceItems.PhpArrayCreateExpression);
     }
     if (x.GetType() == typeof(PhpDefinedConstExpression))
     {
         return(PhpSourceItems.PhpDefinedConstExpression);
     }
     if (x.GetType() == typeof(PhpFreeExpression))
     {
         return(PhpSourceItems.PhpFreeExpression);
     }
     if (x.GetType() == typeof(PhpBreakStatement))
     {
         return(PhpSourceItems.PhpBreakStatement);
     }
     if (x.GetType() == typeof(PhpCodeModuleName))
     {
         return(PhpSourceItems.PhpCodeModuleName);
     }
     if (x.GetType() == typeof(PhpArrayAccessExpression))
     {
         return(PhpSourceItems.PhpArrayAccessExpression);
     }
     if (x.GetType() == typeof(PhpAssignExpression))
     {
         return(PhpSourceItems.PhpAssignExpression);
     }
     if (x.GetType() == typeof(PhpClassFieldAccessExpression))
     {
         return(PhpSourceItems.PhpClassFieldAccessExpression);
     }
     if (x.GetType() == typeof(PhpBinaryOperatorExpression))
     {
         return(PhpSourceItems.PhpBinaryOperatorExpression);
     }
     if (x.GetType() == typeof(PhpConditionalExpression))
     {
         return(PhpSourceItems.PhpConditionalExpression);
     }
     if (x.GetType() == typeof(PhpConstValue))
     {
         return(PhpSourceItems.PhpConstValue);
     }
     if (x.GetType() == typeof(PhpElementAccessExpression))
     {
         return(PhpSourceItems.PhpElementAccessExpression);
     }
     if (x.GetType() == typeof(PhpContinueStatement))
     {
         return(PhpSourceItems.PhpContinueStatement);
     }
     if (x.GetType() == typeof(PhpExpressionStatement))
     {
         return(PhpSourceItems.PhpExpressionStatement);
     }
     if (x.GetType() == typeof(PhpForEachStatement))
     {
         return(PhpSourceItems.PhpForEachStatement);
     }
     if (x.GetType() == typeof(PhpForStatement))
     {
         return(PhpSourceItems.PhpForStatement);
     }
     if (x.GetType() == typeof(PhpIfStatement))
     {
         return(PhpSourceItems.PhpIfStatement);
     }
     if (x.GetType() == typeof(PhpIncrementDecrementExpression))
     {
         return(PhpSourceItems.PhpIncrementDecrementExpression);
     }
     if (x.GetType() == typeof(PhpInstanceFieldAccessExpression))
     {
         return(PhpSourceItems.PhpInstanceFieldAccessExpression);
     }
     if (x.GetType() == typeof(PhpPropertyAccessExpression))
     {
         return(PhpSourceItems.PhpPropertyAccessExpression);
     }
     if (x.GetType() == typeof(PhpMethodInvokeValue))
     {
         return(PhpSourceItems.PhpMethodInvokeValue);
     }
     if (x.GetType() == typeof(PhpMethodCallExpression))
     {
         return(PhpSourceItems.PhpMethodCallExpression);
     }
     if (x.GetType() == typeof(PhpParenthesizedExpression))
     {
         return(PhpSourceItems.PhpParenthesizedExpression);
     }
     if (x.GetType() == typeof(PhpReturnStatement))
     {
         return(PhpSourceItems.PhpReturnStatement);
     }
     if (x.GetType() == typeof(PhpThisExpression))
     {
         return(PhpSourceItems.PhpThisExpression);
     }
     if (x.GetType() == typeof(PhpUnaryOperatorExpression))
     {
         return(PhpSourceItems.PhpUnaryOperatorExpression);
     }
     if (x.GetType() == typeof(PhpVariableExpression))
     {
         return(PhpSourceItems.PhpVariableExpression);
     }
     if (x.GetType() == typeof(PhpWhileStatement))
     {
         return(PhpSourceItems.PhpWhileStatement);
     }
     if (x.GetType() == typeof(PhpSwitchStatement))
     {
         return(PhpSourceItems.PhpSwitchStatement);
     }
     throw new NotSupportedException(x.GetType().FullName);
 }
Exemplo n.º 2
0
        public virtual T Visit(PhpSourceBase node)
        {
            if (node == null)
            {
                return(VisitNull());
            }
            switch (node.Kind)
            {
            case PhpSourceItems.PhpCodeBlock:
                return(VisitPhpCodeBlock(node as PhpCodeBlock));

            case PhpSourceItems.PhpArrayCreateExpression:
                return(VisitPhpArrayCreateExpression(node as PhpArrayCreateExpression));

            case PhpSourceItems.PhpDefinedConstExpression:
                return(VisitPhpDefinedConstExpression(node as PhpDefinedConstExpression));

            case PhpSourceItems.PhpFreeExpression:
                return(VisitPhpFreeExpression(node as PhpFreeExpression));

            case PhpSourceItems.PhpBreakStatement:
                return(VisitPhpBreakStatement(node as PhpBreakStatement));

            case PhpSourceItems.PhpCodeModuleName:
                return(VisitPhpCodeModuleName(node as PhpCodeModuleName));

            case PhpSourceItems.PhpArrayAccessExpression:
                return(VisitPhpArrayAccessExpression(node as PhpArrayAccessExpression));

            case PhpSourceItems.PhpAssignExpression:
                return(VisitPhpAssignExpression(node as PhpAssignExpression));

            case PhpSourceItems.PhpClassFieldAccessExpression:
                return(VisitPhpClassFieldAccessExpression(node as PhpClassFieldAccessExpression));

            case PhpSourceItems.PhpBinaryOperatorExpression:
                return(VisitPhpBinaryOperatorExpression(node as PhpBinaryOperatorExpression));

            case PhpSourceItems.PhpConditionalExpression:
                return(VisitPhpConditionalExpression(node as PhpConditionalExpression));

            case PhpSourceItems.PhpConstValue:
                return(VisitPhpConstValue(node as PhpConstValue));

            case PhpSourceItems.PhpElementAccessExpression:
                return(VisitPhpElementAccessExpression(node as PhpElementAccessExpression));

            case PhpSourceItems.PhpContinueStatement:
                return(VisitPhpContinueStatement(node as PhpContinueStatement));

            case PhpSourceItems.PhpExpressionStatement:
                return(VisitPhpExpressionStatement(node as PhpExpressionStatement));

            case PhpSourceItems.PhpForEachStatement:
                return(VisitPhpForEachStatement(node as PhpForEachStatement));

            case PhpSourceItems.PhpForStatement:
                return(VisitPhpForStatement(node as PhpForStatement));

            case PhpSourceItems.PhpIfStatement:
                return(VisitPhpIfStatement(node as PhpIfStatement));

            case PhpSourceItems.PhpIncrementDecrementExpression:
                return(VisitPhpIncrementDecrementExpression(node as PhpIncrementDecrementExpression));

            case PhpSourceItems.PhpInstanceFieldAccessExpression:
                return(VisitPhpInstanceFieldAccessExpression(node as PhpInstanceFieldAccessExpression));

            case PhpSourceItems.PhpPropertyAccessExpression:
                return(VisitPhpPropertyAccessExpression(node as PhpPropertyAccessExpression));

            case PhpSourceItems.PhpMethodInvokeValue:
                return(VisitPhpMethodInvokeValue(node as PhpMethodInvokeValue));

            case PhpSourceItems.PhpMethodCallExpression:
                return(VisitPhpMethodCallExpression(node as PhpMethodCallExpression));

            case PhpSourceItems.PhpParenthesizedExpression:
                return(VisitPhpParenthesizedExpression(node as PhpParenthesizedExpression));

            case PhpSourceItems.PhpReturnStatement:
                return(VisitPhpReturnStatement(node as PhpReturnStatement));

            case PhpSourceItems.PhpThisExpression:
                return(VisitPhpThisExpression(node as PhpThisExpression));

            case PhpSourceItems.PhpUnaryOperatorExpression:
                return(VisitPhpUnaryOperatorExpression(node as PhpUnaryOperatorExpression));

            case PhpSourceItems.PhpVariableExpression:
                return(VisitPhpVariableExpression(node as PhpVariableExpression));

            case PhpSourceItems.PhpWhileStatement:
                return(VisitPhpWhileStatement(node as PhpWhileStatement));

            case PhpSourceItems.PhpSwitchStatement:
                return(VisitPhpSwitchStatement(node as PhpSwitchStatement));

            default: throw new NotSupportedException(node.Kind.ToString() + "," + node.GetType().Name);
            }
        }