예제 #1
0
        public override void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            if (LambdaType != null) {
                builder.Append("new ");
                CodeGenerationHelper.AppendClassName(builder, LambdaType);
                builder.Append("(");
            }

            builder.Append('(');

            var delimiter = "";
            foreach (var parameter in ParamNames) {
                builder.Append(delimiter);
                parameter.Render(builder);
                delimiter = ",";
            }

            builder.Append(") => {");

            Block.Render(builder, isInnerClass, level + 1, indent);

            builder.Append("}");

            if (LambdaType != null)
            {
                builder.Append(")");
            }
        }
        public void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            if (_methodNode.AssignedMethod == null) {
                throw new IllegalStateException("Method has no assignment for " + _methodNode.AdditionalDebugInfo);
            }
            if (_methodNode.AssignedProviderClassName != null) {
                builder.Append(_methodNode.AssignedProviderClassName);
                builder.Append(".");
            }
            
            builder.Append(_methodNode.AssignedMethod.Name).Append("(");
            var delimiter = "";

            // pass explicit parameters first
            foreach (var expression in _parameters) {
                builder.Append(delimiter);
                expression.Render(builder, isInnerClass, level, indent);
                delimiter = ",";
            }

            // pass pass-thru second
            if (_methodNode.OptionalSymbolProvider == null) {
                foreach (var name in _methodNode.DeepParameters) {
                    builder.Append(delimiter);
                    builder.Append(name);
                    delimiter = ",";
                }
            }

            builder.Append(")");
        }
예제 #3
0
        public override void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            if (isWhile) {
                builder.Append("while (");
                condition.Render(builder, isInnerClass, level + 1, indent);
                builder.Append(") {\n");
            }
            else {
                builder.Append("do {\n");
            }

            Block.Render(builder, isInnerClass, level + 1, indent);
            indent.Indent(builder, level);
            builder.Append("}\n");
            if (!isWhile) {
                indent.Indent(builder, level);
                builder.Append("while (");
                condition.Render(builder, isInnerClass, level + 1, indent);
                builder.Append(");\n");
            }
        }
예제 #4
0
        public override void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            var enumerator = _blocks.GetEnumerator();
            enumerator.MoveNext();

            var first = enumerator.Current;
            first.Render(builder, isInnerClass, level, indent);

            while (enumerator.MoveNext()) {
                builder.Append(" else ");
                enumerator.Current.Render(builder, isInnerClass, level, indent);
            }

            if (_optionalElse != null) {
                builder.Append(" else {\n");
                _optionalElse.Render(builder, isInnerClass, level + 1, indent);
                indent.Indent(builder, level);
                builder.Append("}");
            }

            builder.Append("\n");
        }
예제 #5
0
        public void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            if (_target != null) {
                AppendClassName(builder, _target);
            }
            else {
                builder.Append(_targetClassName);
            }

            builder.Append(".");
            builder.Append(_methodName);

            if (_methodTypeArgs.Length > 0) {
                var delimiter = "";

                builder.Append('<');

                foreach (var methodTypeArg in _methodTypeArgs) {
                    builder.Append(delimiter);
                    AppendClassName(builder, methodTypeArg);
                    delimiter = ",";
                }

                builder.Append('>');
            }

            builder.Append("(");
            RenderExpressions(builder, _params, isInnerClass);
            builder.Append(")");
        }
        public override void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            builder.Append("new ");
            AppendClassName(builder, interfaceOrSuperClass);
            builder.Append("(");
            RenderExpressions(builder, ctorParams.ToArray(), isInnerClass);
            builder.Append(") {\n");

            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();
            foreach (var pair in this.methods) {
                CodegenStackGenerator.RecursiveBuildStack(
                    pair.Second,
                    pair.First,
                    methods,
                    properties);
            }

            // public properties
            var delimiter = "";
            foreach (var publicMethod in properties.PublicProperties)
            {
                builder.Append(delimiter);
                publicMethod.Render(builder, true, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            // private properties
            delimiter = "";
            foreach (var method in properties.PrivateProperties)
            {
                builder.Append(delimiter);
                method.Render(builder, false, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            // public methods
            delimiter = "";
            foreach (var publicMethod in methods.PublicMethods) {
                builder.Append(delimiter);
                publicMethod.Render(builder, true, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            // private methods
            delimiter = "";
            foreach (var method in methods.PrivateMethods) {
                builder.Append(delimiter);
                method.Render(builder, false, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            indent.Indent(builder, level);
            builder.Append("}");
        }
예제 #7
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     RenderClass(target, builder);
 }
예제 #8
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append(_ref).Append(_increment ? "++" : "--");
 }
예제 #9
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append("false");
 }
예제 #10
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     _field.Render(builder);
 }
예제 #11
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append("if (").Append(var).Append("== null) { return false;}\n");
 }
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     Render(builder, isInnerClass, 4, new CodegenIndent(true));
 }
예제 #13
0
 public override void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     throw new NotImplementedException();
 }
