Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement IL codes for #91, #93, fix #105 #104

Open
wants to merge 46 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7ac3be8
Merge branch 'kekyo:devel' into devel
cyborgyn Oct 9, 2021
a2c5f30
Merge branch 'devel' of git://github.com/kekyo/IL2C into kekyo-devel
cyborgyn Oct 10, 2021
69cf5f0
Merge branch 'kekyo-devel' into devel
cyborgyn Oct 10, 2021
e29d09e
Merge pull request #3 from kekyo/devel
cyborgyn Oct 12, 2021
e7fef2b
Merge pull request #4 from cyborgyn/devel
cyborgyn Oct 12, 2021
69e814f
Fix double addition of the same DLL reference, in case the transpiled…
cyborgyn Oct 12, 2021
663563c
Fix discovery of implemented method in case of explicit interface imp…
cyborgyn Oct 12, 2021
4234755
Add bitwise NOT arithmetic operator
cyborgyn Oct 12, 2021
19c92d9
Implement shr, shl IL codes
cyborgyn Oct 12, 2021
f6bb406
Add starg and star.s IL codes
cyborgyn Oct 12, 2021
9091c5b
Fix for #105, stop endless loop, fix static constructor handling #97,…
cyborgyn Oct 13, 2021
bab32a0
Implement Shr.un and Neg IL codes
cyborgyn Oct 13, 2021
80e54b5
Implement Bgt.un and Bgt.un.s IL codes
cyborgyn Oct 13, 2021
c5ac124
Extend ConditionalConverters to handle float type parameters
cyborgyn Oct 13, 2021
e01dc9a
Fix typo
cyborgyn Oct 13, 2021
4833ba2
Implement Stind.i1-i8, Stind.r4-r8 IL codes
cyborgyn Oct 13, 2021
90bd0a3
Fix StargConverter
cyborgyn Oct 13, 2021
05ececc
Add Enum to int conversion handling to GetRightExpression()
cyborgyn Oct 13, 2021
f98e142
Fix NullReferenceException occurring in MethodSignatureTypeComparerIm…
cyborgyn Oct 13, 2021
df35a87
Fix InternalWriteVTableTypePreDefinitions() to correctly handle empty…
cyborgyn Oct 13, 2021
1a9cfe8
Enable IL2C_RUNTIME_TYPE_BEGIN writer, to handle compilation of Syste…
cyborgyn Oct 13, 2021
2a73440
Enable handling without error such cases, where BaseType == null
cyborgyn Oct 13, 2021
e8029c1
Implement Switch IL code, for #93 and #91 v0.1
cyborgyn Oct 13, 2021
e1b6cc4
Implement Ldobj and Stobj IL codes
cyborgyn Oct 14, 2021
30c0889
Updated supported-opcodes.md by Unit tests, no regression so far
cyborgyn Oct 14, 2021
08ea06a
Add switch IL code tests
cyborgyn Oct 14, 2021
ff75c55
Fix switch test + generator
cyborgyn Oct 14, 2021
5453d39
Ldobj IL code test + related fixes in converters
cyborgyn Oct 14, 2021
8e3bac8
Fix ldobj unit test
cyborgyn Oct 14, 2021
e0d75e0
More ldobj tests
cyborgyn Oct 15, 2021
1153f48
More Ldobj tests
cyborgyn Oct 15, 2021
b549284
Merge branch 'devel' into feature/implement-ilcodes
cyborgyn Oct 16, 2021
e43b30c
Merge pull request #5 from kekyo/devel
cyborgyn Oct 17, 2021
3c3a734
Merge pull request #6 from cyborgyn/devel
cyborgyn Oct 17, 2021
796f113
Add Stobj IL Code unit tests
cyborgyn Oct 17, 2021
dd83236
Add more TypeInitializer unit tests
cyborgyn Oct 17, 2021
73afbfb
Add Shr and Shr.un IL Code unit tests + fix for it's converter to mak…
cyborgyn Oct 18, 2021
a28587a
Updated supported-opcodes.md & supported-runtime-system-features.md
cyborgyn Oct 18, 2021
92ed390
Merge branch 'devel' into feature/implement-ilcodes
cyborgyn Oct 18, 2021
76eeee7
Add NOT ILCode unit tests
cyborgyn Oct 19, 2021
2b7b595
Remove breaking unit tests
cyborgyn Oct 19, 2021
3cf87a5
Merge branch 'feature/implement-ilcodes' of github.com:cyborgyn/IL2C …
cyborgyn Oct 19, 2021
bc1476f
Refactor ArithmeticalConverters/ NotConverter according to guidelines
cyborgyn Oct 19, 2021
9753e44
Tried to add more Shr unit tests, but discovery fails then for all ot…
cyborgyn Oct 19, 2021
4790411
Remove method filter comment also for AssemblyPreparer
cyborgyn Oct 19, 2021
ca5706c
StargConverter simplification
cyborgyn Oct 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions tests/IL2C.Core.Test.ILConverters/Not/Not.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@

