diff --git a/docs/Developer-How-To.md b/docs/Developer-How-To.md index b296eb20..3fee5d8e 100644 --- a/docs/Developer-How-To.md +++ b/docs/Developer-How-To.md @@ -1,7 +1,16 @@ ## Add a primitive - Add function/definitions to runtime.h and runtime.c +- sudo make install-includes +- sudo make install-libs - Add to prim? section in transforms.scm. Some functions may need to added to the next section in the file, so they are not constant-folded (IE, evaluated at compile time). - Add to the c-compile-primitive section in cgen.scm. +- cyclone scheme/cyclone/transforms.sld && cyclone scheme/cyclone/cgen.sld +- sudo cp scheme/cyclone/transforms.* /usr/local/share/cyclone/scheme/cyclone/ + and cgen +- run cyclone to build sld's again +- cyclone cyclone.scm , install new cyclone + + - TODO: compile files in what order? And copy them where? I think sld files need to be built and copied, and then cyclone and icyc need to be rebuilt linking against them? - TODO: what about eval.scm? diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 14116caf..dc05da29 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -364,7 +364,7 @@ extern const object primitive_file_91exists_127; extern const object primitive_delete_91file; extern const object primitive_read_91char; extern const object primitive_peek_91char; -extern const object primtitive_Cyc_91read_91line; +extern const object primitive_Cyc_91read_91line; extern const object primitive_Cyc_91write_91char; extern const object primitive_Cyc_91write; extern const object primitive_Cyc_91display; diff --git a/scheme/cyclone/cgen.scm b/scheme/cyclone/cgen.scm index 85e6a30b..6fa34b14 100644 --- a/scheme/cyclone/cgen.scm +++ b/scheme/cyclone/cgen.scm @@ -445,6 +445,7 @@ ((eq? p 'delete-file) "Cyc_io_delete_file") ((eq? p 'read-char) "Cyc_io_read_char") ((eq? p 'peek-char) "Cyc_io_peek_char") + ((eq? p 'Cyc-read-line) "Cyc_io_read_line") ((eq? p 'Cyc-display) "Cyc_display_va") ((eq? p 'Cyc-write) "Cyc_write_va") ((eq? p 'Cyc-write-char) "Cyc_write_char") @@ -559,6 +560,7 @@ ((eq? p 'string-length) "integer_type") ((eq? p 'substring) "string_type") ((eq? p 'apply) "object") + ((eq? p 'Cyc-read-line) "object") ((eq? p 'command-line-arguments) "object") ((eq? p 'make-vector) "object") (else #f))) @@ -582,17 +584,18 @@ string-length substring + - * / apply command-line-arguments + Cyc-read-line cons length vector-length cell)))) ;; Pass continuation as the function's first parameter? (define (prim:cont? exp) (and (prim? exp) - (member exp '(apply command-line-arguments make-vector)))) + (member exp '(Cyc-read-line apply command-line-arguments make-vector)))) ;; TODO: this is a hack, right answer is to include information about ;; how many args each primitive is supposed to take (define (prim:cont-has-args? exp) (and (prim? exp) - (member exp '(apply make-vector)))) + (member exp '(Cyc-read-line apply make-vector)))) ;; Pass an integer arg count as the function's first parameter? (define (prim:arg-count? exp) diff --git a/scheme/cyclone/transforms.scm b/scheme/cyclone/transforms.scm index 3cf3cd76..5062142b 100644 --- a/scheme/cyclone/transforms.scm +++ b/scheme/cyclone/transforms.scm @@ -606,6 +606,7 @@ delete-file read-char peek-char + Cyc-read-line Cyc-write-char Cyc-write Cyc-display)) @@ -654,6 +655,7 @@ delete-file read-char peek-char + Cyc-read-line Cyc-write-char Cyc-write Cyc-display))) diff --git a/scheme/eval.scm b/scheme/eval.scm index 462e09dc..7668dff8 100644 --- a/scheme/eval.scm +++ b/scheme/eval.scm @@ -292,6 +292,7 @@ (list 'delete-file delete-file) (list 'read-char read-char) (list 'peek-char peek-char) + (list 'Cyc-read-line Cyc-read-line) (list 'Cyc-write-char Cyc-write-char) (list 'Cyc-write Cyc-write) (list 'Cyc-display Cyc-display))) diff --git a/test2.scm b/test2.scm index d7105d87..148242fb 100644 --- a/test2.scm +++ b/test2.scm @@ -2,6 +2,8 @@ (scheme file) (scheme write)) +(define fp (open-input-file "test.scm")) +(write (Cyc-read-line fp)) (write (string-set! "abc" 1 #\x)) ;