コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public override void CodeGen(CodeBuilder builder)
        {
            builder.AppendToken("{");
            builder.BeginSeparatedList(",");

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

            builder.EndOfSeparatedList();
            builder.AppendToken("}");
        }
コード例 #4
0
        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();
        }