mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
This commit is contained in:
parent
16a03ff608
commit
440b8ff60f
23 changed files with 80 additions and 77 deletions
|
|
@ -118,7 +118,7 @@
|
|||
<Compile Include="Instruction.cs" />
|
||||
<Compile Include="Label.cs" />
|
||||
<Compile Include="LiteralAssemblerCode.cs" />
|
||||
<Compile Include="MethodInfoLabelGenerator.cs" />
|
||||
<Compile Include="LabelName.cs" />
|
||||
<Compile Include="OpCodeAttribute.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StackContents.cs" />
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.IO;
|
|||
|
||||
namespace Cosmos.Assembler {
|
||||
public class DataMember : BaseAssemblerElement, IComparable<DataMember> {
|
||||
public const string IllegalIdentifierChars = "&.,+$<>{}-`\'/\\ ()[]*!=";
|
||||
public string Name { get; private set; }
|
||||
public bool IsComment { get; set; }
|
||||
public byte[] RawDefaultValue { get; set; }
|
||||
|
|
@ -91,12 +90,15 @@ namespace Cosmos.Assembler {
|
|||
}
|
||||
|
||||
public static string GetStaticFieldName(FieldInfo aField) {
|
||||
return FilterStringForIncorrectChars("static_field__" + MethodInfoLabelGenerator.GetFullName(aField.DeclaringType) + "." + aField.Name);
|
||||
return FilterStringForIncorrectChars("static_field__" + LabelName.GetFullName(aField.DeclaringType) + "." + aField.Name);
|
||||
}
|
||||
|
||||
public const string IllegalIdentifierChars = "&.,+$<>{}-`\'/\\ ()[]*!=";
|
||||
public static string FilterStringForIncorrectChars(string aName) {
|
||||
string xTempResult = aName;
|
||||
foreach (char c in IllegalIdentifierChars) {
|
||||
//TODO Use empty, not _. We need shorter names, and _ can be used for explicit demarkation.
|
||||
// Need to add _ to illegal chars, and cant change currently as it goofs stuff up.
|
||||
xTempResult = xTempResult.Replace(c, '_');
|
||||
}
|
||||
return String.Intern(xTempResult);
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ using System.Text;
|
|||
namespace Cosmos.Assembler {
|
||||
public class Label : Instruction {
|
||||
public static string GetFullName(MethodBase aMethod) {
|
||||
return MethodInfoLabelGenerator.GenerateLabelName(aMethod);
|
||||
return LabelName.Get(aMethod);
|
||||
}
|
||||
|
||||
public string Comment { get; set; }
|
||||
|
||||
public Label(MethodBase aMethod) : this(MethodInfoLabelGenerator.GenerateLabelName(aMethod), "") { }
|
||||
public Label(MethodBase aMethod) : this(LabelName.Get(aMethod), "") { }
|
||||
|
||||
public Label(string aName)
|
||||
: this(aName, "") {
|
||||
|
|
|
|||
|
|
@ -6,29 +6,32 @@ using System.Security.Cryptography;
|
|||
using System.Diagnostics;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
|
||||
namespace Cosmos.Assembler {
|
||||
public static class MethodInfoLabelGenerator {
|
||||
public static uint LabelCount {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public static class LabelName {
|
||||
public static int LabelCount { get; private set; }
|
||||
// Max length of labels at 256. We use 220 here so that we still have room for suffixes
|
||||
// for IL positions, etc.
|
||||
public const int MaxLengthWithoutSuffix = 200;
|
||||
|
||||
public static string GenerateLabelName(MethodBase aMethod) {
|
||||
public static string Get(MethodBase aMethod) {
|
||||
string xResult = DataMember.FilterStringForIncorrectChars(GenerateFullName(aMethod));
|
||||
xResult = GenerateLabelFromFullName(xResult);
|
||||
LabelCount++;
|
||||
return xResult;
|
||||
return Final(xResult);
|
||||
}
|
||||
|
||||
public static string GenerateLabelFromFullName(string xResult) {
|
||||
if (xResult.Length > 245) {
|
||||
public static string Final(string xName) {
|
||||
if (xName.Length > MaxLengthWithoutSuffix) {
|
||||
using (var xHash = MD5.Create()) {
|
||||
xResult = xHash.ComputeHash(
|
||||
Encoding.Default.GetBytes(xResult)).Aggregate("_", (r, x) => r + x.ToString("X2"));
|
||||
var xSB = new StringBuilder();
|
||||
foreach (var xByte in xHash.ComputeHash(Encoding.Default.GetBytes(xName))) {
|
||||
xSB.Append(xByte.ToString("X2"));
|
||||
}
|
||||
// Keep length max 200
|
||||
xName = xName.Substring(0, MaxLengthWithoutSuffix - xSB.Length) + xSB.ToString();
|
||||
}
|
||||
}
|
||||
return xResult;
|
||||
|
||||
LabelCount++;
|
||||
return xName;
|
||||
}
|
||||
|
||||
public static string GetFullName(Type aType) {
|
||||
|
|
@ -65,8 +68,6 @@ namespace Cosmos.Assembler {
|
|||
xSB.Append(GetFullName(xArgs.Last()));
|
||||
xSB.Append(">");
|
||||
}
|
||||
//xSB.Append(", ");
|
||||
//xSB.Append(aType.Assembly.FullName);
|
||||
return xSB.ToString();
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
<PropertyRef Name="ID" />
|
||||
</Key>
|
||||
<Property Name="ID" Type="uniqueidentifier" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="512" />
|
||||
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="256" />
|
||||
<Property Name="Address" Type="bigint" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="LOCAL_ARGUMENT_INFO">
|
||||
|
|
@ -171,7 +171,7 @@
|
|||
<PropertyRef Name="ID" />
|
||||
</Key>
|
||||
<Property Type="Guid" Name="ID" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Type="String" Name="Name" Nullable="false" MaxLength="512" />
|
||||
<Property Type="String" Name="Name" Nullable="false" MaxLength="256" />
|
||||
<Property Type="Int64" Name="Address" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="LOCAL_ARGUMENT_INFO">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-- --------------------------------------------------
|
||||
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
|
||||
-- --------------------------------------------------
|
||||
-- Date Created: 08/06/2012 21:20:56
|
||||
-- Date Created: 08/06/2012 22:45:00
|
||||
-- Generated from EDMX file: D:\source\Cosmos\source2\Debug\Cosmos.Debug.Common\DebugModel.edmx
|
||||
-- --------------------------------------------------
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ GO
|
|||
-- Creating table 'Labels'
|
||||
CREATE TABLE [dbo].[Labels] (
|
||||
[ID] uniqueidentifier NOT NULL,
|
||||
[Name] nvarchar(512) NOT NULL,
|
||||
[Name] nvarchar(256) NOT NULL,
|
||||
[Address] bigint NOT NULL
|
||||
);
|
||||
GO
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ namespace Cosmos.IL2CPU {
|
|||
new Comment("Plugged: " + (aMethod.PlugMethod == null ? "No" : "Yes"));
|
||||
|
||||
if (aMethod.PluggedMethod != null) {
|
||||
new Cosmos.Assembler.Label("PLUG_FOR___" + MethodInfoLabelGenerator.GenerateLabelName(aMethod.PluggedMethod.MethodBase));
|
||||
new Cosmos.Assembler.Label("PLUG_FOR___" + LabelName.Get(aMethod.PluggedMethod.MethodBase));
|
||||
} else {
|
||||
new Cosmos.Assembler.Label(aMethod.MethodBase);
|
||||
}
|
||||
var xMethodLabel = Cosmos.Assembler.Label.LastFullLabel;
|
||||
if (aMethod.MethodBase.IsStatic && aMethod.MethodBase is ConstructorInfo) {
|
||||
new Comment("This is a static constructor. see if it has been called already, and if so, return.");
|
||||
var xName = DataMember.FilterStringForIncorrectChars("CCTOR_CALLED__" + MethodInfoLabelGenerator.GetFullName(aMethod.MethodBase.DeclaringType));
|
||||
var xName = DataMember.FilterStringForIncorrectChars("CCTOR_CALLED__" + LabelName.GetFullName(aMethod.MethodBase.DeclaringType));
|
||||
var xAsmMember = new DataMember(xName, (byte)0);
|
||||
Assembler.DataMembers.Add(xAsmMember);
|
||||
new Compare { DestinationRef = Cosmos.Assembler.ElementReference.New(xName), DestinationIsIndirect = true, Size = 8, SourceValue = 1 };
|
||||
|
|
@ -427,7 +427,7 @@ namespace Cosmos.IL2CPU {
|
|||
|
||||
protected void Call(MethodBase aMethod) {
|
||||
new Cosmos.Assembler.x86.Call {
|
||||
DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(aMethod)
|
||||
DestinationLabel = LabelName.Get(aMethod)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -576,9 +576,9 @@ namespace Cosmos.IL2CPU {
|
|||
}
|
||||
}
|
||||
if (!xType.IsInterface) {
|
||||
Move("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), (int)aGetTypeID(xType));
|
||||
Move("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), (int)aGetTypeID(xType));
|
||||
Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(
|
||||
new DataMember("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), new int[] { (int)aGetTypeID(xType) }));
|
||||
new DataMember("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name), new int[] { (int)aGetTypeID(xType) }));
|
||||
Push((uint)xBaseIndex.Value);
|
||||
xData = new byte[16 + (xEmittedMethods.Count * 4)];
|
||||
xTemp = BitConverter.GetBytes(aGetTypeID(typeof(Array)));
|
||||
|
|
@ -589,10 +589,10 @@ namespace Cosmos.IL2CPU {
|
|||
Array.Copy(xTemp, 0, xData, 8, 4);
|
||||
xTemp = BitConverter.GetBytes(4); // embedded array
|
||||
Array.Copy(xTemp, 0, xData, 12, 4);
|
||||
string xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodIndexesArray";
|
||||
string xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodIndexesArray";
|
||||
Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(xDataName, xData));
|
||||
Push(xDataName);
|
||||
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodAddressesArray";
|
||||
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name) + "__MethodAddressesArray";
|
||||
Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(xDataName, xData));
|
||||
Push(xDataName);
|
||||
xData = new byte[16 + Encoding.Unicode.GetByteCount(xType.FullName + ", " + xType.Module.Assembly.GetName().FullName)];
|
||||
|
|
@ -604,7 +604,7 @@ namespace Cosmos.IL2CPU {
|
|||
Array.Copy(xTemp, 0, xData, 8, 4);
|
||||
xTemp = BitConverter.GetBytes(2); // embedded array
|
||||
Array.Copy(xTemp, 0, xData, 12, 4);
|
||||
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name);
|
||||
xDataName = "____SYSTEM____TYPE___" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(xType) + " ASM_IS__" + xType.Assembly.GetName().Name);
|
||||
Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(xDataName, xData));
|
||||
Push("0" + xEmittedMethods.Count.ToString("X") + "h");
|
||||
Call(xSetTypeInfoRef);
|
||||
|
|
@ -675,7 +675,7 @@ namespace Cosmos.IL2CPU {
|
|||
}
|
||||
|
||||
public void ProcessField(FieldInfo aField) {
|
||||
string xFieldName = MethodInfoLabelGenerator.GetFullName(aField);
|
||||
string xFieldName = LabelName.GetFullName(aField);
|
||||
xFieldName = DataMember.GetStaticFieldName(aField);
|
||||
if (Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Count(x => x.Name == xFieldName) == 0) {
|
||||
var xItemList = (from item in aField.GetCustomAttributes(false)
|
||||
|
|
@ -807,7 +807,7 @@ namespace Cosmos.IL2CPU {
|
|||
}
|
||||
|
||||
protected static void WriteDebug(MethodBase aMethod, uint aSize, uint aSize2) {
|
||||
var xLine = String.Format("{0}\t{1}\t{2}", MethodInfoLabelGenerator.GenerateFullName(aMethod), aSize, aSize2);
|
||||
var xLine = String.Format("{0}\t{1}\t{2}", LabelName.GenerateFullName(aMethod), aSize, aSize2);
|
||||
}
|
||||
|
||||
// These are all temp functions until we move to the new assembler.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Cosmos.IL2CPU {
|
|||
public abstract void Execute(MethodInfo aMethod, ILOpCode aOpCode);
|
||||
|
||||
public static string GetTypeIDLabel(Type aType) {
|
||||
return "VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GetFullName(aType) + " ASM_IS__" + aType.Assembly.GetName().Name);
|
||||
return "VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(aType) + " ASM_IS__" + aType.Assembly.GetName().Name);
|
||||
}
|
||||
|
||||
public static uint Align(uint aSize, uint aAlign) {
|
||||
|
|
@ -41,7 +41,7 @@ namespace Cosmos.IL2CPU {
|
|||
}
|
||||
|
||||
public static string GetMethodLabel(MethodBase aMethod) {
|
||||
return MethodInfoLabelGenerator.GenerateLabelName(aMethod);
|
||||
return LabelName.Get(aMethod);
|
||||
}
|
||||
|
||||
public static string GetMethodLabel(MethodInfo aMethod) {
|
||||
|
|
@ -174,13 +174,13 @@ namespace Cosmos.IL2CPU {
|
|||
DestinationRef = Cosmos.Assembler.ElementReference.New(LdStr.GetContentsArrayName(aMessage))
|
||||
};
|
||||
new CPU.Call {
|
||||
DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(typeof(ExceptionHelper).GetMethod("ThrowNotImplemented", BindingFlags.Static | BindingFlags.Public))
|
||||
DestinationLabel = LabelName.Get(typeof(ExceptionHelper).GetMethod("ThrowNotImplemented", BindingFlags.Static | BindingFlags.Public))
|
||||
};
|
||||
}
|
||||
|
||||
protected void ThrowOverflowException() {
|
||||
new CPU.Call {
|
||||
DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(
|
||||
DestinationLabel = LabelName.Get(
|
||||
typeof(ExceptionHelper).GetMethod("ThrowOverflow", BindingFlags.Static | BindingFlags.Public, null, new Type[] { }, null))
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ namespace Cosmos.IL2CPU {
|
|||
// isn't guaranteed.
|
||||
for (int i = 0; i < xParams.Length; i++) {
|
||||
xParamTypes[i] = xParams[i].ParameterType;
|
||||
Queue(xParamTypes[i], MethodInfoLabelGenerator.GenerateFullName(aMethod), "Parameter");
|
||||
Queue(xParamTypes[i], LabelName.GenerateFullName(aMethod), "Parameter");
|
||||
}
|
||||
var xIsDynamicMethod = aMethod.DeclaringType == null;
|
||||
// Queue Types directly related to method
|
||||
|
|
@ -458,11 +458,11 @@ namespace Cosmos.IL2CPU {
|
|||
// Don't queue declaring types of plugs
|
||||
if (!xIsDynamicMethod) {
|
||||
// dont queue declaring types of dynamic methods either, those dont have a declaring type
|
||||
Queue(aMethod.DeclaringType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Declaring Type");
|
||||
Queue(aMethod.DeclaringType, LabelName.GenerateFullName(aMethod), "Declaring Type");
|
||||
}
|
||||
}
|
||||
if (aMethod is System.Reflection.MethodInfo) {
|
||||
Queue(((System.Reflection.MethodInfo)aMethod).ReturnType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Return Type");
|
||||
Queue(((System.Reflection.MethodInfo)aMethod).ReturnType, LabelName.GenerateFullName(aMethod), "Return Type");
|
||||
}
|
||||
|
||||
// Scan virtuals
|
||||
|
|
@ -509,7 +509,7 @@ namespace Cosmos.IL2CPU {
|
|||
// If it was already in mVirtuals, then ScanType will take
|
||||
// care of new additions.
|
||||
if (xVirtMethod != null) {
|
||||
Queue(xVirtMethod, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Virtual Base");
|
||||
Queue(xVirtMethod, LabelName.GenerateFullName(aMethod), "Virtual Base");
|
||||
mVirtuals.Add(xVirtMethod);
|
||||
if (aMethod.Name == "ToString") {
|
||||
Console.Write("");
|
||||
|
|
@ -525,7 +525,7 @@ namespace Cosmos.IL2CPU {
|
|||
// We need to check IsVirtual, a non virtual could
|
||||
// "replace" a virtual above it?
|
||||
if (xNewMethod.IsVirtual) {
|
||||
Queue(xNewMethod, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Virtual Downscan");
|
||||
Queue(xNewMethod, LabelName.GenerateFullName(aMethod), "Virtual Downscan");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -557,7 +557,7 @@ namespace Cosmos.IL2CPU {
|
|||
}
|
||||
}
|
||||
if (xNeedsPlug) {
|
||||
throw new Exception("Native code encountered, plug required. Please see http://cosmos.codeplex.com/wikipage?title=Plugs). " + MethodInfoLabelGenerator.GenerateFullName(aMethod) + "." + Environment.NewLine + " Called from :" + Environment.NewLine + sourceItem);
|
||||
throw new Exception("Native code encountered, plug required. Please see http://cosmos.codeplex.com/wikipage?title=Plugs). " + LabelName.GenerateFullName(aMethod) + "." + Environment.NewLine + " Called from :" + Environment.NewLine + sourceItem);
|
||||
}
|
||||
|
||||
//TODO: As we scan each method, we could update or put in a new list
|
||||
|
|
@ -581,29 +581,29 @@ namespace Cosmos.IL2CPU {
|
|||
ProcessInstructions(xOpCodes);
|
||||
foreach (var xOpCode in xOpCodes) {
|
||||
if (xOpCode is ILOpCodes.OpMethod) {
|
||||
Queue(((ILOpCodes.OpMethod)xOpCode).Value, MethodInfoLabelGenerator.GenerateFullName(aMethod), "Call", sourceItem);
|
||||
Queue(((ILOpCodes.OpMethod)xOpCode).Value, LabelName.GenerateFullName(aMethod), "Call", sourceItem);
|
||||
} else if (xOpCode is ILOpCodes.OpType) {
|
||||
Queue(((ILOpCodes.OpType)xOpCode).Value, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value");
|
||||
Queue(((ILOpCodes.OpType)xOpCode).Value, LabelName.GenerateFullName(aMethod), "OpCode Value");
|
||||
} else if (xOpCode is ILOpCodes.OpField) {
|
||||
var xOpField = (ILOpCodes.OpField)xOpCode;
|
||||
//TODO: Need to do this? Will we get a ILOpCodes.OpType as well?
|
||||
Queue(xOpField.Value.DeclaringType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value");
|
||||
Queue(xOpField.Value.DeclaringType, LabelName.GenerateFullName(aMethod), "OpCode Value");
|
||||
if (xOpField.Value.IsStatic) {
|
||||
//TODO: Why do we add static fields, but not instance?
|
||||
// AW: instance fields are "added" always, as part of a type, but for static fields, we need to emit a datamember
|
||||
Queue(xOpField.Value, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value");
|
||||
Queue(xOpField.Value, LabelName.GenerateFullName(aMethod), "OpCode Value");
|
||||
}
|
||||
} else if (xOpCode is ILOpCodes.OpToken) {
|
||||
var xTokenOp = (ILOpCodes.OpToken)xOpCode;
|
||||
if (xTokenOp.ValueIsType) {
|
||||
Queue(xTokenOp.ValueType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value");
|
||||
Queue(xTokenOp.ValueType, LabelName.GenerateFullName(aMethod), "OpCode Value");
|
||||
}
|
||||
if (xTokenOp.ValueIsField) {
|
||||
Queue(xTokenOp.ValueField.DeclaringType, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value");
|
||||
Queue(xTokenOp.ValueField.DeclaringType, LabelName.GenerateFullName(aMethod), "OpCode Value");
|
||||
if (xTokenOp.ValueField.IsStatic) {
|
||||
//TODO: Why do we add static fields, but not instance?
|
||||
// AW: instance fields are "added" always, as part of a type, but for static fields, we need to emit a datamember
|
||||
Queue(xTokenOp.ValueField, MethodInfoLabelGenerator.GenerateFullName(aMethod), "OpCode Value");
|
||||
Queue(xTokenOp.ValueField, LabelName.GenerateFullName(aMethod), "OpCode Value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -859,7 +859,7 @@ namespace Cosmos.IL2CPU {
|
|||
break;
|
||||
}
|
||||
if (xAttrib != null && xAttrib.Signature != null) {
|
||||
var xName = DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GenerateFullName(aMethod));
|
||||
var xName = DataMember.FilterStringForIncorrectChars(LabelName.GenerateFullName(aMethod));
|
||||
if (string.Compare(xName, xAttrib.Signature, true) == 0) {
|
||||
xResult = xSigMethod;
|
||||
break;
|
||||
|
|
@ -967,7 +967,7 @@ namespace Cosmos.IL2CPU {
|
|||
#region Plug Caching
|
||||
private Orvid.Collections.SkipList ResolvedPlugs = new Orvid.Collections.SkipList();
|
||||
private static string BuildMethodKeyName(MethodBase m) {
|
||||
return MethodInfoLabelGenerator.GenerateFullName(m);
|
||||
return LabelName.GenerateFullName(m);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
uint xSize = Align(SizeOfType( xType.Value ), 4);
|
||||
string xTypeID = GetTypeIDLabel(xType.Value);
|
||||
new CPUx86.Push { DestinationValue = ( ObjectImpl.FieldDataOffset + xSize ) };
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get( GCImplementationRefs.AllocNewObjectRef ) };
|
||||
new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX };
|
||||
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EBX, SourceRef = Cosmos.Assembler.ElementReference.New( xTypeID ), SourceIsIndirect = true };
|
||||
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true, SourceReg = CPUx86.Registers.EBX };
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Cosmos.IL2CPU.X86.IL {
|
|||
|
||||
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) {
|
||||
var xOpMethod = aOpCode as OpMethod;
|
||||
DoExecute(Assembler, aMethod, xOpMethod.Value, aOpCode, MethodInfoLabelGenerator.GenerateLabelName(aMethod.MethodBase));
|
||||
DoExecute(Assembler, aMethod, xOpMethod.Value, aOpCode, LabelName.Get(aMethod.MethodBase));
|
||||
}
|
||||
|
||||
public static void DoExecute(Cosmos.Assembler.Assembler Assembler, MethodInfo aCurrentMethod, MethodBase aTargetMethod, ILOpCode aCurrent, string currentLabel)
|
||||
|
|
@ -87,9 +87,9 @@ namespace Cosmos.IL2CPU.X86.IL {
|
|||
// , mMethod, mMethodDescription, null, mCurrentMethodInfo.DebugMode);
|
||||
string xNormalAddress = "";
|
||||
if (aTargetMethod.IsStatic || !aTargetMethod.IsVirtual || aTargetMethod.IsFinal) {
|
||||
xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod);
|
||||
xNormalAddress = LabelName.Get(aTargetMethod);
|
||||
} else {
|
||||
xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod);
|
||||
xNormalAddress = LabelName.Get(aTargetMethod);
|
||||
//throw new Exception("Call: non-concrete method called: '" + aTargetMethod.GetFullName() + "'");
|
||||
}
|
||||
var xParameters = aTargetMethod.GetParameters();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
// , mMethod, mMethodDescription, null, mCurrentMethodInfo.DebugMode);
|
||||
string xNormalAddress = "";
|
||||
if (aTargetMethod.IsStatic || !aTargetMethod.IsVirtual || aTargetMethod.IsFinal) {
|
||||
xNormalAddress = MethodInfoLabelGenerator.GenerateLabelName(aTargetMethod);
|
||||
xNormalAddress = LabelName.Get(aTargetMethod);
|
||||
}
|
||||
// mMethodIdentifier = GetService<IMetaDataInfoService>().GetMethodIdLabel(mMethod);
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true };
|
||||
new CPUx86.Push { DestinationValue = aTargetMethodUID };
|
||||
new CPUx86.Call {
|
||||
DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(VTablesImplRefs.GetMethodAddressForTypeRef)
|
||||
DestinationLabel = LabelName.Get(VTablesImplRefs.GetMethodAddressForTypeRef)
|
||||
};
|
||||
if (xExtraStackSize > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
|
||||
new Label( mReturnNullLabel );
|
||||
new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 };
|
||||
string xAllocInfoLabelName = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef );
|
||||
string xAllocInfoLabelName = LabelName.Get( GCImplementationRefs.AllocNewObjectRef );
|
||||
#warning TODO: Emit new exceptions
|
||||
//new Newobj( Assembler ).Execute( aMethod, aOpCode );
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
|
||||
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
|
||||
{
|
||||
new CPUx86.Push { DestinationRef = Cosmos.Assembler.ElementReference.New( MethodInfoLabelGenerator.GenerateLabelName(((OpMethod)aOpCode).Value ) ) };
|
||||
new CPUx86.Push { DestinationRef = Cosmos.Assembler.ElementReference.New( LabelName.Get(((OpMethod)aOpCode).Value ) ) };
|
||||
Assembler.Stack.Push(new StackContents.Item(4, typeof(uint)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();
|
||||
if (xCctor != null)
|
||||
{
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) };
|
||||
ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
|
||||
new Label(".AfterCCTorExceptionCheck");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();
|
||||
if (xCctor != null)
|
||||
{
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) };
|
||||
ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
|
||||
new Label(".AfterCCTorExceptionCheck");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
|
||||
string xTypeID = GetTypeIDLabel(typeof(Array));
|
||||
MethodBase xCtor = typeof( Array ).GetConstructors( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance )[ 0 ];
|
||||
string xCtorName = MethodInfoLabelGenerator.GenerateLabelName( xCtor );
|
||||
string xCtorName = LabelName.Get( xCtor );
|
||||
|
||||
new Comment( Assembler, "Element Size = " + xSize );
|
||||
// element count is on the stack
|
||||
|
|
@ -42,7 +42,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
Assembler.Stack.Push( new StackContents.Item( 4, typeof( uint ) ) );
|
||||
new Add( Assembler ).Execute( aMethod, aOpCode );
|
||||
// the total array size is now on the stack.
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get( GCImplementationRefs.AllocNewObjectRef ) };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true };
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
var xCctor = (objectType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();
|
||||
if (xCctor != null)
|
||||
{
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) };
|
||||
ILOp.EmitExceptionLogic(aAssembler, aMethod, xMethod, true, null, ".AfterCCTorExceptionCheck");
|
||||
new Label(".AfterCCTorExceptionCheck");
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
}
|
||||
|
||||
// todo: probably we want to check for exceptions after calling Alloc
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.AllocNewObjectRef) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(GCImplementationRefs.AllocNewObjectRef) };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true };
|
||||
|
||||
|
|
@ -194,11 +194,11 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
}
|
||||
}
|
||||
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(constructor) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(constructor) };
|
||||
if (aMethod != null)
|
||||
{
|
||||
new CPUx86.Test { DestinationReg = CPUx86.Registers.ECX, SourceValue = 2 };
|
||||
string xNoErrorLabel = currentLabel + ".NoError" + MethodInfoLabelGenerator.LabelCount.ToString();
|
||||
string xNoErrorLabel = currentLabel + ".NoError" + LabelName.LabelCount.ToString();
|
||||
new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = xNoErrorLabel };
|
||||
|
||||
//for( int i = 1; i < aCtorMethodInfo.Arguments.Length; i++ )
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ namespace Cosmos.IL2CPU.X86.IL {
|
|||
if (aNeedsGC) {
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.ECX };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) };
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(GCImplementationRefs.DecRefCountRef) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(GCImplementationRefs.DecRefCountRef) };
|
||||
}
|
||||
#endif
|
||||
new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 };
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();
|
||||
if (xCctor != null)
|
||||
{
|
||||
new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) };
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) };
|
||||
ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
|
||||
new Label(".AfterCCTorExceptionCheck");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Cosmos.IL2CPU.X86.Plugs.NEW_PLUGS {
|
|||
var xGetInvocationListMethod = typeof(MulticastDelegate).GetMethod("GetInvocationList");
|
||||
new CPU.Comment("push address of delgate to stack");
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };//addrof this
|
||||
new CPUx86.Call { DestinationLabel = CPU.MethodInfoLabelGenerator.GenerateLabelName(xGetInvocationListMethod) };
|
||||
new CPUx86.Call { DestinationLabel = CPU.LabelName.Get(xGetInvocationListMethod) };
|
||||
new CPU.Comment("get address from return value -> eax");
|
||||
new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX };
|
||||
;//list
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Cosmos.IL2CPU.X86.Plugs.CustomImplementations.System.Assemblers
|
|||
var xGetInvocationListMethod = typeof(MulticastDelegate).GetMethod("GetInvocationList");
|
||||
new CPU.Comment("push address of delgate to stack");
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };//addrof this
|
||||
new CPUx86.Call { DestinationLabel = CPU.MethodInfoLabelGenerator.GenerateLabelName(xGetInvocationListMethod) };
|
||||
new CPUx86.Call { DestinationLabel = CPU.LabelName.Get(xGetInvocationListMethod) };
|
||||
new CPU.Comment("get address from return value -> eax");
|
||||
new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; ;//list
|
||||
new CPU.Comment("eax+=8 is where the offset where an array's count is");
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ namespace Cosmos.Core.Plugs.Assemblers {
|
|||
if (xHandler == null) {
|
||||
xHandler = GetMethodDef(typeof(INTs).Assembly, typeof(INTs).FullName, "HandleInterrupt_Default", true);
|
||||
}
|
||||
new CPUx86.Call { DestinationLabel = CPUAll.MethodInfoLabelGenerator.GenerateLabelName(xHandler) };
|
||||
new CPUx86.Call { DestinationLabel = CPUAll.LabelName.Get(xHandler) };
|
||||
new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX };
|
||||
new CPUx86.x87.FXStore { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true };
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue