private async Task <string> buildAllPlatforms() { var cSharpCode = await mainWebBrowser.BkyExportCSharp(); var outputList = new List <Tuple <CompilerFunction.Platform, string> >(); if (currentWorkspace.Config.ShouldCompilex86) { outputList.Add(new Tuple <CompilerFunction.Platform, string> (CompilerFunction.Platform.WinDll32, currentWorkspace.GetCompilePathx86())); } if (currentWorkspace.Config.ShouldCompilex64) { outputList.Add(new Tuple <CompilerFunction.Platform, string> (CompilerFunction.Platform.WinDll64, currentWorkspace.GetCompilePathx64())); } if (currentWorkspace.Config.ShouldCompileAnyCpu) { outputList.Add(new Tuple <CompilerFunction.Platform, string> (CompilerFunction.Platform.OpenBve, currentWorkspace.GetCompilePathAnyCpu())); } var notifText = ""; foreach (var pair in outputList) { notifText += "\n" + pair.Item1.ToString() + ": " + pair.Item2; CompilerFunction.Compile(cSharpCode, pair.Item2, pair.Item1, currentWorkspace.Config.IncludeDebugInfo); } return(notifText); }
public void Visit(CompilerFunction n) { Helpers.WriteColor($"{n.FunctionString} ", ConsoleColor.DarkCyan, ConsoleColor.Black); Helpers.Write("("); n.Expression?.Accept(this); Helpers.Write(")"); }
public FormDebug(string codeCSharp) { InitializeComponent(); this.codeOpenBve = CompilerFunction.CombineCode(codeCSharp, CompilerFunction.Platform.OpenBve); this.codeOpenBve = this.codeOpenBve.Replace("\n", Environment.NewLine); this.codeBve456 = CompilerFunction.CombineCode(codeCSharp, CompilerFunction.Platform.WinDll32); this.codeBve456 = this.codeBve456.Replace("\n", Environment.NewLine); ResetTextbox(codeBve456); }
public void Visit(CompilerFunction n) { Helpers.WriteLine($"{_tab}{n.Text} ({n.FunctionString}) [{n.Location.StartLine}, {n.Location.StartColumn}]"); Tab(); Helpers.WriteLine($"{_tab}Expression"); Tab(); n.Expression?.Accept(this); Untab(); Untab(); }
public SemanticAtom Visit(CompilerFunction n) { var type = n.Expression?.Accept(this); SemanticType returnType = Class.Unknown; switch (n.FunctionString) { case "System.out.println": if (type != null && type != Primitive.Int && type != Primitive.Boolean && type != Primitive.String) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Println expression ({type.Name}) is not assignable to {Primitive.String.Name}."); } returnType = Class.Unknown; break; case "System.in.readln": returnType = Primitive.String; break; case "System.compiler.destroy": if (!(type is Class) && type != Primitive.IntArray) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Destroy expression ({type.Name}) is a class or array type."); } returnType = Class.Unknown; break; case "System.compiler.exception": if (type != Primitive.String) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Exception expression ({type.Name}) is not assignable to {Primitive.String.Name}."); } returnType = Class.Unknown; break; case "System.compiler.atol": if (type != Primitive.String) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Atol expression ({type.Name}) is not assignable to {Primitive.String.Name}."); } returnType = Primitive.Int; break; } n.RealizedType = returnType; return(n.RealizedType); }
public SemanticAtom Visit(CompilerFunction n) { n.Expression?.Accept(this); switch (n.FunctionString) { case "System.out.println": if (n.Expression == null) { AddToStringTable("\"\""); } break; } return(null); }
public void Visit(CompilerFunction n) { Globals.Builder.Start($"compiler function ({n.FunctionString}) [{n.Location.StartLine}, {n.Location.StartColumn}]"); switch (n.FunctionString) { case "System.compiler.exception": // TODO: Add kill here? case "System.out.println": SemanticType realizedType; if (n.Expression == null) { Globals.Builder.WriteBinaryOp("lea", "rax", Globals.StringTable["\"\""], $"[{n.Location.StartLine}, {n.Location.StartColumn}] Explicit string."); realizedType = Primitive.String; } else { n.Expression.Accept(this); realizedType = n.Expression.RealizedType; } Globals.Builder.WriteBinaryOp("mov", "rcx", "rax", "Move result for println expression."); if (realizedType == Primitive.Boolean) { Globals.Builder.WriteBinaryOp("cmp", "rcx", 1.ToString()); var labelFalse = $"printBoolFalse{Globals.Builder.Count()}"; var labelEnd = $"printBoolEnd{Globals.Builder.Count()}"; Globals.Builder.WriteUnaryOp("jne", labelFalse); Globals.Builder.WriteBinaryOp("lea", "rcx", "$$true"); Globals.Builder.WriteUnaryOp("jmp", labelEnd); Globals.Builder.WriteLabel(labelFalse); Globals.Builder.WriteBinaryOp("lea", "rcx", "$$false"); Globals.Builder.WriteLabel(labelEnd); Globals.Builder.WriteCall("puts", "CompilerFunction call (bool)."); } else if (realizedType == Primitive.Int) { Globals.Builder.WriteCall("_writeInt", "CompilerFunction call (int)."); } else if (realizedType == Primitive.String) { Globals.Builder.WriteCall("puts", "CompilerFunction call (string)."); } break; case "System.compiler.destroy": n.Expression.Accept(this); Globals.Builder.WriteBinaryOp("mov", "rcx", "rax"); Globals.Builder.WriteCall("free"); break; case "System.in.readln": // Allocate memory for buffer. Globals.Builder.AllocateMemory(2000.ToString(), 1.ToString(), n.Location); Globals.Builder.WriteBinaryOp("mov", "rcx", "rax"); Globals.Builder.WriteCall("gets"); // Rax has returned string. break; case "System.compiler.atol": n.Expression.Accept(this); Globals.Builder.WriteBinaryOp("mov", "rcx", "rax"); Globals.Builder.WriteCall("atol"); // rax has the new int. break; } Globals.Builder.End($"compiler function ({n.FunctionString}) [{n.Location.EndLine}, {n.Location.EndColumn}]"); }