/// <summary> /// Defines given type in generated ABC file /// </summary> /// <param name="type">the type to define</param> /// <returns>tag associated with given type</returns> public object Build(IType type) { if (type == null) { return(null); } if (Abc.IsDefined(type)) { return(type.Data); } var tag = ImportType(type); bool isImported = false; if (tag == null) { if (type.Data != null) { throw new InvalidOperationException(); } tag = BuildCore(type); } else { isImported = true; } if (tag != null) { _generator.SetData(type, tag); RegisterType(type); if (!isImported) { BuildMembers(type); } } return(type.Data); }
private object BuildUserType(IType type) { if (LinkVectorInstance(type)) { return(type.Data); } //NOTE: can be used only in typeof operations if (type.IsGeneric()) { return(null); } if (type.HasGenericParams()) { throw new InvalidOperationException(); } AbcMultiname superName; AbcInstance superType; DefineSuperType(type, out superName, out superType); //NOTE: Fix for enums. if (Abc.IsDefined(type)) { return(type.Data); } #if DEBUG DebugService.LogInfo("DefineUserType started for {0}", type.FullName); #endif var ifaceNames = BuildInterfaces(type); if (Abc.IsDefined(type)) { return(type.AbcInstance()); } var name = DefineInstanceName(type); var instance = new AbcInstance(true) { Type = type, Name = name, BaseTypeName = superName, BaseInstance = superType }; _generator.SetData(type, instance); SetFlags(instance, type); AddInterfaces(instance, type, ifaceNames); Abc.AddInstance(instance); if (_generator.IsRootSprite(type)) { _generator.RootSprite.Instance = instance; } DebugInfoBuilder.Build(_generator, type, instance); #if DEBUG DebugService.LogInfo("DefineUserType succeeded for {0}", type.FullName); #endif return(instance); }