MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuLocals_get

Function PiuLocals_get

modules/piu/All/piuLocals.c:138–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138void PiuLocals_get(xsMachine* the)
139{
140 PiuLocals* self = PIU(Locals, xsThis);
141 xsStringValue string = xsToString(xsArg(0));
142 int32_t* seeds = (*self)->seeds;
143 int32_t* results = (*self)->results;
144 if (seeds && results) {
145 int32_t c = (*self)->length;
146 int32_t d = (int32_t)PiuLocalsHash(0, (uint8_t*)string) % c;
147 int32_t offset;
148 d = c_read32(seeds + 1 + d);
149 if (d < 0)
150 d = 0 - d - 1;
151 else if (d > 0)
152 d = (int32_t)PiuLocalsHash((uint32_t)d, (uint8_t*)string) % c;
153 else
154 return;
155#if !MODDEF_LOCALS_ALL
156 offset = c_read32(seeds + 1 + c + 1 + d);
157 if (c_strcmp((xsStringValue)seeds + offset, string))
158 return;
159#endif
160 offset = c_read32(results + 1 + d);
161 string = (xsStringValue)results + offset;
162 fxStringX(the, &xsResult, string);
163 }
164}

Callers

nothing calls this directly

Calls 2

PiuLocalsHashFunction · 0.85
fxStringXFunction · 0.85

Tested by

no test coverage detected