public override void ToSource(StringBuilder sb)
        {
            sb.Append("foreach (");

            iterator.ToSource(sb);

            sb.Append(" in ");

            collection.ToSource(sb);

            sb.Append(")");

            NewLine(sb);

            statements.ToSource(sb);
        }
Example #2
0
        public override void ToSource(StringBuilder sb)
        {
            sb.Append(IdentNewLine(DocComment));

            if (attributes != null)
            {
                attributes.ToSource(sb);
            }

            TraceModifiers(Modifiers, sb);

            if (isExplicit)
            {
                sb.Append("explicit operator ");
                type.ToSource(sb);
            }
            else if (isImplicit)
            {
                sb.Append("implicit operator ");
                type.ToSource(sb);
            }
            else
            {
                type.ToSource(sb);
                sb.Append(" operator ");
                switch (op)
                {
                case TokenID.Plus:
                case TokenID.Minus:
                case TokenID.Not:
                case TokenID.Tilde:
                case TokenID.Star:
                case TokenID.Slash:
                case TokenID.Percent:
                case TokenID.BAnd:
                case TokenID.BOr:
                case TokenID.BXor:
                case TokenID.Greater:
                case TokenID.Less:
                    sb.Append((char)op);
                    break;

                case TokenID.PlusPlus:
                    sb.Append("++");
                    break;

                case TokenID.MinusMinus:
                    sb.Append("--");
                    break;

                case TokenID.True:
                    sb.Append("true");
                    break;

                case TokenID.False:
                    sb.Append("false");
                    break;

                case TokenID.ShiftLeft:
                    sb.Append("<<");
                    break;

                case TokenID.ShiftRight:
                    sb.Append(">>");
                    break;

                case TokenID.EqualEqual:
                    sb.Append("==");
                    break;

                case TokenID.NotEqual:
                    sb.Append("!=");
                    break;

                case TokenID.GreaterEqual:
                    sb.Append(">=");
                    break;

                case TokenID.LessEqual:
                    sb.Append("<=");
                    break;

                default:
                    sb.Append("<ILLEGAL OPERATOR: " + op + ">");
                    break;
                }
            }

            sb.Append("(");
            if (param1 != null)
            {
                param1.ToSource(sb);
            }
            if (param2 != null)
            {
                sb.Append(", ");
                param2.ToSource(sb);
            }
            sb.Append(")");

            if ((Modifiers & Modifier.Extern) != 0)
            {
                sb.Append(';');
                NewLine(sb);
            }
            else
            {
                NewLine(sb);
                statements.ToSource(sb);
            }
        }