Exemplo n.º 1
0
 private REPL(TypeParser parser)
 {
     DisplayData = new REPLData()
     {
         Packets =
         {
             new REPLData.Packet()
             {
                 User ={ ""            }
             }
         }
     };
     Parser = parser;
     Maker  = new MakeClass(Parser);
 }
Exemplo n.º 2
0
        public static void Main()
        {
            LexToken.ShowError = (msg, theList) =>
            {
                MessageBox.Show(msg + "\n" + theList.CodeFormat, "Error found");
            };

            TypeParser parser = new TypeParser(Assembly.GetExecutingAssembly(), new List <string>()
            {
                "System",
                "System.Collections.Generic",
                "System.Linq",
                "System.Text",
                "System.Windows",
                "System.Windows.Shapes",
                "System.Windows.Controls",
                "System.Windows.Media",
                "System.IO",
                "System.Reflection",
                "Kamimu"
            }
                                               );

            TypeParser.DefaultParser = parser;


            try {
                {
                    Func <TestClass, int>     getLength;
                    Action <TestClass, int[]> setArray;
                    Action <TestClass>        actInit;
                    MakeClass mc = new MakeClass(parser, LexList.Get(@"
          partial class TestClass 
          {
            public int[] LocalInt ;
            public void SetArray ( int[] input ) 
            {
              LocalInt = input ; 
            }   
            public int GetLength () { return LocalInt.Length ; }
          }")).
                                   GetFunc <TestClass, int>("GetLength", out getLength).
                                   GetAction <TestClass, int[]>("SetArray", out setArray).
                                   GetAction <TestClass>("FieldsInitialiser", out actInit);
                    TestClass tc = new TestClass();
                    actInit(tc);
                    int[] thearray = new int[300];
                    setArray(tc, thearray);
                    if (getLength(tc) != thearray.Length)
                    {
                        MessageBox.Show("There was an error", "Test class with dialog");
                    }
                    else
                    {
                        MessageBox.Show("Ran OK", "Test class with dialog");
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show("There was a compilation or execution error.", "Test class with dialog");
            }
        }
Exemplo n.º 3
0
        public static void Main()
        {
            LexToken.ShowError = (msg, theList) =>
            {
                new LexErrorDialog()
                {
                    Message      = msg,
                    CompilerList = theList,
                }.Show();
            };

            TypeParser parser = new TypeParser(Assembly.GetExecutingAssembly(), new List <string>()
            {
                "System",
                "System.Collections.Generic",
                "System.Linq",
                "System.Text",
                "System.Windows",
                "System.Windows.Shapes",
                "System.Windows.Controls",
                "System.Windows.Media",
                "System.IO",
                "System.Reflection",
                "Kamimu"
            }
                                               );

            TypeParser.DefaultParser = parser;



            Directory.CreateDirectory(@"C:\KamimuCodeTemp");
            Persist.ReadFromFile(@"C:\KamimuCodeTemp\CsharpEvalConfiguration.xml");

            try {
                {
                    Func <TestClass, int>     getLength;
                    Action <TestClass, int[]> setArray;
                    Action <TestClass>        actInit;
                    MakeClass mc = new MakeClass(parser, LexList.Get(@"
          partial class TestClass 
          {
            public int[] LocalInt ;
            public void SetArray ( int[] input ) 
            {
              LocalInt = input ; 
            }   
            public int GetLength () { return LocalInt.Length ; }
          }")).
                                   GetFunc <TestClass, int>("GetLength", out getLength).
                                   GetAction <TestClass, int[]>("SetArray", out setArray).
                                   GetAction <TestClass>("FieldsInitialiser", out actInit);
                    TestClass tc = new TestClass();
                    actInit(tc);
                    int[] thearray = new int[300];
                    setArray(tc, thearray);
                    if (getLength(tc) != thearray.Length)
                    {
                        MessageBox.Show("There was an error", "Test class with dialog");
                    }
                    else
                    {
                        MessageBox.Show("Ran OK", "Test class with dialog");
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show("There was a compilation or execution error.", "Test class with dialog");
            }

            Persist.WriteToFile();
        }