public override void CodeGen(CodeBuilder builder)
        {
            if (BaseExpression != null)
            {
                BaseExpression.CodeGen(builder);
                builder.AppendToken(".");
                builder.ForceNoWhitespace();
            }

            builder.AppendToken(Function);
            builder.ForceNoWhitespace();
            builder.AppendToken("(");
            builder.ForceNoWhitespace();
            builder.BeginSeparatedList(",");

            foreach (var argument in Arguments)
            {
                argument.CodeGen(builder);
                builder.EndOfSeparatedListItem();
            }

            builder.EndOfSeparatedList();
            builder.AppendToken(")");

            builder.EndOfStatement();
        }
        public static void CodeGen(this Visibilities visibility, CodeBuilder builder)
        {
            switch (visibility)
            {
            case Visibilities.Public:
                builder.AppendToken("public");
                break;

            case Visibilities.Protected:
                builder.AppendToken("protected");
                break;

            case Visibilities.Internal:
                builder.AppendToken("internal");
                break;

            case Visibilities.ProtectedInternal:
                builder.AppendToken("protected internal");
                break;

            case Visibilities.Private:
                builder.AppendToken("private");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(visibility), visibility, null);
            }
        }
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("if (");
            builder.ForceNoWhitespace();

            ConditionalExpression.CodeGen(builder);

            builder.AppendToken(")");
            builder.BeginBlock();

            ThenStatement.CodeGen(builder);

            builder.EndBlock();

            if (ElseStatement != null)
            {
                builder.EndOfLine(); // Nur einfachen Zeilenumbruch erzwingen

                builder.AppendToken("else");
                builder.BeginBlock();

                ElseStatement.CodeGen(builder);

                builder.EndBlock();
            }
        }
Exemplo n.º 4
0
        public override void CodeGen(CodeBuilder builder)
        {
            base.CodeGen(builder);

            Visibility.CodeGen(builder);
            Type.CodeGen(builder);

            builder.AppendToken(Name);

            builder.BeginBlock();

            // Getter
            builder.AppendToken("get");
            builder.BeginBlock();
            GetterStatement.CodeGen(builder);
            builder.EndBlock();

            builder.EndOfLine(); // EndBlock-Verhalten überschreiben, sodass keine Leerzeile entsteht

            // Setter
            builder.AppendToken("set");
            builder.BeginBlock();
            SetterStatement.CodeGen(builder);
            builder.EndBlock();

            builder.EndBlock();
        }
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("new");

            Type.CodeGen(builder);

            builder.ForceNoWhitespace();
            builder.AppendToken("()");
        }
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("(");
            builder.ForceNoWhitespace();

            builder.AppendToken(Operator);
            builder.ForceNoWhitespace();
            Expression.CodeGen(builder);

            builder.AppendToken(")");
        }
        public override void CodeGen(CodeBuilder builder)
        {
            BaseExpression.CodeGen(builder);

            builder.AppendToken("[");
            builder.ForceNoWhitespace();

            ElementExpression.CodeGen(builder);

            builder.AppendToken("]");
        }
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("(");
            builder.ForceNoWhitespace();
            Left.CodeGen(builder);

            builder.AppendToken(Operator);

            Right.CodeGen(builder);
            builder.AppendToken(")");
        }
        private void CodeGenConstructor(CodeBuilder builder, IReadOnlyList <PropertyBuilder> constructorProperties)
        {
            builder.AppendToken("public");
            builder.AppendToken(Name);
            builder.ForceNoWhitespace();
            builder.AppendToken("(");
            builder.ForceNoWhitespace();
            builder.BeginSeparatedList(",");

            foreach (var property in constructorProperties)
            {
                property.Type.CodeGen(builder);
                builder.AppendToken(property.GenerateParameterName());
                builder.EndOfSeparatedListItem();
            }

            builder.EndOfSeparatedList();
            builder.AppendToken(")");

            builder.BeginBlock();

            foreach (var property in constructorProperties)
            {
                builder.AppendToken(property.Name);
                builder.AppendToken("=");
                builder.AppendToken(property.GenerateParameterName());
                builder.EndOfStatement();
            }

            builder.EndBlock();
        }
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("{");
            builder.BeginSeparatedList(",");

            foreach (var element in Elements)
            {
                element.CodeGen(builder);
                builder.EndOfSeparatedListItem();
            }

            builder.EndOfSeparatedList();
            builder.AppendToken("}");
        }
