Skip to content

Commit

Permalink
More splitting.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jan 8, 2024
1 parent 0a3cd96 commit ea59aec
Show file tree
Hide file tree
Showing 33 changed files with 982 additions and 491 deletions.
61 changes: 1 addition & 60 deletions src/IKVM.Reflection/Emit/AssemblyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,66 +750,7 @@ internal bool IsWindowsRuntime
{
get { return (flags & (AssemblyNameFlags)0x200) != 0; }
}
}

sealed class ManifestModule : NonPEModule
{
private readonly AssemblyBuilder assembly;
private readonly Guid guid = Guid.NewGuid();

internal ManifestModule(AssemblyBuilder assembly)
: base(assembly.universe)
{
this.assembly = assembly;
}

public override int MDStreamVersion
{
get { return assembly.mdStreamVersion; }
}

public override Assembly Assembly
{
get { return assembly; }
}

internal override Type FindType(TypeName typeName)
{
return null;
}

internal override Type FindTypeIgnoreCase(TypeName lowerCaseName)
{
return null;
}

internal override void GetTypesImpl(List<Type> list)
{
}

public override string FullyQualifiedName
{
get { return Path.Combine(assembly.dir, "RefEmit_InMemoryManifestModule"); }
}

public override string Name
{
get { return "<In Memory Module>"; }
}

public override Guid ModuleVersionId
{
get { return guid; }
}

public override string ScopeName
{
get { return "RefEmit_InMemoryManifestModule"; }
}

protected override Exception NotSupportedException()
{
return new InvalidOperationException();
}
}

}
36 changes: 36 additions & 0 deletions src/IKVM.Reflection/Emit/AssemblyBuilderAccess.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright (C) 2008 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
[email protected]
*/

namespace IKVM.Reflection.Emit
{

public enum AssemblyBuilderAccess
{

Save = 2,
ReflectionOnly = 6,

}

}
4 changes: 4 additions & 0 deletions src/IKVM.Reflection/Emit/ConstructorBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ Jeroen Frijters

namespace IKVM.Reflection.Emit
{

public sealed class ConstructorBuilder : ConstructorInfo
{

private readonly MethodBuilder methodBuilder;

internal ConstructorBuilder(MethodBuilder mb)
Expand Down Expand Up @@ -137,5 +139,7 @@ internal override MethodInfo GetMethodOnTypeDefinition()
{
return methodBuilder;
}

}

}
23 changes: 1 addition & 22 deletions src/IKVM.Reflection/Emit/CustomAttributeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,28 +736,7 @@ internal KnownCA KnownCA
return KnownCA.Unknown;
}
}
}

// These are the pseudo-custom attributes that are recognized by name by the runtime (i.e. the type identity is not considered).
// The corresponding list in the runtime is at https://github.com/dotnet/coreclr/blob/1afe5ce4f45045d724a4e129df4b816655d486fb/src/md/compiler/custattr_emit.cpp#L38
// Note that we only need to handle a subset of the types, since we don't need the ones that are only used for validation by the runtime.
enum KnownCA
{
Unknown,
DllImportAttribute,
ComImportAttribute,
SerializableAttribute,
NonSerializedAttribute,
MethodImplAttribute,
MarshalAsAttribute,
PreserveSigAttribute,
InAttribute,
OutAttribute,
OptionalAttribute,
StructLayoutAttribute,
FieldOffsetAttribute,
SpecialNameAttribute,
// the following is not part of the runtime known custom attributes, but we handle it here for efficiency and convenience
SuppressUnmanagedCodeSecurityAttribute,
}

}
4 changes: 4 additions & 0 deletions src/IKVM.Reflection/Emit/CustomModifiersBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ Jeroen Frijters

namespace IKVM.Reflection.Emit
{

public sealed class CustomModifiersBuilder
{

private readonly List<Item> list = new List<Item>();

internal struct Item
Expand Down Expand Up @@ -69,5 +71,7 @@ public CustomModifiers Create()
{
return new CustomModifiers(list);
}

}

}
4 changes: 4 additions & 0 deletions src/IKVM.Reflection/Emit/EnumBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ Jeroen Frijters
*/
namespace IKVM.Reflection.Emit
{

public sealed class EnumBuilder : TypeInfo
{

private readonly TypeBuilder typeBuilder;
private readonly FieldBuilder fieldBuilder;

Expand Down Expand Up @@ -116,5 +118,7 @@ internal override bool IsBaked
{
get { return typeBuilder.IsBaked; }
}

}

}
4 changes: 4 additions & 0 deletions src/IKVM.Reflection/Emit/EventBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Jeroen Frijters

namespace IKVM.Reflection.Emit
{

public sealed class EventBuilder : EventInfo
{

private readonly TypeBuilder typeBuilder;
private readonly string name;
private EventAttributes attributes;
Expand Down Expand Up @@ -274,5 +276,7 @@ internal override int GetCurrentToken()
return lazyPseudoToken;
}
}

}

}
68 changes: 68 additions & 0 deletions src/IKVM.Reflection/Emit/EventToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright (C) 2008 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
[email protected]
*/

namespace IKVM.Reflection.Emit
{
public struct EventToken
{

public static readonly EventToken Empty;
private readonly int token;

internal EventToken(int token)
{
this.token = token;
}

public int Token
{
get { return token; }
}

public override bool Equals(object obj)
{
return obj as EventToken? == this;
}

public override int GetHashCode()
{
return token;
}

public bool Equals(EventToken other)
{
return this == other;
}

public static bool operator ==(EventToken et1, EventToken et2)
{
return et1.token == et2.token;
}

public static bool operator !=(EventToken et1, EventToken et2)
{
return et1.token != et2.token;
}
}
}
3 changes: 3 additions & 0 deletions src/IKVM.Reflection/Emit/ExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Jeroen Frijters

namespace IKVM.Reflection.Emit
{

public struct ExceptionHandler : IEquatable<ExceptionHandler>
{

Expand Down Expand Up @@ -117,5 +118,7 @@ public override int GetHashCode()
{
return !left.Equals(right);
}

}

}
4 changes: 4 additions & 0 deletions src/IKVM.Reflection/Emit/FieldBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ Jeroen Frijters

namespace IKVM.Reflection.Emit
{

public sealed class FieldBuilder : FieldInfo
{

private readonly TypeBuilder typeBuilder;
private readonly string name;
private readonly int pseudoToken;
Expand Down Expand Up @@ -220,5 +222,7 @@ internal override bool IsBaked
{
get { return typeBuilder.IsBaked; }
}

}

}
67 changes: 67 additions & 0 deletions src/IKVM.Reflection/Emit/FieldToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright (C) 2008 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
[email protected]
*/

namespace IKVM.Reflection.Emit
{
public struct FieldToken
{
public static readonly FieldToken Empty;
private readonly int token;

internal FieldToken(int token)
{
this.token = token;
}

public int Token
{
get { return token; }
}

public override bool Equals(object obj)
{
return obj as FieldToken? == this;
}

public override int GetHashCode()
{
return token;
}

public bool Equals(FieldToken other)
{
return this == other;
}

public static bool operator ==(FieldToken ft1, FieldToken ft2)
{
return ft1.token == ft2.token;
}

public static bool operator !=(FieldToken ft1, FieldToken ft2)
{
return ft1.token != ft2.token;
}
}
}
Loading

0 comments on commit ea59aec

Please sign in to comment.