forked from mono/mono
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mono.Compiler] add simple test that fails
- Loading branch information
Showing
9 changed files
with
62 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
mcs/class/Mono.Compiler/Mono.Compiler/CompilerToRuntime.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ICompilerInterfaceTest.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |