mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 17:27:33 +02:00
Call into lib "top-level" for init's
This commit is contained in:
parent
a804e048fd
commit
2ce058bf12
3 changed files with 16 additions and 14 deletions
26
cgen.scm
26
cgen.scm
|
@ -10,6 +10,10 @@
|
||||||
(display line)
|
(display line)
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
(define (emit* . strs)
|
||||||
|
(for-each emits strs)
|
||||||
|
(newline))
|
||||||
|
|
||||||
(define (emits str)
|
(define (emits str)
|
||||||
(display str))
|
(display str))
|
||||||
|
|
||||||
|
@ -972,12 +976,12 @@
|
||||||
(emit "static void c_entry_pt_first_lambda();")
|
(emit "static void c_entry_pt_first_lambda();")
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (lib-name)
|
(lambda (lib-name)
|
||||||
(emit (string-append "extern void c_" (lib:name->string lib-name) "_entry_pt(int argc, closure env, closure cont);")))
|
(emit (string-append "extern void c_" (lib:name->string lib-name) "_entry_pt(int argc, closure cont, object value);")))
|
||||||
required-libs)
|
required-libs)
|
||||||
(emit "static void c_entry_pt(argc, env,cont) int argc; closure env,cont; { "))
|
(emit "static void c_entry_pt(argc, env,cont) int argc; closure env,cont; { "))
|
||||||
(else
|
(else
|
||||||
(emit (string-append "void c_" (lib:name->string lib-name) "_entry_pt(argc, env,cont) int argc; closure env,cont; { "))
|
(emit (string-append "void c_" (lib:name->string lib-name) "_entry_pt(argc, cont,value) int argc; closure cont; object value;{ "))
|
||||||
;DEBUG: (emit (string-append "printf(\"init " (lib:name->string lib-name) "\\n\");"))
|
(emit (string-append "printf(\"init " (lib:name->string lib-name) "\\n\");"))
|
||||||
))
|
))
|
||||||
|
|
||||||
;; Initialize global table
|
;; Initialize global table
|
||||||
|
@ -1077,19 +1081,17 @@
|
||||||
;; Start cont chain, but do not assume funcall1 macro was defined
|
;; Start cont chain, but do not assume funcall1 macro was defined
|
||||||
(string-append "(" this-clo ".fn)(0, &" this-clo ", &" this-clo ");"))
|
(string-append "(" this-clo ".fn)(0, &" this-clo ", &" this-clo ");"))
|
||||||
(emit "}")
|
(emit "}")
|
||||||
(emit "static void c_entry_pt_first_lambda(int argc, closure env, closure cont) {")
|
(emit "static void c_entry_pt_first_lambda(int argc, closure cont, object value) {")
|
||||||
;DEBUG: (emit (string-append "printf(\"init first lambda\\n\");"))
|
(emit (string-append "printf(\"init first lambda\\n\");"))
|
||||||
(emit compiled-program)))
|
(emit compiled-program)))
|
||||||
(else
|
(else
|
||||||
;; Do not use funcall1 macro as it might not have been defined
|
;; Do not use funcall1 macro as it might not have been defined
|
||||||
(emit "cont = ((closure1_type *)cont)->elt1;")
|
(emit "cont = ((closure1_type *)cont)->elt1;")
|
||||||
(emit "((cont)->fn)(1, cont, cont);")
|
;(emit "((cont)->fn)(1, cont, cont);")
|
||||||
;; TODO:
|
(emit*
|
||||||
; need to call into computed func, EG: __glo_lib_91init_117schemeread
|
"(((closure)"
|
||||||
; using cont->elt1 as k.
|
(mangle-global (lib:name->symbol lib-name))
|
||||||
; (emit "}")
|
")->fn)(1, cont, cont);")
|
||||||
; (emit (string-append "static void c_" (lib:name->string lib-name) "_entry_pt_inits(int argc, closure "
|
|
||||||
; (emit compiled-program)
|
|
||||||
))
|
))
|
||||||
|
|
||||||
(emit "}")
|
(emit "}")
|
||||||
|
|
|
@ -425,7 +425,7 @@ list assoc(x,l) object x; list l;
|
||||||
printf("JAE DEBUG, assoc received: ");
|
printf("JAE DEBUG, assoc received: ");
|
||||||
Cyc_display(l);
|
Cyc_display(l);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if (type_of(l) != cons_tag) return boolean_f;
|
if (nullp(l) || is_value_type(l) || type_of(l) != cons_tag) return boolean_f;
|
||||||
for (; !nullp(l); l = cdr(l))
|
for (; !nullp(l); l = cdr(l))
|
||||||
{register list la = car(l); if (boolean_f != equalp(x,car(la))) return la;}
|
{register list la = car(l); if (boolean_f != equalp(x,car(la))) return la;}
|
||||||
return boolean_f;}
|
return boolean_f;}
|
||||||
|
|
|
@ -1569,7 +1569,7 @@
|
||||||
(define (lib:name->symbol name)
|
(define (lib:name->symbol name)
|
||||||
(string->symbol
|
(string->symbol
|
||||||
(string-append
|
(string-append
|
||||||
"lib-init:"
|
"lib-init:" ;; Maybe make this an optional param? Trying to ensure uniqueness
|
||||||
(lib:name->string name))))
|
(lib:name->string name))))
|
||||||
;; Helper function that returns an empty list as a default value
|
;; Helper function that returns an empty list as a default value
|
||||||
(define (lib:result result)
|
(define (lib:result result)
|
||||||
|
|
Loading…
Add table
Reference in a new issue