Commit e205bd85 authored by Erick Gallesio's avatar Erick Gallesio

.

parent b3673910
;;;;
;;;; compfile.stk -- STklos File Compiler
;;;;
;;;; Copyright 2001-2006 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;; Copyright 2001-2007 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;;
;;;; This program is free software; you can redistribute it and/or modify
......@@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 17-Mar-2001 12:11 (eg)
;;;; Last file update: 25-Nov-2006 20:05 (eg)
;;;; Last file update: 25-Jan-2007 21:25 (eg)
;;;;
(select-module STKLOS-COMPILER)
......@@ -37,14 +37,18 @@
(cdr old)))
(else (loop lst (cdr old)))))))
;; Return informations
(list :version (version)
:globals globs)))
(list :version (version)
:globals globs
:expanders (expander-sources))))
(let ((out (open-output-file output))
(globs (compiler-known-globals))
(tm (clock))
(copts (compiler:warn-use-undefined-postpone)))
;; Clear the list containing macros sources
(expander-sources-set! '())
;; Defer warning til the end of the compilation of file
(compiler:warn-use-undefined-postpone #t)
......
;bonus;;;
;;;;
;;;; c o m p i l e r . s t k -- STklos Compiler
;;;;
;;;; Copyright 2000-2007 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
......@@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 26-Feb-2000 10:47 (eg)
;;;; Last file update: 25-Jan-2007 19:53 (eg)
;;;; Last file update: 25-Jan-2007 22:22 (eg)
;;;;
(define-module STKLOS-COMPILER
......@@ -326,12 +326,12 @@ doc>
(if (null? env)
(let ((l (define->lambda e)))
(when (= (length l) 3)
(let* ((l (extended-lambda->lambda l))
(let* ((l (extended-lambda->lambda l))
(name (cadr l))
(proc (caddr l))
(expander `(lambda (form e) (apply ,proc (cdr form)))))
;; Install expander for further compilation
(install-expander! name (eval expander) expander)
(install-expander! name (eval expander) proc)
;; Compile code for installing expander (for byte-code files)
;; YES! we need both (install + compile)
(compile expander '() e #f)
......@@ -344,12 +344,12 @@ doc>
;; (for internal defines -> letrec)
(let ((l (define->lambda e)))
(when (= (length l) 3)
(let* ((l (extended-lambda->lambda l))
(let* ((l (extended-lambda->lambda l))
(name (cadr l))
(proc (caddr l))
(expander `(lambda (form e) (apply ,proc (cdr form)))))
;; Install expander for further compilation
(install-expander! name (eval expander) expander)))))
(install-expander! name (eval expander) proc)))))
;;;;
......@@ -1413,7 +1413,16 @@ doc>
(%file-informations path)
'()))))
(when (pair? infos)
(for-each new-global (key-get infos :globals '())))))
(for-each new-global (key-get infos :globals '()))
;; Install the expanders of the required file
(for-each (lambda (x)
(let* ((name (car x))
(proc (cdr x))
(expander `(lambda (form e) (apply ,proc (cdr form)))))
(eprintf "DEBUG: create back macro ~S\n" name)
(install-expander! name (eval expander) proc)))
(key-get infos :expanders '()))
)))
(compile-normal-call (car e) (cdr e) (length e) env e tail))
......
......@@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 15-Mar-2001 22:49 (eg)
;;;; Last file update: 25-Jan-2007 19:20 (eg)
;;;; Last file update: 25-Jan-2007 21:23 (eg)
;;;;
......@@ -46,6 +46,7 @@
(define *expander-list* '()) ; the macros
(define *expander-list-src* '()) ; their source code
(define (expander? x)
(assq x *expander-list*))
......@@ -64,17 +65,20 @@
(else (application-expander x e)))))))
(define (install-expander! id proc :optional code)
(define (install-expander! id proc code)
(set! *expander-list* (cons (cons id proc) *expander-list*))
;; Keep the code associated to the macro to save it in byte-code header
(when code
(set! *expander-list-src* (cons (cons id code) *expander-list-src*))))
;;(define (remove-expander! id)
;; (let ((exp (assq id *expander-list*)))
;; (set! *expander-list* (delete! exp *expander-list* eq?))))
(set! *expander-list-src* (cons (cons id code) *expander-list-src*)))
;;;
;;; Expander-list-src management
;;;
(define (expander-sources)
*expander-list-src*)
(define (expander-sources-set! v)
(set! *expander-list-src* '()))
;;;
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment