mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 04:25:06 +02:00
WIP
This commit is contained in:
parent
96c3893cb6
commit
acaea412ea
2 changed files with 24 additions and 6 deletions
|
@ -7,7 +7,9 @@
|
||||||
;;;; This module contains information about Cyclone's scheme primitives.
|
;;;; This module contains information about Cyclone's scheme primitives.
|
||||||
;;;;
|
;;;;
|
||||||
(define-library (scheme cyclone primitives)
|
(define-library (scheme cyclone primitives)
|
||||||
(import (scheme base))
|
(import (scheme base)
|
||||||
|
;(scheme write)
|
||||||
|
)
|
||||||
(export
|
(export
|
||||||
prim?
|
prim?
|
||||||
*primitives*
|
*primitives*
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
prim/data-arg?
|
prim/data-arg?
|
||||||
prim/c-var-assign
|
prim/c-var-assign
|
||||||
prim/cvar?
|
prim/cvar?
|
||||||
|
prim:inline-convert-prim-call
|
||||||
prim:check-arg-count
|
prim:check-arg-count
|
||||||
prim:mutates?
|
prim:mutates?
|
||||||
prim:cont?
|
prim:cont?
|
||||||
|
@ -57,6 +60,7 @@
|
||||||
Cyc-stdout
|
Cyc-stdout
|
||||||
Cyc-stdin
|
Cyc-stdin
|
||||||
Cyc-stderr
|
Cyc-stderr
|
||||||
|
Cyc-fast-plus
|
||||||
+
|
+
|
||||||
-
|
-
|
||||||
*
|
*
|
||||||
|
@ -176,6 +180,7 @@
|
||||||
(Cyc-stdout 0 0)
|
(Cyc-stdout 0 0)
|
||||||
(Cyc-stdin 0 0)
|
(Cyc-stdin 0 0)
|
||||||
(Cyc-stderr 0 0)
|
(Cyc-stderr 0 0)
|
||||||
|
(Cyc-fast-plus 2 2)
|
||||||
(- 1 #f)
|
(- 1 #f)
|
||||||
(/ 1 #f)
|
(/ 1 #f)
|
||||||
(= 2 #f)
|
(= 2 #f)
|
||||||
|
@ -402,6 +407,7 @@
|
||||||
((eq? p 'Cyc-stdout) "Cyc_stdout")
|
((eq? p 'Cyc-stdout) "Cyc_stdout")
|
||||||
((eq? p 'Cyc-stdin) "Cyc_stdin")
|
((eq? p 'Cyc-stdin) "Cyc_stdin")
|
||||||
((eq? p 'Cyc-stderr) "Cyc_stderr")
|
((eq? p 'Cyc-stderr) "Cyc_stderr")
|
||||||
|
((eq? p 'Cyc-fast-plus) "Cyc_fast_sum")
|
||||||
((eq? p '+) "Cyc_sum")
|
((eq? p '+) "Cyc_sum")
|
||||||
((eq? p '-) "Cyc_sub")
|
((eq? p '-) "Cyc_sub")
|
||||||
((eq? p '*) "Cyc_mul")
|
((eq? p '*) "Cyc_mul")
|
||||||
|
@ -523,6 +529,7 @@
|
||||||
;; Does the primitive require passing thread data as its first argument?
|
;; Does the primitive require passing thread data as its first argument?
|
||||||
(define (prim/data-arg? p)
|
(define (prim/data-arg? p)
|
||||||
(member p '(
|
(member p '(
|
||||||
|
Cyc-fast-plus
|
||||||
+
|
+
|
||||||
-
|
-
|
||||||
*
|
*
|
||||||
|
@ -604,6 +611,7 @@
|
||||||
((eq? p 'Cyc-stderr) "port_type")
|
((eq? p 'Cyc-stderr) "port_type")
|
||||||
((eq? p 'open-input-file) "port_type")
|
((eq? p 'open-input-file) "port_type")
|
||||||
((eq? p 'open-output-file) "port_type")
|
((eq? p 'open-output-file) "port_type")
|
||||||
|
((eq? p 'Cyc-fast-plus) "common_type")
|
||||||
((eq? p '+) "object")
|
((eq? p '+) "object")
|
||||||
((eq? p '-) "object")
|
((eq? p '-) "object")
|
||||||
((eq? p '*) "object")
|
((eq? p '*) "object")
|
||||||
|
@ -658,6 +666,7 @@
|
||||||
make-vector list->vector
|
make-vector list->vector
|
||||||
symbol->string number->string
|
symbol->string number->string
|
||||||
substring
|
substring
|
||||||
|
Cyc-fast-plus
|
||||||
+ - * / apply
|
+ - * / apply
|
||||||
= > < >= <=
|
= > < >= <=
|
||||||
command-line-arguments
|
command-line-arguments
|
||||||
|
@ -710,4 +719,14 @@
|
||||||
(define (prim:allocates-object? exp)
|
(define (prim:allocates-object? exp)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
(member exp '())))
|
(member exp '())))
|
||||||
|
|
||||||
|
(define (prim:inline-convert-prim-call prim-call)
|
||||||
|
;(write `(prim:inline-convert-prim-call ,prim-call))
|
||||||
|
;(newline)
|
||||||
|
(cond
|
||||||
|
((and (equal? (car prim-call) '+)
|
||||||
|
(= (length prim-call) 3))
|
||||||
|
(cons 'Cyc-fast-plus (cdr prim-call)))
|
||||||
|
(else
|
||||||
|
prim-call)))
|
||||||
))
|
))
|
||||||
|
|
|
@ -1022,8 +1022,6 @@
|
||||||
|
|
||||||
;; Perform actual alpha conversion
|
;; Perform actual alpha conversion
|
||||||
(define (convert ast renamed)
|
(define (convert ast renamed)
|
||||||
;(write `(DEBUG convert ,ast))
|
|
||||||
;(write (newline))
|
|
||||||
(cond
|
(cond
|
||||||
((const? ast) ast)
|
((const? ast) ast)
|
||||||
((quote? ast) ast)
|
((quote? ast) ast)
|
||||||
|
@ -1059,14 +1057,15 @@
|
||||||
new-ast))))
|
new-ast))))
|
||||||
((and (prim-call? ast)
|
((and (prim-call? ast)
|
||||||
;; Not a primitive if the identifier has been redefined
|
;; Not a primitive if the identifier has been redefined
|
||||||
(not assoc (car ast) renamed))
|
(not (assoc (car ast) renamed)))
|
||||||
(let ((converted
|
(let ((converted
|
||||||
(cons (car ast)
|
(cons (car ast)
|
||||||
(map (lambda (a) (convert a renamed))
|
(map (lambda (a) (convert a renamed))
|
||||||
(cdr ast)))))
|
(cdr ast)))))
|
||||||
(if (precompute-prim-app? converted)
|
(if (precompute-prim-app? converted)
|
||||||
(eval converted) ;; OK, evaluate at compile time
|
converted ; TODO:(eval converted) ;; OK, evaluate at compile time
|
||||||
converted)))
|
converted))) ;; No, see if we can fast-convert it
|
||||||
|
;(prim:inline-convert-prim-call converted)))) ;; No, see if we can fast-convert it
|
||||||
((lambda? ast)
|
((lambda? ast)
|
||||||
(let* ((args (lambda-formals->list ast))
|
(let* ((args (lambda-formals->list ast))
|
||||||
(ltype (lambda-formals-type ast))
|
(ltype (lambda-formals-type ast))
|
||||||
|
|
Loading…
Add table
Reference in a new issue