From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: rtl playing with modules and lambda*'s
Date: Sun, 9 Dec 2012 22:20:52 +0100 [thread overview]
Message-ID: <CAGua6m0ec6pp1d3nOwOw4QL3mtq5gT=w1EHoCfE6j0nkiyVuOQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2567 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 2791 bytes --]
next reply other threads:[~2012-12-09 21:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-09 21:20 Stefan Israelsson Tampe [this message]
2012-12-11 14:29 ` rtl playing with modules and lambda*'s Nala Ginrut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGua6m0ec6pp1d3nOwOw4QL3mtq5gT=w1EHoCfE6j0nkiyVuOQ@mail.gmail.com' \
--to=stefan.itampe@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).