mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Added type checking
This commit is contained in:
parent
4910c01d28
commit
5a9a8d322e
1 changed files with 3 additions and 2 deletions
|
@ -746,12 +746,14 @@ object Cyc_eq(object x, object y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
object Cyc_set_car(object l, object val) {
|
object Cyc_set_car(object l, object val) {
|
||||||
|
if (Cyc_is_cons(l) == boolean_f) Cyc_invalid_type_error(cons_tag, l);
|
||||||
car(l) = val;
|
car(l) = val;
|
||||||
add_mutation(l, val);
|
add_mutation(l, val);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
object Cyc_set_cdr(object l, object val) {
|
object Cyc_set_cdr(object l, object val) {
|
||||||
|
if (Cyc_is_cons(l) == boolean_f) Cyc_invalid_type_error(cons_tag, l);
|
||||||
cdr(l) = val;
|
cdr(l) = val;
|
||||||
add_mutation(l, val);
|
add_mutation(l, val);
|
||||||
return l;
|
return l;
|
||||||
|
@ -788,7 +790,7 @@ integer_type Cyc_vector_length(object v) {
|
||||||
integer_type Cyc_length(object l){
|
integer_type Cyc_length(object l){
|
||||||
make_int(len, 0);
|
make_int(len, 0);
|
||||||
while(!nullp(l)){
|
while(!nullp(l)){
|
||||||
if (((list)l)->tag != cons_tag){
|
if (is_value_type(l) || ((list)l)->tag != cons_tag){
|
||||||
Cyc_rt_raise_msg("length - invalid parameter, expected list\n");
|
Cyc_rt_raise_msg("length - invalid parameter, expected list\n");
|
||||||
}
|
}
|
||||||
l = cdr(l);
|
l = cdr(l);
|
||||||
|
@ -1398,7 +1400,6 @@ void _equal_127(object cont, object args){
|
||||||
return_funcall1(cont, equalp(car(args), cadr(args))); }
|
return_funcall1(cont, equalp(car(args), cadr(args))); }
|
||||||
void _length(object cont, object args){
|
void _length(object cont, object args){
|
||||||
Cyc_check_num_args("length", 1, args);
|
Cyc_check_num_args("length", 1, args);
|
||||||
if (!nullp(car(args))) Cyc_check_cons(car(args));
|
|
||||||
{ integer_type i = Cyc_length(car(args));
|
{ integer_type i = Cyc_length(car(args));
|
||||||
return_funcall1(cont, &i); }}
|
return_funcall1(cont, &i); }}
|
||||||
void _vector_91length(object cont, object args){
|
void _vector_91length(object cont, object args){
|
||||||
|
|
Loading…
Add table
Reference in a new issue