mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 22:12:25 +00:00
This commit is contained in:
parent
9c8e74d864
commit
8e472f1d0e
2 changed files with 0 additions and 79 deletions
|
|
@ -1,78 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Cosmos.Assembler;
|
||||
using Cosmos.Assembler.x86;
|
||||
|
||||
namespace Cosmos.Assembler.XSharp {
|
||||
public class CodeGroup {
|
||||
protected Cosmos.Assembler.Assembler mAsm = Cosmos.Assembler.Assembler.CurrentInstance;
|
||||
|
||||
protected void SetDataMembers(object aInst) {
|
||||
var xThisType = aInst.GetType();
|
||||
var xParts = xThisType.FullName.Split('.');
|
||||
string xBaseLabel = xParts[xParts.Length - 1].Replace('+', '_') + "_";
|
||||
|
||||
foreach (var xMember in xThisType.GetFields(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
|
||||
if (xMember.FieldType.IsSubclassOf(typeof(DataMemberBase))) {
|
||||
var xCtor = xMember.FieldType.GetConstructor(new Type[] { typeof(string) });
|
||||
var xInst = (DataMemberBase)(xCtor.Invoke(new Object[] { xBaseLabel + xMember.Name }));
|
||||
xMember.SetValue(aInst, xInst);
|
||||
mAsm.DataMembers.Add(xInst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Assemble() {
|
||||
var xThisType = this.GetType();
|
||||
|
||||
// Generate Global DataMembers
|
||||
SetDataMembers(this);
|
||||
|
||||
foreach (var xType in xThisType.GetNestedTypes()) {
|
||||
// Skip abstracts so inlines can be supported. See DebugStub.
|
||||
if (xType.IsSubclassOf(typeof(CodeBlock)) && !xType.IsAbstract) {
|
||||
var xCtor = xType.GetConstructor(new Type[0]);
|
||||
var xBlock = (CodeBlock)(xCtor.Invoke(new Object[0]));
|
||||
|
||||
var xMethod = xType.GetMethod("Assemble");
|
||||
var xAttribs = xMethod.GetCustomAttributes(typeof(XSharpAttribute), false);
|
||||
bool xPreserveStack = false;
|
||||
bool xIsInterruptHandler = false;
|
||||
if (xAttribs.Length > 0) {
|
||||
var xAttrib = (XSharpAttribute)xAttribs[0];
|
||||
xPreserveStack = xAttrib.PreserveStack;
|
||||
xIsInterruptHandler = xAttrib.IsInteruptHandler;
|
||||
}
|
||||
|
||||
// Generate Local DataMembers
|
||||
SetDataMembers(xBlock);
|
||||
|
||||
// Issue label for the routine
|
||||
xBlock.Label = CodeBlock.MakeLabel(xType);
|
||||
|
||||
if (xPreserveStack) {
|
||||
xBlock.PushAll();
|
||||
}
|
||||
// Assemble the routine itself
|
||||
xBlock.Assemble();
|
||||
xBlock.Label = ".Exit";
|
||||
if (xPreserveStack) {
|
||||
xBlock.PopAll();
|
||||
}
|
||||
|
||||
// Issue the return for the routine
|
||||
if (xIsInterruptHandler) {
|
||||
xBlock.ReturnFromInterrupt();
|
||||
} else {
|
||||
xBlock.Return();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -69,7 +69,6 @@
|
|||
<Compile Include="Address.cs" />
|
||||
<Compile Include="AddressDirect.cs" />
|
||||
<Compile Include="AddressIndirect.cs" />
|
||||
<Compile Include="CodeGroup.cs" />
|
||||
<Compile Include="DataMemberBase.cs" />
|
||||
<Compile Include="DataMember32.cs" />
|
||||
<Compile Include="Memory.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue