| 178 |
new_symbol= hash(env->symbols, in_string); |
new_symbol= hash(env->symbols, in_string); |
| 179 |
new_value->content.ptr= *new_symbol; |
new_value->content.ptr= *new_symbol; |
| 180 |
|
|
| 181 |
if(new_value->content.ptr==NULL) { /* If symbol was undefined */ |
if(*new_symbol==NULL) { /* If symbol was undefined */ |
| 182 |
|
|
| 183 |
/* Create a new symbol */ |
/* Create a new symbol */ |
| 184 |
*new_symbol= malloc(sizeof(symbol)); |
(*new_symbol)= malloc(sizeof(symbol)); |
| 185 |
(*new_symbol)->val= NULL; /* undefined value */ |
(*new_symbol)->val= NULL; /* undefined value */ |
| 186 |
(*new_symbol)->next= NULL; |
(*new_symbol)->next= NULL; |
| 187 |
(*new_symbol)->id= malloc(strlen(in_string)+1); |
(*new_symbol)->id= malloc(strlen(in_string)+1); |
| 348 |
return out_item; |
return out_item; |
| 349 |
} |
} |
| 350 |
|
|
| 351 |
|
extern void rcl(environment *env) |
| 352 |
|
{ |
| 353 |
|
value *val; |
| 354 |
|
|
| 355 |
|
if(env->head == NULL) { |
| 356 |
|
printerr("Stack empty"); |
| 357 |
|
return; |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
if(env->head->item->type!=symb) { |
| 361 |
|
printerr("Not a symbol"); |
| 362 |
|
return; |
| 363 |
|
} |
| 364 |
|
val=((symbol *)(env->head->item->content.ptr))->val; |
| 365 |
|
toss(env); /* toss the symbol */ |
| 366 |
|
push_val(&(env->head), val); /* Return its bound value */ |
| 367 |
|
} |
| 368 |
|
|
| 369 |
/* If the top element is a symbol, determine if it's bound to a |
/* If the top element is a symbol, determine if it's bound to a |
| 370 |
function value, and if it is, toss the symbol and execute the |
function value, and if it is, toss the symbol and execute the |
| 409 |
return; |
return; |
| 410 |
} |
} |
| 411 |
|
|
|
/* push(&(env->head), copy(env->head)); */ |
|
|
/* swap(env); */ |
|
|
/* toss(env); */ |
|
| 412 |
} |
} |
| 413 |
|
|
| 414 |
/* Make a list. */ |
/* Make a list. */ |