Skip to content

Commit ae2ed64

Browse files
committed
minor
1 parent 1ff5de8 commit ae2ed64

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/sci/impl/deftype.cljc

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
(sci.impl.deftype/->type-impl '~rec-type ~record-name ~record-name (zipmap ~(list 'quote fields) ~fields)))
193193
protocol-impls))))
194194

195-
(defn ^:private standard-record-path
195+
(defn ^:private analyze-defrecord*
196196
"Record-specific path — protocol implementations with keyword-based field access."
197197
[ctx form rec-type record-name constructor-fn-sym map-factory-sym
198198
field-set protocol-impls]
@@ -253,26 +253,6 @@
253253
(emit-record-type rec-type record-name constructor-fn-sym map-factory-sym
254254
protocol-impls)))
255255

256-
(defn deftype-macro
257-
"Macro expansion for deftype. Emits a (do (declare ->TypeName) (deftype* ...) (import ...))
258-
so that macroexpand reveals the constructor for static-analysis tools (e.g. Clerk).
259-
The declare is overwritten at analysis time by analyze-deftype*."
260-
[[_fname] _ record-name fields & raw-protocol-impls]
261-
(let [ns-name (utils/current-ns-name)
262-
tagged-name (symbol (str ns-name) (str record-name))
263-
class-name (symbol (str (munge ns-name) "." record-name))
264-
factory-fn-sym (symbol (str "->" record-name))
265-
protocol-impls (utils/split-when symbol? raw-protocol-impls)
266-
interfaces (mapv first protocol-impls)
267-
method-counts (mapv #(count (rest %)) protocol-impls)
268-
methods (mapcat rest protocol-impls)]
269-
(list 'do
270-
(list 'declare factory-fn-sym)
271-
(list* 'deftype* tagged-name class-name fields
272-
:implements (with-meta interfaces {:method-counts method-counts})
273-
methods)
274-
(list 'import (list (symbol (str ns-name)) record-name)))))
275-
276256
(defn analyze-deftype*
277257
"Analyzer handler for deftype* special form.
278258
Generates the type definition and protocol implementations,
@@ -304,9 +284,9 @@
304284
;; (factory fns are in the macro expansion)
305285
(let [constructor-fn-sym (symbol (str "__" factory-fn-str "__ctor__"))
306286
map-factory-sym (symbol (str "map->" record-name))]
307-
(standard-record-path ctx form rec-type record-name
308-
constructor-fn-sym map-factory-sym
309-
field-set protocol-impls))
287+
(analyze-defrecord* ctx form rec-type record-name
288+
constructor-fn-sym map-factory-sym
289+
field-set protocol-impls))
310290
;; Standard deftype code generation
311291
#?(:clj
312292
(let [deftype-fn (:deftype-fn ctx)
@@ -447,3 +427,23 @@
447427
[:namespaces (symbol (namespace tagged-name)) :types]
448428
assoc record-name (sci.lang.Type. {:sci.impl/type-name rec-type}))
449429
(@utils/analyze ctx result)))))
430+
431+
(defn deftype-macro
432+
"Macro expansion for deftype. Emits a (do (declare ->TypeName) (deftype* ...) (import ...))
433+
so that macroexpand reveals the constructor for static-analysis tools (e.g. Clerk).
434+
The declare is overwritten at analysis time by analyze-deftype*."
435+
[[_fname] _ record-name fields & raw-protocol-impls]
436+
(let [ns-name (utils/current-ns-name)
437+
tagged-name (symbol (str ns-name) (str record-name))
438+
class-name (symbol (str (munge ns-name) "." record-name))
439+
factory-fn-sym (symbol (str "->" record-name))
440+
protocol-impls (utils/split-when symbol? raw-protocol-impls)
441+
interfaces (mapv first protocol-impls)
442+
method-counts (mapv #(count (rest %)) protocol-impls)
443+
methods (mapcat rest protocol-impls)]
444+
(list 'do
445+
(list 'declare factory-fn-sym)
446+
(list* 'deftype* tagged-name class-name fields
447+
:implements (with-meta interfaces {:method-counts method-counts})
448+
methods)
449+
(list 'import (list (symbol (str ns-name)) record-name)))))

0 commit comments

Comments
 (0)