/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { base.Decode(ctx, decoder); Token token = decoder.DecodeTokenType(); ctx.RuntimeField = decoder.Method.Module.GetField(token); // FIXME: Can this be put into a re-used method? if (ctx.RuntimeField.ContainsGenericParameter || ctx.RuntimeField.DeclaringType.ContainsOpenGenericParameters) { foreach (var field in decoder.Method.DeclaringType.Fields) { if (field.Name == ctx.RuntimeField.Name) { ctx.RuntimeField = field; break; } } if (ctx.RuntimeField.ContainsGenericParameter) { ctx.RuntimeField = decoder.GenericTypePatcher.PatchField(decoder.TypeModule, decoder.Method.DeclaringType as CilGenericType, ctx.RuntimeField); } decoder.Compiler.Scheduler.TrackFieldReferenced(ctx.RuntimeField); Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter); } SigType sigType = new RefSigType(ctx.RuntimeField.SignatureType); ctx.Result = LoadInstruction.CreateResultOperand(decoder, Operand.StackTypeFromSigType(sigType), sigType); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Read the branch target // Is this a short branch target? // FIXME: Remove unary branch instructions from this list. if (_opcode == OpCode.Beq_s || _opcode == OpCode.Bge_s || _opcode == OpCode.Bge_un_s || _opcode == OpCode.Bgt_s || _opcode == OpCode.Bgt_un_s || _opcode == OpCode.Ble_s || _opcode == OpCode.Ble_un_s || _opcode == OpCode.Blt_s || _opcode == OpCode.Blt_un_s || _opcode == OpCode.Bne_un_s) { sbyte target; decoder.Decode(out target); ctx.SetBranch(target); } else if (_opcode == OpCode.Beq || _opcode == OpCode.Bge || _opcode == OpCode.Bge_un || _opcode == OpCode.Bgt || _opcode == OpCode.Bgt_un || _opcode == OpCode.Ble || _opcode == OpCode.Ble_un || _opcode == OpCode.Blt || _opcode == OpCode.Blt_un || _opcode == OpCode.Bne_un) { int target; decoder.Decode(out target); ctx.SetBranch(target); } else { throw new NotSupportedException(@"Invalid branch opcode specified for BinaryBranchInstruction"); } }
/// <summary> /// Decodes the specified CIL instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> /// <remarks> /// This method is used by instructions to retrieve immediate operands /// From the instruction stream. /// </remarks> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); int index; // Opcode specific handling switch (opcode) { case OpCode.Ldarg: case OpCode.Ldarg_s: index = (int)decoder.Instruction.Operand; break; case OpCode.Ldarg_0: index = 0; break; case OpCode.Ldarg_1: index = 1; break; case OpCode.Ldarg_2: index = 2; break; case OpCode.Ldarg_3: index = 3; break; default: throw new System.NotImplementedException(); } // Push the loaded value onto the evaluation stack var parameterOperand = decoder.Compiler.GetParameterOperand(index); var result = LoadInstruction.CreateResultOperand(decoder, parameterOperand.Type); ctx.Operand1 = parameterOperand; ctx.Result = result; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Load the _stackFrameIndex token from the immediate Token token = decoder.DecodeTokenType(); //Console.WriteLine("Stfld used in {0}.{1}", decoder.Method.DeclaringType.FullName, decoder.Method.Name); Debug.Assert(token.Table == TableType.Field || token.Table == TableType.MemberRef, @"Invalid token type."); ITypeModule module = null; Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType; if (genericType != null) module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module; else module = decoder.Method.Module; ctx.RuntimeField = module.GetField(token); if (ctx.RuntimeField.ContainsGenericParameter) { foreach (RuntimeField field in decoder.Method.DeclaringType.Fields) if (field.Name == ctx.RuntimeField.Name) { ctx.RuntimeField = field; break; } Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter); } }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Opcode specific handling int index; switch (opcode) { case OpCode.Ldloc: case OpCode.Ldloc_s: index = (int)decoder.Instruction.Operand; break; case OpCode.Ldloc_0: index = 0; break; case OpCode.Ldloc_1: index = 1; break; case OpCode.Ldloc_2: index = 2; break; case OpCode.Ldloc_3: index = 3; break; default: throw new InvalidMetadataException(); } // Push the loaded value onto the evaluation stack var local = decoder.Compiler.GetLocalOperand(index); var result = LoadInstruction.CreateResultOperand(decoder, local.Type); ctx.Operand1 = local; ctx.Result = result; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); throw new NotImplementedException(); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Read the branch target // Is this a short branch target? if (opcode == OpCode.Brfalse_s || opcode == OpCode.Brtrue_s) { sbyte target = decoder.DecodeSByte(); ctx.SetBranch(target); } else if (opcode == OpCode.Brfalse || opcode == OpCode.Brtrue) { int target = decoder.DecodeInt(); ctx.SetBranch(target); } else if (opcode == OpCode.Switch) { // Don't do anything, the derived class will do everything } else { throw new NotSupportedException(@"Invalid opcode " + opcode.ToString() + " specified for UnaryBranchInstruction."); } }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode the base first base.Decode(ctx, decoder); ushort argIdx; // Opcode specific handling if (opcode == OpCode.Starg_s) { byte arg = decoder.DecodeByte(); argIdx = arg; } else { argIdx = decoder.DecodeUShort(); } // The argument is the result ctx.Result = decoder.Compiler.GetParameterOperand(argIdx); // FIXME: Do some type compatibility checks // See verification for this instruction and // verification types. }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Load the _stackFrameIndex token from the immediate TokenTypes token = decoder.DecodeTokenType(); //Console.WriteLine("Stfld used in {0}.{1}", decoder.Method.DeclaringType.FullName, decoder.Method.Name); Debug.Assert(TokenTypes.Field == (TokenTypes.TableMask & token) || TokenTypes.MemberRef == (TokenTypes.TableMask & token), @"Invalid token type."); ctx.RuntimeField = decoder.ModuleTypeSystem.GetField(token); if (ctx.RuntimeField.ContainsGenericParameter) { foreach (RuntimeField field in decoder.Method.DeclaringType.Fields) if (field.Name == ctx.RuntimeField.Name) { ctx.RuntimeField = field; break; } Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter); } }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); Token token = decoder.DecodeTokenType(); ITypeModule module = null; Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType; if (genericType != null) module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module; else module = decoder.Method.Module; ctx.RuntimeField = module.GetField(token); if (ctx.RuntimeField.ContainsGenericParameter) { foreach (RuntimeField field in decoder.Method.DeclaringType.Fields) if (field.Name == ctx.RuntimeField.Name) { ctx.RuntimeField = field; break; } Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter); } SigType sigType = ctx.RuntimeField.SignatureType; ctx.Result = LoadInstruction.CreateResultOperand(decoder, Operand.StackTypeFromSigType(sigType), sigType); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Opcode specific handling int index; switch (opcode) { case OpCode.Ldloc: case OpCode.Ldloc_s: index = (int)decoder.Instruction.Operand; break; case OpCode.Ldloc_0: index = 0; break; case OpCode.Ldloc_1: index = 1; break; case OpCode.Ldloc_2: index = 2; break; case OpCode.Ldloc_3: index = 3; break; default: throw new InvalidMetadataException(); } // Push the loaded value onto the evaluation stack var local = decoder.Compiler.LocalVariables[index]; var result = AllocateVirtualRegisterOrStackSlot(decoder.Compiler, local.Type); ctx.Operand1 = local; ctx.Result = result; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Read the type specification TokenTypes arrayEType; decoder.Decode(out arrayEType); ctx.Token = arrayEType; Mosa.Runtime.Vm.RuntimeType type = RuntimeBase.Instance.TypeLoader.GetType(decoder.Compiler.Assembly, arrayEType); //ctx.Result = /* TypeReference eType = MetadataTypeReference.FromToken(decoder.Metadata, arrayEType); // FIXME: If _operands[0] is an integral constant, we can infer the maximum size of the array // and instantiate an ArrayTypeSpecification with max. sizes. This way we could eliminate bounds // checks in an optimization stage later on, if we find that a value never exceeds the array // bounds. // Build a type specification ArrayTypeSpecification typeRef = new ArrayTypeSpecification(eType); _results[0] = CreateResultOperand(typeRef); */ }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Push the address on the stack ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.U); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); byte alignment = decoder.DecodeByte(); ctx.Other = alignment; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // FIXME: Validate operands & verify instruction ctx.Result = decoder.Compiler.CreateTemporary(new SigType(CilElementType.I4)); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // FIXME: Validate operands & verify instruction ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.I4); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Set the result ctx.Result = decoder.Compiler.CreateTemporary(new SigType(CilElementType.I4)); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); byte alignment = (byte)decoder.Instruction.Operand; ctx.Other = alignment; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Set the result ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.I4); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // FIXME: Validate operands & verify instruction ctx.Result = decoder.Compiler.CreateVirtualRegister(BuiltInSigType.Int32); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Set the result ctx.Result = decoder.Compiler.CreateTemporary(BuiltInSigType.Int32); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Push the address on the stack ctx.Result = decoder.Compiler.CreateTemporary(BuiltInSigType.IntPtr); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var type = (MosaType)decoder.Instruction.Operand; ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.Object); ctx.MosaType = type; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var block = decoder.GetBlock((int)decoder.Instruction.Operand); ctx.AddBranchTarget(block); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var type = (MosaType)decoder.Instruction.Operand; ctx.Result = decoder.Compiler.CreateVirtualRegister(type.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); byte nocheck = (byte)decoder.Instruction.Operand; //FUTURE: //ctx.Other = nocheck; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); byte nocheck= decoder.DecodeByte(); ctx.Other = nocheck; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var type = (MosaType)decoder.Instruction.Operand; throw new NotImplementCompilerException(); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Set the result ctx.TokenType = ((HeapIndexToken)decoder.DecodeInt()) | HeapIndexToken.UserString; ctx.Result = decoder.Compiler.CreateTemporary(BuiltInSigType.String); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Retrieve the provider token to check against TokenTypes token = decoder.DecodeTokenType(); ctx.Result = decoder.Compiler.CreateTemporary(new ClassSigType(token)); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); MosaType type = (elementType == null) ? type = (MosaType)decoder.Instruction.Operand : type = decoder.TypeSystem.GetTypeFromTypeCode(elementType.Value); ctx.MosaType = type; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var field = (MosaField)decoder.Instruction.Operand; decoder.Compiler.Scheduler.TrackFieldReferenced(field); ctx.MosaField = field; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { base.Decode(ctx, decoder); var field = (MosaField)decoder.Instruction.Operand; decoder.Compiler.Scheduler.TrackFieldReferenced(field); ctx.MosaField = field; ctx.Result = LoadInstruction.CreateResultOperand(decoder, field.FieldType.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Retrieve a type reference from the immediate argument // FIXME: Limit the token types Token token = decoder.DecodeTokenType(); throw new NotImplementedException(); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); MosaType type = (MosaType)decoder.Instruction.Operand; ctx.MosaType = type; ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.I4); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); MosaType type = (elementType == null) ? type = (MosaType)decoder.Instruction.Operand : type = decoder.TypeSystem.GetTypeFromTypeCode(elementType.Value); ctx.Result = AllocateVirtualRegisterOrStackSlot(decoder.Compiler, type); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); // Retrieve a type reference from the immediate argument // FIXME: Limit the token types var token = (MosaType)decoder.Instruction.Operand; throw new CompilerException(); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); node.MosaType = (elementType == null) ? (MosaType)decoder.Instruction.Operand : decoder.MethodCompiler.Compiler.GetTypeFromTypeCode(elementType.Value); // FIXME: Check the value/destinations }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); byte nocheck; decoder.Decode(out nocheck); ctx.Other = nocheck; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { base.Decode(ctx, decoder); var field = (MosaField)decoder.Instruction.Operand; decoder.Compiler.Scheduler.TrackFieldReferenced(field); ctx.MosaField = field; ctx.Result = AllocateVirtualRegisterOrStackSlot(decoder.Compiler, field.FieldType.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode the base first base.Decode(ctx, decoder); // The argument is the result ctx.Result = decoder.Compiler.GetParameterOperand((int)decoder.Instruction.Operand); // FIXME: Do some type compatibility checks // See verification for this instruction and // verification types. }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Opcode specific handling Operand local = decoder.Compiler.GetLocalOperand((int)decoder.Instruction.Operand); ctx.Operand1 = local; ctx.Result = decoder.Compiler.CreateVirtualRegister(local.Type.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); var field = (MosaField)decoder.Instruction.Operand; Debug.Assert(field.IsStatic, "Static field access on non-static field."); node.MosaField = field; node.Result = decoder.MethodCompiler.AllocateVirtualRegisterOrStackSlot(field.FieldType); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode the base first base.Decode(node, decoder); // The argument is the result node.Result = decoder.MethodCompiler.Parameters[(int)decoder.Instruction.Operand]; // FIXME: Do some type compatibility checks // See verification for this instruction and // verification types. }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); var field = (MosaField)decoder.Instruction.Operand; decoder.MethodCompiler.Scheduler.TrackFieldReferenced(field); node.Result = AllocateVirtualRegisterOrStackSlot(decoder.MethodCompiler, field.FieldType); node.MosaField = field; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); Token token = decoder.DecodeTokenType(); RuntimeType type = decoder.TypeModule.GetType(token); ctx.Result = decoder.Compiler.CreateTemporary(new ClassSigType(token)); //throw new NotImplementedException(); }
public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var type = (MosaType)decoder.Instruction.Operand; //Operand result = decoder.Compiler.CreateVirtualRegister(type); //ctx.Result = result; ctx.Result = LoadInstruction.CreateResultOperand(decoder, type); ctx.MosaType = type; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var field = (MosaField)decoder.Instruction.Operand; decoder.Compiler.Scheduler.TrackFieldReferenced(field); ctx.MosaField = field; ctx.Result = LoadInstruction.CreateResultOperand(decoder, field.FieldType); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); var method = (MosaMethod)decoder.Instruction.Operand; decoder.MethodCompiler.Scheduler.TrackMethodInvoked(method); node.Result = decoder.MethodCompiler.CreateVirtualRegister(decoder.TypeSystem.ToFnPtr(method.Signature)); node.InvokeMethod = method; }
public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); var type = (MosaType)decoder.Instruction.Operand; //Operand result = decoder.Compiler.CreateVirtualRegister(type); //ctx.Result = result; node.Result = decoder.MethodCompiler.AllocateVirtualRegisterOrStackSlot(type); node.MosaType = type; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); var field = (MosaField)decoder.Instruction.Operand; decoder.Compiler.Scheduler.TrackFieldReferenced(field); ctx.MosaField = field; ctx.Result = decoder.Compiler.CreateVirtualRegister(field.FieldType.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Retrieve the type reference Token token = decoder.DecodeTokenType(); ctx.Token = token; decoder.TypeModule.GetType(token); }
/// <summary> /// Decodes the invocation target. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The IL decoder, which provides decoding functionality.</param> /// <param name="flags">Flags, which control the</param> /// <returns></returns> protected static Token DecodeInvocationTarget(Context ctx, IInstructionDecoder decoder, InvokeSupportFlags flags) { // Retrieve the immediate argument - it contains the token // of the methoddef, methodref, methodspec or callsite to call. Token callTarget = decoder.DecodeTokenType(); if (!IsCallTargetSupported(callTarget.Table, flags)) { throw new InvalidOperationException(@"Invalid IL call target specification."); } RuntimeMethod method = null; ITypeModule module = null; Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType; if (genericType != null) { module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module; } else { module = decoder.Method.Module; } switch (callTarget.Table) { case TableType.MethodDef: method = module.GetMethod(callTarget); break; case TableType.MemberRef: method = module.GetMethod(callTarget, decoder.Method.DeclaringType); if (method.DeclaringType.IsGeneric) { decoder.Compiler.Scheduler.ScheduleTypeForCompilation(method.DeclaringType); } break; case TableType.MethodSpec: method = module.GetMethod(callTarget); decoder.Compiler.Scheduler.ScheduleTypeForCompilation(method.DeclaringType); break; default: Debug.Assert(false, @"Should never reach this!"); break; } SetInvokeTarget(ctx, decoder.Compiler, method); return(callTarget); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); MosaType type = (elementType == null) ? type = (MosaType)decoder.Instruction.Operand : type = decoder.TypeSystem.GetTypeFromTypeCode(elementType.Value); node.MosaType = type; // FIXME: Check the value/destinations }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Opcode specific handling int index = (int)decoder.Instruction.Operand; var parameterOperand = decoder.Compiler.Parameters[index]; ctx.Operand1 = parameterOperand; ctx.Result = decoder.Compiler.CreateVirtualRegister(parameterOperand.Type.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Retrieve a type reference From the immediate argument // FIXME: Limit the token types TokenTypes token; decoder.Decode(out token); throw new NotImplementedException(); //_typeRef = MetadataTypeReference.FromToken(decoder.Metadata, token); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Do we have a type? if (this._typeRef == null) { // No, retrieve a type reference from the immediate argument Token token = decoder.DecodeTokenType(); this._typeRef = new ClassSigType(token); } }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); MosaType type = (elementType == null) ? type = (MosaType)decoder.Instruction.Operand : type = decoder.TypeSystem.GetTypeFromTypeCode(elementType.Value); // Push the loaded value ctx.Result = LoadInstruction.CreateResultOperand(decoder, type); ctx.MosaType = type; }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="node">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(InstructionNode node, IInstructionDecoder decoder) { // Decode base classes first base.Decode(node, decoder); // Opcode specific handling var local = decoder.MethodCompiler.LocalVariables[(int)decoder.Instruction.Operand]; local = decoder.ConvertVirtualRegisterToStackLocal(local); node.Operand1 = local; node.Result = decoder.MethodCompiler.CreateVirtualRegister(local.Type.ToManagedPointer()); }
/// <summary> /// Decodes the specified instruction. /// </summary> /// <param name="ctx">The context.</param> /// <param name="decoder">The instruction decoder, which holds the code stream.</param> public override void Decode(Context ctx, IInstructionDecoder decoder) { // Decode base classes first base.Decode(ctx, decoder); // Read the field From the code TokenTypes token; decoder.Decode(out token); ctx.RuntimeField = RuntimeBase.Instance.TypeLoader.GetField(decoder.Compiler.Assembly, token); Debug.Assert((ctx.RuntimeField.Attributes & FieldAttributes.Static) == FieldAttributes.Static, @"Static field access on non-static field."); }