Added (Cyc-installation-dir)

This commit is contained in:
Justin Ethier 2015-07-17 21:39:57 -04:00
parent 1dc3c13d33
commit c744080984
7 changed files with 28 additions and 2 deletions

View file

@ -56,7 +56,7 @@ libcyclone.so.1: runtime.c runtime.h
gcc -shared -Wl,-soname,libcyclone.so.1 -o libcyclone.so.1.0.1 runtime.o
libcyclone.a: runtime.c runtime.h dispatch.c
$(CC) -g -c dispatch.c -o dispatch.o
$(CC) -g -c runtime.c -o runtime.o
$(CC) -g -c -DCYC_INSTALL_DIR=\"$(PREFIX)\" runtime.c -o runtime.o
$(AR) rcs libcyclone.a runtime.o dispatch.o
# Instructions from: http://www.adp-gmbh.ch/cpp/gcc/create_lib.html
# Note compiler will have to link to this, eg:

2
TODO
View file

@ -22,6 +22,8 @@ how about we add installation-dir (AKA PREFIX) as a libcyclone.a function?
the code can assume a cyc:get function for install dir and act accordingly.
in addition, the chicken code can just hardwire it to the current directory or a home dir (maybe ideal, that is just debug anyway)
1) makefile needs to pass PREFIX when building the runtime lib
* purge (cyc:get-*-dir) functions
should only need these maybe for the chicken install.
* figure out how a build will go now. is it possible to build locally

View file

@ -495,6 +495,7 @@
((eq? p 'string-length) "Cyc_string_length")
((eq? p 'string-ref) "Cyc_string_ref")
((eq? p 'substring) "Cyc_substring")
((eq? p 'Cyc-installation-dir) "Cyc_installation_dir")
((eq? p 'command-line-arguments) "Cyc_command_line_arguments")
((eq? p 'system) "Cyc_system")
((eq? p 'assq) "assq")
@ -542,6 +543,7 @@
((eq? p 'length) "integer_type")
((eq? p 'vector-length) "integer_type")
((eq? p 'char->integer) "integer_type")
((eq? p 'Cyc-installation-dir) "string_type")
((eq? p 'system) "integer_type")
((eq? p '+) "common_type")
((eq? p '-) "common_type")
@ -569,7 +571,10 @@
Cyc-stderr
open-input-file
open-output-file
char->integer system string->number
char->integer
system
Cyc-installation-dir
string->number
string-append string-cmp list->string string->list
make-vector list->vector
symbol->string number->string

View file

@ -201,6 +201,7 @@
(list 'apply apply)
(list '%halt %halt)
(list 'exit exit)
(list 'Cyc-installation-dir Cyc-installation-dir)
(list 'system system)
(list 'command-line-arguments command-line-arguments)
(list 'error error)

View file

@ -938,6 +938,15 @@ string_type Cyc_substring(object str, object start, object end) {
}
}
/**
* Return directory where cyclone is installed.
* This is configured via the makefile during a build.
*/
string_type Cyc_installation_dir() {
make_string(str, CYC_INSTALL_DIR);
return str;
}
/**
* Perform same role as the CHICKEN function:
*
@ -1459,6 +1468,9 @@ void _cyc_string_91ref(object cont, object args) {
Cyc_check_num_args("string-ref", 2, args);
{ object c = Cyc_string_ref(car(args), cadr(args));
return_funcall1(cont, c); }}
void _Cyc_91installation_91dir(object cont, object args) {
string_type dir = Cyc_installation_dir();
return_funcall1(cont, &dir);}
void _command_91line_91arguments(object cont, object args) {
object cmdline = Cyc_command_line_arguments(cont);
return_funcall1(cont, cmdline); }
@ -2151,6 +2163,7 @@ static primitive_type string_91_125number_primitive = {primitive_tag, "string->n
static primitive_type string_91length_primitive = {primitive_tag, "string-length", &_string_91length};
static primitive_type substring_primitive = {primitive_tag, "substring", &_cyc_substring};
static primitive_type string_91ref_primitive = {primitive_tag, "string-ref", &_cyc_string_91ref};
static primitive_type Cyc_91installation_91dir_primitive = {primitive_tag, "Cyc-installation-dir", &_Cyc_91installation_91dir};
static primitive_type command_91line_91arguments_primitive = {primitive_tag, "command-line-arguments", &_command_91line_91arguments};
static primitive_type system_primitive = {primitive_tag, "system", &_cyc_system};
static primitive_type string_91cmp_primitive = {primitive_tag, "string-cmp", &_string_91cmp};
@ -2266,6 +2279,7 @@ const object primitive_string_91_125number = &string_91_125number_primitive;
const object primitive_string_91length = &string_91length_primitive;
const object primitive_substring = &substring_primitive;
const object primitive_string_91ref = &string_91ref_primitive;
const object primitive_Cyc_91installation_91dir = &Cyc_91installation_91dir_primitive;
const object primitive_command_91line_91arguments = &command_91line_91arguments_primitive;
const object primitive_system = &system_primitive;
const object primitive_string_91cmp = &string_91cmp_primitive;

View file

@ -105,6 +105,7 @@ string_type Cyc_string_append_va_list(int argc, object str1, va_list ap);
integer_type Cyc_string_length(object str);
string_type Cyc_substring(object str, object start, object end);
object Cyc_string_ref(object str, object k);
string_type Cyc_installation_dir();
object Cyc_command_line_arguments(object cont);
integer_type Cyc_system(object cmd);
integer_type Cyc_char2integer(object chr);
@ -327,6 +328,7 @@ extern const object primitive_list_91_125vector;
extern const object primitive_vector_91ref;
extern const object primitive_vector_91set_67;
extern const object primitive_string_91ref;
extern const object primitive_Cyc_91installation_91dir;
extern const object primitive_command_91line_91arguments;
extern const object primitive_system;
extern const object primitive_boolean_127;

View file

@ -541,6 +541,7 @@
exit
system
command-line-arguments
Cyc-installation-dir
Cyc-default-exception-handler
Cyc-current-exception-handler
cons
@ -628,6 +629,7 @@
exit
system
command-line-arguments
Cyc-installation-dir
Cyc-default-exception-handler
Cyc-current-exception-handler
cell-get