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 void BuildMembers(IType type) { var instance = type.AbcInstance(); if (instance == null) { return; } if (instance.IsForeign) { return; } if (type.IsArray) { return; } //NOTE: //For array types we define only System.Array. //Therefore in order to correctly define memebers //we should use System.Array instead of SomeType[]. if (!ReferenceEquals(instance.Type, type)) { type = instance.Type; } if (!type.IsInterface) { _generator.FlexAppBuilder.DefineMembers(instance); DefineFields(type); } Initializers.EnshureInitializers(instance); //DefineCompiledMethods(type); DefineExposedMethods(type); }