public void SetDefinition(TypeSpec ts) { this.definition = ts.MemberDefinition; this.info = ts.GetMetaInfo(); this.BaseType = ts.BaseType; this.Interfaces = ts.Interfaces; this.modifiers = ts.Modifiers; }
public void Emit(OpCode opcode, TypeSpec type) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(opcode, type.GetMetaInfo()); }
public LocalBuilder DeclareLocal(TypeSpec type, bool pinned) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } return(ig.DeclareLocal(type.GetMetaInfo(), pinned)); }
public void BeginCatchBlock(TypeSpec type) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.BeginCatchBlock(type.GetMetaInfo()); }
public override void AddTypeForwarder(TypeSpec type, Location loc) { try { if (add_type_forwarder == null) { add_type_forwarder = typeof(AssemblyBuilder).GetMethod("AddTypeForwarder", BindingFlags.NonPublic | BindingFlags.Instance); } add_type_forwarder.Invoke(builder, new object[] { type.GetMetaInfo() }); } catch { base.AddTypeForwarder(type, loc); } }
// // The stack contains the pointer and the value of type `type' // public void EmitStoreFromPtr(TypeSpec type) { if (type.IsEnum) { type = EnumSpec.GetUnderlyingType(type); } if (type == TypeManager.int32_type || type == TypeManager.uint32_type) { ig.Emit(OpCodes.Stind_I4); } else if (type == TypeManager.int64_type || type == TypeManager.uint64_type) { ig.Emit(OpCodes.Stind_I8); } else if (type == TypeManager.char_type || type == TypeManager.short_type || type == TypeManager.ushort_type) { ig.Emit(OpCodes.Stind_I2); } else if (type == TypeManager.float_type) { ig.Emit(OpCodes.Stind_R4); } else if (type == TypeManager.double_type) { ig.Emit(OpCodes.Stind_R8); } else if (type == TypeManager.byte_type || type == TypeManager.sbyte_type || type == TypeManager.bool_type) { ig.Emit(OpCodes.Stind_I1); } else if (type == TypeManager.intptr_type) { ig.Emit(OpCodes.Stind_I); } else if (TypeManager.IsStruct(type) || TypeManager.IsGenericParameter(type)) { ig.Emit(OpCodes.Stobj, type.GetMetaInfo()); } else { ig.Emit(OpCodes.Stind_Ref); } }
public void Emit(OpCode opcode, TypeSpec type) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(opcode, type.GetMetaInfo()); if (TrackStackTypes) { switch (opcode.StackBehaviourPush) { case StackBehaviour.Push0: // Nothing break; case StackBehaviour.Pushi: SetStackType(ReferenceContainer.MakeType(Module, type)); break; case StackBehaviour.Push1: SetStackType(type); break; default: if (opcode == OpCodes.Box) { SetStackType(Module.Compiler.BuiltinTypes.Object); } else if (opcode == OpCodes.Castclass) { SetStackType(type); } else { throw new NotImplementedException(opcode.Name); } break; } } }
// // The stack contains the pointer and the value of type `type' // public void EmitStoreFromPtr(TypeSpec type) { if (type.IsEnum) { type = EnumSpec.GetUnderlyingType(type); } switch (type.BuiltinType) { case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: ig.Emit(OpCodes.Stind_I4); return; case BuiltinTypeSpec.Type.Long: case BuiltinTypeSpec.Type.ULong: ig.Emit(OpCodes.Stind_I8); return; case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.UShort: ig.Emit(OpCodes.Stind_I2); return; case BuiltinTypeSpec.Type.Float: ig.Emit(OpCodes.Stind_R4); return; case BuiltinTypeSpec.Type.Double: ig.Emit(OpCodes.Stind_R8); return; case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.SByte: case BuiltinTypeSpec.Type.Bool: ig.Emit(OpCodes.Stind_I1); return; case BuiltinTypeSpec.Type.IntPtr: ig.Emit(OpCodes.Stind_I); return; } switch (type.Kind) { case MemberKind.Struct: case MemberKind.TypeParameter: if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(OpCodes.Stobj, type.GetMetaInfo()); break; default: ig.Emit(OpCodes.Stind_Ref); break; } }
public override void AddTypeForwarder(TypeSpec type, Location loc) { builder.__AddTypeForwarder(type.GetMetaInfo(), false); }
public void BeginCatchBlock(TypeSpec type) { ig.BeginCatchBlock(type.GetMetaInfo()); }
// // Load the object from the pointer. // public void EmitLoadFromPtr(TypeSpec type) { if (type.Kind == MemberKind.Enum) { type = EnumSpec.GetUnderlyingType(type); } switch (type.BuiltinType) { case BuiltinTypeSpec.Type.Int: ig.Emit(OpCodes.Ldind_I4); break; case BuiltinTypeSpec.Type.UInt: ig.Emit(OpCodes.Ldind_U4); break; case BuiltinTypeSpec.Type.Short: ig.Emit(OpCodes.Ldind_I2); break; case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.Char: ig.Emit(OpCodes.Ldind_U2); break; case BuiltinTypeSpec.Type.Byte: ig.Emit(OpCodes.Ldind_U1); break; case BuiltinTypeSpec.Type.SByte: case BuiltinTypeSpec.Type.Bool: ig.Emit(OpCodes.Ldind_I1); break; case BuiltinTypeSpec.Type.ULong: case BuiltinTypeSpec.Type.Long: ig.Emit(OpCodes.Ldind_I8); break; case BuiltinTypeSpec.Type.Float: ig.Emit(OpCodes.Ldind_R4); break; case BuiltinTypeSpec.Type.Double: ig.Emit(OpCodes.Ldind_R8); break; case BuiltinTypeSpec.Type.IntPtr: ig.Emit(OpCodes.Ldind_I); break; default: switch (type.Kind) { case MemberKind.Struct: case MemberKind.TypeParameter: if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(OpCodes.Ldobj, type.GetMetaInfo()); break; case MemberKind.PointerType: ig.Emit(OpCodes.Ldind_I); break; default: ig.Emit(OpCodes.Ldind_Ref); break; } break; } if (TrackStackTypes) { // TODO: test for async when `this' can be used inside structs SetStackType(type); } }