setText() public method

public setText ( String value ) : void
value String
return void
Ejemplo n.º 1
0
   //-----------<Test Stub>--------
 static void main(string[] args)
 {
     Console.WriteLine("\nTesting the IntegerElement class");
     Console.WriteLine("\n================================\n");
     IntegerElement int_elem = new IntegerElement();
     string val = "3";
     int_elem.setText(val);
     Console.WriteLine("{0} The Integer element is:", int_elem.getText());
 }
Ejemplo n.º 2
0
 //----< visit Addition Operation >------------------------------
 public override void VisitAdditionOperationElement(AdditionOperationElement element)
 {
     VisitElement(element.getLhs());
       VisitElement(element.getRhs());
       int rhs = int.Parse(mIntStack.Pop().getText());
       int lhs = int.Parse(mIntStack.Pop().getText());
       IntegerElement result = new IntegerElement();
       result.setText((lhs + rhs).ToString());
       mIntStack.Push(result);
 }
Ejemplo n.º 3
0
   //-----------<Test Stub>--------
 static void main(string[] args)
 {
     Console.WriteLine("\nTesting the MatrixElement class");
     Console.WriteLine("\n================================\n");
     MatrixElement elem_mat = new MatrixElement();
     VariableElement elem_var = new VariableElement();
     IntegerElement elem_int = new IntegerElement();
     string var = "matrix";
     string row = "3";
     string column = "4";
     elem_var.setText(var);
     elem_mat.setVar(elem_var);
     elem_int.setText(row);
     elem_mat.setRow(elem_int);
     elem_int.setText(column);
     elem_mat.setColumn(elem_int);
     VariableElement varelement = elem_mat.getVar();
     IntegerElement rowelement = elem_mat.getRow();
     IntegerElement columnelement = elem_mat.getColumn();
     Console.WriteLine("The Matrix element is:{0},[{1}],[{2}]", varelement.getText(),rowelement.getText(),columnelement.getText());
 }
Ejemplo n.º 4
0
    static void Main()
    {
        AdditiveElement add = new AdditiveElement();
        IntegerElement a = new IntegerElement();
        IntegerElement b = new IntegerElement();
        
        a.setText("5");

        b.setText("5");
        add.setLhs(a);
       add.setRhs(b);
      Element c ;
      Element d ;
        c = (Element)add.getLhs();
        d = (Element)add.getRhs();
    }
Ejemplo n.º 5
0
    static void Main()
    {
        MultiplicationElement mul = new MultiplicationElement();
        IntegerElement a = new IntegerElement();
        IntegerElement b = new IntegerElement();
        
        a.setText("5");

        b.setText("5");
        mul.setLhs(a);
       mul.setRhs(b);
      Element c ;
      Element d ;
        c = (Element)mul.getLhs();
        d = (Element)mul.getRhs();
    } 
Ejemplo n.º 6
0
    static void Main()
    {
        SubtractionElement sub = new SubtractionElement();
        IntegerElement a = new IntegerElement();
        IntegerElement b = new IntegerElement();

        a.setText("5");

        b.setText("5");
        sub.setLhs(a);
        sub.setRhs(b);
        Element c;
        Element d;
        c = (Element)sub.getLhs();
        d = (Element)sub.getRhs();
    }
Ejemplo n.º 7
0
    //-----------<Test Stub>--------
  static void main(string[] args)
  {
      Console.WriteLine("\nTesting the AssignmentOperationElement class");
      Console.WriteLine("\n==========================================\n");
      AssignmentOperationElement elem_assign = new AssignmentOperationElement();
      IntegerElement int_elem = new IntegerElement();
      VariableElement var_elem = new VariableElement();
      string lhsval = "a";
      string rhsval = "3";
      VariableElement lhs = var_elem;
      Element rhs = int_elem;
      int_elem.setText(rhsval);
      var_elem.setText(lhsval);
      elem_assign.setLhs(lhs);
      elem_assign.setRhs(rhs);
      var_elem=elem_assign.getLhs();
      int_elem = (IntegerElement)elem_assign.getRhs();
      Console.WriteLine("{0} The element at Lhs is:", int_elem.getText());
      Console.WriteLine("{0} The element at the rhs is:", var_elem.getText());

  }
Ejemplo n.º 8
0
 private void PerformIntMultiplication(Object obj_rhs, Object obj_lhs)
 {
     try
     {
         IntegerElement stk_rhs = (IntegerElement)(obj_rhs);
         IntegerElement stk_lhs = (IntegerElement)(obj_lhs);
         IntegerElement final = new IntegerElement();
         if (stk_lhs != null && stk_rhs != null)
         {
             int temp_lhs = int.Parse(stk_lhs.getText());
             int temp_rhs = int.Parse(stk_rhs.getText());
             final.setText((temp_lhs * temp_rhs).ToString());
             Object result = (Object)(final);
             mat_stack.Push(result);
             Console.Write("Product: " + final.getText());
         }
     }
     catch (Exception e) { sendres(112, "Unassigned variables\n"); e.GetType(); };
 }
Ejemplo n.º 9
0
 public override void VisitForStatementElement(ForStatementElement element)
 {
     //throw new NotImplementedException();
     if (inParallelFor == 1)
     {
         parallelString.Append("for(" + element.RANGEVARIABLE.getText() + "->");
         parallelString.Append(element.STARTINGRANGE.getText() + " to " + element.ENDINGRANGE.getText() + ")");
         parallelString.Append("\n{");
         for (int i = 0; element.CODELIST.Count != 0 && i < element.CODELIST.Count; i++)
         {
             VisitElement(element.CODELIST[i]);
         }
         parallelString.Append("\n}");
         CreateForData(element);
     }
     else
     {
     try
     {
         int start = 0; int end = 0;
         if (element.RANGEVARIABLE.getText() != null && element.STARTINGRANGE.getText() != null && element.ENDINGRANGE.getText() != null)
         {
             try
             {
                 start = int.Parse(element.STARTINGRANGE.getText());
                 end = int.Parse(element.ENDINGRANGE.getText());
              }
             catch(Exception err)
             {
                 sendres(113, "The range for the for loop is not set"); err.GetType();
             }
             if (end != 0)
             {
                 if (start <= end)
                 {
                     if (!map_contains_matrix(element.RANGEVARIABLE.getText()))
                     {
                         //local++;
                         //Hashtable localTable = new Hashtable();
                         //scope.Push(localTable);
                         ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration();
                         scalar_elem.setType("int");
                         scalar_elem.setVar(element.RANGEVARIABLE);
                         VisitElement(scalar_elem);
                         for (int i = start; i <= end; i++)
                         {
                             AssignmentOperationElement elem = new AssignmentOperationElement();
                             elem.setLhs(element.RANGEVARIABLE);
                             IntegerElement int_elem = new IntegerElement();
                             int_elem.setText(i.ToString());
                             elem.setRhs(int_elem);
                             VisitElement(elem);
                             List<Element> codeList = new List<Element>();
                             codeList = element.CODELIST;
                             for (int j = 0; j < codeList.Count; j++)
                             {
                                 VisitElement(codeList[j]);
                             }
                         }
                         //scope.Pop();
                         //local--;
                     }
                     else
                         sendres(112, "The range variable in the for loop has already been used in the program. Please use a different variable.");
                 }
                 else
                     sendres(112, "The starting index should be less than the ending index");
             }
         }
         else
             sendres(112, "The ending index of the for loop cannot be zero");
     }
     catch(Exception err)
     {
         sendres(113, "For loop cannot be executed. Please check for semantic errors"); err.GetType();
     }
   }
 }
