Esempio n. 1
0
 private void Relocate(uint offest)
 {
     GruntyOS.IO.BinaryWriter bw = new GruntyOS.IO.BinaryWriter(new GruntyOS.IO.MemoryStream(code));
     GruntyOS.IO.BinaryReader br = new GruntyOS.IO.BinaryReader(new GruntyOS.IO.MemoryStream(code));
     for (int i = 0; i < symbolsToRelocate.Count; i++)
     {
         br.BaseStream.Position = (int)symbolsToRelocate[i].Offest;
         ushort val = BitConverter.ToUInt16(new byte[] { br.ReadByte(), br.ReadByte() }, 0);
     }
 }
        public static byte[] Compile(string code)
        {
            byte[] result = null;
            GruntyOS.IO.BinaryWriter wr = new GruntyOS.IO.BinaryWriter(new GruntyOS.IO.MemoryStream(result));
            // Mark it as FlowScript file
            wr.Write("FLOWSCRIPT");
            int abc = 0;

            for (int i = 0; i < code.Split('\n').Length - 1; i++)
            {
                string cmd = code.Split('\n')[i];
                if (cmd.Substring(0, 6) == "push ")
                {
                    wr.Write(Push);
                    if (Int32.TryParse(cmd.Substring(5), out abc))
                    {
                        wr.Write(cmd.Substring(5));
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.WriteLine("Syntax error : trying to push a non-integer object");
                    }
                }
                if (cmd.Substring(0, 7) == "push$ ")
                {
                    wr.Write(PushString);
                    wr.Write(cmd.Substring(6));
                }
                if (cmd == "wfk")
                {
                    wr.Write(WaitForKey);
                }
                if (cmd == "cls")
                {
                    wr.Write(ClearScreen);
                }
            }
            return(result);
        }
Esempio n. 3
0
 private void Relocate(uint offest)
 {
     GruntyOS.IO.BinaryWriter bw = new GruntyOS.IO.BinaryWriter(new GruntyOS.IO.MemoryStream(code));
     GruntyOS.IO.BinaryReader br = new GruntyOS.IO.BinaryReader(new GruntyOS.IO.MemoryStream(code));
     for (int i = 0; i < symbolsToRelocate.Count; i++)
     {
         br.BaseStream.Position = (int)symbolsToRelocate[i].Offest;
         ushort val = BitConverter.ToUInt16(new byte[] { br.ReadByte(), br.ReadByte() }, 0);
     }
 }