Exemple #1
0
 CILVariable ParseLocalVariable(string str)
 {
     // TODO: Need cleanup and reparse using Scanner
     // with better treatment for array declaration
     string[] ss = str.Split();
     CILVariable ret;
     switch(ss[0])
     {
         case "class":
             ret = new CILVar_object(ss[2], program.GetClass(ss[1]));
             break;
         case "bool":
         case "int32":
             ret = new CILVar_int32(ss[1]);
             break;
         case "int64":
             ret = new CILVar_int64(ss[1]);
             break;
         case "float64":
             ret = new CILVar_double(ss[1]);
             break;
         case "int32[]":
             ret = new CILVar_array(ss[1], new CILVar_int32(""));
             break;
         case "float64[]":
             ret = new CILVar_array(ss[1], new CILVar_double(""));
             break;
         default:
             throw new Exception("Unknown local variable type");
     }
     return ret;
 }
Exemple #2
0
 CIL_ldsfld ParseLdsfld(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken();
     string fieldtype = st.NextToken();
     string subFieldType = null;
     if(fieldtype == "class")
         subFieldType = st.NextToken();
     string classname = st.NextToken(":");
     string fieldname = st.NextToken(":");
     CILClass classType = program.GetClass(classname);
     CILVariable field;
     if(fieldtype == "int32")
         field = new CILVar_int32(fieldname);
     else if(fieldtype == "int64")
         field = new CILVar_int64(fieldname);
     else if(fieldtype == "float64")
         field = new CILVar_double(fieldname);
     else if(fieldtype == "int32[]")
         field = new CILVar_array(fieldname, new CILVar_int32(""));
     else if(fieldtype == "int64[]")
         field = new CILVar_array(fieldname, new CILVar_int64(""));
     else if(fieldtype == "float64[]")
         field = new CILVar_array(fieldname, new CILVar_double(""));
     else if(fieldtype == "class")
         field = new CILVar_object(fieldname, program.GetClass(subFieldType));
     else
         throw new Exception("Not implemented yet");
     return new CIL_ldsfld(label, classType, field);
 }