Changeset 12436 in project for chicken


Ignore:
Timestamp:
11/10/08 09:17:27 (11 years ago)
Author:
felix winkelmann
Message:

non-exported syntax is added to import libs to allow references from exported syntax

Location:
chicken/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/TODO

    r12398 r12436  
    99
    1010** expander
    11 *** when import-libraries are used, reference to unexported syntax in exported syntax fails
    12     it seems that we have to add unexported syntax to the import lib, in case it is referenced
    13     from exported syntax. ugh.
    1411*** expansion of r5rs_pitfall 4.2 incorrect
    1512    possibly due to a non-aliased implicit "begin" somewhere
  • chicken/trunk/expand.scm

    r12342 r12436  
    13351335      (set-module-defined-syntax-list!
    13361336       mod
    1337        (cons sym (module-defined-syntax-list mod))))))
     1337       (cons (cons sym val) (module-defined-syntax-list mod))))))
    13381338
    13391339(define (##sys#register-undefined sym mod)
     
    14141414        (mname (module-name mod))
    14151415        (ifs (module-import-forms mod))
     1416        (sexports (module-sexports mod))
    14161417        (mifs (module-meta-import-forms mod)))
    14171418    `(,@(if (pair? ifs) `((eval '(import ,@ifs))) '())
     
    14341435                     (error 'module "(internal) exported syntax has no source" name mname))
    14351436                   `(cons ',(car sexport) ,(cdr a))))
    1436                (module-sexports mod)))))))
    1437 
    1438 (define (##sys#register-compiled-module name iexports vexports sexports)
     1437               sexports))
     1438       (list
     1439        ,@(let loop ((sd (module-defined-syntax-list mod)))
     1440            (cond ((null? sd) '())
     1441                  ((assq (caar sd) sexports) (loop (cdr sd)))
     1442                  (else
     1443                   (let ((name (caar sd)))
     1444                     (cons `(cons ',(caar sd) ,(cdar sd))
     1445                           (loop (cdr sd))))))))))))
     1446
     1447(define (##sys#register-compiled-module name iexports vexports sexports #!optional
     1448                                        (sdefs '()))
    14391449  (let* ((sexps
    14401450          (map (lambda (se)
     
    14471457                     ie))
    14481458               iexports))
     1459         (nexps
     1460          (map (lambda (ne)
     1461                 (list (car ne) #f (##sys#er-transformer (cdr ne))))
     1462               sdefs))
    14491463         (mod (make-module name '() vexports sexps))
    1450          (exports (merge-se
    1451                    (##sys#macro-environment)
    1452                    (##sys#current-environment)
    1453                    iexps vexports sexps)))
     1464         (senv (merge-se
     1465                (##sys#macro-environment)
     1466                (##sys#current-environment)
     1467                iexps vexports sexps nexps)))
    14541468    (##sys#mark-imported-symbols iexps)
    14551469    (for-each
    14561470     (lambda (sexp)
    1457        (set-car! (cdr sexp) exports))
     1471       (set-car! (cdr sexp) senv))
    14581472     sexps)
    14591473    (for-each
    14601474     (lambda (iexp)
    14611475       (when (pair? (cdr iexp))
    1462          (set-car! (cdr iexp) exports)))
     1476         (set-car! (cdr iexp) senv)))
    14631477     iexps)
     1478    (for-each
     1479     (lambda (nexp)
     1480       (set-car! (cdr nexp) senv))
     1481     nexps)
    14641482    (set! ##sys#module-table (cons (cons name mod) ##sys#module-table))
    14651483    mod))
     
    15031521         (dlist (module-defined-list mod))
    15041522         (elist (module-exist-list mod))
    1505          (sdlist (map (lambda (sym) (assq sym (##sys#macro-environment)))
     1523         (sdlist (map (lambda (sym) (assq (car sym) (##sys#macro-environment)))
    15061524                      (module-defined-syntax-list mod)))
    15071525         (sexports
    15081526          (if (eq? #t explist)
    1509               (map (lambda (sd) (assq (car sd) (##sys#macro-environment)))
    1510                    sdlist)
     1527              sdlist
    15111528              (let loop ((me (##sys#macro-environment)))
    15121529                (cond ((null? me) '())
  • chicken/trunk/tests/runtests.sh

    r12114 r12436  
    2828echo "======================================== syntax tests (compiled) ..."
    2929$compile syntax-tests.scm && ./a.out
     30
     31echo "======================================== import library tests ..."
     32rm -f foo.import.*
     33$compile import-library-test1.scm -emit-import-library foo
     34$interpret -s import-library-test2.scm
     35$compile_s -s foo.import.scm -o foo.import.so
     36$interpret -s import-library-test2.scm
     37$compile import-library-test2.scm && ./a.out
    3038
    3139echo "======================================== syntax tests (matchable) ..."
Note: See TracChangeset for help on using the changeset viewer.