Skip to content

Commit

Permalink
[Mono.Compiler] add simple test that fails
Browse files Browse the repository at this point in the history
  • Loading branch information
lewurm committed Jul 22, 2018
1 parent 8367208 commit 0dc97ba
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 39 deletions.
2 changes: 1 addition & 1 deletion mcs/class/Mono.Compiler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LIBRARY_WARN_AS_ERROR = yes
KEYFILE = $(LIBRARY_SNK)

LIB_REFS =
LIB_MCS_FLAGS = /publicsign /nowarn:0618
LIB_MCS_FLAGS = /publicsign /nowarn:0618 /unsafe

XTEST_LIB_REFS =

Expand Down
14 changes: 0 additions & 14 deletions mcs/class/Mono.Compiler/Mono.Compiler.Aot/AotModule.cs

This file was deleted.

21 changes: 0 additions & 21 deletions mcs/class/Mono.Compiler/Mono.Compiler.Aot/AotRuntime.cs

This file was deleted.

3 changes: 2 additions & 1 deletion mcs/class/Mono.Compiler/Mono.Compiler.dll.sources
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ Assembly/AssemblyInfo.cs
Mono.Compiler/CompilationFlags.cs
Mono.Compiler/CompilationResult.cs
Mono.Compiler/CompilerInformation.cs
Mono.Compiler/CompilerToRuntime.cs
Mono.Compiler/ICompiler.cs
Mono.Compiler/ICompilerInformation.cs
Mono.Compiler/IDynamicInformation.cs
Mono.Compiler/IStaticInformation.cs
Mono.Compiler/MethodInfo.cs
Mono.Compiler.Aot/AotRuntime.cs
Mono.Compiler/NativeCodeHandle.cs
15 changes: 15 additions & 0 deletions mcs/class/Mono.Compiler/Mono.Compiler/CompilerToRuntime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace Mono.Compiler {
public class CompilerToRuntime {
public bool InstallCompilationResult (CompilationResult compilationResult, NativeCodeHandle codeHandle)
{
throw new Exception ("not implemented yet");

}

public object ExecuteInstalledMethod (NativeCodeHandle codeHandle, params object[] args) {
throw new Exception ("icall into runtime");
}
}
}
2 changes: 1 addition & 1 deletion mcs/class/Mono.Compiler/Mono.Compiler/ICompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Mono.Compiler
{
public interface ICompiler
{
CompilationResult CompileMethod (ICompilerInformation compilerInfo, MethodInfo methodInfo, CompilationFlags flags, out byte nativeCode, out ulong nativeCodeSize);
CompilationResult CompileMethod (ICompilerInformation compilerInfo, MethodInfo methodInfo, CompilationFlags flags, out NativeCodeHandle nativeCode);
}
}
11 changes: 11 additions & 0 deletions mcs/class/Mono.Compiler/Mono.Compiler/NativeCodeHandle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Mono.Compiler {
public unsafe class NativeCodeHandle {
private byte *blob;
private long length;

public unsafe NativeCodeHandle (byte *codeBlob, long codeLength) {
this.blob = codeBlob;
this.length = codeLength;
}
}
}
1 change: 1 addition & 0 deletions mcs/class/Mono.Compiler/Mono.Compiler_test.dll.sources
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ICompilerInterfaceTest.cs
32 changes: 31 additions & 1 deletion mcs/class/Mono.Compiler/Test/ICompilerInterfaceTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
using System;
using NUnit.Framework;
using Mono.Compiler;

namespace MonoTests.Mono.CompilerInterface
{
[TestFixture]
public class ICompilerTests
{
CompilerToRuntime c2r = null;
ICompiler compiler = null;

[TestFixtureSetUp]
public void Init () {
c2r = new CompilerToRuntime ();
// TODO: compiler == ??
}


public int AddMethod (int a, int b) {
return a + b;
}

[Test]
public void TestAddMethod () {
ICompilerInformation cinfo = null;
MethodInfo methodInfo = null; // TODO: get EmptyMethod somehow?
NativeCodeHandle nativeCode;

CompilationResult result = compiler.CompileMethod (cinfo, methodInfo, CompilationFlags.None, out nativeCode);
bool installation = c2r.InstallCompilationResult (result, nativeCode);
Assert.True (installation);

int addition = (int) c2r.ExecuteInstalledMethod (nativeCode, 1, 2);
Assert.Equals (addition, 3);
}
}
}
}

0 comments on commit 0dc97ba

Please sign in to comment.