예제 #1
0
        public void Compile()
        {
            compileStatus = CompileTimeStatus.Compiling;
            rep.Invoke(new MethodInvoker(delegate { rep.Refresh(); }));
            Thread.Sleep(50);
            try {
                if (language == Language.PUFFIN)
                {
                    if (!File.Exists(Main.inst.Explorer.WorkingDirectory + "/" + Name + ".p"))
                    {
                        FileStream fs = File.Create(Main.inst.Explorer.WorkingDirectory + "/" + Name + ".p");
                        fs.Close();
                    }

                    List <string> tocompcode = Code.Split('\n').ToList();

                    for (int i = 0; i < tocompcode.Count; i++)
                    {
                        tocompcode[i] = tocompcode[i].TrimEnd('\r');
                    }
                    SnapScript.SnapCompiler compiler = new SnapScript.SnapCompiler(tocompcode.ToArray());
                    string[] compiledPASM            = compiler.CompileToPASM();
                    File.WriteAllLines(Main.inst.Explorer.WorkingDirectory + "/" + Name + ".p", compiledPASM);
                    //TODO: Write out the header file.

                    Log("Compilation Successfull...");
                }
                else if (language == Language.PASM)
                {
                    Code = File.ReadAllText(Main.inst.Explorer.WorkingDirectory + "/" + HardName);
                    List <string> fixedcode = Code.Split('\n').ToList();

                    string construct = "";

                    for (int i = 0; i < fixedcode.Count; i++)
                    {
                        construct += fixedcode[i].TrimEnd('\r') + "\n";
                    }
                    Code = construct;
                }
            }
            finally { compileStatus = CompileTimeStatus.Complete; rep.Invoke(new MethodInvoker(delegate { rep.Refresh(); })); }
        }