-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Description
I got curious and tried emitting a record with the library.
The awesome part is it just worked. The "hard" part was it did not emit the default constructor emitted by javac, so I had to write one myself.
Looking at some bytecode, generating it seems straightforward:
(defn emit-record-constructor
[fields]
(conj
(into
[[:aload 0]
[:invokespecial :super :init [:void]]]
cat
(map-indexed
(fn [i {:keys [name type]}]
[[:aload 0]
[:aload (inc i)]
[:putfield :this name type]])
fields))
[:return]))Do you think it should be added by default when no init is provided with the same desc? (when the class's flags have :record)