121 |
|
|
122 |
int push_ref(stackitem** stack_head, hashtbl in_hash, const char* in_string) |
int push_ref(stackitem** stack_head, hashtbl in_hash, const char* in_string) |
123 |
{ |
{ |
124 |
void* handle; |
static void* handle= NULL; |
125 |
void* symbol; |
void* symbol; |
126 |
|
|
127 |
stackitem* new_item= malloc(sizeof(stackitem)); |
stackitem* new_item= malloc(sizeof(stackitem)); |
128 |
new_item->content.ptr= *hash(in_hash, in_string); |
new_item->content.ptr= *hash(in_hash, in_string); |
129 |
new_item->type= ref; |
new_item->type= ref; |
130 |
|
|
131 |
if(new_item->content.ptr==NULL) { |
if(handle==NULL) |
132 |
handle= dlopen(NULL, RTLD_LAZY); |
handle= dlopen(NULL, RTLD_LAZY); |
133 |
|
|
134 |
|
if(new_item->content.ptr==NULL) { |
135 |
symbol= dlsym(handle, in_string); |
symbol= dlsym(handle, in_string); |
136 |
if(dlerror()==NULL) |
if(dlerror()==NULL) |
137 |
def_func(in_hash, symbol, in_string); |
def_func(in_hash, symbol, in_string); |
169 |
printf("%ld: \"%s\"\n", counter, (char*)stack_head->content.ptr); |
printf("%ld: \"%s\"\n", counter, (char*)stack_head->content.ptr); |
170 |
break; |
break; |
171 |
case ref: |
case ref: |
172 |
|
printf("%ld: %s\n", counter, ((stackitem*)stack_head->content.ptr)->id); |
173 |
|
break; |
174 |
case func: |
case func: |
175 |
case symbol: |
case symbol: |
176 |
printf("%ld: %p\n", counter, stack_head->content.ptr); |
printf("%ld: %p\n", counter, stack_head->content.ptr); |
240 |
if((*stack_head)==NULL) |
if((*stack_head)==NULL) |
241 |
return; |
return; |
242 |
|
|
243 |
if((*stack_head)->type==value) |
switch((*stack_head)->type){ |
244 |
|
case value: |
245 |
printf("%d", (*stack_head)->content.val); |
printf("%d", (*stack_head)->content.val); |
246 |
else if((*stack_head)->type==string) |
break; |
247 |
|
case string: |
248 |
printf("%s", (char*)(*stack_head)->content.ptr); |
printf("%s", (char*)(*stack_head)->content.ptr); |
249 |
else |
break; |
250 |
|
case ref: |
251 |
|
printf("%s", ((stackitem*)(*stack_head)->content.ptr)->id); |
252 |
|
break; |
253 |
|
case symbol: |
254 |
|
default: |
255 |
printf("%p", (*stack_head)->content.ptr); |
printf("%p", (*stack_head)->content.ptr); |
256 |
|
break; |
257 |
|
} |
258 |
|
|
259 |
toss(stack_head); |
toss(stack_head); |
260 |
} |
} |
264 |
printf("\n"); |
printf("\n"); |
265 |
} |
} |
266 |
|
|
267 |
|
extern void quit() |
268 |
|
{ |
269 |
|
exit(EXIT_SUCCESS); |
270 |
|
} |
271 |
|
|
272 |
int main() |
int main() |
273 |
{ |
{ |
274 |
stackitem* s= NULL; |
stackitem* s= NULL; |