getRhs() public method

public getRhs ( ) : Element,
return Element,
示例#1
0
        private void createIf(IfStatementElement element)
        {
            string strlhs = "";
            string strrhs = "";
            if (element.getLhs() is VariableElement)
                strlhs = ((VariableElement)element.getLhs()).getText();
            //struct
            parallelString.Append("if(" + strlhs);
            if (element.OP == "eq")
                parallelString.Append("==");
            else if (element.OP == "ne")
                parallelString.Append("!=");
            else if (element.OP == "lt")
                parallelString.Append("<");
            else if (element.OP == "le")
                parallelString.Append("<=");
            else if (element.OP == "gt")
                parallelString.Append(">");
            else if (element.OP == "ge")
                parallelString.Append(">=");

            if (element.getRhs() is VariableElement)
                strrhs = ((VariableElement)element.getRhs()).getText();
            else if(element.getRhs() is IntegerElement)
                strrhs = ((IntegerElement)element.getRhs()).getText();
            else if (element.getRhs() is DoubleElement)
                strrhs = ((DoubleElement)element.getRhs()).getText();
            else if (element.getRhs() is StringElement) 
                strrhs = ((StringElement)element.getRhs()).getText();
            parallelString.Append(strrhs + ")" + "\n" + "{\n");
            for (int i = 0; element.IFCODE.Count != 0 && i < element.IFCODE.Count; i++)
            {
                VisitElement(element.IFCODE[i]);
                parallelString.Append(";");
            }
            parallelString.Append("\n}");
        }
示例#2
0
        public override void VisitIfStatementElement(IfStatementElement element)
        {
            String lhs = getIfElement(element.getLhs()); //.getConditionLhs());
            String rhs = getIfElement(element.getRhs()); //.getConditionRhs());

            if (lhs == null || rhs == null)
            { Console.WriteLine("\n Variable not allowed. "); return; }

            if (mVariableMap.ContainsKey(lhs) == false || mVariableMap.ContainsKey(rhs) == false)
                Console.WriteLine("\n Invalid Comparison.");

            if (
                 (element.OP == "eq" && String.Compare(lhs, rhs) == 0) ||
                 (element.OP == "ne" && String.Compare(lhs, rhs) != 0) ||
                 (element.OP == "lt" && String.Compare(lhs, rhs) < 0) ||
                 (element.OP == "le" && String.Compare(lhs, rhs) <= 0) ||
                 (element.OP == "gt" && String.Compare(lhs, rhs) < 0) ||
                 (element.OP == "ge" && String.Compare(lhs, rhs) >= 0)
               )
            {
                Console.WriteLine("\n Loop condition true - entered true. ");
            }
            else
            {
                if (element.ELSECODE.Count != 0)
                { Console.WriteLine("\n Loop condition false - entered else. "); }
            }

            //throw new NotImplementedException();
        }