Beispiel #1
0
 private void SourceTextChanged(object sender, EventArgs e)
 {
     string input = this.Source.Text.Replace("\t", "    ");
     File.WriteAllText("test.sc", input);
     try
     {
         TargetCpp sugar_cpp = new TargetCpp();
         string output = sugar_cpp.Compile(input, "test").Implementation;
         this.Result.Text = output;
         File.WriteAllText("test.cpp", output);
     }
     catch (Exception ex)
     {
         string output = string.Format("Compile Error:\n{0}", ex.Message);
         this.Result.Text = output;
     }
 }
Beispiel #2
0
 private void Source_TextChanged_1(object sender, EventArgs e)
 {
     string input = this.Source.Text;
     File.WriteAllText("test.sc", input);
     try
     {
         TargetCpp sugar_cpp = new TargetCpp();
         var result = sugar_cpp.Compile(input, "test");
         this.Header.Text = result.Header;
         File.WriteAllText("test.h", this.Header.Text);
         this.Implementation.Text = result.Implementation;
         File.WriteAllText("test.cpp", this.Implementation.Text);
     }
     catch (Exception ex)
     {
         string output = string.Format("Compile Error:\n{0}", ex.Message);
         this.Header.Text = output;
     }
 }
Beispiel #3
0
        internal static void DoCompile(string inputFileName, string arguments)
        {
            string cppFileName = Path.GetTempFileName();

            string input = File.ReadAllText(inputFileName);
            TargetCppResult result = null;
            try
            {
                TargetCpp sugarCpp = new TargetCpp();
                result = sugarCpp.Compile(input, cppFileName);
            }
            catch (Exception ex)
            {
                Program.Panic(string.Format("Compile Error:\n{0}", ex.Message));
            }
            // Write to temperory file
            File.Delete(cppFileName);
            File.WriteAllText(cppFileName + ".h", result.Header);
            File.WriteAllText(cppFileName + ".cpp", result.Implementation);

            // Execute compiler
            RunCommand(compiler.Command, cppFileName + ".cpp" + " " + arguments + " " + compiler.AdditionalArgs);
        }
Beispiel #4
0
        private void OnFileEvent(object sender, FileSystemEventArgs e)
        {
            Thread.Sleep(1);

            string root = watcher_to_root[sender];
            string input = null;
            try
            {
                input = File.ReadAllText(e.FullPath);
            }
            catch (Exception)
            {
                compile_info[root][e.Name] = string.Format("Failed to read file.");
                UpdateGui();
                return;
            }

            string result = null;
            try
            {
                TargetCpp sugar_cpp = new TargetCpp();
                result = sugar_cpp.Compile(input, "test").Implementation;
            }
            catch (Exception err)
            {
                compile_info[root][e.Name] = string.Format("Compile Error:\n{0}", err);
                Console.WriteLine("Compile Error!");
                UpdateGui();
                return;
            }

            try
            {
                string name = e.Name.Substring(0, e.Name.Length - 3) + ".cpp";
                name = name.Substring(name.LastIndexOf("/") + 1);
                name = name.Substring(name.LastIndexOf("\\") + 1);
                File.WriteAllText(root + "/" + name, result);
            }
            catch (Exception)
            {
                compile_info[root][e.Name] = string.Format("Can't access file.");
                UpdateGui();
                return;
            }

            compile_info[root][e.Name] = null;
            Console.WriteLine("Compile Success!");
            UpdateGui();
        }
Beispiel #5
0
 public string Compile(string input)
 {
     var sugarCpp = new TargetCpp();
     return sugarCpp.Compile(input, "test").Implementation;
 }
Beispiel #6
0
 public void SpeedTest1MB()
 {
     var sugarCpp = new TargetCpp();
     sugarCpp.Compile(_input1MB, "test");
 }