|
69 | 69 |
|
70 | 70 | :debug string of arbitrary debug information - optional. |
71 | 71 |
|
72 | | - :emit-seq-fn fn to call with each bytecode seq. This is an advanced |
73 | | - option and, if present, will be passed both the ASM |
74 | | - MethodVisitor and the raw (possibly nested) :emit op |
75 | | - seq for each method. Can be used to support new op |
76 | | - data types. For example, the `insn.op-map/emit-seq` fn |
77 | | - can be used to enable map-style op sequences. |
| 72 | + :emit-fn fn to be called to emit method bytecode. This is an |
| 73 | + advanced option and, if present, will be passed both |
| 74 | + the ASM MethodVisitor and the raw :emit value for each |
| 75 | + method. Can be used to support new op data types. For |
| 76 | + example, the `insn.op-map/emit-seq` fn can be used to |
| 77 | + enable map-style op sequences. |
78 | 78 |
|
79 | 79 | Each field and method can also be given :annotations and a :signature |
80 | 80 | as per above. |
|
200 | 200 | :emit [[:aload 0] |
201 | 201 | [:invokespecial :super :init [:void]] |
202 | 202 | [:return]]})) |
203 | | - emit-seq (:emit-seq-fn t op/emit-seq)] |
| 203 | + emit-fn (:emit-fn t op/emit-seq)] |
204 | 204 | (binding [util/*this* this |
205 | 205 | util/*super* super] |
206 | 206 | (doseq [f (:fields t)] |
207 | 207 | (visit-field cv f)) |
208 | 208 | (doseq [m (:methods t)] |
209 | | - (visit-method cv m emit-seq)) |
| 209 | + (visit-method cv m emit-fn)) |
210 | 210 | (doto cv |
211 | 211 | (ann/visit (:annotations t)) |
212 | 212 | .visitEnd)) |
|
225 | 225 | (ann/visit fv (:annotations f)) |
226 | 226 | (.visitEnd fv))) |
227 | 227 |
|
228 | | -(defn- visit-method [^ClassVisitor cv m emit-seq] |
| 228 | +(defn- visit-method [^ClassVisitor cv m emit-fn] |
229 | 229 | (let [mname (util/method-name (:name m)) |
230 | 230 | clinit? (= mname "<clinit>") |
231 | 231 | init? (= mname "<init>") |
|
255 | 255 | (binding [util/*labels* (atom {})] |
256 | 256 | (if (fn? emit) |
257 | 257 | (emit mv) |
258 | | - (emit-seq mv emit))) |
| 258 | + (emit-fn mv emit))) |
259 | 259 | (ann/visit mv (:annotations m)) |
260 | 260 | (doseq [[i anns] (or (:parameter-annotations m) (:param-annotations m))] |
261 | 261 | (ann/visit mv i anns)) |
|
0 commit comments