/// <summary> /// Get the abstract syntax tree for the generated code. /// </summary> /// <param name="itd"></param> /// <param name="method"></param> /// <param name="inputAttributes"></param> /// <returns></returns> internal List <ITypeDeclaration> GetTransformedDeclaration(ITypeDeclaration itd, MethodBase method, AttributeRegistry <object, ICompilerAttribute> inputAttributes) { TransformerChain tc = ConstructTransformChain(method); List <ITypeDeclaration> output; try { Compiling?.Invoke(this, new CompileEventArgs()); bool trackTransform = (BrowserMode != BrowserMode.Never); List <TransformError> warnings; output = tc.TransformToDeclaration(itd, inputAttributes, trackTransform, ShowProgress, out warnings, CatchExceptions, TreatWarningsAsErrors); OnCompiled(new CompileEventArgs() { Warnings = warnings }); if (BrowserMode == BrowserMode.Always) { ShowBrowser(tc, GeneratedSourceFolder, output[0].Name); } else if (BrowserMode == BrowserMode.WriteFiles) { tc.WriteAllOutputs(Path.Combine(GeneratedSourceFolder, output[0].Name + " Transforms")); } if (ShowSchedule && InferenceEngine.Visualizer?.TaskGraphVisualizer != null) { foreach (CodeTransformer ct in tc.transformers) { DeadCodeTransform bst = ct.Transform as DeadCodeTransform; //SchedulingTransform bst = ct.Transform as SchedulingTransform; if (bst != null) { foreach (ITypeDeclaration itd2 in ct.transformMap.Values) { InferenceEngine.Visualizer.TaskGraphVisualizer.VisualizeTaskGraph(itd2, (BasicTransformContext)bst.Context); } } } } } catch (TransformFailedException ex) { OnCompiled(new CompileEventArgs() { Exception = ex }); if (BrowserMode != BrowserMode.Never) { ShowBrowser(tc, GeneratedSourceFolder, itd.Name); } throw new CompilationFailedException(ex.Results, ex.Message); } return(output); }
public void fastColoredTextBox1_TextChangedDelayed(object sender, TextChangedEventArgs e) { // MessageBox.Show("You are typing now :)");//method when you are typing _textEditor = GetEditor(); if (_textEditor == null) { return; } SaveFile_realTime(_textEditor, _textEditor.Tag.ToString()); // MessageBox.Show("You are typing now 2 :)"); var file = _textEditor.Tag.ToString(); if (Getextension(_textEditor).Equals("Java")) {//run the project // MessageBox.Show("You are typing now ww2 :)"); _compilingJava = new Compiling(file); var s = _compilingJava.CompilingJavaCode(); if (s.Equals("")) { int[] line = { -1 }; SetLines(line); _textEditor.PaintLine += fastColoredTextBox1_PaintLine; _fochild.Errortext.Text = ""; } else { // MessageBox.Show(s); var bugs = new ErrorDetector(s, Path.GetFileName(file)); var res = bugs.GetResult(); fillInErrorTextBox(res, file); var s1 = ""; for (var i = 0; i < res.GetLength(0); i += 1) { // s1 += res.GetLength(i)+" : "; for (int j = 0; j < res.GetLength(1); j++) { s1 += res[i, j] + " - "; } s1 += '\n'; } // MessageBox.Show("Errors:: " + s1); var errorLines = new int[res.GetLength(0)]; for (var i = 0; i < res.GetLength(0); i += 1) { errorLines[i] = Convert.ToInt32(res[i, 0]) - 1; } SetLines(errorLines); _textEditor.PaintLine += fastColoredTextBox1_PaintLine; } } }
public bool DoIt(string[] args) { // Parse Args List <string> inputs = new List <string>(); LinkFile linkFile = new LinkFile(); List <string> symbols = new List <string>(); string output = ""; bool quiet = true; bool disableWarnings = true; bool clean = true; int opLevel = 2; for (int i = 0; i < args.Length; i++) { if (args[i] == "-i") { for (int j = i + 1; j < args.Length; j++) { if (File.Exists(args[j])) { inputs.Add(Path.GetFullPath(args[j])); } else { break; } } } if (args[i] == "-o" && i + 1 < args.Length) { output = Path.GetFullPath(args[i + 1]); } if (args[i] == "-s" && i + 1 < args.Length) { for (int j = i + 1; j < args.Length; j++) { if (!string.IsNullOrEmpty(args[j])) { symbols.Add(args[j]); } else { break; } } } if (args[i] == "-v") { quiet = false; } } // if (symbols.Count <= 0) { Console.WriteLine("Error: No symbols specified"); return(false); } // if output is null set the name to the symbol name if (string.IsNullOrEmpty(output)) { Console.WriteLine("Error: No output path specified"); return(false); } // load link file in mex directory foreach (var f in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory)) { if (Path.GetExtension(f).ToLower().Equals(".link")) { linkFile.LoadLinkFile(f); } } // print instruction and exit if no input if ((inputs.Count == 0) || args.Length == 0) { return(false); } // create output path if one isn't entered if (string.IsNullOrEmpty(output)) { output = Path.Combine(Path.GetDirectoryName(inputs[0]), Path.GetFileName(inputs[0]).Replace(Path.GetExtension(inputs[0]), ".dat")); } // compile functions var elfs = Compiling.Compile(inputs.ToArray(), disableWarnings, clean, opLevel); var lelf = LinkELFs(elfs, linkFile, symbols.ToArray(), quiet); var file = BuildDatFile(lelf); if (file == null) { return(false); } file.Save(output); // create DAT file /*if (function != null) * { * // save new file * if (!string.IsNullOrEmpty(output)) * { * var f = new HSDRawFile(); * //DatTools.InjectSymbolIntoDat(f, symbolName, function); * f.Save(output); * Console.WriteLine("saving " + output + "..."); * } * * // We did it boys * Console.WriteLine(); * Console.WriteLine("Sucessfully Compiled and Converted to DAT!"); * * return true; * }*/ return(true); }
public string CompileShader(NamedTypeSymbol Symbol, MethodDeclarationSyntax vertex_method, MethodDeclarationSyntax fragment_method) { ClearString(); // Declare samplers and other relevant structures needed for the Fragment Shader Write(SpaceFormat(FileBegin)); EndLine(); WriteLine(); WriteLine(VertexMethodParameters); CompileVertexSignature(vertex_method); EndLine(); WriteLine(FragmentMethodParameters); var LocalFragmentLookup = CompileFragmentSignature(fragment_method); EndLine(); // Referenced foreign variables Write(SpaceFormat(ReferencedForeignVarsPreamble)); EndLine(); Write("<$0$>"); // This is where we will insert referenced foreign variables. WriteLine(); // Referenced methods Write(SpaceFormat(ReferencedMethodsPreamble)); EndLine(); Write("<$1$>"); // This is where we will insert referenced methods. WriteLine(); // Vertex Shader method CurrentMethod = Compiling.VertexMethod; Write(SpaceFormat(VertexShaderBegin)); EndLine(); var PrevIndent = Indent(); FunctionParameterPrefix = VertexShaderParameterPrefix; CompileStatement(vertex_method.Body); RestoreIndent(PrevIndent); Write(SpaceFormat(VertexShaderEnd)); EndLine(); WriteLine(); // Fragment Shader method UseLocalSymbolMap(LocalFragmentLookup); CurrentMethod = Compiling.FragmentMethod; Write(FragmentShaderBegin, Tab, LineBreak, VertexToPixelDecl); EndLine(); PrevIndent = Indent(); FunctionParameterPrefix = FragmentShaderParameterPrefix; CompileStatement(fragment_method.Body); RestoreIndent(PrevIndent); Write(SpaceFormat(FragmentShaderEnd)); EndLine(); UseLocalSymbolMap(null); WriteLine(); Write(SpaceFormat(FileEnd)); // We must wait until after compiling the shader to know which methods that shader references. string methods = GetReferencedMethods(); // We must wait until after compiling the shader to know which foreign variables that shader references. string foreign_vars = GetForeignVars(); // Now get the full string written so far and insert the referenced methods. string fragment = GetString(); fragment = SpecialFormat(fragment, foreign_vars, methods); return fragment; }
/// <summary> /// /// </summary> /// <param name="input"></param> /// <param name="fightFuncTable"></param> /// <param name="quiet"></param> /// <returns></returns> private static List <RelocELF> CompileElfs(string[] inputs, bool disableWarnings, bool clean, int optimizationLevel = 2, string[] includes = null, string buildPath = null, bool debug = false, bool quiet = true) { return(Compiling.Compile(inputs, disableWarnings, clean, optimizationLevel, includes, buildPath, debug, quiet)); }
private void run(string file) { _fochild.richTextBox3.Text = ""; _fochild.richTextBox4.Text = ""; // _fochild.richTextBox2.Text = ""; _fochild.Errortext.Text = ""; if (Getextension(_textEditor).Equals("Java")) {//run the project var p = new ImplementPMD(); var xml = p.RunPMD(Path.GetDirectoryName(file), Path.GetFileName(file)); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); GenerateFeedbackOutput(_fochild.richTextBox3, xmlDoc); _compilingJava = new Compiling(file); var s = _compilingJava.CompilingJavaCode(); if (s.Equals("")) { // var p = new ImplementPMD(file); // var xml = p.RunPMD(Path.GetDirectoryName(file), Path.GetFileName(file)); // var xmlDoc = new XmlDocument(); // xmlDoc.LoadXml(xml); // GenerateFeedbackOutput(_fochild.richTextBox3,xmlDoc); var style = new JavaCompilingToolMurtada.StyleChecker.ImplementStyleChecker(file); // _fochild.richTextBox2.Text = style.StyleJavaCodeFeedback(); _fochild.richTextBox4.Text = _runJava.RunJavaProject(file); } else { // MessageBox.Show(s); // _fochild.Errortext.Text = s; var bugs = new ErrorDetector(s, Path.GetFileName(file)); var res = bugs.GetResult(); // MessageBox.Show("Errors:: " + s1); var errorLines = new int[res.GetLength(0)]; for (var i = 0; i < res.GetLength(0); i += 1) { errorLines[i] = Convert.ToInt32(res[i, 0]) - 1; } SetLines(errorLines); var totalErrorCount = res.Length / 3; _textEditor.PaintLine += fastColoredTextBox1_PaintLine; const float bigFont = 12.0f; var richTextBox = _fochild.Errortext; var fontOriginal = richTextBox.Font.Size; richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, bigFont, FontStyle.Underline); richTextBox.AppendText("Total Errors found: " + totalErrorCount + "\n\n"); richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, fontOriginal, FontStyle.Regular); for (var errorIndex = 0; errorIndex < totalErrorCount; errorIndex++) { var errorLine = Convert.ToInt32(res[errorIndex, 0]); var errorSomething = res[errorIndex, 1]; var error = res[errorIndex, 2]; richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, bigFont, FontStyle.Bold); richTextBox.AppendText("Error "); richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, bigFont, FontStyle.Regular); richTextBox.AppendText((errorIndex + 1) + "\n\n"); richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, fontOriginal, FontStyle.Regular); richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Bold); richTextBox.AppendText("In file: "); richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Regular); richTextBox.AppendText(file + "\n"); richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Bold); richTextBox.AppendText("On line nr: "); richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Regular); richTextBox.AppendText(errorLine + "\n"); richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Bold); richTextBox.AppendText("Details:\n"); richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Regular); int asd = error.IndexOf("error:"); richTextBox.AppendText(error.Substring(asd + 7) + "\n"); richTextBox.AppendText("\n"); } } if (s.Equals("")) { // var p = new ImplementPMD(file); // var xml = p.RunPMD(Path.GetDirectoryName(file), Path.GetFileName(file)); // var xmlDoc = new XmlDocument(); // xmlDoc.LoadXml(xml); // GenerateFeedbackOutput(_fochild.richTextBox3,xmlDoc); var style = new JavaCompilingToolMurtada.StyleChecker.ImplementStyleChecker(file); // _fochild.richTextBox2.Text = style.StyleJavaCodeFeedback(); _fochild.richTextBox4.Text = _runJava.RunJavaProject(file); } else { var bugs = new ErrorDetector(s, Path.GetFileName(file)); var res = bugs.GetResult(); // MessageBox.Show("Errors:: " + s1); var errorLines = new int[res.GetLength(0)]; for (var i = 0; i < res.GetLength(0); i += 1) { errorLines[i] = Convert.ToInt32(res[i, 0]) - 1; } SetLines(errorLines); _textEditor.PaintLine += fastColoredTextBox1_PaintLine; fillInErrorTextBox(res, file); } } else { _textEditor = GetEditor(); JavaCompilingToolMurtada.CSharpRunner.CSharpRunner cs = new JavaCompilingToolMurtada.CSharpRunner.CSharpRunner(_textEditor.Text); _fochild.richTextBox4.Text = cs.Compile(_textEditor.Text); } }