namespace IL2C.ILConverters
{
[TestCase(~(sbyte)0x12, "Not_int8", (sbyte)0x12)]
[TestCase(~(byte)0x12, "Not_uint8", (byte)0x12)]
[TestCase(~(short)0x1234, "Not_int16", (short)0x1234)]
[TestCase(~(ushort)0x1234, "Not_uint16", (ushort)0x1234)]
// Breaks unit testing framework???
//[TestCase(~(sbyte)0x12, "Not_int8", (sbyte)0x12)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyborgyn The test case result expression (TestCase attribute first argument) is object type, so (comparing) value can makes final cast operator.

Result with C# interactive window:

> (~(sbyte)0x12).GetType().FullName
"System.Int32"

Therefore:

[TestCase((sbyte)~(sbyte)0x12, "Not_int8", (sbyte)0x12)]

//[TestCase(~(byte)0x12, "Not_uint8", (byte)0x12)]
//[TestCase(~(short)0x1234, "Not_int16", (short)0x1234)]
//[TestCase(~(ushort)0x1234, "Not_uint16", (ushort)0x1234)]
[TestCase(~(int)0x12345678, "Not_int32", (int)0x12345678)]
[TestCase(~(uint)0x12345678, "Not_uint32", (uint)0x12345678)]
[TestCase(~(long)0x12345678, "Not_int64", (long)0x12345678)]
[TestCase(~(ulong)0x12345678, "Not_uint64", (ulong)0x12345678)]
[TestCase(-1, "Not_IntPtr", 0)]
[TestCase(-1, "Not_UIntPtr", 0)]
// If I implement in IL, whole testing system goes down.
// C# compiler says: CS0023: Operator '~' cannot be applied to operand of type 'IntPtr'
//[TestCase(~IntPtr.Zero, "not_intptr", 0)]
Copy link
Owner

@kekyo kekyo Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntPtr couldn't make any constant value on .NET attribute. Because .NET attribute has to serialize argument into binary format, but IntPtr type is having to call constructor from any constant value.

In these cases, test framework will apply automatically conversion between IntPtr/UIntPtr and integer types at this then this.

Therefore:

[TestCase(~0, "not_intptr", 0)]

But IntPtr value be going to cause different result on runtime environment (test case on 32/64bit, native test is only 32bit gcc).

Unfortunately all test case disabled when IntPtr was used... I wrote this case:

// IL2C.BasicTypes.System_IntPtr
[TestCase(4, "SizeOf", Assert = TestCaseAsserts.IgnoreValidateInvokeResult)]    // Unit test environment is unknown, gcc is 32bit

IgnoreValidateInvokeResult flag will ignore regression test execution on CLR. Then test case result value can make from 32bit value.

//[TestCase(-1, "not_uintptr", (uint)0)]
public sealed class Not
{
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern sbyte Not_int8(sbyte v);

[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern byte Not_uin8(byte v);
public static extern byte Not_uint8(byte v);

[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern short Not_int16(short v);
Expand All @@ -43,10 +46,10 @@ public sealed class Not
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern ulong Not_uint64(ulong v);

[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern IntPtr Not_IntPtr(IntPtr v);
//[MethodImpl(MethodImplOptions.ForwardRef)]
//public static extern IntPtr Not_IntPtr(int v);

[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern UIntPtr Not_UIntPtr(UIntPtr v);
//[MethodImpl(MethodImplOptions.ForwardRef)]
//public static extern UIntPtr Not_UIntPtr(uint v);
}
}
51 changes: 1 addition & 50 deletions tests/IL2C.Core.Test.ILConverters/Not/Not.il
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
.class public IL2C.ILConverters.Not
{
.method public static int8 Not_int8(int8 v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}

.method public static uint8 Not_uint8(uint8 v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}

.method public static int16 Not_int16(int16 v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}

.method public static uint16 Not_uint16(uint16 v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}

.method public static int32 Not_int32(int32 v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}

.method public static uint32 Not_uint32(uint32 v) cil managed
{
.maxstack 1
Expand All @@ -63,21 +31,4 @@
not
ret
}
/*
.method public static native int Not_IntPtr(native int v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}

.method public static native uint Not_UIntPtr(native uint v) cil managed
{
.maxstack 1
ldarg.0
not
ret
}
*/
}