Skip to content

Commit

Permalink
Fixed Ourpalm#278
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Sep 25, 2019
1 parent 51353c4 commit 9cae9ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ILRuntime/Runtime/Intepreter/ILIntepreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public object Run(ILMethod method, object instance, object[] p)
for (int i = 0; i < method.LocalVariableCount; i++)
{
var v = method.Variables[i];
if (v.VariableType.IsValueType && !v.VariableType.IsPrimitive)
bool isEnum = (v.VariableType is Mono.Cecil.TypeDefinition td) ? td.IsEnum : false;
if (v.VariableType.IsValueType && !v.VariableType.IsPrimitive && !isEnum)
{
var t = AppDomain.GetType(v.VariableType, method.DeclearingType, method);
if (t is ILType)
Expand Down Expand Up @@ -210,7 +211,7 @@ public object Run(ILMethod method, object instance, object[] p)
}
else
{
if (v.VariableType.IsPrimitive)
if (v.VariableType.IsPrimitive || isEnum)
{
var t = AppDomain.GetType(v.VariableType, method.DeclearingType, method);
var loc = Add(v1, i);
Expand Down
20 changes: 20 additions & 0 deletions TestCases/EnumTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ public static void Test16()
Console.WriteLine(item);
}
}

public static void Test17()
{
/*Dictionary<TestEnum, int> dic = new Dictionary<TestEnum, int>();
dic[TestEnum.Enum2] = 123;
int res;
if (dic.TryGetValue(TestEnum.Enum2, out res))
{
Console.WriteLine(res);
}*/

//下面这个用例跑不过
Dictionary<string, TestEnum> dic2 = new Dictionary<string, TestEnum>();
dic2["abc"] = TestEnum.Enum1;
TestEnum e;
if (dic2.TryGetValue("abc", out e))
{
Console.WriteLine(e);
}
}
class SystemType
{
public int value = 10;
Expand Down

0 comments on commit 9cae9ff

Please sign in to comment.