mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
WIP - eval/lambda
This commit is contained in:
parent
8c3d5347ab
commit
cbb969221a
4 changed files with 45 additions and 23 deletions
5
Makefile
5
Makefile
|
@ -108,6 +108,11 @@ install-libs:
|
|||
$(MKDIR) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m0644 libcyclone.a $(DESTDIR)$(LIBDIR)/
|
||||
|
||||
install-bin:
|
||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -m0755 cyclone $(DESTDIR)$(BINDIR)/
|
||||
$(INSTALL) -m0755 icyc $(DESTDIR)$(BINDIR)/
|
||||
|
||||
# TODO: rewrite install to be in terms of incremental steps above.
|
||||
# also want to propagate this change to cyclone-bootstrap
|
||||
install:
|
||||
|
|
2
TODO
2
TODO
|
@ -15,6 +15,8 @@ Working TODO list. should start creating issues for these to get them out of her
|
|||
need to think about how macros from sld's will end up being
|
||||
loaded though. do we need to emit .meta files or such?
|
||||
|
||||
problem right now in that built-in macros work because they become compiled functions, but macros loaded at compile time may be just scheme objects (and eventually, compiled functions from libs).
|
||||
|
||||
- profile cyclone code, see if there are any bottlenecks we can reduce
|
||||
EG: prof cyclone transforms.sld
|
||||
|
||||
|
|
13
runtime.c
13
runtime.c
|
@ -1867,14 +1867,23 @@ object apply(object cont, object func, object args){
|
|||
case cons_tag:
|
||||
{
|
||||
// TODO: should add more error checking here, make sure car(func) is a symbol
|
||||
object fobj = car(func);
|
||||
|
||||
if (!is_object_type(fobj) || type_of(fobj) != symbol_tag) {
|
||||
Cyc_rt_raise2("Call of non-procedure: ", func);
|
||||
} else if (strncmp(((symbol)fobj)->pname, "lambda", 7) == 0) {
|
||||
make_cons(c, func, args);
|
||||
printf("JAE DEBUG, sending to eval: ");
|
||||
Cyc_display(&c, stderr);
|
||||
((closure)__glo_eval)->fn(3, __glo_eval, cont, &c, nil);
|
||||
|
||||
// TODO: would be better to compare directly against symbols here,
|
||||
// but need a way of looking them up ahead of time.
|
||||
// maybe a libinit() or such is required.
|
||||
if (strncmp(((symbol)car(func))->pname, "primitive", 10) == 0) {
|
||||
} else if (strncmp(((symbol)fobj)->pname, "primitive", 10) == 0) {
|
||||
make_cons(c, cadr(func), args);
|
||||
((closure)__glo_eval)->fn(3, __glo_eval, cont, &c, nil);
|
||||
} else if (strncmp(((symbol)car(func))->pname, "procedure", 10) == 0) {
|
||||
} else if (strncmp(((symbol)fobj)->pname, "procedure", 10) == 0) {
|
||||
make_cons(c, func, args);
|
||||
((closure)__glo_eval)->fn(3, __glo_eval, cont, &c, nil);
|
||||
} else {
|
||||
|
|
48
test2.scm
48
test2.scm
|
@ -1,24 +1,30 @@
|
|||
(import (scheme base)
|
||||
(scheme write))
|
||||
(import (scheme eval))
|
||||
|
||||
;(define-syntax test
|
||||
(eval '((lambda (expr rename compare) (cond ((null? (cdr expr))) ((null? (cddr expr)) (cadr expr)) (else (list (rename (quote if)) (cadr expr) (cons (rename (quote and)) (cddr expr)) #f)))) (test 1 2 3) (lambda (x) x) '()))
|
||||
;(eval '((lambda (x) x) 1))
|
||||
|
||||
|
||||
;(import (scheme base)
|
||||
; (scheme write))
|
||||
;
|
||||
;;(define-syntax test
|
||||
;; (er-macro-transformer
|
||||
;; (lambda (expr rename compare)
|
||||
;; `((lambda ()
|
||||
;; (write "testing")
|
||||
;; (write (quote ,(cdr expr))))))))
|
||||
;;
|
||||
;; WTF is the macro unable to be evaluated when the same code works as part of *defined-macros*???
|
||||
;;
|
||||
;(define-syntax test
|
||||
; (er-macro-transformer
|
||||
; (lambda (expr rename compare)
|
||||
; `((lambda ()
|
||||
; (write "testing")
|
||||
; (write (quote ,(cdr expr))))))))
|
||||
; (lambda (expr rename compare)
|
||||
; (cond ((null? (cdr expr)))
|
||||
; ((null? (cddr expr)) (cadr expr))
|
||||
; (else (list (rename 'if) (cadr expr)
|
||||
; (cons (rename 'and) (cddr expr))
|
||||
; #f))))))
|
||||
;
|
||||
; WTF is the macro unable to be evaluated when the same code works as part of *defined-macros*???
|
||||
;
|
||||
(define-syntax test
|
||||
(er-macro-transformer
|
||||
(lambda (expr rename compare)
|
||||
(cond ((null? (cdr expr)))
|
||||
((null? (cddr expr)) (cadr expr))
|
||||
(else (list (rename 'if) (cadr expr)
|
||||
(cons (rename 'and) (cddr expr))
|
||||
#f))))))
|
||||
|
||||
(test 1 2 3)
|
||||
;(test 'done)
|
||||
'done
|
||||
;(test 1 2 3)
|
||||
;;(test 'done)
|
||||
;'done
|
||||
|
|
Loading…
Add table
Reference in a new issue