Skip to content

Commit

Permalink
Fix marshalling enums to StackSlots
Browse files Browse the repository at this point in the history
  • Loading branch information
puff committed Jul 14, 2023
1 parent 8febe6c commit d7e19e8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@ private TypeSignature GetElementType(TypeSignature type)
{
switch (type.ElementType)
{
case ElementType.Enum:
case ElementType.ValueType:
if (!_resolvedTypes.TryGetValue(type, out var definition))
{
definition = type.Resolve();
if (definition is not null)
_resolvedTypes.Add(type, definition);
}

if (definition?.GetEnumUnderlyingType() is not { } enumUnderlyingType)
if (!definition?.IsEnum ?? true)
return type;

if (definition.GetEnumUnderlyingType() is not { } enumUnderlyingType)

Check warning on line 42 in src/Platforms/Echo.Platforms.AsmResolver/Emulation/CliMarshaller.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 42 in src/Platforms/Echo.Platforms.AsmResolver/Emulation/CliMarshaller.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 42 in src/Platforms/Echo.Platforms.AsmResolver/Emulation/CliMarshaller.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
throw new CilEmulatorException($"Could not resolve enum type {type.FullName}.");

return GetElementType(enumUnderlyingType);
return enumUnderlyingType;

default:
return type;
Expand Down

0 comments on commit d7e19e8

Please sign in to comment.