Converted Cyc-installation-dir

This commit is contained in:
Justin Ethier 2015-10-10 22:18:54 -04:00
parent 09515b2141
commit 53aad98d71
3 changed files with 11 additions and 13 deletions

View file

@ -92,8 +92,6 @@ object apply(object cont, object func, object args);
void Cyc_apply(int argc, closure cont, object prim, ...); void Cyc_apply(int argc, closure cont, object prim, ...);
integer_type Cyc_string_cmp(object str1, object str2); integer_type Cyc_string_cmp(object str1, object str2);
void dispatch_string_91append(int argc, object clo, object cont, object str1, ...); void dispatch_string_91append(int argc, object clo, object cont, object str1, ...);
string_type Cyc_string_append(int argc, object str1, ...);
string_type Cyc_string_append_va_list(int, object, va_list);
list mcons(object,object); list mcons(object,object);
cvar_type *mcvar(object *var); cvar_type *mcvar(object *var);
object Cyc_display(object, FILE *port); object Cyc_display(object, FILE *port);
@ -134,7 +132,7 @@ integer_type Cyc_string_length(object str);
object Cyc_substring(object cont, object str, object start, object end); object Cyc_substring(object cont, object str, object start, object end);
object Cyc_string_ref(object str, object k); object Cyc_string_ref(object str, object k);
object Cyc_string_set(object str, object k, object chr); object Cyc_string_set(object str, object k, object chr);
string_type Cyc_installation_dir(); object Cyc_installation_dir(object cont, object type);
object Cyc_command_line_arguments(object cont); object Cyc_command_line_arguments(object cont);
integer_type Cyc_system(object cmd); integer_type Cyc_system(object cmd);
integer_type Cyc_char2integer(object chr); integer_type Cyc_char2integer(object chr);

View file

@ -1054,7 +1054,7 @@ object Cyc_substring(object cont, object str, object start, object end) {
{ {
make_string_with_len(sub, raw + s, e - s); make_string_with_len(sub, raw + s, e - s);
return_closcall1(cont, sub); return_closcall1(cont, &sub);
} }
} }
@ -1062,28 +1062,28 @@ object Cyc_substring(object cont, object str, object start, object end) {
* Return directory where cyclone is installed. * Return directory where cyclone is installed.
* This is configured via the makefile during a build. * This is configured via the makefile during a build.
*/ */
string_type Cyc_installation_dir(object type) { object Cyc_installation_dir(object cont, object type) {
if (Cyc_is_symbol(type) == boolean_t && if (Cyc_is_symbol(type) == boolean_t &&
strncmp(((symbol)type)->pname, "sld", 5) == 0) { strncmp(((symbol)type)->pname, "sld", 5) == 0) {
char buf[1024]; char buf[1024];
snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_SLD); snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_SLD);
make_string(str, buf); make_string(str, buf);
return str; return_closcall1(cont, &str);
} else if (Cyc_is_symbol(type) == boolean_t && } else if (Cyc_is_symbol(type) == boolean_t &&
strncmp(((symbol)type)->pname, "lib", 5) == 0) { strncmp(((symbol)type)->pname, "lib", 5) == 0) {
char buf[1024]; char buf[1024];
snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_LIB); snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_LIB);
make_string(str, buf); make_string(str, buf);
return str; return_closcall1(cont, &str);
} else if (Cyc_is_symbol(type) == boolean_t && } else if (Cyc_is_symbol(type) == boolean_t &&
strncmp(((symbol)type)->pname, "inc", 5) == 0) { strncmp(((symbol)type)->pname, "inc", 5) == 0) {
char buf[1024]; char buf[1024];
snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_INC); snprintf(buf, sizeof(buf), "%s", CYC_INSTALL_INC);
make_string(str, buf); make_string(str, buf);
return str; return_closcall1(cont, &str);
} else { } else {
make_string(str, CYC_INSTALL_DIR); make_string(str, CYC_INSTALL_DIR);
return str; return_closcall1(cont, &str);
} }
} }
@ -1727,8 +1727,7 @@ void _cyc_string_91ref(object cont, object args) {
return_closcall1(cont, c); }} return_closcall1(cont, c); }}
void _Cyc_91installation_91dir(object cont, object args) { void _Cyc_91installation_91dir(object cont, object args) {
Cyc_check_num_args("Cyc-installation-dir", 1, args); Cyc_check_num_args("Cyc-installation-dir", 1, args);
{ string_type dir = Cyc_installation_dir(car(args)); Cyc_installation_dir(cont, car(args));}
return_closcall1(cont, &dir);}}
void _command_91line_91arguments(object cont, object args) { void _command_91line_91arguments(object cont, object args) {
object cmdline = Cyc_command_line_arguments(cont); object cmdline = Cyc_command_line_arguments(cont);
return_closcall1(cont, cmdline); } return_closcall1(cont, cmdline); }

View file

@ -590,6 +590,7 @@
((eq? p 'make-vector) "object") ((eq? p 'make-vector) "object")
((eq? p 'list->string) "object") ((eq? p 'list->string) "object")
((eq? p 'list->vector) "object") ((eq? p 'list->vector) "object")
((eq? p 'Cyc-installation-dir) "object")
(else #f))) (else #f)))
;; Determine if primitive creates a C variable ;; Determine if primitive creates a C variable
@ -619,14 +620,14 @@
(and (prim? exp) (and (prim? exp)
(member exp '(Cyc-read-line apply command-line-arguments number->string (member exp '(Cyc-read-line apply command-line-arguments number->string
symbol->string list->string substring symbol->string list->string substring
make-vector list->vector)))) make-vector list->vector Cyc-installation-dir))))
;; TODO: this is a hack, right answer is to include information about ;; TODO: this is a hack, right answer is to include information about
;; how many args each primitive is supposed to take ;; how many args each primitive is supposed to take
(define (prim:cont-has-args? exp) (define (prim:cont-has-args? exp)
(and (prim? exp) (and (prim? exp)
(member exp '(Cyc-read-line apply number->string symbol->string (member exp '(Cyc-read-line apply number->string symbol->string
list->string substring list->string substring
make-vector list->vector)))) make-vector list->vector Cyc-installation-dir))))
;; Pass an integer arg count as the function's first parameter? ;; Pass an integer arg count as the function's first parameter?
(define (prim:arg-count? exp) (define (prim:arg-count? exp)