Skip to content

Commit

Permalink
Fixes and tests
Browse files Browse the repository at this point in the history
- Add quick fix to Stfld transformation
- Add test to ValueTypeTests to test for structs that contain struct
type fields
  • Loading branch information
charsleysa committed Sep 25, 2016
1 parent fdf1e8e commit 79e6794
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -1549,7 +1549,7 @@ private void Stfld(Context context)
}
else
{
var storeInstruction = GetStoreInstruction(context.Operand1.Type);
var storeInstruction = GetStoreInstruction(fieldType);
context.SetInstruction(storeInstruction, size, null, objectOperand, offsetOperand, valueOperand);
context.MosaType = fieldType;
}
Expand Down
20 changes: 20 additions & 0 deletions Source/Mosa.UnitTest.Collection/ValueTypeTests.cs
Expand Up @@ -27,6 +27,11 @@ private class wrapper
public valuetype content;
}

private struct valuewrapper
{
public valuetype content;
}

public static bool TestValueTypeVariable()
{
valuetype p = new valuetype();
Expand Down Expand Up @@ -64,6 +69,21 @@ public static bool TestValueTypeInstanceField()
return obj.content.a == 1 && obj.content.b == 7 & obj.content.c == 21 && obj.content.d == 171;
}

public static bool TestNestedValueTypeField()
{
valuetype p = new valuetype();
p.a = 1;
p.b = 7;
p.c = 21;
p.d = 171;

valuewrapper val = new valuewrapper();
val.content = p;

valuetype r = val.content;
return r.a == 1 && r.b == 7 & r.c == 21 && r.d == 171;
}

private static bool ParameterOk(valuetype p)
{
return p.a == 1 && p.b == 7 & p.c == 21 && p.d == 171;
Expand Down

0 comments on commit 79e6794

Please sign in to comment.