mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +00:00
Exceptions work, no finally/catch support yet, though
This commit is contained in:
parent
f96ba2ecfd
commit
af530d3847
38 changed files with 464 additions and 89 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
# ----------- Compile with IL2CPU
|
# ----------- Compile with IL2CPU
|
||||||
remove-item output.asm -ea SilentlyContinue
|
remove-item output.asm -ea SilentlyContinue
|
||||||
|
|
||||||
..\..\source\il2cpu\bin\Debug\il2cpu "-in:..\..\source\Cosmos\Cosmos.Shell.Console\bin\Debug\Cosmos.Shell.Console.exe" "-plug:..\..\source\Cosmos\Cosmos.Kernel.Plugs\bin\Debug\Cosmos.Kernel.Plugs.dll" "-out:output.obj" "-platform:nativex86" "-asm:.\"
|
..\..\source\il2cpu\bin\Debug\il2cpu "-in:..\..\source\Cosmos\Cosmos.Shell.Console\bin\Debug\Cosmos.Shell.Console.exe" "-plug:..\..\source\Cosmos\Cosmos.Kernel.Plugs\bin\Debug\Cosmos.Kernel.Plugs.dll" "-out:output.obj" "-platform:nativex86" "-asm:.\asm"
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,15 @@ namespace Cosmos.Hardware.Screen {
|
||||||
public const int Columns = 80;
|
public const int Columns = 80;
|
||||||
public const int Lines = 24;
|
public const int Lines = 24;
|
||||||
public const uint VideoAddr = 0xB8000;
|
public const uint VideoAddr = 0xB8000;
|
||||||
private static uint Color = 7;
|
private static byte Color = 7;
|
||||||
|
|
||||||
public static unsafe void Clear() {
|
public static unsafe void Clear() {
|
||||||
for (int i = 0; i < Columns * Lines * 2; i++) {
|
for (int i = 0; i < Columns * Lines; i++) {
|
||||||
byte* xScreenPtr = (byte*)VideoAddr;
|
byte* xScreenPtr = (byte*)VideoAddr;
|
||||||
xScreenPtr += i;
|
xScreenPtr += i*2;
|
||||||
*xScreenPtr = 0;
|
*xScreenPtr = 0;
|
||||||
|
xScreenPtr += 1;
|
||||||
|
*xScreenPtr = Color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +30,7 @@ namespace Cosmos.Hardware.Screen {
|
||||||
byte* xScreenPtr = (byte*)(VideoAddr + (i + Lines * Columns) * 2);
|
byte* xScreenPtr = (byte*)(VideoAddr + (i + Lines * Columns) * 2);
|
||||||
*xScreenPtr = 0;
|
*xScreenPtr = 0;
|
||||||
xScreenPtr += 1;
|
xScreenPtr += 1;
|
||||||
*xScreenPtr = 0;
|
*xScreenPtr = Color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,12 +40,11 @@ namespace Cosmos.Hardware.Screen {
|
||||||
byte xVal = (byte)aChar;
|
byte xVal = (byte)aChar;
|
||||||
*xScreenPtr = (byte)(xVal & 0xFF);
|
*xScreenPtr = (byte)(xVal & 0xFF);
|
||||||
xScreenPtr += 1;
|
xScreenPtr += 1;
|
||||||
*xScreenPtr = (byte)Color;
|
*xScreenPtr = Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetColors(ConsoleColor foreground, ConsoleColor background)
|
public static void SetColors(ConsoleColor foreground, ConsoleColor background) {
|
||||||
{
|
Color = (byte)((byte)foreground | ((byte)background << 4));
|
||||||
Color = (uint)((byte)foreground | ((byte)background << 4));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Cosmos.Kernel.Plugs.Assemblers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aErrorWhenNotFound) {
|
if (aErrorWhenNotFound) {
|
||||||
throw new Exception("Method '" + aType + "::" + aMethodName + "' not found!");
|
throw new System.Exception("Method '" + aType + "::" + aMethodName + "' not found!");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,14 @@ namespace Cosmos.Kernel.Plugs {
|
||||||
return TextScreen.CurrentLine;
|
return TextScreen.CurrentLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int get_WindowHeight() {
|
||||||
|
return TextScreen.WindowHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int get_WindowWidth() {
|
||||||
|
return TextScreen.WindowWidth;
|
||||||
|
}
|
||||||
|
|
||||||
public static void set_CursorTop(int y) {
|
public static void set_CursorTop(int y) {
|
||||||
TextScreen.CurrentLine = y;
|
TextScreen.CurrentLine = y;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,18 @@ namespace Cosmos.Kernel {
|
||||||
public static int CurrentLine = 0;
|
public static int CurrentLine = 0;
|
||||||
public static int CurrentChar = 0;
|
public static int CurrentChar = 0;
|
||||||
|
|
||||||
|
public static int WindowHeight {
|
||||||
|
get {
|
||||||
|
return HW.Text.Lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int WindowWidth {
|
||||||
|
get {
|
||||||
|
return HW.Text.Columns;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the console colors.
|
/// Sets the console colors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ namespace Cosmos.Shell.Console.Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(string param) {
|
public override void Execute(string param) {
|
||||||
Kernel.FileSystem.TestsMatthijs.TestNewATA();
|
//Kernel.FileSystem.TestsMatthijs.TestNewATA();
|
||||||
|
//System.Diagnostics.Debugger.Break();
|
||||||
|
throw new Exception("Hello, Error!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help() {
|
public override void Help() {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ namespace Indy.IL2CPU.Assembler.X86.Native {
|
||||||
: base(aGetStreamForGroup) {
|
: base(aGetStreamForGroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override void EmitCodeSectionHeader(string aGroup, StreamWriter aOutputWriter) {
|
protected override void EmitCodeSectionHeader(string aGroup, StreamWriter aOutputWriter) {
|
||||||
base.EmitCodeSectionHeader(aGroup, aOutputWriter);
|
base.EmitCodeSectionHeader(aGroup, aOutputWriter);
|
||||||
aOutputWriter.WriteLine("section .text");
|
aOutputWriter.WriteLine("section .text");
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Indy.IL2CPU.Assembler.X86 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetValidGroupName(string aGroup) {
|
private static string GetValidGroupName(string aGroup) {
|
||||||
return aGroup;
|
return aGroup.Replace('-','_').Replace('.', '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void EmitHeader(string aGroup, StreamWriter aOutputWriter) {
|
protected override void EmitHeader(string aGroup, StreamWriter aOutputWriter) {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="i4o, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\Tools\I4O\i4o.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ namespace Indy.IL2CPU.Assembler.X86 {
|
||||||
protected JumpBase(string aAddress) {
|
protected JumpBase(string aAddress) {
|
||||||
Address = aAddress;
|
Address = aAddress;
|
||||||
if (Address.StartsWith(".")) {
|
if (Address.StartsWith(".")) {
|
||||||
string xPrefix = (from item in Assembler.CurrentInstance.Instructions
|
//string xPrefix = (from item in Assembler.CurrentInstance.Instructions
|
||||||
let xTheLabel = item.Value as Label
|
// where !Label.GetLabel(item).StartsWith(".")
|
||||||
where xTheLabel != null && !xTheLabel.Name.StartsWith(".")
|
// select Label.GetLabel(item)).Last();
|
||||||
select xTheLabel.Name).Last();
|
string xPrefix = Label.LastFullLabel;
|
||||||
Address = xPrefix + "__DOT__" + Address.Substring(1);
|
Address = xPrefix + "__DOT__" + Address.Substring(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,65 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using i4o;
|
using i4o;
|
||||||
|
using Mono.Cecil;
|
||||||
|
|
||||||
namespace Indy.IL2CPU.Assembler {
|
namespace Indy.IL2CPU.Assembler {
|
||||||
public abstract class Assembler: IDisposable {
|
public abstract class Assembler: IDisposable {
|
||||||
|
// TODO: When threading is being worked on, fix this to work multithreaded!
|
||||||
|
//public const string CurrentExceptionDataMember = "__CURRENT_EXCEPTION__";
|
||||||
|
public static Exception CurrentException;
|
||||||
|
public static void PrintException() {
|
||||||
|
Console.BackgroundColor = ConsoleColor.Blue;
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
string xClearLine = new String(' ', Console.WindowWidth);
|
||||||
|
for (int i = 0; i < Console.WindowHeight; i++) {
|
||||||
|
Console.Write(" ");
|
||||||
|
}
|
||||||
|
//Console.Clear();
|
||||||
|
System.Console.WriteLine("Cosmos Kernel. Copyright 2008 The Cosmos Project.");
|
||||||
|
System.Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("BSOD's Rule!");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.Write("Unhandled error occurred: ");
|
||||||
|
Console.WriteLine(CurrentException.ToString());
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("");
|
||||||
|
}
|
||||||
|
private static FieldDefinition mCurrentExceptionRef;
|
||||||
|
public static FieldDefinition CurrentExceptionRef {
|
||||||
|
get {
|
||||||
|
if (mCurrentExceptionRef == null) {
|
||||||
|
AssemblyDefinition xAsm = AssemblyFactory.GetAssembly(typeof(Assembler).Assembly.Location);
|
||||||
|
foreach (ModuleDefinition xMod in xAsm.Modules) {
|
||||||
|
if (xMod.Types.Contains(typeof(Assembler).FullName)) {
|
||||||
|
mCurrentExceptionRef = xMod.Types[typeof(Assembler).FullName].Fields.GetField("CurrentException");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mCurrentExceptionRef == null) {
|
||||||
|
throw new Exception("Couldn't find CurrentException field!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mCurrentExceptionRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
public const string EntryPointName = "__ENGINE_ENTRYPOINT__";
|
public const string EntryPointName = "__ENGINE_ENTRYPOINT__";
|
||||||
protected List<KeyValuePair<string, Instruction>> mInstructions = new List<KeyValuePair<string, Instruction>>();
|
protected IndexableCollection<KeyValuePair<string, Instruction>> mInstructions = new IndexableCollection<KeyValuePair<string, Instruction>>();
|
||||||
private IndexableCollection<KeyValuePair<string, DataMember>> mDataMembers = new IndexableCollection<KeyValuePair<string, DataMember>>();
|
private IndexableCollection<KeyValuePair<string, DataMember>> mDataMembers = new IndexableCollection<KeyValuePair<string, DataMember>>();
|
||||||
private List<KeyValuePair<string, string>> mIncludes = new List<KeyValuePair<string, string>>();
|
private List<KeyValuePair<string, string>> mIncludes = new List<KeyValuePair<string, string>>();
|
||||||
private IndexableCollection<KeyValuePair<string, ImportMember>> mImportMembers = new IndexableCollection<KeyValuePair<string, ImportMember>>();
|
private IndexableCollection<KeyValuePair<string, ImportMember>> mImportMembers = new IndexableCollection<KeyValuePair<string, ImportMember>>();
|
||||||
|
|
@ -37,9 +91,10 @@ namespace Indy.IL2CPU.Assembler {
|
||||||
mGetFileNameForGroup = aGetFileNameForGroup;
|
mGetFileNameForGroup = aGetFileNameForGroup;
|
||||||
mInMetalMode = aInMetalMode;
|
mInMetalMode = aInMetalMode;
|
||||||
CurrentInstance = this;
|
CurrentInstance = this;
|
||||||
|
//mInstructions.AddComplexIndexDefinition(
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<KeyValuePair<string, Instruction>> Instructions {
|
public IndexableCollection<KeyValuePair<string, Instruction>> Instructions {
|
||||||
get {
|
get {
|
||||||
return mInstructions;
|
return mInstructions;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,31 @@ namespace Indy.IL2CPU.Assembler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetLabel(object aObject) {
|
||||||
|
Label xLabel = aObject as Label;
|
||||||
|
if (xLabel == null)
|
||||||
|
return "";
|
||||||
|
return xLabel.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string LastFullLabel {
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public Label(string aName) {
|
public Label(string aName) {
|
||||||
mName = aName;
|
mName = aName;
|
||||||
|
if (!aName.StartsWith(".")) {
|
||||||
|
LastFullLabel = aName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return Name + ":";
|
return Name + ":";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Label(string aType, params string[] aParamTypes) {
|
public Label(string aType, params string[] aParamTypes)
|
||||||
mName = Init(aType, typeof(void).FullName, ".ctor", aParamTypes);
|
: this(Init(aType, typeof(void).FullName, ".ctor", aParamTypes)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateLabelName(MethodReference aMethod) {
|
public static string GenerateLabelName(MethodReference aMethod) {
|
||||||
|
|
@ -36,16 +51,16 @@ namespace Indy.IL2CPU.Assembler {
|
||||||
return Init(aMethod.DeclaringType.FullName, aMethod.ReturnType.ReturnType.FullName, aMethod.Name, xParams.ToArray());
|
return Init(aMethod.DeclaringType.FullName, aMethod.ReturnType.ReturnType.FullName, aMethod.Name, xParams.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Label(MethodReference aMethod) {
|
public Label(MethodReference aMethod)
|
||||||
mName = GenerateLabelName(aMethod);
|
: this(GenerateLabelName(aMethod)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Label(string aType, string aMethodName, params string[] aParamTypes) {
|
public Label(string aType, string aMethodName, params string[] aParamTypes)
|
||||||
mName = Init(aType, typeof(void).FullName, aMethodName, aParamTypes);
|
: this(Init(aType, typeof(void).FullName, aMethodName, aParamTypes)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Label(string aType, string aReturnType, string aMethodName, params string[] aParamTypes) {
|
public Label(string aType, string aReturnType, string aMethodName, params string[] aParamTypes)
|
||||||
mName = Init(aType, aReturnType, aMethodName, aParamTypes);
|
: this(Init(aType, aReturnType, aMethodName, aParamTypes)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static string Init(string aType, string aReturnType, string aMethodName, params string[] aParamTypes) {
|
protected static string Init(string aType, string aReturnType, string aMethodName, params string[] aParamTypes) {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,10 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
}
|
}
|
||||||
public void Assemble(string aMethod, int aArgumentCount) {
|
public void Assemble(string aMethod, int aArgumentCount) {
|
||||||
new CPUx86.Call(aMethod);
|
new CPUx86.Call(aMethod);
|
||||||
|
if (!Assembler.InMetalMode) {
|
||||||
|
new CPUx86.Test("ecx", "2");
|
||||||
|
new CPUx86.JumpIfNotEquals(MethodFooterOp.EndOfMethodLabelNameException);
|
||||||
|
}
|
||||||
for (int i = 0; i < aArgumentCount; i++) {
|
for (int i = 0; i < aArgumentCount; i++) {
|
||||||
Assembler.StackSizes.Pop();
|
Assembler.StackSizes.Pop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
private readonly int mThisOffset;
|
private readonly int mThisOffset;
|
||||||
private readonly int mArgumentCount;
|
private readonly int mArgumentCount;
|
||||||
private readonly int mReturnSize;
|
private readonly int mReturnSize;
|
||||||
|
private readonly string mLabelName;
|
||||||
public Callvirt(Instruction aInstruction, MethodInformation aMethodInfo)
|
public Callvirt(Instruction aInstruction, MethodInformation aMethodInfo)
|
||||||
: base(aInstruction, aMethodInfo) {
|
: base(aInstruction, aMethodInfo) {
|
||||||
|
mLabelName = GetInstructionLabel(aInstruction);
|
||||||
int xThisOffSet = (from item in aMethodInfo.Locals
|
int xThisOffSet = (from item in aMethodInfo.Locals
|
||||||
select item.Offset + item.Size).LastOrDefault();
|
select item.Offset + item.Size).LastOrDefault();
|
||||||
MethodReference xMethod = aInstruction.Operand as MethodReference;
|
MethodReference xMethod = aInstruction.Operand as MethodReference;
|
||||||
|
|
@ -53,6 +55,10 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
new CPUx86.Call(CPU.Label.GenerateLabelName(VTablesImplRefs.GetMethodAddressForTypeRef));
|
new CPUx86.Call(CPU.Label.GenerateLabelName(VTablesImplRefs.GetMethodAddressForTypeRef));
|
||||||
new CPUx86.Call(CPUx86.Registers.EAX);
|
new CPUx86.Call(CPUx86.Registers.EAX);
|
||||||
}
|
}
|
||||||
|
if (!Assembler.InMetalMode) {
|
||||||
|
new CPUx86.Test("ecx", "2");
|
||||||
|
new CPUx86.JumpIfNotEquals(MethodFooterOp.EndOfMethodLabelNameException);
|
||||||
|
}
|
||||||
for (int i = 0; i < mArgumentCount; i++) {
|
for (int i = 0; i < mArgumentCount; i++) {
|
||||||
Assembler.StackSizes.Pop();
|
Assembler.StackSizes.Pop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.X86.CustomImplementations.System {
|
||||||
|
[Plug(Target = typeof(Exception))]
|
||||||
|
public static class ExceptionImpl {
|
||||||
|
public static string ToString(Exception aThis) {
|
||||||
|
return aThis.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
[PlugMethod(Signature = "System_String___System_Exception_GetClassName____")]
|
||||||
|
public static unsafe string GetClassName(uint* aThis) {
|
||||||
|
int xObjectType = (int)*aThis;
|
||||||
|
return VTablesImpl.GetTypeName(xObjectType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -139,6 +139,7 @@
|
||||||
<Compile Include="CustomImplementations\System\Buffer.cs" />
|
<Compile Include="CustomImplementations\System\Buffer.cs" />
|
||||||
<Compile Include="CustomImplementations\System\DelegateImpl.cs" />
|
<Compile Include="CustomImplementations\System\DelegateImpl.cs" />
|
||||||
<Compile Include="CustomImplementations\System\EnumImpl.cs" />
|
<Compile Include="CustomImplementations\System\EnumImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\ExceptionImpl.cs" />
|
||||||
<Compile Include="CustomImplementations\System\MulticastDelegateImpl.cs" />
|
<Compile Include="CustomImplementations\System\MulticastDelegateImpl.cs" />
|
||||||
<Compile Include="CustomImplementations\System\MulticastDelegateImplRefs.cs" />
|
<Compile Include="CustomImplementations\System\MulticastDelegateImplRefs.cs" />
|
||||||
<Compile Include="CustomImplementations\System\EventHandlerImpl.cs" />
|
<Compile Include="CustomImplementations\System\EventHandlerImpl.cs" />
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
: base(aInstruction, aMethodInfo) {
|
: base(aInstruction, aMethodInfo) {
|
||||||
}
|
}
|
||||||
public override void DoAssemble() {
|
public override void DoAssemble() {
|
||||||
new CPU.JumpAlways(".END__OF__METHOD");
|
new CPU.JumpAlways(MethodFooterOp.EndOfMethodLabelNameNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,26 +3,25 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Mono.Cecil;
|
using Mono.Cecil;
|
||||||
using Mono.Cecil.Cil;
|
using Mono.Cecil.Cil;
|
||||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
using CPU = Indy.IL2CPU.Assembler;
|
||||||
|
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||||
|
|
||||||
namespace Indy.IL2CPU.IL.X86 {
|
namespace Indy.IL2CPU.IL.X86 {
|
||||||
[OpCode(Code.Throw, false)]
|
[OpCode(Code.Throw, false)]
|
||||||
public class Throw: Op {
|
public class Throw: Op {
|
||||||
// TODO: When threading is being worked on, fix this to work multithreaded!
|
|
||||||
public const string CurrentExceptionDataMember = "__CURRENT_EXCEPTION__";
|
|
||||||
|
|
||||||
public Throw(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
public Throw(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||||
: base(aInstruction, aMethodInfo) {
|
: base(aInstruction, aMethodInfo) {
|
||||||
}
|
}
|
||||||
public override void DoAssemble() {
|
public override void DoAssemble() {
|
||||||
if ((from item in Assembler.DataMembers
|
//if ((from item in Assembler.DataMembers
|
||||||
where item.Value.Name == CurrentExceptionDataMember
|
// where item.Value.Name == CPU.Assembler.CurrentExceptionDataMember
|
||||||
select item).Count() == 0) {
|
// select item).Count() == 0) {
|
||||||
Assembler.DataMembers.Add(new System.Collections.Generic.KeyValuePair<string, Indy.IL2CPU.Assembler.DataMember>("il2cpu-system", new Indy.IL2CPU.Assembler.DataMember(CurrentExceptionDataMember, "dd", "0")));
|
// Assembler.DataMembers.Add(new System.Collections.Generic.KeyValuePair<string, Indy.IL2CPU.Assembler.DataMember>("il2cpu-system", new Indy.IL2CPU.Assembler.DataMember(CPU.Assembler.CurrentExceptionDataMember, "dd", "0")));
|
||||||
}
|
//}
|
||||||
new CPU.Pop("eax");
|
new CPUx86.Pop("eax");
|
||||||
new CPU.Move("[" + CurrentExceptionDataMember + "]", "eax");
|
new CPUx86.Move("[" + CPU.DataMember.GetStaticFieldName(CPU.Assembler.CurrentExceptionRef) + "]", "eax");
|
||||||
new CPU.JumpAlways(MethodFooterOp.EndOfMethodLabelNameException);
|
new CPUx86.Move("ecx", "3");
|
||||||
|
new CPUx86.JumpAlways(MethodFooterOp.EndOfMethodLabelNameException);
|
||||||
Assembler.StackSizes.Pop();
|
Assembler.StackSizes.Pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,20 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
new CPUx86.Pushd(aValue);
|
new CPUx86.Pushd(aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int xLabelId = 0;
|
||||||
|
|
||||||
public override void Call(MethodDefinition aMethod) {
|
public override void Call(MethodDefinition aMethod) {
|
||||||
Engine.QueueMethod(aMethod);
|
Engine.QueueMethod(aMethod);
|
||||||
Call(CPU.Label.GenerateLabelName(aMethod));
|
Call(CPU.Label.GenerateLabelName(aMethod));
|
||||||
|
if (!Assembler.InMetalMode) {
|
||||||
|
new CPUx86.Test("ecx", "2");
|
||||||
|
string xLabel = ".Call_Part2_" + xLabelId++.ToString();
|
||||||
|
new CPUx86.JumpIfEquals(xLabel);
|
||||||
|
new CPUx86.Call("_CODE_REQUESTED_BREAK_");
|
||||||
|
Engine.QueueMethod(Engine.GetMethodDefinition(Engine.GetTypeDefinitionFromReflectionType(typeof(Assembler.Assembler)), "PrintException"));
|
||||||
|
new CPUx86.Call(CPU.Label.GenerateLabelName(Engine.GetMethodDefinition(Engine.GetTypeDefinitionFromReflectionType(typeof(Assembler.Assembler)), "PrintException")));
|
||||||
|
new CPU.Label(xLabel);
|
||||||
|
}
|
||||||
if(!aMethod.ReturnType.ReturnType.FullName.StartsWith("System.Void")) {
|
if(!aMethod.ReturnType.ReturnType.FullName.StartsWith("System.Void")) {
|
||||||
new CPUx86.Pushd(CPUx86.Registers.EAX);
|
new CPUx86.Pushd(CPUx86.Registers.EAX);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
//new CPUx86.JumpAlways("._GENERIC_Footer");
|
//new CPUx86.JumpAlways("._GENERIC_Footer");
|
||||||
new Label(EndOfMethodLabelNameException);
|
new Label(EndOfMethodLabelNameException);
|
||||||
if (!aAssembler.InMetalMode) {
|
if (!aAssembler.InMetalMode) {
|
||||||
|
new CPUx86.Push("ecx");
|
||||||
Engine.QueueMethodRef(GCImplementationRefs.DecRefCountRef);
|
Engine.QueueMethodRef(GCImplementationRefs.DecRefCountRef);
|
||||||
foreach (MethodInformation.Variable xLocal in aLocals) {
|
foreach (MethodInformation.Variable xLocal in aLocals) {
|
||||||
if (xLocal.IsReferenceType) {
|
if (xLocal.IsReferenceType) {
|
||||||
|
|
@ -48,6 +49,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
new CPUx86.Call(Label.GenerateLabelName(GCImplementationRefs.DecRefCountRef));
|
new CPUx86.Call(Label.GenerateLabelName(GCImplementationRefs.DecRefCountRef));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
new CPUx86.Pop("ecx");
|
||||||
}
|
}
|
||||||
if (aReturnSize > 0) {
|
if (aReturnSize > 0) {
|
||||||
if (aReturnSize > 8) {
|
if (aReturnSize > 8) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(bool))]
|
||||||
|
public static class BooleanImpl {
|
||||||
|
public static string ToString(bool aThis) {
|
||||||
|
if (aThis) {
|
||||||
|
return "true";
|
||||||
|
} else {
|
||||||
|
return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target = typeof(byte))]
|
||||||
|
public static class ByteImpl {
|
||||||
|
public static string ToString(byte aThis) {
|
||||||
|
char[] xResult = new char[4];
|
||||||
|
string xDigits = "0123456789ABCDEF";
|
||||||
|
xResult[0] = '0';
|
||||||
|
xResult[1] = 'x';
|
||||||
|
xResult[3] = xDigits[aThis & 0xF];
|
||||||
|
xResult[2] = xDigits[aThis >> 4];
|
||||||
|
return new String(xResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target = typeof(char))]
|
||||||
|
public static class CharImpl {
|
||||||
|
public static string ToString(char aThis) {
|
||||||
|
ushort xValue = aThis;
|
||||||
|
return UInt16Impl.ToString(xValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target = typeof(Enum))]
|
||||||
|
public static class EnumImpl {
|
||||||
|
[PlugMethod(Signature = "System_String___System_Enum_ToString____")]
|
||||||
|
public static string ToString(uint aThis) {
|
||||||
|
return UInt32Impl.ToString(aThis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(short))]
|
||||||
|
public static class Int16Impl {
|
||||||
|
public static string ToString(short aThis) {
|
||||||
|
string xDigits = "0123456789ABCDEF";
|
||||||
|
char[] xResult = new char[6];
|
||||||
|
xResult[0] = '0';
|
||||||
|
xResult[1] = 'x';
|
||||||
|
xResult[2] = xDigits[aThis >> 12];
|
||||||
|
xResult[3] = xDigits[aThis >> 8];
|
||||||
|
xResult[4] = xDigits[aThis >> 4];
|
||||||
|
xResult[5] = xDigits[aThis & 0xF];
|
||||||
|
return new String(xResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(Int32))]
|
||||||
|
public static class Int32Impl {
|
||||||
|
public static string ToString(int aThis) {
|
||||||
|
return UInt32Impl.ToString((uint)aThis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(IntPtr))]
|
||||||
|
public static class IntPtrImpl {
|
||||||
|
[PlugMethod(Signature="System_String___System_IntPtr_ToString____")]
|
||||||
|
public static string ToString(uint aThis) {
|
||||||
|
return UInt32Impl.ToString(aThis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(Object))]
|
||||||
|
public static class ObjectImpl {
|
||||||
|
public static string ToString(object aThis) {
|
||||||
|
return "--object--";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(ushort))]
|
||||||
|
public static class UInt16Impl {
|
||||||
|
public static string ToString(ushort aThis) {
|
||||||
|
string xDigits = "0123456789ABCDEF";
|
||||||
|
char[] xResult = new char[6];
|
||||||
|
xResult[0] = '0';
|
||||||
|
xResult[1] = 'x';
|
||||||
|
xResult[2] = xDigits[aThis >> 12];
|
||||||
|
xResult[3] = xDigits[aThis >> 8];
|
||||||
|
xResult[4] = xDigits[aThis >> 4];
|
||||||
|
xResult[5] = xDigits[aThis & 0xF];
|
||||||
|
return new String(xResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.IL.CustomImplementations.System {
|
||||||
|
[Plug(Target=typeof(UInt32))]
|
||||||
|
public static class UInt32Impl {
|
||||||
|
public static string ToString(uint aThis) {
|
||||||
|
string xDigits = "0123456789ABCDEF";
|
||||||
|
char[] xResult = new char[10];
|
||||||
|
xResult[0] = '0';
|
||||||
|
xResult[1] = 'x';
|
||||||
|
xResult[2] = xDigits[(int)(aThis >> 28) & 0xF];
|
||||||
|
xResult[3] = xDigits[(int)(aThis >> 24) & 0xF];
|
||||||
|
xResult[4] = xDigits[(int)(aThis >> 20) & 0xF];
|
||||||
|
xResult[5] = xDigits[(int)(aThis >> 16) & 0xF];
|
||||||
|
xResult[6] = xDigits[(int)(aThis >> 12) & 0xF];
|
||||||
|
xResult[7] = xDigits[(int)(aThis >> 8) & 0xF];
|
||||||
|
xResult[8] = xDigits[(int)(aThis >> 4) & 0xF];
|
||||||
|
xResult[9] = xDigits[(int)aThis & 0xF];
|
||||||
|
return new String(xResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProductVersion>9.0.20706</ProductVersion>
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{5A39A8DF-D99E-4112-9676-BD3EED969A9C}</ProjectGuid>
|
<ProjectGuid>{5A39A8DF-D99E-4112-9676-BD3EED969A9C}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
|
|
@ -51,6 +51,16 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="CustomImplementations\System\BooleanImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\ByteImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\CharImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\IntPtrImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\UInt32Impl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\Int32Impl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\UInt16Impl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\EnumImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\Int16Impl.cs" />
|
||||||
|
<Compile Include="CustomImplementations\System\ObjectImpl.cs" />
|
||||||
<Compile Include="CustomImplementations\System\SRImpl.cs" />
|
<Compile Include="CustomImplementations\System\SRImpl.cs" />
|
||||||
<Compile Include="CustomMethodImplementationOp.cs" />
|
<Compile Include="CustomMethodImplementationOp.cs" />
|
||||||
<Compile Include="CustomMethodImplementationProxyOp.cs" />
|
<Compile Include="CustomMethodImplementationProxyOp.cs" />
|
||||||
|
|
|
||||||
|
|
@ -124,11 +124,16 @@ namespace Indy.IL2CPU.IL {
|
||||||
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(mTypes[i].FullName) + "__MethodAddressesArray";
|
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(mTypes[i].FullName) + "__MethodAddressesArray";
|
||||||
Assembler.DataMembers.Add(new KeyValuePair<string, DataMember>(Assembler.CurrentGroup, new DataMember(xDataName, "db", xDataValue.TrimEnd(','))));
|
Assembler.DataMembers.Add(new KeyValuePair<string, DataMember>(Assembler.CurrentGroup, new DataMember(xDataName, "db", xDataValue.TrimEnd(','))));
|
||||||
Pushd(xDataName);
|
Pushd(xDataName);
|
||||||
//xDataValue = Encoding.ASCII.GetBytes(mTypes[i].FullName + ", " + mTypes[i].Module.Assembly.Name.FullName).Aggregate("", (b, x) => b + x + ",") + "0";
|
xDataByteArray.Remove(0, xDataByteArray.Length);
|
||||||
//xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(mTypes[i].FullName);
|
xDataByteArray.Append(BitConverter.GetBytes(ArrayTypeId).Aggregate("", (r, b) => r + b + ","));
|
||||||
//mAssembler.DataMembers.Add(new DataMember(xDataName, "db", xDataValue));
|
xDataByteArray.Append(BitConverter.GetBytes(0x80000002 /* EmbeddedArray */).Aggregate("", (r, b) => r + b + ","));
|
||||||
//Pushd(xDataName);
|
xDataByteArray.Append(BitConverter.GetBytes((mTypes[i].FullName + ", " + mTypes[i].Module.Assembly.Name.FullName).Length).Aggregate("", (r, b) => r + b + ","));
|
||||||
Pushd("0");
|
xDataByteArray.Append(BitConverter.GetBytes((uint)2).Aggregate("", (r, b) => r + b + ","));
|
||||||
|
xDataByteArray.Append(Encoding.Unicode.GetBytes(mTypes[i].FullName + ", " + mTypes[i].Module.Assembly.Name.FullName).Aggregate("", (b, x) => b + x + ",") + "0");
|
||||||
|
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(mTypes[i].FullName);
|
||||||
|
mAssembler.DataMembers.Add(new KeyValuePair<string, DataMember>(Assembler.CurrentGroup, new DataMember(xDataName, "db", xDataByteArray.ToString())));
|
||||||
|
Pushd(xDataName);
|
||||||
|
//Pushd("0");
|
||||||
Call(SetTypeInfoRef);
|
Call(SetTypeInfoRef);
|
||||||
for (int j = 0; j < xEmittedMethods.Count; j++) {
|
for (int j = 0; j < xEmittedMethods.Count; j++) {
|
||||||
MethodDefinition xMethod = xEmittedMethods[j];
|
MethodDefinition xMethod = xEmittedMethods[j];
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ using Mono.Cecil.Cil;
|
||||||
namespace Indy.IL2CPU.IL {
|
namespace Indy.IL2CPU.IL {
|
||||||
public abstract class MethodFooterOp: Op {
|
public abstract class MethodFooterOp: Op {
|
||||||
public const string EndOfMethodLabelNameNormal = ".END__OF__METHOD_NORMAL";
|
public const string EndOfMethodLabelNameNormal = ".END__OF__METHOD_NORMAL";
|
||||||
public const string EndOfMethodLabelNameException = ".END__OF__METHOD_NORMAL";
|
public const string EndOfMethodLabelNameException = ".END__OF__METHOD_EXCEPTION";
|
||||||
|
|
||||||
public MethodFooterOp(Instruction aInstruction, MethodInformation aMethodInfo)
|
public MethodFooterOp(Instruction aInstruction, MethodInformation aMethodInfo)
|
||||||
: base(aInstruction, aMethodInfo) {
|
: base(aInstruction, aMethodInfo) {
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,17 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
|
||||||
namespace Indy.IL2CPU.CustomImplementation.System {
|
namespace Indy.IL2CPU.CustomImplementation.System {
|
||||||
|
[Plug(Target=typeof(Environment))]
|
||||||
public static class EnvironmentImpl {
|
public static class EnvironmentImpl {
|
||||||
[MethodAlias(Name = "System.String System.Environment.GetResourceFromDefault(System.String)")]
|
|
||||||
public static string GetResourceFromDefault(string aResource) {
|
public static string GetResourceFromDefault(string aResource) {
|
||||||
return aResource;
|
return aResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetResourceString(string aResource) {
|
||||||
|
return aResource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Indy.IL2CPU.Plugs;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace Indy.IL2CPU.CustomImplementation.System.Globalization {
|
||||||
|
[Plug(Target = typeof(CultureInfo))]
|
||||||
|
public static class CultureInfoImpl {
|
||||||
|
public static CultureInfo get_CurrentCulture() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,25 @@ namespace Indy.IL2CPU.CustomImplementation.System {
|
||||||
aStorage = aChars;
|
aStorage = aChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string Format(object aFormatProvider, string aFormat, object[] aArgs) {
|
||||||
|
string[] xStrings = new string[1 + 2 + (aArgs.Length * 7) - 1];
|
||||||
|
xStrings[0] = aFormat;
|
||||||
|
xStrings[1] = "(";
|
||||||
|
for (int i = 0; i < aArgs.Length; i++) {
|
||||||
|
xStrings[2 + (i *7)] = "Param";
|
||||||
|
xStrings[3 + (i *7)] = i.ToString();
|
||||||
|
xStrings[4 + (i *7)] = "=";
|
||||||
|
xStrings[5 + (i *7)] = "\"";
|
||||||
|
xStrings[6 + (i * 7)] = aArgs[i].ToString();
|
||||||
|
xStrings[7 + (i * 7)] = "\"";
|
||||||
|
if (i < (aArgs.Length - 1)) {
|
||||||
|
xStrings[8 + (i * 7)] = ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xStrings[xStrings.Length - 1] = ")";
|
||||||
|
return String.Concat(xStrings);
|
||||||
|
}
|
||||||
|
|
||||||
public static int IndexOf(string aThis, char c) {
|
public static int IndexOf(string aThis, char c) {
|
||||||
for (int i = 0; i < aThis.Length; i++) {
|
for (int i = 0; i < aThis.Length; i++) {
|
||||||
if (aThis[i] == c) {
|
if (aThis[i] == c) {
|
||||||
|
|
@ -38,8 +57,7 @@ namespace Indy.IL2CPU.CustomImplementation.System {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Substring(string aThis, int startpos)
|
public static string Substring(string aThis, int startpos) {
|
||||||
{
|
|
||||||
char[] cs = new char[aThis.Length - startpos];
|
char[] cs = new char[aThis.Length - startpos];
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
@ -49,8 +67,7 @@ namespace Indy.IL2CPU.CustomImplementation.System {
|
||||||
return new string(cs);
|
return new string(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Substring(string aThis, int startpos, int length)
|
public static string Substring(string aThis, int startpos, int length) {
|
||||||
{
|
|
||||||
if (startpos + length > aThis.Length)
|
if (startpos + length > aThis.Length)
|
||||||
length = aThis.Length - startpos;
|
length = aThis.Length - startpos;
|
||||||
|
|
||||||
|
|
@ -64,8 +81,7 @@ namespace Indy.IL2CPU.CustomImplementation.System {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: We need to redo this once char support is complete (only returns 0, -1).
|
// HACK: We need to redo this once char support is complete (only returns 0, -1).
|
||||||
public static int CompareTo(string aThis, string other)
|
public static int CompareTo(string aThis, string other) {
|
||||||
{
|
|
||||||
if (aThis.Length != other.Length)
|
if (aThis.Length != other.Length)
|
||||||
return -1;
|
return -1;
|
||||||
for (int i = 0; i < aThis.Length; i++)
|
for (int i = 0; i < aThis.Length; i++)
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@
|
||||||
<Compile Include="CustomImplementation\System\ArrayImplRefs.cs" />
|
<Compile Include="CustomImplementation\System\ArrayImplRefs.cs" />
|
||||||
<Compile Include="CustomImplementation\System\DelegateImpl.cs" />
|
<Compile Include="CustomImplementation\System\DelegateImpl.cs" />
|
||||||
<Compile Include="CustomImplementation\System\EnvironmentImpl.cs" />
|
<Compile Include="CustomImplementation\System\EnvironmentImpl.cs" />
|
||||||
|
<Compile Include="CustomImplementation\System\Globalization\CultureInfoImpl.cs" />
|
||||||
<Compile Include="CustomImplementation\System\MulticastDelegateImpl.cs" />
|
<Compile Include="CustomImplementation\System\MulticastDelegateImpl.cs" />
|
||||||
<Compile Include="CustomImplementation\System\RuntimeType.RuntimeTypeCache.cs" />
|
<Compile Include="CustomImplementation\System\RuntimeType.RuntimeTypeCache.cs" />
|
||||||
<Compile Include="CustomImplementation\System\StringImpl.cs" />
|
<Compile Include="CustomImplementation\System\StringImpl.cs" />
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Indy.IL2CPU {
|
||||||
//mTypes = new VTable[aTypeCount];
|
//mTypes = new VTable[aTypeCount];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetTypeInfo(int aType, int aBaseType, ref int[] aMethodIndexes, ref int[] aMethodAddresses, int aName) {
|
public static void SetTypeInfo(int aType, int aBaseType, ref int[] aMethodIndexes, ref int[] aMethodAddresses, char[] aName) {
|
||||||
mTypes[aType] = new VTable();
|
mTypes[aType] = new VTable();
|
||||||
mTypes[aType].BaseTypeIdentifier = aBaseType;
|
mTypes[aType].BaseTypeIdentifier = aBaseType;
|
||||||
mTypes[aType].MethodIndexes = aMethodIndexes;
|
mTypes[aType].MethodIndexes = aMethodIndexes;
|
||||||
|
|
@ -32,6 +32,10 @@ namespace Indy.IL2CPU {
|
||||||
mTypes[aType].Name = aName;
|
mTypes[aType].Name = aName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetTypeName(int aType) {
|
||||||
|
return new String(mTypes[aType].Name);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) {
|
public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) {
|
||||||
mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier;
|
mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier;
|
||||||
mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress;
|
mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress;
|
||||||
|
|
@ -50,7 +54,7 @@ namespace Indy.IL2CPU {
|
||||||
|
|
||||||
public struct VTable {
|
public struct VTable {
|
||||||
public int BaseTypeIdentifier;
|
public int BaseTypeIdentifier;
|
||||||
public int Name;
|
public char[] Name;
|
||||||
public int[] MethodIndexes;
|
public int[] MethodIndexes;
|
||||||
public int[] MethodAddresses;
|
public int[] MethodAddresses;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue