diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index d5c46f91a..f8a415b53 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2923,7 +2923,7 @@ namespace PascalABCCompiler } CompilationUnit CurrentUnit = null; if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - if ((CurrentUnit = ReadDLL(UnitName)) != null) + if ((CurrentUnit = ReadDLL(UnitName, sc)) != null) { Units.AddElement(CurrentUnit.SemanticTree, null); UnitTable[UnitName] = CurrentUnit; @@ -3969,7 +3969,7 @@ namespace PascalABCCompiler - public CompilationUnit ReadDLL(string FileName) + public CompilationUnit ReadDLL(string FileName, SyntaxTree.SourceContext sc=null) { if (DLLCache.ContainsKey(FileName)) return DLLCache[FileName]; @@ -3992,6 +3992,8 @@ namespace PascalABCCompiler } catch (ReflectionTypeLoadException e) { + foreach (var assm in assemblyResolveScope.missingAssemblies) + errorsList.Add(new AssemblyNotFound(CurrentCompilationUnit.UnitFileName, assm, sc)); Console.Error.WriteLine(e.Message); foreach (var eLoaderException in e.LoaderExceptions) { diff --git a/TestSuite/Eto.dll b/TestSuite/Eto.dll new file mode 100644 index 000000000..55a11edcd Binary files /dev/null and b/TestSuite/Eto.dll differ diff --git a/TestSuite/errors/Eto.WinForms.dll b/TestSuite/errors/Eto.WinForms.dll new file mode 100644 index 000000000..2f67562fc Binary files /dev/null and b/TestSuite/errors/Eto.WinForms.dll differ diff --git a/TestSuite/errors/Eto.dll b/TestSuite/errors/Eto.dll new file mode 100644 index 000000000..55a11edcd Binary files /dev/null and b/TestSuite/errors/Eto.dll differ diff --git a/TestSuite/errors/err0527_eto.pas b/TestSuite/errors/err0527_eto.pas new file mode 100644 index 000000000..41e7d870f --- /dev/null +++ b/TestSuite/errors/err0527_eto.pas @@ -0,0 +1,19 @@ +//!Сборка 'Microsoft.WindowsAPICodePack.Shell.dll' не найдена +{$apptype windows} +{$reference Eto.dll} +{$reference Eto.WinForms.dll} +uses Eto.Forms; + +type MyForm = class(Form) + constructor; + begin + Title := 'My Cross-Platform App'; + ClientSize := new Eto.Drawing.Size(200, 200); + var lbl := new &Label(); + lbl.Text := 'Test'; + Content := lbl; + end; +end; +begin + (new Application()).Run(new MyForm()); +end. \ No newline at end of file diff --git a/TestSuite/eto.pas b/TestSuite/eto.pas new file mode 100644 index 000000000..bce9475e2 --- /dev/null +++ b/TestSuite/eto.pas @@ -0,0 +1,4 @@ +{$reference Eto.dll} +begin + +end. \ No newline at end of file diff --git a/TreeConverter/NetWrappers/AssemblyResolveScope.cs b/TreeConverter/NetWrappers/AssemblyResolveScope.cs index ddc73c6b7..972fcadb5 100644 --- a/TreeConverter/NetWrappers/AssemblyResolveScope.cs +++ b/TreeConverter/NetWrappers/AssemblyResolveScope.cs @@ -60,6 +60,90 @@ namespace PascalABCCompiler.NetHelper _appDomain.AssemblyResolve -= OnAssemblyResolve; } + static string standartAssemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(string)).ManifestModule.FullyQualifiedName); + + private string GetStandardAssemblyPath(string name) + { + name = name.Replace("%GAC%\\", ""); + string ttn = System.IO.Path.GetFileNameWithoutExtension(name); + string tn = Path.Combine(standartAssemblyPath, name); + if (File.Exists(tn)) + return tn; + if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX) + { + string windir = Path.Combine(Environment.GetEnvironmentVariable("windir"), "Microsoft.NET"); + tn = windir + @"\assembly\GAC_MSIL\"; + tn += ttn + "\\"; + System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_64\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_32\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + windir = Environment.GetEnvironmentVariable("windir"); + tn = windir + @"\assembly\GAC_MSIL\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_64\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_32\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + return null; + } + } + } + } + } + } + } + } + System.IO.DirectoryInfo[] diarr = di.GetDirectories(); + tn = Path.Combine((diarr[0]).FullName, name); + } + else + { + string gac_path = "/usr/lib/mono/4.0/gac"; + DirectoryInfo di = new DirectoryInfo(Path.Combine(gac_path, ttn)); + if (di.Exists) + { + System.IO.DirectoryInfo[] diarr = di.GetDirectories(); + tn = Path.Combine((diarr[diarr.Length - 1]).FullName, name); + } + else + return null; + + } + return tn; + + } + + public List missingAssemblies = new List(); + private Assembly OnAssemblyResolve(object obj, ResolveEventArgs args) { var requestedName = new AssemblyName(args.Name); @@ -68,7 +152,14 @@ namespace PascalABCCompiler.NetHelper var dir = NetHelper.GetAssemblyDirectory(args.RequestingAssembly); if (string.IsNullOrEmpty(dir)) return null; - string path = Path.Combine(dir, args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"); + string fileName = args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"; + string path = Path.Combine(dir, fileName); + if (!File.Exists(path)) + { + string assmPath = GetStandardAssemblyPath(fileName); + if (assmPath != null) + path = assmPath; + } if (File.Exists(path)) { try @@ -81,6 +172,8 @@ namespace PascalABCCompiler.NetHelper } } + if (!missingAssemblies.Contains(fileName)) + missingAssemblies.Add(fileName); return null; } } diff --git a/TreeConverter/OpenMP/OpenMP.cs b/TreeConverter/OpenMP/OpenMP.cs index 4d29ce5e1..58919b951 100644 --- a/TreeConverter/OpenMP/OpenMP.cs +++ b/TreeConverter/OpenMP/OpenMP.cs @@ -1205,6 +1205,7 @@ namespace PascalABCCompiler.TreeConverter } return null; } + private static SyntaxTree.type_definition get_diapason(type_node sem_type) { if (sem_type is compiled_type_node) @@ -1223,6 +1224,7 @@ namespace PascalABCCompiler.TreeConverter } return null; } + /// /// Возвращает по семантическому типу соответсвующий ему синтаксический тип /// diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index e79299418..88435cdea 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -684,6 +684,15 @@ namespace PascalABCCompiler.TreeRealization } } + + public override string PrintableName + { + get + { + return "λ_anytype"; + } + } + public override string ToString() => "λ_anytype"; }