The binding of name in one frame: hashed when the frame has an index, * otherwise the linear chunk scan (small frames, or no index memory). */
| 133 | /* The binding of name in one frame: hashed when the frame has an index, |
| 134 | * otherwise the linear chunk scan (small frames, or no index memory). */ |
| 135 | static CBMVarBinding *scope_frame_find(const CBMScope *scope, const char *name) { |
| 136 | if (scope->index.cap > 0) { |
| 137 | uint32_t mask = (uint32_t)scope->index.cap - 1; |
| 138 | for (uint32_t i = scope_name_hash(name) & mask;; i = (i + 1) & mask) { |
| 139 | CBMVarBinding *b = scope->index.slots[i]; |
| 140 | if (!b) { |
| 141 | return NULL; |
| 142 | } |
| 143 | CBM_LSP_WORK(1); |
| 144 | if (strcmp(b->name, name) == 0) { |
| 145 | return b; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | for (CBMScopeChunk *c = scope->chunks; c != NULL; c = c->next) { |
| 150 | for (int i = 0; i < c->used; i++) { |
| 151 | CBM_LSP_WORK(1); |
| 152 | if (c->bindings[i].name && strcmp(c->bindings[i].name, name) == 0) { |
| 153 | return &c->bindings[i]; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | return NULL; |
| 158 | } |
| 159 | |
| 160 | /* Returns false when the binding could NOT be recorded in THIS frame. |
| 161 | * |
no test coverage detected