Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
		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();
			}
		}
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
		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();
			}
		}
Exemplo n.º 6
0
		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();
			}
		}
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 9
0
		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();
			}
		}
Exemplo n.º 10
0
		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();
			}
		}
Exemplo n.º 11
0
        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();
            }
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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();
            }
        }
Exemplo n.º 14
0
		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();
                }
            }
        }
Exemplo n.º 16
0
		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();
				}
			}
		}
Exemplo n.º 17
0
		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();
		}
Exemplo n.º 18
0
		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();
			}
		}