Skip to content

Commit

Permalink
Fixed #293
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Apr 1, 2020
1 parent 70bfd54 commit edd9852
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ILRuntime/Runtime/Stack/StackObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public unsafe static void Initialized(ref StackObject esp, int idx, Type t, ITyp
public unsafe static void Initialized(StackObject* esp, IType type)
{
var t = type.TypeForCLR;
if (type.IsPrimitive || type.IsEnum)

if (type.IsPrimitive)
{
if (t == typeof(int) || t == typeof(uint) || t == typeof(short) || t == typeof(ushort) || t == typeof(byte) || t == typeof(sbyte) || t == typeof(char) || t == typeof(bool))
{
Expand Down Expand Up @@ -218,6 +219,12 @@ public unsafe static void Initialized(StackObject* esp, IType type)
else
throw new NotImplementedException();
}
else if (type.IsEnum)
{
esp->ObjectType = ObjectTypes.Integer;
esp->Value = 0;
esp->ValueLow = 0;
}
else
{
*esp = Null;
Expand Down
11 changes: 11 additions & 0 deletions TestCases/Structs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,16 @@ public static void StructTest4()
{
Console.WriteLine(Number.minValue.val);
}

struct EnumTestStruct
{
public ILRuntimeTest.TestFramework.TestCLREnum value;
}

public static void StructTest5()
{
EnumTestStruct val = new EnumTestStruct();
Console.WriteLine(val.value);
}
}
}

0 comments on commit edd9852

Please sign in to comment.