Exemple #1
0
        private void SetVMCall(InstructionNode node, VmCall vmcall, Operand result, List <Operand> operands)
        {
            var method = GetVMCallMethod(vmcall);
            var symbol = Operand.CreateSymbolFromMethod(method, TypeSystem);

            node.SetInstruction(IRInstruction.CallStatic, result, symbol, operands);
        }
        private MosaMethod GetVMCallMethod(VmCall vmcall)
        {
            string methodName = vmcall.ToString();

            var method = InternalRuntimeType.FindMethodByName(methodName) ?? PlatformInternalRuntimeType.FindMethodByName(methodName);

            Debug.Assert(method != null, "Cannot find method: " + methodName);

            return(method);
        }
        /// <summary>
        /// Replaces the instruction with an internal call.
        /// </summary>
        /// <param name="context">The transformation context.</param>
        /// <param name="internalCallTarget">The internal call target.</param>
        private void ReplaceWithVmCall(Context context, VmCall internalCallTarget)
        {
            var type = TypeSystem.GetTypeByName("Mosa.Platform.Internal." + MethodCompiler.Architecture.PlatformName, "Runtime");

            Debug.Assert(type != null, "Cannot find platform runtime type");

            var method = type.FindMethodByName(internalCallTarget.ToString());

            Debug.Assert(method != null, "Cannot find method: " + internalCallTarget.ToString());

            context.ReplaceInstructionOnly(IRInstruction.Call);
            context.SetOperand(0, Operand.CreateSymbolFromMethod(TypeSystem, method));
            context.OperandCount = 1;
            context.MosaMethod = method;
        }
        /// <summary>
        /// Replaces the instruction with an internal call.
        /// </summary>
        /// <param name="context">The transformation context.</param>
        /// <param name="internalCallTarget">The internal call target.</param>
        private void ReplaceWithVmCall(Context context, VmCall internalCallTarget)
        {
            RuntimeType type = typeSystem.GetType(@"Mosa.Internal.Runtime");
            Debug.Assert(type != null, "Cannot find Mosa.Internal.Runtime");

            RuntimeMethod method = type.FindMethod(internalCallTarget.ToString());
            Debug.Assert(method != null, "Cannot find method: " + internalCallTarget.ToString());

            context.ReplaceInstructionOnly(IRInstruction.Call);
            context.SetOperand(0, Operand.CreateSymbolFromMethod(method));
            context.OperandCount = 1;
        }
        /// <summary>
        /// Replaces the instruction with an internal call.
        /// </summary>
        /// <param name="ctx">The transformation context.</param>
        /// <param name="internalCallTarget">The internal call target.</param>
        private void ReplaceWithInternalCall(Context ctx, VmCall internalCallTarget)
        {
            RuntimeType rt = RuntimeBase.Instance.TypeLoader.GetType(@"Mosa.Runtime.RuntimeBase");
            RuntimeMethod callTarget = FindMethod(rt, internalCallTarget.ToString());

            ctx.ReplaceInstructionOnly(IR.Instruction.CallInstruction);
            ctx.InvokeTarget = callTarget;
        }
        /// <summary>
        /// Replaces the instruction with an internal call.
        /// </summary>
        /// <param name="context">The transformation context.</param>
        /// <param name="internalCallTarget">The internal call target.</param>
        private void ReplaceWithVmCall(Context context, VmCall internalCallTarget)
        {
            var method = InternalRuntimeType.FindMethodByName(internalCallTarget.ToString());

            if (method == null)
            {
                method = PlatformInternalRuntimeType.FindMethodByName(internalCallTarget.ToString());
            }

            Debug.Assert(method != null, "Cannot find method: " + internalCallTarget.ToString());

            context.ReplaceInstructionOnly(IRInstruction.Call);
            context.SetOperand(0, Operand.CreateSymbolFromMethod(TypeSystem, method));
            context.OperandCount = 1;
            context.InvokeMethod = method;
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VmCallAttribute"/> class.
 /// </summary>
 /// <param name="runtimeCall">The runtime call.</param>
 public VmCallAttribute(VmCall runtimeCall)
 {
     this.runtimeCall = runtimeCall;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VmCallAttribute"/> class.
 /// </summary>
 /// <param name="runtimeCall">The runtime call.</param>
 public VmCallAttribute(VmCall runtimeCall)
 {
     this.runtimeCall = runtimeCall;
 }
        /// <summary>
        /// Replaces the instruction with an internal call.
        /// </summary>
        /// <param name="context">The transformation context.</param>
        /// <param name="internalCallTarget">The internal call target.</param>
        private void ReplaceWithVmCall(Context context, VmCall internalCallTarget)
        {
            RuntimeType rt = typeSystem.GetType(@"Mosa.Vm.Runtime");
            Debug.Assert(rt != null, "@rt / @callTarget=" + internalCallTarget.ToString());

            RuntimeMethod callTarget = rt.FindMethod(internalCallTarget.ToString());
            Debug.Assert(callTarget != null, "@callTarget=" + internalCallTarget.ToString());

            context.ReplaceInstructionOnly(IR.Instruction.CallInstruction);
            context.SetOperand(0, SymbolOperand.FromMethod(callTarget));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="VmCallAttribute"/> class.
 /// </summary>
 /// <param name="vmCall">The runtime call.</param>
 public VmCallAttribute(VmCall vmCall)
 {
     this.vmCall = vmCall;
 }