summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-09-14 23:31:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-09-14 23:31:30 -0700
commit186a9866d9625dd67a725870a37afb64d934f51a (patch)
tree444ea187895cd6b92e0de758fa07f69794ef9d5a /stdlib
parentbb803a2a19989ba495933a6c40aff60652bc7fa2 (diff)
downloadtxr-186a9866d9625dd67a725870a37afb64d934f51a.tar.gz
txr-186a9866d9625dd67a725870a37afb64d934f51a.tar.bz2
txr-186a9866d9625dd67a725870a37afb64d934f51a.zip
compiler: eliminate uses of cdar.
* stdlib/compiler.tl (env (extend-var, extend-var*)): Return the variable binding rather than the alist containing it. (compiler (comp-catch, comp-let, comp-tree-case)): Drop use of cdar on return value of extend-var to ferret out the binding from the alist.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/compiler.tl16
1 files changed, 9 insertions, 7 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl
index bea78e33..8bb9f1d3 100644
--- a/stdlib/compiler.tl
+++ b/stdlib/compiler.tl
@@ -111,12 +111,14 @@
(compile-error me.co.last-form "duplicate variable: ~s" sym))
(let* ((loc ^(v ,(ppred me.lev) ,(pinc me.v-cntr)))
(bn (new vbinding sym sym loc loc env me)))
- (set me.vb (acons sym bn me.vb))))
+ (set me.vb (acons sym bn me.vb))
+ bn))
(:method extend-var* (me sym)
(let* ((loc ^(v ,(ppred me.lev) ,(pinc me.v-cntr)))
(bn (new vbinding sym sym loc loc env me)))
- (set me.vb (acons sym bn me.vb))))
+ (set me.vb (acons sym bn me.vb))
+ bn))
(:method extend-fun (me sym)
(when (assoc sym me.fb)
@@ -850,8 +852,8 @@
(mac-param-bind form (op symbols try-expr desc-expr . clauses) form
(with-gensyms (ex-sym-var ex-args-var)
(let* ((nenv (new env up env co me))
- (esvb (cdar nenv.(extend-var ex-sym-var)))
- (eavb (cdar nenv.(extend-var ex-args-var)))
+ (esvb nenv.(extend-var ex-sym-var))
+ (eavb nenv.(extend-var ex-args-var))
(tfrag me.(compile oreg nenv try-expr))
(dfrag me.(compile oreg nenv desc-expr))
(lhand (gensym "l"))
@@ -973,7 +975,7 @@
(form
(let* ((tmp (if seq (gensym)))
(bind (if seq
- (cdar nenv.(extend-var tmp))
+ nenv.(extend-var tmp)
nenv.(lookup-var sym)))
(frag me.(compile bind.loc fenv form)))
(when seq
@@ -1510,8 +1512,8 @@
(mac-param-bind form (op obj . cases) form
(let* ((ncases (len cases))
(nenv (new env up env co me))
- (obj-immut-var (cdar nenv.(extend-var (gensym))))
- (obj-var (cdar nenv.(extend-var (gensym))))
+ (obj-immut-var nenv.(extend-var (gensym)))
+ (obj-var nenv.(extend-var (gensym)))
(err-blk (gensym))
(lout (gensym "l"))
(ctx-form ^',form)