mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-11 23:07:36 +02:00
Allow optional fill arg to (make-vector) in compiled code
This commit is contained in:
parent
943dd1aad5
commit
d0914d863f
3 changed files with 5 additions and 25 deletions
|
@ -153,8 +153,7 @@ integer_type Cyc_length_as_object(void *d, object l);
|
||||||
object Cyc_vector_length(void *data, object v);
|
object Cyc_vector_length(void *data, object v);
|
||||||
object Cyc_vector_ref(void *d, object v, object k);
|
object Cyc_vector_ref(void *d, object v, object k);
|
||||||
object Cyc_vector_set(void *d, object v, object k, object obj);
|
object Cyc_vector_set(void *d, object v, object k, object obj);
|
||||||
object Cyc_make_vector(void *data, object cont, object len, object fill);
|
object Cyc_make_vector(void *data, object cont, int argc, object len, ...);
|
||||||
object Cyc_make_vector2(void *data, object cont, int argc, object len, ...);
|
|
||||||
object Cyc_list2vector(void *data, object cont, object l);
|
object Cyc_list2vector(void *data, object cont, object l);
|
||||||
object Cyc_number2string(void *d, object cont, object n);
|
object Cyc_number2string(void *d, object cont, object n);
|
||||||
object Cyc_symbol2string(void *d, object cont, object sym) ;
|
object Cyc_symbol2string(void *d, object cont, object sym) ;
|
||||||
|
|
25
runtime.c
25
runtime.c
|
@ -1329,26 +1329,7 @@ object Cyc_command_line_arguments(void *data, object cont) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
object Cyc_make_vector(void *data, object cont, object len, object fill) {
|
object Cyc_make_vector(void *data, object cont, int argc, object len, ...) {
|
||||||
object v = nil;
|
|
||||||
int i;
|
|
||||||
Cyc_check_int(data, len);
|
|
||||||
v = alloca(sizeof(vector_type));
|
|
||||||
((vector)v)->hdr.mark = gc_color_red;
|
|
||||||
((vector)v)->hdr.grayed = 0;
|
|
||||||
((vector)v)->tag = vector_tag;
|
|
||||||
((vector)v)->num_elt = obj_is_int(len) ? obj_obj2int(len) : ((integer_type *)len)->value;
|
|
||||||
((vector)v)->elts =
|
|
||||||
(((vector)v)->num_elt > 0) ?
|
|
||||||
(object *)alloca(sizeof(object) * ((vector)v)->num_elt) :
|
|
||||||
NULL;
|
|
||||||
for (i = 0; i < ((vector)v)->num_elt; i++) {
|
|
||||||
((vector)v)->elts[i] = fill;
|
|
||||||
}
|
|
||||||
return_closcall1(data, cont, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
object Cyc_make_vector2(void *data, object cont, int argc, object len, ...) {
|
|
||||||
object v = nil;
|
object v = nil;
|
||||||
object fill = boolean_f;
|
object fill = boolean_f;
|
||||||
int i;
|
int i;
|
||||||
|
@ -2023,9 +2004,9 @@ void _make_91vector(void *data, object cont, object args) {
|
||||||
Cyc_check_num_args(data, "make-vector", 1, args);
|
Cyc_check_num_args(data, "make-vector", 1, args);
|
||||||
{ object argc = Cyc_length(data, args);
|
{ object argc = Cyc_length(data, args);
|
||||||
if (obj_obj2int(argc) >= 2) {
|
if (obj_obj2int(argc) >= 2) {
|
||||||
Cyc_make_vector2(data, cont, 2, car(args), cadr(args));}
|
Cyc_make_vector(data, cont, 2, car(args), cadr(args));}
|
||||||
else {
|
else {
|
||||||
Cyc_make_vector2(data, cont, 2, car(args), boolean_f);}}}
|
Cyc_make_vector(data, cont, 2, car(args), boolean_f);}}}
|
||||||
void _vector_91ref(void *data, object cont, object args) {
|
void _vector_91ref(void *data, object cont, object args) {
|
||||||
Cyc_check_num_args(data, "vector-ref", 2, args);
|
Cyc_check_num_args(data, "vector-ref", 2, args);
|
||||||
{ object ref = Cyc_vector_ref(data, car(args), cadr(args));
|
{ object ref = Cyc_vector_ref(data, car(args), cadr(args));
|
||||||
|
|
|
@ -524,7 +524,7 @@
|
||||||
((eq? p 'integer->char) "Cyc_integer2char")
|
((eq? p 'integer->char) "Cyc_integer2char")
|
||||||
((eq? p 'string->number)"Cyc_string2number2_")
|
((eq? p 'string->number)"Cyc_string2number2_")
|
||||||
((eq? p 'list->string) "Cyc_list2string")
|
((eq? p 'list->string) "Cyc_list2string")
|
||||||
((eq? p 'make-vector) "Cyc_make_vector2")
|
((eq? p 'make-vector) "Cyc_make_vector")
|
||||||
((eq? p 'list->vector) "Cyc_list2vector")
|
((eq? p 'list->vector) "Cyc_list2vector")
|
||||||
((eq? p 'vector-length) "Cyc_vector_length")
|
((eq? p 'vector-length) "Cyc_vector_length")
|
||||||
((eq? p 'vector-ref) "Cyc_vector_ref")
|
((eq? p 'vector-ref) "Cyc_vector_ref")
|
||||||
|
|
Loading…
Add table
Reference in a new issue