This commit is contained in:
Ivan Bondarev 2023-11-12 12:17:38 +01:00
parent 36c606fe4c
commit f3a18c9e33
9 changed files with 132 additions and 3 deletions

View file

@ -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)
{

BIN
TestSuite/Eto.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
TestSuite/errors/Eto.dll Normal file

Binary file not shown.

View file

@ -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.

4
TestSuite/eto.pas Normal file
View file

@ -0,0 +1,4 @@
{$reference Eto.dll}
begin
end.

View file

@ -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<string> missingAssemblies = new List<string>();
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;
}
}

View file

@ -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;
}
/// <summary>
/// Возвращает по семантическому типу соответсвующий ему синтаксический тип
/// </summary>

View file

@ -684,6 +684,15 @@ namespace PascalABCCompiler.TreeRealization
}
}
public override string PrintableName
{
get
{
return "λ_anytype";
}
}
public override string ToString() => "λ_anytype";
}