예제 #14
0
 public virtual void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append(_ref);
 }
예제 #15
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     RenderConstant(builder, _constant);
 }
예제 #16
0
 public override void RenderStatement(
     StringBuilder builder,
     bool isInnerClass)
 {
     var indent = new CodegenIndent(true);
     @ref.Render(builder, isInnerClass, 1, indent);
     builder.Append("=");
     assignment.Render(builder, isInnerClass, 1, indent);
 }
예제 #17
0
 public override void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     base.Render(builder, isInnerClass, level, indent);
     builder.Append(_col);
 }
예제 #18
0
 public override void RenderStatement(
     StringBuilder builder,
     bool isInnerClass)
 {
     var codegenIndent = new CodegenIndent(true);
     _lhs.Render(builder, isInnerClass, 1, codegenIndent);
     builder.Append('=');
     _assignment.Render(builder, isInnerClass, 1, codegenIndent);
 }
예제 #19
0
 public virtual void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     RenderStatement(builder, isInnerClass);
     builder.Append(";\n");
 }
예제 #20
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     _expr.Render(builder, isInnerClass, level, indent);
     builder.Append(_increment ? "++" : "--");
 }
예제 #21
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     _lhs.Render(builder, isInnerClass, level, indent);
     builder.Append("=");
     _rhs.Render(builder, isInnerClass, level, indent);
 }
예제 #22
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append("new ").Append(_innerName).Append("(");
     CodegenExpressionBuilder.RenderExpressions(builder, _params, isInnerClass);
     builder.Append(")");
 }
예제 #23
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append("((");
     AppendClassName(builder, _clazz);
     builder.Append(")").Append(_ref).Append(")");
 }
예제 #24
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     _instance.Render(builder, isInnerClass, level, indent);
     builder.Append('.');
     builder.Append(_fieldNode.Name);
 }
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append("if (");
     _expression.Render(builder, isInnerClass, level + 1, indent);
     builder.Append(" == null) {return null;}\n");
 }
예제 #26
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     builder.Append("default(");
     builder.Append(_type.CleanName());
     builder.Append(")");
 }
예제 #27
0
 public override void RenderStatement(
     StringBuilder builder,
     bool isInnerClass)
 {
     var indent = new CodegenIndent(true);
     array.Render(builder, isInnerClass, 1, indent);
     builder.Append("[");
     index.Render(builder, isInnerClass, 1, indent);
     builder.Append("]=");
     expression.Render(builder, isInnerClass, 1, indent);
 }
예제 #28
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     foreach (var statement in statements) {
         indent.Indent(builder, level);
         statement.Render(builder, isInnerClass, level, indent);
     }
 }
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     _expression.Render(builder, isInnerClass, level, indent);
     builder.Append("[");
     _index.Render(builder, isInnerClass, level, indent);
     builder.Append("]");
 }
예제 #30
0
 public void Render(
     StringBuilder builder,
     bool isInnerClass,
     int level,
     CodegenIndent indent)
 {
     _lhs.Render(builder, isInnerClass, level, indent);
     builder.Append(" ");
     builder.Append(_not ? "!=" : "==");
     builder.Append(" null");
 }