IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ManagedTypeResolver.cs
Go to the documentation of this file.
1using System;
2
6
7using Type = IKVM.Reflection.Type;
8
10{
11
13 {
14
15 readonly StaticCompiler compiler;
16 readonly Assembly baseAssembly;
17 readonly IkvmReflectionSymbolContext context = new();
18
24 public ManagedTypeResolver(StaticCompiler compiler, Assembly baseAssembly)
25 {
26 this.compiler = compiler ?? throw new ArgumentNullException(nameof(compiler));
27 this.baseAssembly = baseAssembly;
28 }
29
35 {
36 return baseAssembly != null ? context.GetOrCreateAssemblySymbol(baseAssembly) : null;
37 }
38
44 public IAssemblySymbol ResolveAssembly(string assemblyName)
45 {
46 return compiler.Load(assemblyName) is { } a ? context.GetOrCreateAssemblySymbol(a) : null;
47 }
48
54 public ITypeSymbol ResolveCoreType(string typeName)
55 {
56 foreach (var assembly in compiler.Universe.GetAssemblies())
57 if (assembly.GetType(typeName) is Type t)
58 return context.GetOrCreateTypeSymbol(t);
59
60 return null;
61 }
62
68 public ITypeSymbol ResolveRuntimeType(string typeName)
69 {
70 return compiler.GetRuntimeType(typeName) is { } t ? context.GetOrCreateTypeSymbol(t) : null;
71 }
72
73 }
74
75}
Holds references to symbols derived from System.Reflection.
ManagedTypeResolver(StaticCompiler compiler, Assembly baseAssembly)
Initializes a new instance.
ITypeSymbol ResolveRuntimeType(string typeName)
Attempts to resolve a type from the IKVM runtime assembly.
IAssemblySymbol ResolveBaseAssembly()
Attempts to resolve the base Java assembly.
ITypeSymbol ResolveCoreType(string typeName)
Attempts to resolve a type from one of the assembly sources.
IAssemblySymbol ResolveAssembly(string assemblyName)
Attempts to resolve an assembly from one of the assembly sources.
Holds the static compiler information.
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
Provides an interface to resolve a maaged type symbols.
Represents type declarations: class types, interface types, array types, value types,...