private AbcInstance DefineEnumSuperType(IType type) { if (!type.IsEnum) { throw new InvalidOperationException("type is not enum"); } var vtype = type.ValueType; var st = vtype.SystemType(); if (st == null) { throw new InvalidOperationException(string.Format("invalid enum type {0}", type.FullName)); } int index = GetEnumIndex(st); var instance = _enumSuperTypes[index]; if (instance != null) { return(instance); } var super = BuildInstance(type.BaseType); instance = _enumSuperTypes[index]; if (instance != null) { return(instance); } instance = new AbcInstance(true) { Name = Abc.DefineName(QName.PfxPackage(GetEnumName(st))), BaseTypeName = super.Name, BaseInstance = super, Initializer = Initializers.BuildDefaultInitializer(Abc, null) }; Abc.AddInstance(instance); instance.Class.Initializer = Abc.DefineEmptyMethod(); _enumSuperTypes[index] = instance; string name = Const.Boxing.Value; instance.CreateSlot(Abc.DefineName(QName.Global(name)), BuildMemberType(vtype)); //SetFlags(instance, type); return(instance); }
private AbcTrait CreateSlot(AbcMultiname type, string name) { var traitName = DefineSlotName(name); AbcTrait t; if (AbcGenConfig.UseActivationTraits) { t = _body.Traits.AddSlot(type, traitName); t.SlotId = _body.Traits.Count; } else { t = _activation.CreateSlot(traitName, type); t.SlotId = _activation.Traits.Count; } return(t); }