예제 #1
0
        ConversionResult?Visit(NODE node)
        {
            INSTANCE instance = node as INSTANCE;

            if (instance != null)
            {
                return(VisitInstance(instance));
            }
            BINARY binary = node as BINARY;

            if (binary != null)
            {
                ConversionResult?leftResult  = Visit(binary.left_operand);
                ConversionResult?rightResult = Visit(binary.right_operand);
                if (leftResult != null && rightResult != null)
                {
                    ConversionResult left  = leftResult.Value;
                    ConversionResult right = rightResult.Value;
                    if (TYPE.sameType(left.ElementType, right.ElementType))
                    {
                        PLUS plus = node as PLUS;
                        if (plus != null)
                        {
                            return(VisitElementWiseBinary(plus, "+", left, right));
                        }
                        MINUS minus = node as MINUS;
                        if (minus != null)
                        {
                            return(VisitElementWiseBinary(minus, "-", left, right));
                        }
                        MULTIPLY_ELEMENTWISE multiplyElementwise = node as MULTIPLY_ELEMENTWISE;
                        if (multiplyElementwise != null)
                        {
                            return(VisitElementWiseBinary(multiplyElementwise, "*", left, right));
                        }
                        DIVIDE_ELEMENTWISE divideElementwise = node as DIVIDE_ELEMENTWISE;
                        if (divideElementwise != null)
                        {
                            return(VisitElementWiseBinary(divideElementwise, "/", left, right));
                        }
                        MULTIPLY multiply = node as MULTIPLY;
                        if (multiply != null)
                        {
                            return(VisitMultiplication(multiply, left, right));
                        }
                    }
                }
            }
            return(null);
        }