| 82a2bc67 |
1 | /* |
| 2 | |
| 82a2bc67 |
3 | This code was written as part of the CMU Common Lisp project at |
| 4 | Carnegie Mellon University, and has been placed in the public domain. |
| 5 | |
| 6 | */ |
| 7 | |
| 0ac2c885 |
8 | #include <string.h> |
| 62957726 |
9 | #include "lisp.h" |
| 10 | #include "internals.h" |
| 11 | #include "os.h" |
| 12 | #include "search.h" |
| 13 | |
| 9a8c1c2f |
14 | boolean |
| 15 | search_for_type(int type, lispobj ** start, int *count) |
| 62957726 |
16 | { |
| 17 | lispobj obj, *addr; |
| 18 | |
| 19 | while ((*count == -1 || (*count > 0)) && |
| 9a8c1c2f |
20 | valid_addr((os_vm_address_t) * start)) { |
| 21 | obj = **start; |
| 22 | addr = *start; |
| 23 | if (*count != -1) |
| 24 | *count -= 2; |
| 62957726 |
25 | |
| 9a8c1c2f |
26 | if (TypeOf(obj) == type) |
| 27 | return TRUE; |
| 62957726 |
28 | |
| 9a8c1c2f |
29 | (*start) += 2; |
| 62957726 |
30 | } |
| 31 | return FALSE; |
| 32 | } |
| 33 | |
| 34 | |
| 9a8c1c2f |
35 | boolean |
| 36 | search_for_symbol(char *name, lispobj ** start, int *count) |
| 62957726 |
37 | { |
| 38 | struct symbol *symbol; |
| 39 | struct vector *symbol_name; |
| 40 | |
| 41 | while (search_for_type(type_SymbolHeader, start, count)) { |
| 9a8c1c2f |
42 | symbol = (struct symbol *) PTR((lispobj) * start); |
| 62957726 |
43 | if (LowtagOf(symbol->name) == type_OtherPointer) { |
| 9a8c1c2f |
44 | symbol_name = (struct vector *) PTR(symbol->name); |
| 45 | if (valid_addr((os_vm_address_t) symbol_name) && |
| 62957726 |
46 | TypeOf(symbol_name->header) == type_SimpleString && |
| 9a8c1c2f |
47 | strcmp((char *) symbol_name->data, name) == 0) |
| 48 | return TRUE; |
| 62957726 |
49 | } |
| 9a8c1c2f |
50 | (*start) += 2; |
| 62957726 |
51 | } |
| 52 | return FALSE; |
| 53 | } |