StructType AddStructType(StructDecl decl) { var name = decl.Name.ToLower(); Raise <TypeCheckException> .If(_types.ContainsKey(name)); const string nmsp = "DanglingLang.Runner"; const TypeAttributes typeAttr = TypeAttributes.Sealed | TypeAttributes.Public | TypeAttributes.AnsiClass | TypeAttributes.BeforeFieldInit | TypeAttributes.SequentialLayout; var typeDef = new TypeDefinition(nmsp, name, typeAttr, Module.Import(typeof(object))); var type = new StructType(name, typeDef); foreach (var f in decl.Fields) { var fieldType = GetType(f.Item2); Raise <TypeCheckException> .IfAreEqual("void", fieldType.Name, "Field cannot be void"); type.AddField(f.Item1, fieldType); } _types.Add(name, type); _structTypes.Add(name, type); return(type); }
void RunExecutable() { var exec = new Process { StartInfo = { UseShellExecute = false, RedirectStandardOutput = true, FileName = Settings.Default.ExecutablePath, Arguments = Settings.Default.ExecutableArgs, CreateNoWindow = true } }; exec.Start(); ScriptOutputTxt.ReadOnly = false; while (!exec.StandardOutput.EndOfStream) { ScriptOutputTxt.Text += exec.StandardOutput.ReadLine() + NewLine; } ScriptOutputTxt.ReadOnly = true; exec.WaitForExit(); Raise <Exception> .IfAreEqual(exec.ExitCode, 1, "Execution failed :("); }
void RunCompiler() { File.WriteAllText(SourceFile, _scriptCodeTxt.Text + NewLine); var compiler = new Process { StartInfo = { UseShellExecute = false, RedirectStandardOutput = true, FileName = Settings.Default.CompilerPath, Arguments = Settings.Default.CompilerArgs, CreateNoWindow = true } }; compiler.Start(); CompilerOutputTxt.ReadOnly = false; while (!compiler.StandardOutput.EndOfStream) { CompilerOutputTxt.Text += compiler.StandardOutput.ReadLine() + NewLine; } CompilerOutputTxt.ReadOnly = true; compiler.WaitForExit(); Raise <Exception> .IfAreEqual(compiler.ExitCode, 1, "Compilation failed :("); }