public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.SwitchVar)) { generator.IndentLine(level); generator.OutputStream.Write(String.Format("switch ({0})", this.SwitchVar)); generator.WriteNewLine(); generator.IndentLine(level); generator.OutputStream.Write("{"); generator.WriteNewLine(); SwitchCase defaultCase = null; // generate 'default' always as last case foreach (SwitchCase switchCase in this.switches) { if (switchCase.IsDefault) { defaultCase = switchCase; } else { switchCase.GenerateCode(level + 1, generator); } } if (defaultCase != null) { defaultCase.GenerateCode(level + 1, generator); } generator.IndentLine(level); generator.OutputStream.Write("}"); generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.Value)) { generator.IndentLine(level); if (this.IsDefault) { generator.OutputStream.Write("default:"); } else { generator.OutputStream.Write(String.Format("case {0}:", this.Value)); } generator.WriteNewLine(); generator.IndentLine(level + 1); generator.OutputStream.Write("{"); generator.WriteNewLine(); base.GenerateCode(level + 1, generator); generator.IndentLine(level + 1); generator.OutputStream.Write("}"); generator.WriteNewLine(); generator.IndentLine(level + 1); generator.OutputStream.Write("break;"); generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.Condition)) { generator.OutputStream.Write("#if " + this.Condition); generator.WriteNewLine(); base.GenerateCode(level, generator); generator.OutputStream.Write("#endif /* " + this.Condition + " */"); generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { if (this.Type != null) { generator.IndentLine(level); if (this.IsStatic) { generator.OutputStream.Write("static "); } // declare the variable this.Type.GenerateCode(generator); if (!String.IsNullOrWhiteSpace(this.InitialValue)) { // add initialization value generator.OutputStream.Write(" = "); generator.WriteMultilineString(this.InitialValue, level); } generator.OutputStream.Write(";"); generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.Condition)) { generator.IndentLine(level); generator.OutputStream.Write(String.Format("else if ({0})", this.Condition)); generator.WriteNewLine(); generator.IndentLine(level); generator.OutputStream.Write("{"); generator.WriteNewLine(); base.GenerateCode(level, generator); generator.IndentLine(level); generator.OutputStream.Write("}"); generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.Macro)) { if (this.Inverted) { generator.OutputStream.Write("#ifndef " + this.Macro); } else { generator.OutputStream.Write("#ifdef " + this.Macro); } generator.WriteNewLine(); base.GenerateCode(level, generator); generator.OutputStream.Write("#endif /* " + this.Macro + " */"); generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { generator.IndentLine(level); if (this.IsStatic) { generator.OutputStream.Write("static "); } this.returnType.GenerateCode(generator); generator.OutputStream.Write(" " + this.Name + "("); if (this.Parameter.Count > 0) { for (int i = 0; i < this.parameter.Count; i++) { this.parameter[i].GenerateCode(generator); if (i < (this.parameter.Count - 1)) { generator.OutputStream.Write(", "); } } } else { generator.OutputStream.Write("void"); } generator.OutputStream.Write(")"); generator.WriteNewLine(); generator.IndentLine(level); generator.OutputStream.Write("{"); generator.WriteNewLine(); base.GenerateCode(level, generator); generator.IndentLine(level); generator.OutputStream.Write("}"); generator.WriteNewLine(); }
public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.File)) { // includes are never indented if (this.IsLocal) { generator.OutputStream.Write("#include \"" + this.File + "\""); } else { generator.OutputStream.Write("#include <" + this.File + ">"); } generator.WriteNewLine(); } }
public override void GenerateCode(int level, CGenerator generator) { if (!String.IsNullOrWhiteSpace(this.Condition)) { generator.IndentLine(level); generator.OutputStream.Write(String.Format("if ({0})", this.Condition)); generator.WriteNewLine(); generator.IndentLine(level); generator.OutputStream.Write("{"); generator.WriteNewLine(); base.GenerateCode(level, generator); generator.IndentLine(level); generator.OutputStream.Write("}"); generator.WriteNewLine(); foreach (ElseIf elif in this.elseIf) { elif.GenerateCode(level, generator); } if (this.else_.InnerElements.Count > 0) { generator.IndentLine(level); generator.OutputStream.Write("else"); generator.WriteNewLine(); generator.IndentLine(level); generator.OutputStream.Write("{"); generator.WriteNewLine(); this.else_.GenerateCode(level, generator); generator.IndentLine(level); generator.OutputStream.Write("}"); generator.WriteNewLine(); } } }
public override void GenerateCode(int level, CGenerator generator) { generator.IndentLine(level); if (this.IsExtern) { generator.OutputStream.Write("extern "); } if (this.IsStatic) { generator.OutputStream.Write("static "); } this.returnType.GenerateCode(generator); generator.OutputStream.Write(" " + this.Name + "("); if (this.Parameter.Count > 0) { for (int i = 0; i < this.parameter.Count; i++) { this.parameter[i].GenerateCode(generator); if (i < (this.parameter.Count - 1)) { generator.OutputStream.Write(", "); } } } else { generator.OutputStream.Write("void"); } generator.OutputStream.Write(");"); generator.WriteNewLine(); }