protected virtual void EmitInstantiableBlock() { if (TypeInfo.IsEnum) { if (Emitter.GetTypeDefinition(TypeInfo.Type) .CustomAttributes.Any(attr => attr.AttributeType.FullName == "System.FlagsAttribute")) { EnsureComma(); Write(JS.Fields.FLAGS + ": true"); Emitter.Comma = true; } var etype = TypeInfo.Type.GetDefinition().EnumUnderlyingType; var enumMode = Helpers.EnumEmitMode(TypeInfo.Type); var isString = enumMode >= 3 && enumMode <= 6; if (isString) { etype = Emitter.Resolver.Compilation.FindType(KnownTypeCode.String); } if (!etype.IsKnownType(KnownTypeCode.Int32)) { EnsureComma(); Write(JS.Fields.UNDERLYINGTYPE + ": "); Write(H5Types.ToJsName(etype, Emitter)); Emitter.Comma = true; } } if (HasEntryPoint) { EnsureComma(); Write(JS.Fields.ENTRY_POINT + ": true"); Emitter.Comma = true; } var ctorBlock = new ConstructorBlock(Emitter, TypeInfo, false); if (TypeInfo.HasRealInstantiable(Emitter) || TypeInfo.ClassType == ClassType.Struct) { ctorBlock.Emit(); new MethodBlock(Emitter, TypeInfo, false).Emit(); } }
protected virtual void EmitStaticBlock() { int pos = Emitter.Output.Length; bool comma = Emitter.Comma; bool newLine = Emitter.IsNewLine; Emitter.StaticBlock = true; EnsureComma(); if (TypeInfo.InstanceMethods.Any(m => m.Value.Any(subm => Emitter.GetEntityName(subm) == JS.Fields.STATICS)) || TypeInfo.InstanceConfig.Fields.Any(m => m.GetName(Emitter) == JS.Fields.STATICS)) { Write(JS.Vars.D); } Write(JS.Fields.STATICS); WriteColon(); BeginBlock(); int checkOutputPos = Emitter.Output.Length; var ctorBlock = new ConstructorBlock(Emitter, TypeInfo, true); ctorBlock.Emit(); HasEntryPoint = ctorBlock.HasEntryPoint; new MethodBlock(Emitter, TypeInfo, true).Emit(); var clear = checkOutputPos == Emitter.Output.Length; WriteNewLine(); EndBlock(); if (clear) { Emitter.Output.Length = pos; Emitter.Comma = comma; Emitter.IsNewLine = newLine; } else { Emitter.Comma = true; } Emitter.StaticBlock = false; }