Ejemplo n.º 1
0
        CIL_newobj ParseNewobj(string label, string str)
        {
            Strtok st1 = new Strtok(str);
            if(st1.NextToken() != "newobj")
                throw new Exception("unrecognized newobj");
            if(st1.NextToken() != "instance")
                throw new Exception("unrecognized newobj");
            if(st1.NextToken() != "void")
                throw new Exception("unrecognized newobj");

            // get the classname, it's just before ::
            string classname = st1.NextToken(":");
            if(st1.NextToken(":(") != ".ctor")
                throw new Exception("unrecognized newobj");

            // find the constructor signature
            string ctorsig = "";
            ctorsig += "(";
            int i;
            i = str.IndexOf("(") + 1;

            while(true)
            {
                if(i < str.Length)
                {
                    if(str[i] == ')')
                        break;
                    ctorsig += str[i];
                    i++;
                }
                else
                {
                    i = 0;
                    str = GetNextLine();
                }
            }
            ctorsig += ")";

            return new CIL_newobj(label, program.GetClass(classname), ctorsig);
        }
Ejemplo n.º 2
0
 static void LoadConfiguration(string filename)
 {
     StreamReader fin = new StreamReader(filename);
     while(true)
     {
         string s = fin.ReadLine();
         if(s == null)
             break;
         s.Trim();
         if(s.Length < 1)
             continue;
         if(s.StartsWith("#"))
             continue;
         Strtok st = new Strtok(s);
         string key = st.NextToken("=");
         string value = st.NextToken("\n");
         properties.Add(key, value);
     }
     fin.Close();
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 CIL_leave ParseLeave(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken();
     return new CIL_leave(label, st.NextToken());
 }
Ejemplo n.º 5
0
 CIL_ldc_r8 ParseLdcR8(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken(); // skip the ldc.r8
     return new CIL_ldc_r8(label, Double.Parse(st.NextToken()));
 }
Ejemplo n.º 6
0
        CIL_ldftn ParseLdftn(string label, string str)
        {
            Strtok st1 = new Strtok(str);
            if(st1.NextToken() != "ldftn")
                throw new Exception("unrecognized ldftn");
            string tmp = st1.NextToken();
            if(tmp == "instance")
            {
                tmp = st1.NextToken();
                if(tmp != "void")
                    throw new Exception("unrecognized ldftn");
            }else
                if(tmp != "void")
                    throw new Exception("unrecognized ldftn");

            // get the classname, it's just before ::
            string classname = st1.NextToken(":");

            // find the constructor signature
            string methodsig = st1.NextToken(":(");
            methodsig += "(";
            int i;
            i = str.IndexOf("(") + 1;

            while(true)
            {
                if(i < str.Length)
                {
                    if(str[i] == ')')
                        break;
                    methodsig += str[i];
                    i++;
                }
                else
                {
                    i = 0;
                    str = GetNextLine();
                }
            }
            methodsig += ")";

            CILClass theclass = program.GetClass(classname);
            CILMethod themethod = theclass.GetMethod(
                methodsig.Substring(0, methodsig.IndexOf("(")),
                methodsig.Substring(methodsig.IndexOf("("), methodsig.Length - methodsig.IndexOf("(")));
            return new CIL_ldftn(label, themethod);
        }
Ejemplo n.º 7
0
 CIL_brtrue ParseBrtrue(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken();
     return new CIL_brtrue(label, st.NextToken());
 }
Ejemplo n.º 8
0
 CIL_bne_un ParseBneun(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken();
     return new CIL_bne_un(label, st.NextToken());
 }
Ejemplo n.º 9
0
 CIL_blt ParseBlt(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken();
     return new CIL_blt(label, st.NextToken());
 }
Ejemplo n.º 10
0
 CIL_beq ParseBeq(string label, string str)
 {
     Strtok st = new Strtok(str);
     st.NextToken();
     return new CIL_beq(label, st.NextToken());
 }
Ejemplo n.º 11
0
        public static void GuidedSearch(State state)
        {
            string path = CheckerConfiguration.GetProperty("guided_path");
            Strtok st = new Strtok(path);

            while(true)
            {
                string sc = st.NextToken();
                if(sc == null)
                    break;
                int choice = Int32.Parse(sc);
                if(choice < state.GetForwardStateCount())
                {
                    DelayedAction da = state.IsForwardReordering(choice);
                    state.Forward(choice);
                    if(CheckerConfiguration.DoPrintExecution)
                        if(da != null)
                            Console.WriteLine("Reordered: " + da.SourceInstruction.ToString());
                }
                else
                {
                    Console.WriteLine("wrong path is supplied");
                    break;
                }
            }
        }