|
82 | 82 | function emit_field_info!(ctx::TypeEmitter, @nospecialize(dt::DataType), field::Int; indent::Int = 0)
|
83 | 83 | desc = Base.DataTypeFieldDesc(dt)[field]
|
84 | 84 | type_id = ctx.type_ids[fieldtype(dt, field)]
|
85 |
| - let indented_println(args...) = println(ctx.io, " " ^ indent, args...) |
86 |
| - indented_println("{") |
87 |
| - indented_println(" \"name\": ", field_name_json(dt, field), ",") |
88 |
| - indented_println(" \"offset\": ", desc.offset, ",") |
89 |
| - indented_println(" \"type\": ", type_id) |
90 |
| - print(ctx.io, " " ^ indent, "}") |
91 |
| - end |
| 85 | + print(ctx.io, " " ^ indent) |
| 86 | + print(ctx.io, "{") |
| 87 | + print(ctx.io, " \"name\": ", field_name_json(dt, field), ",") |
| 88 | + print(ctx.io, " \"type\": ", type_id, ",") |
| 89 | + print(ctx.io, " \"offset\": ", desc.offset) |
| 90 | + print(ctx.io, " }") |
92 | 91 | end
|
93 | 92 |
|
94 | 93 | function emit_struct_info!(ctx::TypeEmitter, @nospecialize(dt::DataType); indent::Int = 0)
|
@@ -157,15 +156,14 @@ function emit_method_info!(ctx::TypeEmitter, method::Core.Method; indent::Int =
|
157 | 156 | indented_println(" \"name\": ", escape_string_json(name), ",")
|
158 | 157 | indented_println(" \"arguments\": [")
|
159 | 158 | for i in 2:length(sig.parameters)
|
160 |
| - indented_println(" {") |
161 |
| - indented_println(" \"name\": ", escape_string_json(argnames[i]), ",") |
162 |
| - indented_println(" \"type\": ", ctx.type_ids[sig.parameters[i]]) |
163 |
| - indented_println(" }", i == length(sig.parameters) ? "" : ",") |
| 159 | + print(ctx.io, " " ^ (indent + 4)) |
| 160 | + print(ctx.io, "{") |
| 161 | + print(ctx.io, " \"name\": ", escape_string_json(argnames[i]), ",") |
| 162 | + print(ctx.io, " \"type\": ", ctx.type_ids[sig.parameters[i]]) |
| 163 | + println(ctx.io, i == length(sig.parameters) ? " }" : " },") |
164 | 164 | end
|
165 | 165 | indented_println(" ],")
|
166 |
| - indented_println(" \"returns\": {") |
167 |
| - indented_println(" \"type\": ", ctx.type_ids[rt]) |
168 |
| - indented_println(" }") |
| 166 | + indented_println(" \"returns\": { \"type\": ", ctx.type_ids[rt], " }") |
169 | 167 | print(ctx.io, " " ^ indent, "}")
|
170 | 168 | end
|
171 | 169 | end
|
|
0 commit comments