本文整理汇总了C#中ITypeSystem类的典型用法代码示例。如果您正苦于以下问题:C# ITypeSystem类的具体用法?C# ITypeSystem怎么用?C# ITypeSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITypeSystem类属于命名空间,在下文中一共展示了ITypeSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
/// <summary>
/// Replaces the intrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
{
var result = context.Result;
var op1 = context.Operand1;
var op2 = context.Operand2;
var constant = Operand.CreateConstant(BuiltInSigType.IntPtr, parameters.Count * 4);
var eax = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX); // FIXME - need access to virtual register allocator
var edx = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EDX); // FIXME - need access to virtual register allocator
var esp = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.ESP); // FIXME - need access to virtual register allocator
var ebp = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.EBP); // FIXME - need access to virtual register allocator
context.SetInstruction(X86.Sub, esp, constant);
context.AppendInstruction(X86.Mov, edx, esp);
var size = parameters.Count * 4 + 4;
foreach (var parameter in parameters)
{
context.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, edx, new IntPtr(size - 4)), Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, ebp, new IntPtr(size + 4)));
size -= 4;
}
context.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(BuiltInSigType.IntPtr, edx, new IntPtr(size - 4)), op1);
context.AppendInstruction(X86.Mov, eax, op2);
context.AppendInstruction(X86.Call, null, eax);
context.AppendInstruction(X86.Add, esp, constant);
context.AppendInstruction(X86.Mov, result, Operand.CreateCPURegister(result.Type, GeneralPurposeRegister.EAX)); // FIXME - need access to virtual register allocator
}
示例2: WebFormsDefaultHandler
public WebFormsDefaultHandler(ICommunicationContext context, ITypeSystem typeSystem, IDependencyResolver resolver)
{
_context = context;
_typeSystem = typeSystem;
_resolver = resolver;
_pageType = typeSystem.FromClr<Page>();
}
示例3: RegisterOperand
/// <summary>
/// Replaces the intrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
{
var result = context.Result;
//var op1 = context.Operand1;
var op2 = context.Operand2;
var eax = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX);
var edx = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EDX);
var esp = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.ESP);
var ebp = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EBP);
context.SetInstruction(X86.Sub, esp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4));
context.AppendInstruction(X86.Mov, edx, esp);
var size = parameters.Count * 4;
foreach (var parameter in parameters)
{
context.AppendInstruction(X86.Mov, new MemoryOperand(BuiltInSigType.IntPtr, edx.Register, new IntPtr(size - 4)), new MemoryOperand(BuiltInSigType.IntPtr, ebp.Register, new IntPtr(size + 8)));
size -= 4;
}
context.AppendInstruction(X86.Mov, eax, op2);
context.AppendInstruction(X86.Call, null, new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.EAX));
context.AppendInstruction(X86.Add, esp, new ConstantOperand(BuiltInSigType.IntPtr, parameters.Count * 4));
context.AppendInstruction(X86.Mov,result, new RegisterOperand(result.Type, GeneralPurposeRegister.EAX));
}
示例4: GetInternalAllocateStringCallTarget
private SymbolOperand GetInternalAllocateStringCallTarget(ITypeSystem typeSystem)
{
RuntimeType runtimeType = typeSystem.GetType(@"Mosa.Internal.Runtime");
RuntimeMethod callTarget = runtimeType.FindMethod(@"AllocateString");
return SymbolOperand.FromMethod(callTarget);
}
示例5: InternalTypeModule
/// <summary>
/// Initializes static data members of the type loader.
/// </summary>
/// <param name="typeSystem">The type system.</param>
public InternalTypeModule(ITypeSystem typeSystem)
{
Debug.Assert(typeSystem != null);
this.typeSystem = typeSystem;
this.types = new List<RuntimeType>();
}
示例6: DefaultModuleTypeSystem
/// <summary>
/// Initializes static data members of the type loader.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="metadataModule">The metadata module.</param>
public DefaultModuleTypeSystem(ITypeSystem typeSystem, IMetadataModule metadataModule)
{
Debug.Assert(typeSystem != null);
Debug.Assert(metadataModule != null);
Debug.Assert(metadataModule.Metadata != null);
this.typeSystem = typeSystem;
this.metadataModule = metadataModule;
this.metadata = metadataModule.Metadata;
methods = new RuntimeMethod[GetTableRows(TokenTypes.MethodDef)];
fields = new RuntimeField[GetTableRows(TokenTypes.Field)];
types = new RuntimeType[GetTableRows(TokenTypes.TypeDef)];
parameters = new RuntimeParameter[GetTableRows(TokenTypes.Param)];
typeSpecs = new RuntimeType[GetTableRows(TokenTypes.TypeSpec)];
methodSpecs = new RuntimeMethod[GetTableRows(TokenTypes.MethodSpec)];
// Load all types from the assembly into the type array
LoadTypes();
LoadGenerics();
LoadTypeSpecs();
LoadParameters();
LoadCustomAttributes();
}
示例7: Compile
/// <summary>
/// Link time code generator used to compile dynamically created methods during link time.
/// </summary>
/// <param name="compiler">The assembly compiler used to compile this method.</param>
/// <param name="methodName">The name of the created method.</param>
/// <param name="instructionSet">The instruction set.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException"><paramref name="compiler"/>, <paramref name="methodName"/> or <paramref name="instructionSet"/> is null.</exception>
/// <exception cref="System.ArgumentException"><paramref name="methodName"/> is invalid.</exception>
public static LinkerGeneratedMethod Compile(AssemblyCompiler compiler, string methodName, InstructionSet instructionSet, ITypeSystem typeSystem)
{
if (compiler == null)
throw new ArgumentNullException(@"compiler");
if (methodName == null)
throw new ArgumentNullException(@"methodName");
if (methodName.Length == 0)
throw new ArgumentException(@"Invalid method name.");
LinkerGeneratedType compilerGeneratedType = typeSystem.InternalTypeModule.GetType(@"Mosa.Tools.Compiler", @"LinkerGenerated") as LinkerGeneratedType;
// Create the type if we need to.
if (compilerGeneratedType == null)
{
compilerGeneratedType = new LinkerGeneratedType(typeSystem.InternalTypeModule, @"Mosa.Tools.Compiler", @"LinkerGenerated", null);
typeSystem.AddInternalType(compilerGeneratedType);
}
MethodSignature signature = new MethodSignature(BuiltInSigType.Void, new SigType[0]);
// Create the method
// HACK: <$> prevents the method from being called from CIL
LinkerGeneratedMethod method = new LinkerGeneratedMethod(typeSystem.InternalTypeModule, "<$>" + methodName, compilerGeneratedType, signature);
compilerGeneratedType.AddMethod(method);
LinkerMethodCompiler methodCompiler = new LinkerMethodCompiler(compiler, compiler.Pipeline.FindFirst<ICompilationSchedulerStage>(), method, instructionSet);
methodCompiler.Compile();
return method;
}
示例8:
/// <summary>
/// Replaces the intrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
{
// Retrieve register context
//context.SetInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP, new IntPtr(28)));
// Restore registers (Note: EAX and EDX are NOT restored!)
//context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EDX), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(28)));
//context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBX), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(4)));
//context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EDI), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(20)));
//context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESI), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(16)));
//context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(32)));
//context.AppendInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EBP), Operand.CreateMemoryAddress(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX, new IntPtr(24)));
//uint ebp, uint esp, int eip
Operand edx = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EDX);
Operand ebp = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EBP);
Operand esp = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP);
// Restore registers
context.SetInstruction(X86.Mov, Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.ESP), context.Operand1);
// Jmp to EIP (stored in EDX)
context.AppendInstruction(X86.Jmp, null, edx);
//context.SetOperand(0, edx);
}
示例9: SimpleJitMethodCompiler
public SimpleJitMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, Stream codeStream, ITypeSystem typeSystem)
: base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, typeSystem, compiler.Pipeline.FindFirst<ITypeLayout>())
{
if (codeStream == null)
throw new ArgumentNullException(@"codeStream");
this.codeStream = codeStream;
}
示例10:
/// <summary>
/// Replaces the intrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
{
Operand result = context.Result;
Operand imm = Operand.CreateCPURegister(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX);
context.SetInstruction(IR.IRInstruction.Move, imm, Operand.CreateCPURegister(BuiltInSigType.UInt32, control));
context.AppendInstruction(IR.IRInstruction.Move, result, imm);
}
示例11: AssemblyCompiler
/// <summary>
/// Initializes a new compiler instance.
/// </summary>
/// <param name="architecture">The compiler target architecture.</param>
/// <param name="typeSystem">The type system.</param>
protected AssemblyCompiler(IArchitecture architecture, ITypeSystem typeSystem)
{
if (architecture == null)
throw new ArgumentNullException(@"architecture");
this.architecture = architecture;
this.pipeline = new CompilerPipeline();
this.typeSystem = typeSystem;
}
示例12: RegisterOperand
/// <summary>
/// Replaces the intrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
{
Operand result = context.Result;
RegisterOperand imm = new RegisterOperand(BuiltInSigType.UInt32, GeneralPurposeRegister.EAX);
context.SetInstruction(IR.Instruction.MoveInstruction, imm, new RegisterOperand(BuiltInSigType.UInt32, control));
context.AppendInstruction(IR.Instruction.MoveInstruction, result, imm);
}
示例13:
/// <summary>
/// Replaces the intrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
void IIntrinsicInternalMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
{
Operand callTargetOperand = this.GetInternalAllocateStringCallTarget(typeSystem);
Operand methodTableOperand = Operand.CreateSymbol(BuiltInSigType.IntPtr, StringClassMethodTableSymbolName);
Operand lengthOperand = context.Operand1;
Operand result = context.Result;
context.SetInstruction(IRInstruction.Call, result, callTargetOperand, methodTableOperand, lengthOperand);
}
示例14: InternalTypeModule
/// <summary>
/// Initializes static data members of the type loader.
/// </summary>
/// <param name="typeSystem">The type system.</param>
public InternalTypeModule(ITypeSystem typeSystem)
{
Debug.Assert(typeSystem != null);
this.typeSystem = typeSystem;
this.types = new List<RuntimeType>();
this.methods = new List<RuntimeMethod>();
this.typeNames = new HashSet<string>();
}
示例15: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
Operand result = context.Result;
RegisterOperand imm = new RegisterOperand(new SigType(CilElementType.U4), GeneralPurposeRegister.EAX);
context.SetInstruction(IR.Instruction.MoveInstruction, imm, new RegisterOperand(new SigType(CilElementType.U4), _control));
context.AppendInstruction(IR.Instruction.MoveInstruction, result, imm);
}