Exemplo n.º 11
0
        public override void CodeGen(CodeBuilder builder)
        {
            base.CodeGen(builder);

            Visibility.CodeGen(builder);
            Type.CodeGen(builder);

            builder.AppendToken(Name);

            builder.AppendToken("=>");

            Expression.CodeGen(builder);

            builder.EndOfStatement();
            builder.EndOfLineBlock();
        }
        public override void CodeGen(CodeBuilder builder)
        {
            switch (Keyword)
            {
            case Keywords.This:
                builder.AppendToken("this");
                break;

            case Keywords.Value:
                builder.AppendToken("value");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("return");

            Expression.CodeGen(builder);

            builder.EndOfStatement();
        }
Exemplo n.º 14
0
        public void CodeGen(CodeBuilder builder)
        {
            if (string.IsNullOrEmpty(Namespace))
            {
                throw new InvalidOperationException("Kein Namespace angegeben");
            }

            // Header
            if (!string.IsNullOrEmpty(Header))
            {
                builder.AppendMultiLineComment(Header);
            }

            // Using-Direktiven
            foreach (string u in Usings)
            {
                builder.AppendToken("using");
                builder.AppendToken(u);
                builder.EndOfStatement();
            }

            builder.EndOfLineBlock();

            // Namespace
            builder.AppendToken("namespace");
            builder.AppendToken(Namespace);
            builder.BeginBlock();

            // Inhalt
            foreach (var module in Modules)
            {
                module.CodeGen(builder);
            }

            builder.EndBlock();
        }
Exemplo n.º 15
0
        public override void CodeGen(CodeBuilder builder)
        {
            string resultType;

            switch (Type.FullName)
            {
            case "System.Double":
                resultType = "double";
                break;

            case "System.Int32":
                resultType = "int";
                break;

            case "System.String":
                resultType = "string";
                break;

            case "System.Decimal":
                resultType = "decimal";
                break;

            case "System.Decimal[]":
                resultType = "decimal[]";
                break;

            case "System.Int64":
                resultType = "long";
                break;

            default:
                resultType = Type.FullName;
                break;
            }
            builder.AppendToken(resultType);
        }
Exemplo n.º 16
0
        public override void CodeGen(CodeBuilder builder)
        {
            base.CodeGen(builder);

            if (!Getter && !Setter)
            {
                throw new InvalidOperationException("Property muss einen Getter oder Setter haben");
            }

            Visibility.CodeGen(builder);
            Type.CodeGen(builder);

            builder.AppendToken(Name);

            builder.AppendToken("{");
            if (Getter)
            {
                builder.AppendToken("get;");
            }
            if (Setter)
            {
                builder.AppendToken("set;");
            }
            builder.AppendToken("}");

            if (DefaultExpression != null)
            {
                builder.AppendToken("=");
                DefaultExpression.CodeGen(builder);

                builder.EndOfStatement();
                builder.EndOfLineBlock();
            }
            else
            {
                builder.EndOfLineBlock();
            }
        }
        public void CodeGen(CodeBuilder builder)
        {
            Visibility.CodeGen(builder);

            switch (ModuleType)
            {
            case ModuleTypes.Class:
                builder.AppendToken("class");
                break;

            case ModuleTypes.Struct:
                builder.AppendToken("struct");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            builder.AppendToken(Name);

            if (Inheritations.Any())
            {
                builder.AppendToken(":");
                builder.BeginSeparatedList(",");

                foreach (var inheritation in Inheritations)
                {
                    inheritation.CodeGen(builder);
                    builder.EndOfSeparatedListItem();
                }

                builder.EndOfSeparatedList();
            }

            builder.BeginBlock();

            foreach (var constant in Constants)
            {
                constant.CodeGen(builder);
            }

            // Leerzeile nach den Konstanten
            if (Constants.Any())
            {
                builder.EndOfLineBlock();
            }

            // Konstruktor erzeugen
            var constructorProperties = Properties.Where(p => p.SetInConstructor).ToList();

            if (constructorProperties.Any())
            {
                CodeGenConstructor(builder, constructorProperties);
            }

            foreach (var property in Properties)
            {
                property.CodeGen(builder);
            }

            foreach (var method in Methods)
            {
                method.CodeGen(builder);
            }

            foreach (string code in StaticCode)
            {
                builder.AppendStaticCode(code);
            }

            builder.EndBlock();
        }
 public override void CodeGen(CodeBuilder builder)
 {
     builder.AppendToken(string.Join(".", MemberPath));
 }
 public override void CodeGen(CodeBuilder builder)
 {
     builder.AppendToken(ConstantExpressionConverter.ToConstantString(Type, TextConstant));
 }
Exemplo n.º 20
0
 public override void CodeGen(CodeBuilder builder)
 {
     builder.AppendToken(Type);
 }