diff --git a/.gitignore b/.gitignore index 53a63d13e..5befbdf06 100644 --- a/.gitignore +++ b/.gitignore @@ -90,7 +90,6 @@ /bin/ICSharpCode.SharpZipLib.dll /bin/ICSharpCode.TextEditor.dll /bin/ICSharpCode.TextEditorLinux.dll -/bin/Microsoft.Scripting.dll /bin/Mono.Cecil.dll /bin/SharpDisasm.dll /bin/WeifenLuo.WinFormsUI.Docking.dll diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index b31e8908b..e923babf5 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -141,9 +141,6 @@ #define DEBUG -using Microsoft.Scripting; -using Microsoft.Scripting.Hosting; - using PascalABCCompiler.Errors; using PascalABCCompiler.PCU; using PascalABCCompiler.SemanticTreeConverters; @@ -1013,475 +1010,6 @@ namespace PascalABCCompiler }*/ - #region LEGACY - Visual Basic and IronPython - - /*class ProgInfo - { - public string entry_module; - public int entry_method_name_pos; - public int entry_method_line; - public int using_pos = -1; - public List modules = new List(); - public List addit_imports = new List(); - public List addit_project_files = new List(); - }*/ - - /* - private void add_import_info(ProgInfo info, List imports) - { - Hashtable ht = new Hashtable(StringComparer.CurrentCultureIgnoreCase); - ht["GraphABC"] = "GraphABC"; - ht["GraphABCHelper"] = "GraphABCHelper"; - ht["ABCObjects"] = "ABCObjects"; - ht["Robot"] = "Robot"; - ht["Drawman"] = "Drawman"; - ht["DrawManField"] = "DrawManField"; - foreach (string s in imports) - { - string low_s = s.ToLower(); - //string mod_file = FindSourceFileInDirectories(s+".mod",Path.Combine(this.CompilerOptions.SystemDirectory,"lib")); - if (ht[s] != null) - { - string name = ht[s] as string; - if (!info.modules.Contains(name)) - { - info.modules.Add(name); - info.addit_imports.Add(name + "." + name); - } - } - // Этот if был закомментирован EVA - if (!string.IsNullOrEmpty(mod_file)) - { - switch (low_s) - { - case "graphabc" : - if (!info.modules.Contains("GraphABC") && !info.modules.Contains("ABCObjects") && !info.modules.Contains("ABCButtons") && !info.modules.Contains("ABCHouse") - && !info.modules.Contains("ABCSprites") && !info.modules.Contains("RobotField")) - { - info.modules.Add("GraphABC"); - info.addit_imports.Add("GraphABC.GraphABC"); - } - else if (!info.addit_imports.Contains("GraphABC.GraphABC")) - { - info.addit_imports.Add("GraphABC.GraphABC"); - } - break; - case "abcobjects" : - if (!info.modules.Contains("ABCObjects") && !info.modules.Contains("ABCButtons") && !info.modules.Contains("ABCHouse") - && !info.modules.Contains("ABCSprites") && !info.modules.Contains("RobotField")) - { - info.modules.Add("ABCObjects"); - info.addit_imports.Add("ABCObjects.ABCObjects"); - if (info.modules.Contains("GraphABC")) - { - info.modules.Remove("GraphABC"); - //info.addit_imports.Remove("GraphABC.GraphABC"); - } - } - break; - default: - if (!info.modules.Contains(s)) - { - info.modules.Add(s); - info.addit_imports.Add(s+"."+s); - } - break; - } - } - else - { - string source_file = FindFileWithExtensionInDirs(s + ".vb", out _, Path.GetDirectoryName(CompilerOptions.SourceFileName), Path.Combine(this.CompilerOptions.SystemDirectory, "lib"), - Path.Combine(this.CompilerOptions.SystemDirectory, "LibSource")); - if (!string.IsNullOrEmpty(source_file)) - { - if (!info.addit_project_files.Contains(source_file)) - { - info.addit_project_files.Add(source_file); - } - } - } - } - // весь код ниже был закомментирован EVA - List mods = new List(); - List inds = new List(); - for (int i=0; i usings = new List(); - foreach (ICSharpCode.NRefactory.Ast.INode node in cu.Children) - { - if (node is ICSharpCode.NRefactory.Ast.TypeDeclaration) - { - ICSharpCode.NRefactory.Ast.TypeDeclaration td = node as ICSharpCode.NRefactory.Ast.TypeDeclaration; - if (td.Type == ICSharpCode.NRefactory.Ast.ClassType.Module) - { - foreach (ICSharpCode.NRefactory.Ast.INode node2 in td.Children) - { - if (node2 is ICSharpCode.NRefactory.Ast.MethodDeclaration) - { - ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node2 as ICSharpCode.NRefactory.Ast.MethodDeclaration; - if (string.Compare(meth.Name, "Main", true) == 0 && (meth.Parameters == null || meth.Parameters.Count == 0)) - { - //info = new ProgInfo(); - info.entry_module = (meth.Parent as ICSharpCode.NRefactory.Ast.TypeDeclaration).Name; - //info.entry_method_name_line = meth.StartLocation.Line; - //info.entry_method_name_col = meth.StartLocation.Column; - info.entry_method_name_pos = find_pos(source, meth.StartLocation.Line, meth.StartLocation.Column, true); - if (meth.Body.Children.Count > 0) - { - for (int i = 0; i < meth.Body.Children.Count; i++) - { - if (!(meth.Body.Children[i] is ICSharpCode.NRefactory.Ast.LocalVariableDeclaration)) - { - info.entry_method_line = meth.Body.Children[i].StartLocation.Line; - break; - } - } - } - else - info.entry_method_line = meth.Body.EndLocation.Line; - } - } - } - } - } - else if (node is ICSharpCode.NRefactory.Ast.UsingDeclaration) - { - ICSharpCode.NRefactory.Ast.UsingDeclaration using_node = node as ICSharpCode.NRefactory.Ast.UsingDeclaration; - - foreach (ICSharpCode.NRefactory.Ast.Using us in using_node.Usings) - if (!string.IsNullOrEmpty(us.Name)) - usings.Add(us.Name); - if (info.using_pos == -1) - info.using_pos = find_pos(source, using_node.EndLocation.Line, using_node.EndLocation.Column, false); - } - } - if (info.entry_module != null) - { - add_import_info(info, usings); - return info; - } - return null; - }*/ - - /*public string CompileWithProvider(string[] sources, System.CodeDom.Compiler.CodeDomProvider cp, params string[] RefAssemblies) - { - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); - Reset(); - - //var cscp = new Microsoft.CSharp.CSharpCodeProvider(); - var comp_opt = new CompilerParameters(); - comp_opt.IncludeDebugInformation = CompilerOptions.Debug; - comp_opt.GenerateExecutable = true; - comp_opt.WarningLevel = 3; - comp_opt.CompilerOptions = "/platform:x86 "; - comp_opt.OutputAssembly = CompilerOptions.OutputFileName; - if (RefAssemblies != null) - comp_opt.ReferencedAssemblies.AddRange(RefAssemblies); - - //string source = GetSourceFileText(CompilerOptions.SourceFileName); - var res = cp.CompileAssemblyFromSource(comp_opt, sources); - if (res.Errors.Count > 0) - { - for (int i = 0; i < res.Errors.Count; i++) - { - if (!res.Errors[i].IsWarning && errorsList.Count == 0 *//*&& dlls.Errors[i].file_name != redirect_fname*//*) - { - if (File.Exists(res.Errors[i].FileName)) - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); - else - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, CompilerOptions.SourceFileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); - } - else if (res.Errors[i].IsWarning) - { - warnings.Add(new Errors.CommonWarning(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line, res.Errors[i].Column)); - } - } - } - - //linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); - - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - ClearAll(); - OnChangeCompilerState(this, CompilerState.Ready, null); - - if (errorsList.Count > 0) - return null; - else - return res.PathToAssembly; - }*/ - - /*class PyErrorHandler : ErrorListener - { - Compiler c; - public PyErrorHandler(Compiler cc) { c = cc; } - public override void ErrorReported(ScriptSource source, string message, SourceSpan span, int errorCode, Severity severity) - { - if (severity == Severity.Warning) - c.warnings.Add(new Errors.CommonWarning(message, c.CompilerOptions.SourceFileName, span.Start.Line, span.Start.Column)); - else - c.errorsList.Add(new Errors.CommonCompilerError(message, c.CompilerOptions.SourceFileName, span.Start.Line, span.Start.Column)); - } - }*/ - - /* - private Assembly IronPythonAssembly; - private MethodInfo PythonCreateEngineMethod; - public string CompilePy() - { - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); - Reset(); - - if (IronPythonAssembly == null) - { - IronPythonAssembly = Assembly.LoadFrom("IronPython.dll"); - PythonCreateEngineMethod = IronPythonAssembly.GetType("IronPython.Hosting.Python").GetMethod("CreateEngine"); - } - string source = GetSourceFileText(CompilerOptions.SourceFileName); - - ScriptEngine pyEngine = (ScriptEngine)PythonCreateEngineMethod.Invoke(null, new object[0]); ; - - ScriptSource src = pyEngine.CreateScriptSourceFromString(source); - CompiledCode compiled = src.Compile(new PyErrorHandler(this)); - if (compiled != null) - compiled.Execute(); - - linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); - - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - ClearAll(); - OnChangeCompilerState(this, CompilerState.Ready, null); - - //if (errorsList.Count > 0) - return null; - //else return dlls.PathToAssembly; - }*/ - - /*public string CompileVB() - { - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); - Reset(); - Microsoft.VisualBasic.VBCodeProvider vbcp = new Microsoft.VisualBasic.VBCodeProvider(); - List sources = new List(); - sources.Add(CompilerOptions.SourceFileName); - System.CodeDom.Compiler.CompilerParameters comp_opt = new System.CodeDom.Compiler.CompilerParameters(); - comp_opt.OutputAssembly = CompilerOptions.OutputFileName; - comp_opt.WarningLevel = 3; - comp_opt.ReferencedAssemblies.Add("System.Windows.Forms.dll"); - comp_opt.ReferencedAssemblies.Add("System.Drawing.dll"); - comp_opt.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll"); - comp_opt.IncludeDebugInformation = CompilerOptions.Debug; - comp_opt.GenerateExecutable = true; - string fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName), "_temp$" + Path.GetFileName(CompilerOptions.SourceFileName)); - File.Copy(CompilerOptions.SourceFileName, fname, true); - string source = GetSourceFileText(CompilerOptions.SourceFileName); - - IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.VBNet, new StringReader(source)); - parser.Parse(); - ProgInfo info = get_programm_info(parser.CompilationUnit, source); - parser.Dispose(); - if (info != null) - sources.AddRange(info.addit_project_files); - string redirect_base_fname = FindFileWithExtensionInDirs("__RedirectIOMode.vb", out _, Path.Combine(this.CompilerOptions.SystemDirectory, "Lib"), Path.Combine(this.CompilerOptions.SystemDirectory, "LibSource")); - string system_unit_name = FindFileWithExtensionInDirs("VBSystem.vb", out _, Path.Combine(this.CompilerOptions.SystemDirectory, "lib"), Path.Combine(this.CompilerOptions.SystemDirectory, "LibSource")); - string redirect_fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName), "_RedirectIOMode.vb"); - StreamReader sr = File.OpenText(redirect_base_fname); - string redirect_module = sr.ReadToEnd(); - sr.Close(); - if (info != null) - { - System.Text.StringBuilder tmp_sb = new System.Text.StringBuilder(); - if (info.modules.Count > 0) - { - tmp_sb.AppendLine("GetType(Fictive.Fictive).Assembly.GetType(\"PABCSystem_implementation$.PABCSystem_implementation$\").GetMethod(\"$Initialization\").Invoke(Nothing,Nothing)"); - } - for (int i = 0; i < info.modules.Count; i++) - { - tmp_sb.AppendLine("GetType(Fictive.Fictive).Assembly.GetType(\"" + info.modules[i] + "_implementation$." + info.modules[i] + - "_implementation$\").GetMethod(\"$Initialization\").Invoke(Nothing,Nothing)"); - - } - tmp_sb.AppendLine(info.entry_module + "." + "___Main()"); - for (int i = 0; i < info.modules.Count; i++) - { - tmp_sb.AppendLine("GetType(Fictive.Fictive).Assembly.GetType(\"" + info.modules[i] + "_implementation$." + info.modules[i] + - "_implementation$\").GetMethod(\"$Finalization\").Invoke(Nothing,Nothing)"); - - } - redirect_module = redirect_module.Replace("%MAIN%", tmp_sb.ToString()); - } - StreamWriter sw = new StreamWriter(redirect_fname, false); - if (info != null) - { - sw.WriteLine(redirect_module); - } - else - { - sw.WriteLine("module _RedirectIOMode"); - sw.WriteLine("End module"); - } - sw.Close(); - - sw = new StreamWriter(CompilerOptions.SourceFileName, false); - if (info != null && info.entry_method_name_pos != -1) - { - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - int start_pos = 0; - if (info.using_pos != -1) - { - start_pos = info.using_pos; - sb.Append(source.Substring(0, info.using_pos)); - for (int i = 0; i < info.addit_imports.Count; i++) - { - sb.Append("," + info.addit_imports[i]); - } - sb.Append(",System.Collections.Generic"); - - sb.Append(",Microsoft.VisualBasic.Strings"); - sb.Append(",Microsoft.VisualBasic.Constants"); - sb.Append(",Microsoft.VisualBasic.VBMath"); - sb.Append(",Microsoft.VisualBasic.Information"); - sb.Append(",Microsoft.VisualBasic.Interaction"); - sb.Append(",Microsoft.VisualBasic.FileSystem"); - sb.Append(",Microsoft.VisualBasic.Financial"); - sb.Append(",Microsoft.VisualBasic.DateAndTime"); - } - else - { - start_pos = 0; - sb.Append("Imports System"); - sb.Append(",System.Collections.Generic"); - sb.Append(",Microsoft.VisualBasic.Strings"); - sb.Append(",Microsoft.VisualBasic.Constants"); - sb.Append(",Microsoft.VisualBasic.VBMath"); - sb.Append(",Microsoft.VisualBasic.Information"); - sb.Append(",Microsoft.VisualBasic.Interaction"); - sb.Append(",Microsoft.VisualBasic.FileSystem"); - sb.Append(",Microsoft.VisualBasic.Financial"); - sb.Append(",Microsoft.VisualBasic.DateAndTime"); - sb.Append(":"); - } - sb.Append(source.Substring(start_pos, info.entry_method_name_pos - start_pos)); - sb.Append("___"); - sb.Append(source.Substring(info.entry_method_name_pos)); - sw.Write(sb.ToString()); - } - else - { - sw.Write(source); - } - sw.Close(); - - if (info != null && info.modules.Count > 0) - { - comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName), StringConstants.pabc_rtl_dll_name)); - string mod_file_name = FindFileWithExtensionInDirs("PABCRtl.dll", out _, Path.Combine(this.CompilerOptions.SystemDirectory, "Lib")); - File.Copy(mod_file_name, Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName), "PABCRtl.dll"), true); - *//*foreach (string mod in info.modules) - { - comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),mod+".dll")); - string mod_file_name = FindSourceFileInDirectories(mod+".mod",Path.Combine(this.CompilerOptions.SystemDirectory,"lib")); - File.Copy(mod_file_name,Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),mod+".dll"),true); - }*//* - } - sources.Add(redirect_fname); - sources.Add(system_unit_name); - System.CodeDom.Compiler.CompilerResults res = vbcp.CompileAssemblyFromFile(comp_opt, sources.ToArray()); - if (res.Errors.Count > 0) - { - for (int i = 0; i < res.Errors.Count; i++) - { - if (!res.Errors[i].IsWarning && errorsList.Count == 0 *//*&& dlls.Errors[i].file_name != redirect_fname*//*) - { - if (File.Exists(res.Errors[i].FileName)) - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, 1)); - else - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, CompilerOptions.SourceFileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, 1)); - } - else if (res.Errors[i].IsWarning) - { - warnings.Add(new Errors.CommonWarning(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line, 1)); - } - } - } - linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); - if (info != null) - { - beginOffset = info.entry_method_line; - //if (info.using_pos == -1) - // beginOffset -= 1; - } - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - ClearAll(); - File.Copy(fname, CompilerOptions.SourceFileName, true); - File.Delete(fname); - File.Delete(redirect_fname); - OnChangeCompilerState(this, CompilerState.Ready, null); - if (errorsList.Count > 0) - return null; - else - return res.PathToAssembly; - }*/ - - #endregion - public string CompileCS() { OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); diff --git a/Compiler/Compiler.csproj b/Compiler/Compiler.csproj index eb2ac80fa..c67555ad9 100644 --- a/Compiler/Compiler.csproj +++ b/Compiler/Compiler.csproj @@ -28,15 +28,4 @@ - - - - ..\Libraries\ICSharpCode.NRefactory.dll - False - - - False - ..\Libraries\Microsoft.Scripting.dll - - \ No newline at end of file diff --git a/Libraries/ICSharpCode.NRefactory.dll b/Libraries/ICSharpCode.NRefactory.dll deleted file mode 100644 index a74d27845..000000000 Binary files a/Libraries/ICSharpCode.NRefactory.dll and /dev/null differ diff --git a/Libraries/Microsoft.Dynamic.dll b/Libraries/Microsoft.Dynamic.dll deleted file mode 100644 index d65ec715a..000000000 Binary files a/Libraries/Microsoft.Dynamic.dll and /dev/null differ diff --git a/Libraries/Microsoft.Scripting.dll b/Libraries/Microsoft.Scripting.dll deleted file mode 100644 index 66e3f1a53..000000000 Binary files a/Libraries/Microsoft.Scripting.dll and /dev/null differ diff --git a/_GenerateLinuxVersion.bat b/_GenerateLinuxVersion.bat index 613f4ebd6..bcf320d4e 100644 --- a/_GenerateLinuxVersion.bat +++ b/_GenerateLinuxVersion.bat @@ -21,7 +21,6 @@ copy bin\ICSharpCode.SharpDevelop.dll Release\PascalABCNETLinux\ICSharpCode.Shar copy bin\ICSharpCode.SharpDevelop.Dom.dll Release\PascalABCNETLinux\ICSharpCode.SharpDevelop.Dom.dll copy bin\ICSharpCode.TextEditorLinux.dll Release\PascalABCNETLinux\ICSharpCode.TextEditorLinux.dll copy bin\Localization.dll Release\PascalABCNETLinux\Localization.dll -copy bin\Microsoft.Scripting.dll Release\PascalABCNETLinux\Microsoft.Scripting.dll copy bin\Mono.Cecil.dll Release\PascalABCNETLinux\Mono.Cecil.dll copy bin\Mono.Debugger.Soft.dll Release\PascalABCNETLinux\Mono.Debugger.Soft.dll copy bin\mono_pabcIDE.bat Release\PascalABCNETLinux\mono_pabcIDE.bat