Several small fixes

This commit is contained in:
mterwoord_cp 2008-05-14 09:28:03 +00:00
parent f7ba8f72d5
commit bbfb2b8a0d
11 changed files with 2190 additions and 65 deletions

View file

@ -117,7 +117,7 @@ namespace Cosmos.Build.Windows {
};
xEngine.DebugLog += DoDebugLog;
xEngine.Execute(xTarget.Location, TargetPlatformEnum.X86, g => Path.Combine(xAsmPath, g + ".asm"), false,
new string[] { Path.Combine(Path.Combine(ToolsPath, "Cosmos.Kernel.Plugs"), "Cosmos.Kernel.Plugs.dll") }, aDebugMode, aDebugComport, BuildPath);
new string[] { Path.Combine(Path.Combine(ToolsPath, "Cosmos.Kernel.Plugs"), "Cosmos.Kernel.Plugs.dll") }, aDebugMode, aDebugComport, xAsmPath);
xSW.Stop();
Console.WriteLine("IL2CPU Run took " + xSW.Elapsed.ToString());

View file

@ -34,7 +34,7 @@ namespace Cosmos.Build.Windows {
}
if (aWait || (aCapture && xProcess.HasExited)) {
if (!xProcess.WaitForExit(60 * 1000) || xProcess.ExitCode != 0) {
if (!xProcess.WaitForExit(120 * 1000) || xProcess.ExitCode != 0) {
//TODO: Fix
if (aCapture) {
Console.ForegroundColor = ConsoleColor.Red;

View file

@ -41,6 +41,7 @@ namespace Indy.IL2CPU.IL.X86 {
mArgumentCount = mTargetMethodInfo.Arguments.Length;
mReturnSize = mTargetMethodInfo.ReturnSize;
mThisOffset = mTargetMethodInfo.Arguments[0].Offset;
if (mTargetMethodInfo.ExtraStackSize > 0) { mThisOffset -= mTargetMethodInfo.ExtraStackSize; }
mCurrentILOffset = aReader.Position;
mExtraStackSpace = mTargetMethodInfo.ExtraStackSize;

View file

@ -1,5 +1,4 @@
#define MTW_DEBUG
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -22,7 +21,10 @@ namespace Indy.IL2CPU.IL {
public InitVmtImplementationOp(ILReader aReader, MethodInformation aMethodInfo)
: base(aReader, aMethodInfo) {
}
private static readonly bool mDebugMode = false;
static InitVmtImplementationOp() {
mDebugMode = Environment.MachineName.Equals("laptop-matthijs", StringComparison.InvariantCultureIgnoreCase);
}
private IList<Type> mTypes;
public MethodBase LoadTypeTableRef;
public MethodBase SetTypeInfoRef;
@ -46,20 +48,23 @@ namespace Indy.IL2CPU.IL {
protected abstract void Call(MethodBase aMethod);
public override void DoAssemble() {
#if MTW_DEBUG
using (XmlWriter xDebug = XmlWriter.Create(@"d:\vtables.xml")) {
xDebug.WriteStartDocument();
xDebug.WriteStartElement("VTables");
xDebug.WriteStartElement("AllMethods");
for(int i = 0; i < Methods.Count; i++){
MethodBase xTheMethod = Methods[i];
xDebug.WriteStartElement("Method");
xDebug.WriteAttributeString("Id", GetMethodIdentifier(xTheMethod).ToString("X"));
xDebug.WriteAttributeString("Name", xTheMethod.GetFullName());
xDebug.WriteEndElement();
}
xDebug.WriteEndElement();
#endif
XmlWriter xDebug=null;
if (mDebugMode)
{
xDebug = XmlWriter.Create(@"d:\vtables.xml");
xDebug.WriteStartDocument();
xDebug.WriteStartElement("VTables");
xDebug.WriteStartElement("AllMethods");
for (int i = 0; i < Methods.Count; i++)
{
MethodBase xTheMethod = Methods[i];
xDebug.WriteStartElement("Method");
xDebug.WriteAttributeString("Id", GetMethodIdentifier(xTheMethod).ToString("X"));
xDebug.WriteAttributeString("Name", xTheMethod.GetFullName());
xDebug.WriteEndElement();
}
xDebug.WriteEndElement();
}
string xTheName = DataMember.GetStaticFieldName(TypesFieldRef);
DataMember xDataMember = (from item in Assembler.DataMembers
where item.Value.Name == xTheName
@ -84,11 +89,12 @@ namespace Indy.IL2CPU.IL {
Pushd("0" + mTypes.Count.ToString("X") + "h");
Call(LoadTypeTableRef);
for (int i = 0; i < mTypes.Count; i++) {
#if MTW_DEBUG
xDebug.WriteStartElement("Type");
xDebug.WriteAttributeString("Id", i.ToString("X"));
if (mDebugMode)
{
xDebug.WriteStartElement("Type");
xDebug.WriteAttributeString("Id", i.ToString("X"));
xDebug.WriteAttributeString("Name", mTypes[i].FullName);
#endif
}
try
{
Type xType = mTypes[i];
@ -159,9 +165,10 @@ namespace Indy.IL2CPU.IL {
{
throw new Exception("Base type not found!");
}
#if MTW_DEBUG
xDebug.WriteAttributeString("BaseId", xBaseIndex.Value.ToString("X"));
#endif
if (mDebugMode)
{
xDebug.WriteAttributeString("BaseId", xBaseIndex.Value.ToString("X"));
}
if (!xType.IsInterface)
{
@ -215,12 +222,13 @@ namespace Indy.IL2CPU.IL {
if (xNewMethod == null) { System.Diagnostics.Debugger.Break(); }
xMethod = xNewMethod;
}
#if MTW_DEBUG
xDebug.WriteStartElement("Method");
xDebug.WriteAttributeString("Id", xMethodId.ToString("X"));
xDebug.WriteAttributeString("Name", xMethod.GetFullName());
xDebug.WriteEndElement();
#endif
if (mDebugMode)
{
xDebug.WriteStartElement("Method");
xDebug.WriteAttributeString("Id", xMethodId.ToString("X"));
xDebug.WriteAttributeString("Name", xMethod.GetFullName());
xDebug.WriteEndElement();
}
if (!xType.IsInterface)
{
@ -240,14 +248,17 @@ namespace Indy.IL2CPU.IL {
}
finally
{
#if MTW_DEBUG
xDebug.WriteEndElement();
#endif
if (mDebugMode)
{
xDebug.WriteEndElement();
}
}
}
#if MTW_DEBUG
}
#endif
if (mDebugMode)
{
xDebug.Close();
}
}
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Indy.IL2CPU.Plugs;
using Microsoft.Win32;
namespace Indy.IL2CPU.CustomImplementation.Microsoft.Win32
{
[Plug(Target=typeof(RegistryKey))]
public static class RegistryKeyImpl
{
[PlugMethod(Signature="System_Void__Microsoft_Win32_RegistryKey__cctor__")]
public static void CCtor() { }
}
}

View file

@ -2,9 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Indy.IL2CPU.Plugs;
namespace Indy.IL2CPU.CustomImplementation.System {
[Plug(Target=typeof(Array))]
public static class ArrayImpl {
public static object Clone(Array aThis) { return aThis; }
//[MethodAlias(Name = "System.Void System.Array.Copy(System.Array,System.Int32,System.Array,System.Int32,System.Int32,System.Boolean)")]
//public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) {
// for(int i = sourceIndex; i < length; i++) {

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Indy.IL2CPU.Plugs;
namespace Indy.IL2CPU.CustomImplementation.System.Security.Cryptography
{
[Plug(TargetName="System.Security.Cryptography.Utils")]
public static class Utils
{
public static int get_FipsAlgorithmPolicy() { return 0; }
}
}

View file

@ -139,7 +139,7 @@ namespace Indy.IL2CPU {
}
public event Action ProgressChanged;
private Func<string, string> mGetFileNameForGroup;
private void OnProgressChanged() {
if (ProgressChanged != null) {
ProgressChanged();
@ -853,26 +853,28 @@ namespace Indy.IL2CPU {
if (xManifestResourceName != null) {
RegisterType(xCurrentField.FieldType);
string xTheData = "";
string xFileName = Path.Combine(mOutputDir, (xCurrentField.DeclaringType.Assembly.FullName + "__" + xManifestResourceName).Replace(",", "_") + ".res");
using (var xStream = xCurrentField.DeclaringType.Assembly.GetManifestResourceStream(xManifestResourceName))
{
// todo: abstract this array code out.
StringBuilder xSB = new StringBuilder((int)((xStream.Length * 4) + 32));
xSB.Append(BitConverter.GetBytes(Engine.RegisterType(Engine.GetType("mscorlib", "System.Array"))).Aggregate("", (r, b) => r + b + ","));
xSB.Append(BitConverter.GetBytes((uint)InstanceTypeEnum.StaticEmbeddedArray).Aggregate("", (r, b) => r + b + ","));
xSB.Append(BitConverter.GetBytes((int)xStream.Length).Aggregate("", (r, b) => r + b + ","));
xSB.Append(BitConverter.GetBytes((int)1).Aggregate("", (r, b) => r + b + ","));
var xBuff = new byte [128];
while(xStream.Position < xStream.Length){
int xBytesRead = xStream.Read(xBuff, 0, 128);
xSB.Append(xBuff.Take(xBytesRead).Aggregate("", (r, b) => r + b + ","));
using (var xTarget = File.Create(xFileName))
{
// todo: abstract this array code out.
xTarget.Write(BitConverter.GetBytes(Engine.RegisterType(Engine.GetType("mscorlib", "System.Array"))), 0, 4);
xTarget.Write(BitConverter.GetBytes((uint)InstanceTypeEnum.StaticEmbeddedArray), 0, 4);
xTarget.Write(BitConverter.GetBytes((int)xStream.Length), 0, 4);
xTarget.Write(BitConverter.GetBytes((int)1), 0, 4);
var xBuff = new byte[128];
while (xStream.Position < xStream.Length)
{
int xBytesRead = xStream.Read(xBuff, 0, 128);
xTarget.Write(xBuff, 0, xBytesRead);
}
}
xTheData = xSB.ToString();
}
xTheData = xTheData.TrimEnd(',');
mAssembler.DataMembers.Add(new KeyValuePair<string, DataMember>("ManifestResourceStreams",
new DataMember("___" + xFieldName + "___Contents",
"db",
xTheData)));
"incbin",
"\"" + xFileName + "\"")));
mAssembler.DataMembers.Add(new KeyValuePair<string, DataMember>("ManifestResourceStreams",
new DataMember(xFieldName,
"dd",

View file

@ -91,6 +91,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="CustomImplementation\Microsoft\Win32\RegistryKeyImpl.cs" />
<Compile Include="CustomImplementation\System\ArrayImpl.cs" />
<Compile Include="CustomImplementation\System\ArrayImplRefs.cs" />
<Compile Include="CustomImplementation\System\DelegateImpl.cs" />
@ -98,6 +99,7 @@
<Compile Include="CustomImplementation\System\Globalization\CultureInfoImpl.cs" />
<Compile Include="CustomImplementation\System\MulticastDelegateImpl.cs" />
<Compile Include="CustomImplementation\System\RuntimeType.RuntimeTypeCache.cs" />
<Compile Include="CustomImplementation\System\Security\Cryptography\Utils.cs" />
<Compile Include="CustomImplementation\System\StringImpl.cs" />
<Compile Include="CustomImplementation\System\RuntimeType.cs" />
<Compile Include="CustomImplementation\System\StringImplRefs.cs" />

View file

@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Cosmos.Build.Windows;
using System.Collections;
using System.Security.Cryptography;
namespace MatthijsTest
{
@ -28,19 +30,61 @@ namespace MatthijsTest
public static void Init()
{
Console.Clear();
if (TheManifestResource == null) {
Console.WriteLine("Field TheManifestResource is null!");
return; }
MemoryStream xMS = new MemoryStream(TheManifestResource, false);
Console.Write("Length: ");
Console.WriteLine(TheManifestResource.Length.ToString());
int xLength = TheManifestResource.Length;
if(xLength > 10) {
Console.WriteLine("Too much data!");
return;
}
for(int i = 0; i < xLength;i++) {
Console.WriteLine(TheManifestResource[i].ToString());
Console.WriteLine(((int)xMS.Length).ToString());
SHA256Managed xSHA = new SHA256Managed();
var xHash = xSHA.ComputeHash(xMS);
Console.Write("0x");
for (int i = 0; i < xHash.Length; i++) {
PrintHex(xHash[i]);}
Console.WriteLine("");
}
private static string SingleDigitToHex(byte d)
{
switch (d)
{
case 0:
return "0";
case 1:
return "1";
case 2:
return "2";
case 3:
return "3";
case 4:
return "4";
case 5:
return "5";
case 6:
return "6";
case 7:
return "7";
case 8:
return "8";
case 9:
return "9";
case 10:
return "A";
case 11:
return "B";
case 12:
return "C";
case 13:
return "D";
case 14:
return "E";
case 15:
return "F";
}
return " ";
}
public static void PrintHex(byte aByte) {
Console.Write(SingleDigitToHex((byte)(aByte / 16)));
Console.Write(SingleDigitToHex((byte)(aByte & 0xF)));
}
}
}

File diff suppressed because it is too large Load diff