Exemplo n.º 1
0
 static int RunFile(string path)
 {
     if (File.Exists(path))
     {
         _loadedFile = path;
         string source = File.ReadAllText(path);
         SophieVM vm = new SophieVM { LoadModuleFn = LoadModule };
         return (int)vm.Interpret(path, source);
     }
     return 66; // File Not Found
 }
Exemplo n.º 2
0
        static void RunRepl()
        {
            SophieVM vm = new SophieVM();

            Console.WriteLine("-- sophie v0.0.0");

            string line = "";

            for (; line != "/exit"; )
            {
                Console.Write("> ");
                line = Console.ReadLine();

                // TODO: Handle failure.
                vm.Interpret("Prompt", line);
            }
        }
Exemplo n.º 3
0
 public static void LoadSystemLibrary(SophieVM vm)
 {
     vm.Interpret("", SystemLibSource);
     ObjClass system = (ObjClass)vm.FindVariable("System");
     vm.Primitive(system.ClassObj, "writeString_(_)", WriteString);
     vm.Primitive(system.ClassObj, "read", Read);
     vm.Primitive(system.ClassObj, "clock", Clock);
     vm.Primitive(system.ClassObj, "time", Time);
 }