IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ManagedResolver.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2014 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25
28
29using Type = IKVM.Reflection.Type;
30
31namespace IKVM.Tools.Importer
32{
33
35 {
36
37 readonly StaticCompiler compiler;
38 readonly IkvmReflectionSymbolContext context = new();
39
45 {
46 this.compiler = compiler ?? throw new ArgumentNullException(nameof(compiler));
47 }
48
50 {
51 return compiler.baseAssembly != null ? context.GetOrCreateAssemblySymbol(compiler.baseAssembly) : null;
52 }
53
54 public IAssemblySymbol ResolveAssembly(string assemblyName)
55 {
56 return compiler.Universe.Load(assemblyName) is { } a ? context.GetOrCreateAssemblySymbol(a) : null;
57 }
58
59 public ITypeSymbol ResolveCoreType(string typeName)
60 {
61 foreach (var assembly in compiler.Universe.GetAssemblies())
62 if (assembly.GetType(typeName) is Type t)
63 return context.GetOrCreateTypeSymbol(t);
64
65 return null;
66 }
67
68 public ITypeSymbol ResolveRuntimeType(string typeName)
69 {
70 return compiler.GetRuntimeType(typeName) is { } t ? context.GetOrCreateTypeSymbol(t) : null;
71 }
72
73 }
74
75}
IKVM.Reflection.Type Type
Holds references to symbols derived from System.Reflection.
IAssemblySymbol ResolveBaseAssembly()
Resolves the known Java base assembly.
ITypeSymbol ResolveCoreType(string typeName)
Resolves the named type from any reference source.
IAssemblySymbol ResolveAssembly(string assemblyName)
Resolves the named assembly from any reference source.
ITypeSymbol ResolveRuntimeType(string typeName)
Resolves the named type from the IKVM runtime assembly.
ManagedResolver(StaticCompiler compiler)
Initializes a new instance.
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,...