Ejemplo n.º 10
0
 public void PerformVectorSingleElementOperation(VectorElement temp)
 {
     if (map_contains_matrix(temp.getVar().getText()))
     {
         VectorVariableDeclaration matTemp = null;
         if (temp != null)
         {
             matTemp = (VectorVariableDeclaration)mVariableMap[temp.getVar().getText()];
             int loc = getIndex(temp);
             
             if (matTemp != null)
             {
                 if (loc < int.Parse(matTemp.getRange().getText()))
                 {
                     if (matTemp.getType() == "int")
                     {
                         int val = matTemp.getintValueat(loc);
                         IntegerElement elem = new IntegerElement();
                         elem.setText(val.ToString());
                         mat_stack.Push(elem);
                     }
                     else if (matTemp.getType() == "double")
                     {
                         double val = matTemp.getdoubleValueat(loc);
                         DoubleElement elem = new DoubleElement();
                         elem.setText(val.ToString());
                         mat_stack.Push(elem);
                     }
                 }
                 else
                 {
                     Console.Write("Range out of bound\n");
                     sendres(112, "Range out of bound\n");
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
        private void PerformMatrixSingleElementOperation(MatrixElement temp)
        {
            if (map_contains_matrix(temp.getVar().getText()))
            {
                MatrixVariableDeclaration matTemp = null;
                if (temp != null)
                {
                    matTemp = (MatrixVariableDeclaration)mVariableMap[temp.getVar().getText()];
                    int row = getMatrixRow(temp);
                    int col = getMatrixCol(temp);

                    if (matTemp != null)
                    {
                        if (row < int.Parse(matTemp.getRow().getText()) && col < int.Parse(matTemp.getColumn().getText()))
                        {
                            if (matTemp.getType() == "int")
                            {
                                int val = matTemp.getintValueat(row, col);
                                IntegerElement elem = new IntegerElement();
                                elem.setText(val.ToString());
                                mat_stack.Push(elem);
                            }
                            else if (matTemp.getType() == "double")
                            {
                                double val = matTemp.getdoubleValueat(row, col);
                                DoubleElement elem = new DoubleElement();
                                elem.setText(val.ToString());
                                mat_stack.Push(elem);
                            }
                        }
                        else
                        {
                            Console.Write("Range out of bound\n");
                            sendres(112, "Range out of bound\n");
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void CreateData()
        {
            int curElement = 0;
            
            StringReader readStr = new StringReader(matStr.ToString());
            XmlTextReader xf = new XmlTextReader(readStr);
            MatrixVariableDeclaration mat=null;
            VectorVariableDeclaration vec = null;
            string matElem="";
            int currRow = 0;
            int index = 0;
            string type="";
            int totalRows = 0;
            int totalCols = 0;
            int currCol = -1;
            int[,] elems = new int[10, 10]; ;
            while (xf.Read())
            {
                switch (xf.NodeType)
                {
                    case XmlNodeType.Element:
                        {
                            if (xf.Name == "Matrix")
                            {
                                curElement = 1;
                                mat = new MatrixVariableDeclaration();
                                currRow = 0; currCol = -1;
                            }
                            if (xf.Name == "Vector")
                            {
                                curElement = 2;
                                vec = new VectorVariableDeclaration();
                            }
                            if (curElement == 2)
                            {
                                if (xf.Name == "name")
                                    matElem = "name";
                               
                            }
                            if (curElement == 1)
                            {
                                if (xf.Name == "name")
                                    matElem = "name";
                                if (xf.Name == "row")
                                    matElem = "row";
                                if (xf.Name == "col")
                                    matElem = "column";
                                if (xf.Name == "type")
                                    matElem = "type";
                                if (xf.Name == "Elements")
                                {
                                    elems = new int[totalRows, totalCols];
                                }
                                if (xf.Name == "Element")
                                {
                                    matElem = "elem";
                                    if (currCol == totalCols - 1 && currRow < totalRows - 1)
                                    {
                                        currRow += 1;
                                        currCol = 0;
                                    }
                                    else currCol += 1;
                                }
                            }

                            break;
                        }
                    case XmlNodeType.Text:
                        {
                            if (curElement == 1)
                            {
                                if (matElem == "row")
                                {
                                    IntegerElement row = new IntegerElement();
                                    totalRows = int.Parse(xf.Value.ToString());
                                    row.setText(xf.Value);
                                    mat.setRow(row);
                                }
                                if (matElem == "column")
                                {
                                    IntegerElement col = new IntegerElement();
                                    totalCols = int.Parse(xf.Value.ToString());
                                    col.setText(xf.Value);
                                    mat.setColumn(col);
                                }
                                if (matElem == "name")
                                {
                                    VariableElement val = new VariableElement();
                                    val.setText(xf.Value);
                                    mat.setVar(val);
                                }
                                if (matElem == "type")
                                    {
                                        type = xf.Value;
                                        mat.setType(type);
                                    }
                                if (matElem == "elem")
                                {
                                    if (type == "int")
                                    {
                                        elems[currRow, currCol] = int.Parse(xf.Value.ToString());
                                    }
                                    else if (type == "double")
                                        mat.setdoubleValueat(currRow, currCol, double.Parse(xf.Value.ToString()));
                                }
                            }
                            break;
                        }
                    case XmlNodeType.EndElement:
                        {
                            if (xf.Name == "Elements" && curElement==1)
                            {
                                mat.setIntMatrix(elems);
                                parallelMap.Add(mat.getVar().getText(), mat);
                            }
                            Console.Write("End:" + xf.Name);
                            break;
                        }
                    default:
                        {
                            Console.Write("\n");
                            break;
                        }
                }
            }
        }
Ejemplo n.º 13
0
    //----< visit Parallel Addition Operation >------------------------------
    public override void VisitParallelAdditionOperationElement(ParallelAdditionOperationElement element)
    {
        Console.WriteLine("VisitParallelAddition");
          //dele("VisitParallelAddition");
          ParallelElement pe_lhs;
          if (element.getLhs() is ParallelElement)
          {
          pe_lhs = (ParallelElement)element.getLhs();
          pe_lhs.setValue(element.getValue());
          pe_lhs.setVariable(element.getVariable());
          }
          VisitElement(element.getLhs());

          ParallelElement pe_rhs;
          if (element.getRhs() is ParallelElement)
          {
          pe_rhs = (ParallelElement)element.getRhs();
          pe_rhs.setValue(element.getValue());
          pe_rhs.setVariable(element.getVariable());
          }
          VisitElement(element.getRhs());

          IntegerElement rhs = mIntStack.Pop();
          IntegerElement lhs = mIntStack.Pop();
          int result_int = int.Parse(rhs.getText()) + int.Parse(lhs.getText());
          IntegerElement result = new IntegerElement();
          result.setText(result_int.ToString());
          mIntStack.Push(result);
    }
Ejemplo n.º 14
0
 static void Main(String[] args)
 {
     Console.WriteLine("\nTesting the ForStatementElement class");
     Console.WriteLine("\n==========================================\n");
     RangeElement elem = new RangeElement();
     VariableElement var_elem = new VariableElement();
     var_elem.setText("a");
     elem.RANGEVARIABLE = var_elem;
     IntegerElement int_elem = new IntegerElement();
     int_elem.setText("1");
     elem.STARTINGRANGE = int_elem;
     IntegerElement int_elem2 = new IntegerElement();
     int_elem2.setText("10");
     elem.ENDINGRANGE = int_elem2;
     ForStatementElement for_elem = new ForStatementElement();
     for_elem.RANGE = elem;
     ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration();
     scalar_elem.setType("int");
     scalar_elem.setVar(var_elem);
     for_elem.ADDCODE = scalar_elem;
     RangeElement Relem = new RangeElement();
     Relem = for_elem.RANGE;
     Console.Write("Range is "+Relem.STARTINGRANGE.getText()+" to "+ Relem.ENDINGRANGE.getText()+"\n");
     List<Element> elem_list = new List<Element>();
     elem_list = for_elem.CODELIST;
     for(int i=0; i<elem_list.Count;i++)
     {
         Console.Write("The for statement list has " + elem_list[i].ToString()+"\n");
     }
 }
Ejemplo n.º 15
0
   //-----------<Test Stub>--------
 static void main(string[] args)
 {
     Console.WriteLine("\nTesting the MatrixVariableDeclaration class");
     Console.WriteLine("\n===========================================\n");
     MatrixVariableDeclaration elem_mat = new MatrixVariableDeclaration();
     VariableElement elem_var = new VariableElement();
     IntegerElement elem_int = new IntegerElement();
     //List<Element> elementlist = new List<Element>();
     string var = "matrix";
     string row = "3";
     string column = "2";
     elem_var.setText(var);
     elem_mat.setVar(elem_var);
     elem_int.setText(row);
     elem_mat.setRow(elem_int);
     elem_int.setText(column);
     elem_mat.setColumn(elem_int);
     for (int i = 0; i < (int.Parse(row) * int.Parse(column)); i++)
     {
         elem_int.setText(i.ToString());
         elem_mat.addValue(elem_int);
     }
     string type = "int";
     elem_mat.setType(type);
     elem_mat.setValue();
     int[,] matrix = new int[int.Parse(row), int.Parse(column)];
     matrix = elem_mat.getintValue();
     Console.WriteLine("The name of the Matrix is:{0}", elem_mat.getVar().getText());
     Console.WriteLine("The Row and Column of the Matrix is:{0},{1}", elem_mat.getRow().getText(), elem_mat.getColumn().getText());
     Console.WriteLine("The type of matrix is:{0}", elem_mat.getType());
     for(int i=0;i<int.Parse(row);i++)
     {
         for (int j = 0; j < int.Parse(column); j++)
         {
             Console.WriteLine("The value of matrix is:{0}", matrix[i, j]);
         }
     }
     
 }
Ejemplo n.º 16
0
 static void Main(String[] args)
 {
     Console.WriteLine("\nTesting the ParallelForStatementElement class");
     Console.WriteLine("\n==========================================\n");
     RangeElement elem = new RangeElement();
     VariableElement var_elem = new VariableElement();
     var_elem.setText("a");
     elem.RANGEVARIABLE = var_elem;
     IntegerElement int_elem = new IntegerElement();
     int_elem.setText("1");
     elem.STARTINGRANGE = int_elem;
     IntegerElement int_elem2 = new IntegerElement();
     int_elem2.setText("10");
     elem.ENDINGRANGE = int_elem2;
     ParallelForElement for_elem = new ParallelForElement();
     for_elem.RANGE = elem;
     ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration();
     scalar_elem.setType("int");
     scalar_elem.setVar(var_elem);
     for_elem.ADDCODE = scalar_elem;
     for_elem.syncfunction();
     VariableElement elem2 = new VariableElement();
     elem2.setText("b");
     for_elem.ADDCODE = elem2;
     for_elem.syncfunction();
     RangeElement Relem = new RangeElement();
     Relem = for_elem.RANGE;
     Console.Write("Range is " + Relem.STARTINGRANGE.getText() + " to " + Relem.ENDINGRANGE.getText() + "\n");
     List<List<Element>> elem_list = new List<List<Element>>();
     elem_list = for_elem.PARALLELCODE;
     for(int i=0; i<elem_list.Count;i++)
     {
         List<Element> code = new List<Element>();
         code = elem_list[i];
         for (int j = 0; j<code.Count; j++)
         {
             Console.Write("The parallelfor statement code list "+ (i+1) +" has "+ code[j].ToString() + "\n");
         }
     }
 }
Ejemplo n.º 17
0
    //----< visit VectorIndexElement >------------------------------
    public override void VisitVectorIndexElement(VectorIndexElement element)
    {
        Element first_index = element.getFirstIndexElement();
          Element second_index = element.getSecondIndexElement();
          int first_index_num = setVectorIndexValue(element, first_index);
          int second_index_num = setVectorIndexValue(element, second_index);

          VariableElement matrix_var = element.getVariableElement() as VariableElement;

          if (mVariableMap.ContainsKey(matrix_var.getText()))
          {
          MatrixElement element_value = (MatrixElement)mVariableMap[matrix_var.getText()];
          List<RowElement> rows = element_value.getRows();
          RowElement row = rows[first_index_num];

          IntegerElement new_int = new IntegerElement();
          new_int.setText(row.getElement(second_index_num).ToString());
          mIntStack.Push(new_int);
          }
    }
Ejemplo n.º 18
0
     static void Main(String[] args)
 {
     Console.WriteLine("\nTesting the IfStatementElement class");
     Console.WriteLine("\n==========================================\n");
     EqualityOperationElement elem = new EqualityOperationElement();
     VariableElement var_elem = new VariableElement();
     var_elem.setText("a");
     elem.setequalityLhs(var_elem);
     IntegerElement int_elem = new IntegerElement();
     int_elem.setText("1");
     elem.setequalityRhs(int_elem);
     VariableElement elem2 = new VariableElement();
     elem2.setText("b");
     IfStatementElement if_elem = new IfStatementElement();
     if_elem.CONDITION= elem;
     ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration();
     scalar_elem.setType("int");
     scalar_elem.setVar(var_elem);
     List<Element> Iflist = new List<Element>();
     Iflist.Add(scalar_elem);
     if_elem.IFCODE = Iflist;
     List<Element> ElseList = new List<Element>();
     ElseList.Add(int_elem);
     if_elem.ELSECODE = ElseList;
     Console.Write("IfStatement element " + var_elem1.GetType().ToString()+" "+ var_elem1.getText().ToString() + "\n");
     EqualityOperationElement eq_elem = new EqualityOperationElement();
     eq_elem = (EqualityOperationElement)if_elem.CONDITION;
     Console.Write("The condition has : "+eq_elem.ToString()+"->"+eq_elem.getequalityLhs()+" == "+eq_elem.getequalityRhs()+"\n");
     List<Element> elem_list = new List<Element>();
     elem_list = if_elem.IFCODE;
     for (int i = 0; i < elem_list.Count; i++)
     {
         Console.Write("The if loop list has " + elem_list[i].ToString() + "\n");
     }
     elem_list = if_elem.ELSECODE;
     for (int i = 0; i < elem_list.Count; i++)
     {
         Console.Write("The Else loop list has " + elem_list[i].ToString() + "\n");
     }
 }
Ejemplo n.º 19
0
    static void Main()
    {
        PlotFunctionElement plotElement = new PlotFunctionElement();
        IntegerElement row = new IntegerElement();
        row.setText("2");
        
        IntegerElement col = new IntegerElement();
        col.setText("2");
        VariableElement varElement = new VariableElement();
        varElement.setText("a");
        DoubleElement dblElement = new DoubleElement();

        plotElement.setPlotFunction("subPlot");
        plotElement.setRow(row);
        plotElement.setColumn(col);
        plotElement.setData(varElement);
        


    }