guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rtl playing with modules and lambda*'s


From: Stefan Israelsson Tampe
Subject: rtl playing with modules and lambda*'s
Date: Sun, 9 Dec 2012 22:20:52 +0100

Hi all,

Until wingo starts coding we can only support him by learning the current code base and learn what is needed in order
to finalize that work. Also shelving out bugs by exercising the code would be nice. So I have this grand plan of compiling
the whole of guile to in rtl and use the tests already made, to find the bugs, fix them and so on.

So my latest endeavor have been into

1. Making modules work
2. Making lambda* work

To make this work one need to implement a few wrapper instructions, as described in the previous mail.
Those are,

(define-macro-assembler (toplevel-set asm dst val sym sm ss)
  (let ((s (emit-non-immediate asm sym))
        (d (emit-non-immediate asm (current-module))))
    (emit-static-ref asm sm d)
    (emit-static-ref asm ss s)
    (emit-resolve asm dst sm ss)
    (emit-box-set! asm dst val)))

(define-macro-assembler (toplevel-define asm rsp val ss sym)
  (let ((s (emit-non-immediate asm sym)))
    (emit-static-ref asm ss s)
    (emit-define asm rsp ss val)))

(define-macro-assembler (module asm dst mod sym pred)
  (let ((s (emit-non-immediate asm sym))
        (m (emit-non-immediate asm (cons pred mod)))
        (v (intern-constant asm 0 #:slot #t)))
    (emit-module-ref asm dst v m s)))

(define-macro-assembler (module-set asm dst sm mod ss sym pred v)
  (let ((s (emit-non-immediate asm sym))
        (m (emit-non-immediate asm mod))
        (p (if pred 1 0)))
    (emit-static-ref asm sm m)
    (emit-static-ref asm ss s)
    (emit-resolve-module asm dst ss  p)
    (emit-resolve        asm dst dst ss)
    (emit-box-set! asm dst v)))

(define-macro-assembler (keys-opt asm nreq nopts allow-other-keys? has-rest? kw)
  (let* ((nreq       nreq)
         (iao       (if allow-other-keys? 1 0))
         (ihr       (if has-rest?         2 0))
         (flags     (+ iao ihr))
         (nreq+nopt (+ nopts nreq))
         (ntotal    (+ nreq+nopt (length kw)))
         (kw-ref    (emit-non-immediate asm kw)))
    (emit-bind-kwargs asm nreq flags nreq+nopt ntotal kw-ref)))

As you can see the reference module operations are straightforward but the set! is very verbose
and somewhat complex to use. Also the keys-opt one used to make lambda* works is not but a simple wrapper that
construct the static data in order for the function to work as advertized.

with this I can now compile srfi-1.scm to rtl and also the basics of modules also seems to be in place! cool.

So the next step would be to compile srfi-1 to actual rtl-value and start thinking of testing the code for correctness as well.

Have fun
/Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]