4 ms·
This part of the code hints at what else is left unimplemented: case TOK_CASE: case TOK_CATCH: case TOK_CLASS: case TOK_CONST: case TOK_DEFAULT: case T
by unwind 5y ago
This part of the code hints at what else is left unimplemented:
case TOK_CASE: case TOK_CATCH: case TOK_CLASS: case TOK_CONST:
case TOK_DEFAULT: case TOK_DELETE: case TOK_DO: case TOK_FINALLY:
case TOK_FOR: case TOK_IN: case TOK_INSTANCEOF: case TOK_NEW:
case TOK_SWITCH: case TOK_THIS: case TOK_THROW: case TOK_TRY:
case TOK_VAR: case TOK_VOID: case TOK_WITH: case TOK_YIELD:
res = js_err(js, "'%.*s' not implemented", (int) js->tlen, js->code + js->toff);
break;
So that's quite a lot of the language I guess, but it does say that it's a sub-set so of course that's fine. Very impressive code, it really shows that the developer has an eye to minimizing the memory footprint. I was fooled for a couple of seconds by the init call:
char mem[200];
struct js *js = js_create(mem, sizeof(mem));
Since it really "feels" like a function that creates a struct instance on the heap, but of course it does not: it's created inside the working memory passed in (so if it works, js == mem).
- BoorishBears 5y agoI write embedded code and the moment I see (data, sizeof(data)) in any kind of initialization method, I immediately expect it not to allocate. Trust but verify, but also I'll feel mislead if it does since it's an extremely common pattern