protected override void GenerateInner(CodeGenerator generator, CodeCompositeTypeDeclaration enclosingType) { Modifiers.Generate(generator); generator.OutputIdentifier(TokenType.Identifier, enclosingType.Name); generator.Write(TokenType.Punctuation, '('); Parameters.GenerateCommaSeparated(generator); generator.Write(TokenType.Punctuation, ')'); if (Initializer != null) { Initializer.Generate(generator); } if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); foreach (var parameter in Parameters) { generator.ReserveLocal(parameter.Name); } Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.ExitLocalScope(); generator.Indent--; generator.WriteClosingBrace(); } else { generator.WriteEmptyBlock(); } }
protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions) { generator.WriteBlankLineBeforeEnteringBlock(); generator.WriteLine(TokenType.Keyword, "do"); if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); Statements.ReserveLocals(generator, default(CodeStatementEmitOptions)); Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.EnterLocalScope(); generator.Indent--; generator.WriteMiddleClosingBrace(true); } else { generator.WriteEmptyBlock(true); } generator.Write(TokenType.Keyword, "while"); generator.Write(TokenType.Space, ' '); generator.Write(TokenType.Punctuation, '('); Condition.Generate(generator); generator.WriteLine(TokenType.Punctuation, ");"); }
protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions) { generator.WriteBlankLineBeforeEnteringBlock(); generator.EnterLocalScope(); generator.Write(TokenType.Keyword, "using"); generator.Write(TokenType.Space, ' '); generator.Write(TokenType.Punctuation, '('); InitStatement.Generate(generator, CodeStatementEmitOptions.OmitSemiColon); generator.Write(TokenType.Punctuation, ')'); if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); Statements.ReserveLocals(generator, default(CodeStatementEmitOptions)); Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.ExitLocalScope(); generator.Indent--; generator.WriteClosingBrace(); } else { generator.WriteEmptyBlock(); } generator.ExitLocalScope(); }
protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions) { generator.Indent--; generator.Write(TokenType.Keyword, "case "); Value.Generate(generator); generator.WriteLine(TokenType.Punctuation, ':'); generator.Indent++; if (!Fallthrough) { generator.EnterLocalScope(); Statements.ReserveLocals(generator, default(CodeStatementEmitOptions)); } Statements.Generate(generator, default(CodeStatementEmitOptions)); if (!Fallthrough) { bool needsBreak = true; if (Statements.Count > 0) { var lastStatement = Statements[Statements.Count - 1]; needsBreak = !lastStatement.IsTerminator; } if (needsBreak) { generator.Write(TokenType.Keyword, "break"); generator.WriteLine(TokenType.Punctuation, ';'); } generator.ExitLocalScope(); } }
protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions) { generator.WriteBlankLineBeforeEnteringBlock(); generator.EnterLocalScope(); generator.Write(TokenType.Keyword, "foreach"); generator.Write(TokenType.Space, ' '); generator.Write(TokenType.Punctuation, '('); Declaration.Type.Generate(generator); generator.Write(TokenType.Space, ' '); generator.OutputIdentifier(TokenType.Identifier, Declaration.Name); generator.Write(TokenType.Space, ' '); generator.Write(TokenType.Keyword, "in"); generator.Write(TokenType.Space, ' '); Expression.Generate(generator); generator.Write(TokenType.Punctuation, ')'); if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); Statements.ReserveLocals(generator, default(CodeStatementEmitOptions)); Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.ExitLocalScope(); generator.Indent--; generator.WriteClosingBrace(); } else { generator.WriteEmptyBlock(); } generator.ExitLocalScope(); }
protected override void GenerateInner(CodeGenerator generator, CodeCompositeTypeDeclaration enclosingType) { generator.Write(TokenType.Keyword, "static"); generator.Write(TokenType.Space, ' '); generator.Write(TokenType.Identifier, enclosingType.Name); generator.Write(TokenType.Punctuation, "()"); if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); foreach (var parameter in Parameters) { generator.ReserveLocal(parameter.Name); } Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.ExitLocalScope(); generator.Indent--; generator.WriteClosingBrace(); } else { generator.WriteEmptyBlock(); } }
protected override void GenerateInner(CodeGenerator generator, CodeCompositeTypeDeclaration enclosingType) { generator.GenerateAttributes(ReturnTypeCustomAttributes, "return"); if (ExplicitImplementationType == null) { Modifiers.Generate(generator); } ReturnType.Generate(generator); generator.Write(TokenType.Space, ' '); if (ExplicitImplementationType != null) { ExplicitImplementationType.Generate(generator); generator.Write(TokenType.Punctuation, '.'); } generator.OutputIdentifier(TokenType.Identifier, Name); generator.OutputTypeParameters(TypeParameters); generator.Write(TokenType.Punctuation, '('); Parameters.GenerateCommaSeparated(generator); generator.Write(TokenType.Punctuation, ')'); foreach (var typeParameter in TypeParameters) { typeParameter.GenerateConstraints(generator); } if (enclosingType.IsInterface || (Modifiers & CodeMemberModifiers.ScopeMask) == CodeMemberModifiers.Abstract) { generator.WriteLine(TokenType.Punctuation, ';'); } else { if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); foreach (var parameter in Parameters) { generator.ReserveLocal(parameter.Name); } Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.ExitLocalScope(); generator.Indent--; generator.WriteClosingBrace(); } else { generator.WriteEmptyBlock(); } } }
protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions) { if (Statements.Count > 0) { generator.WriteOpeningBrace(); generator.Indent++; generator.EnterLocalScope(); Statements.ReserveLocals(generator, default(CodeStatementEmitOptions)); Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.ExitLocalScope(); generator.Indent--; generator.WriteClosingBrace(); } else { generator.WriteEmptyBlock(); } }
protected override void GenerateInner(CodeGenerator generator) { bool implicitlyTyped = true; foreach (var parameter in Parameters) { if (parameter.Type.RawName != "var") { implicitlyTyped = false; } } generator.EnterLocalScope(); if (implicitlyTyped) { if (Parameters.Count == 1) { generator.OutputIdentifier(TokenType.Identifier, Parameters[0].Name); } else { generator.Write(TokenType.Punctuation, '('); bool first = true; foreach (var parameter in Parameters) { if (first) { first = false; } else { generator.Write(TokenType.Punctuation, ','); generator.Write(TokenType.Space, ' '); } generator.OutputIdentifier(TokenType.Identifier, parameter.Name); } generator.Write(TokenType.Punctuation, ')'); } } else { generator.Write(TokenType.Punctuation, '('); Parameters.GenerateCommaSeparated(generator); generator.Write(TokenType.Punctuation, ')'); } generator.Write(TokenType.Space, ' '); generator.Write(TokenType.Operator, "=>"); generator.Write(TokenType.Space, ' '); if (ExpressionBody != null) { ExpressionBody.Generate(generator); } else { generator.WriteOpeningBrace(); generator.Indent++; Statements.Generate(generator, default(CodeStatementEmitOptions)); generator.Indent--; generator.WriteClosingBrace(true); } generator.ExitLocalScope(); }