Example #1
0
        private void loadFileOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.openDialog.ShowDialog() != DialogResult.OK)
                return;

            string filename = this.openDialog.FileName;

            Loader loader = new Loader(filename, new VmCompiler());
            loader.LoadAndExecute(this.machine);
            this.SetMachine(this.machine);
        }
Example #2
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Machine machine = new Machine();

            if (File.Exists(BootFile))
            {
                Loader loader = new Loader(BootFile, new VmCompiler());
                loader.LoadAndExecute(machine);
            }

            Application.Run(new Browser(machine));
        }
Example #3
0
 public void CreateRemotingAndClientServerAndExportClass()
 {
     Loader loader = new Loader(@"DefineRectangleWithNewAndInitialize.st", new SimpleCompiler());
     Machine machine = new Machine(true);
     RemotingHostServer server = new RemotingHostServer(machine, 10004, "Server4");
     Machine machine2 = new Machine(true);
     loader.LoadAndExecute(machine2);
     BaseClass rect = (BaseClass)machine2.GetGlobalObject("Rectangle");
     RemotingHostClient client = new RemotingHostClient("localhost", 10004, "Server4");
     client.Execute(rect.ToOutputString());
     object result = machine.GetGlobalObject("Rectangle");
     Assert.IsNotNull(result);
     Assert.IsInstanceOfType(result, typeof(BaseClass));
     object newresult = client.Evaluate("Rectangle new");
     Assert.IsNotNull(newresult);
     Assert.IsInstanceOfType(newresult, typeof(IObject));
     IObject newrect = (IObject)newresult;
     Assert.AreSame(rect, newrect.Behavior);
     Assert.AreEqual(10, newrect[0]);
     Assert.AreEqual(20, newrect[1]);
     server.Stop();
 }
Example #4
0
 private void LoadFile(string filename)
 {
     Loader loader = new Loader(filename, new VmCompiler());
     loader.LoadAndExecute(this.machine);
 }
Example #5
0
 private static void LoadFile(Machine machine, string filename)
 {
     Loader loader = new Loader(filename, new VmCompiler());
     loader.LoadAndExecute(machine);
 }
Example #6
0
        public static void Main(string[] args)
        {
            //// According http://msdn.microsoft.com/en-us/magazine/cc300474.aspx
            LifetimeServices.LeaseTime = TimeSpan.FromMinutes(10);
            LifetimeServices.RenewOnCallTime = TimeSpan.FromMinutes(15);
            LifetimeServices.SponsorshipTimeout = TimeSpan.FromMinutes(1);

            Machine machine = null;

            string imageloadname = GetImageFileName(args);

            if (imageloadname != null)
            {
                var stream = File.Open(imageloadname, FileMode.Open);
                var reader = new BinaryReader(stream);
                ImageSerializer serializer = new ImageSerializer(reader, null);
                machine = (Machine)serializer.Deserialize();
                Machine.SetCurrent(machine);
                reader.Close();

                object pgm = machine.GetGlobalObject("Program");

                if (pgm != null)
                {
                    IBehavior program = (IBehavior)pgm;
                    machine.SendMessage(program, "main", null, null);
                    return;
                }
            }
            else
                machine = new Machine();

            foreach (string arg in GetFileNames(args))
            {
                Loader ldr = new Loader(arg, new VmCompiler());
                try
                {
                    ldr.LoadAndExecute(machine);
                }
                catch (Exception ex)
                {
                    System.Console.Error.WriteLine(ex.Message);
                    System.Console.Error.WriteLine(ex.StackTrace);
                }
            }

            string imagesavename = GetOption("save", "s", args);

            if (imagesavename != null)
            {
                var stream = File.Open(imagesavename, FileMode.Create);
                var writer = new BinaryWriter(stream);
                ImageSerializer serializer = new ImageSerializer(writer);
                serializer.Serialize(machine);
                writer.Close();
                return;
            }

            Loader loader = new Loader(System.Console.In, new VmCompiler());

            while (true)
            {
                try
                {
                    loader.LoadAndExecute(machine);
                }
                catch (Exception ex)
                {
                    System.Console.Error.WriteLine(ex.Message);
                    System.Console.Error.WriteLine(ex.StackTrace);
                }
            }
        }
Example #7
0
        public void Execute(string command)
        {
            Machine current = Machine.Current;
            Loader loader = new Loader(new StringReader(command), new SimpleCompiler());

            try
            {
                this.machine.SetCurrent();
                loader.LoadAndExecute(this.machine);
            }
            finally
            {
                Machine.SetCurrent(current);
            }
        }
Example #8
0
 private Machine LoadMachine(string filename)
 {
     Machine machine = new Machine();
     Loader loader = new Loader(filename, new SimpleCompiler());
     loader.LoadAndExecute(machine);
     return machine;
 }