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