Exemple #1
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();
            }
        }
Exemple #2
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();
        }
Exemple #3
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();
        }
        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();
        }