MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

well-known flag

+14 -3
+1
include/ant.h
··· 99 99 ant_value_t js_mkstr_permanent(ant_t *, const void *, size_t); 100 100 ant_value_t js_mkbigint(ant_t *, const char *digits, size_t len, bool negative); 101 101 ant_value_t js_mksym(ant_t *, const char *desc); 102 + ant_value_t js_mksym_well_known(ant_t *, const char *desc); 102 103 ant_value_t js_mkfun(ant_value_t (*fn)(ant_t *, ant_value_t *, int)); 103 104 ant_value_t js_heavy_mkfun(ant_t *js, ant_value_t (*fn)(ant_t *, ant_value_t *, int), ant_value_t data); 104 105
+12 -2
src/ant.c
··· 3357 3357 return result; 3358 3358 } 3359 3359 3360 - #define SYM_FLAG_GLOBAL 1u 3360 + #define SYM_FLAG_GLOBAL 1u 3361 + #define SYM_FLAG_WELL_KNOWN 2u 3361 3362 3362 3363 typedef struct sym_registry_entry { 3363 3364 const char *key; ··· 3384 3385 } 3385 3386 3386 3387 return mkval(T_SYMBOL, (uintptr_t)sym_ptr); 3388 + } 3389 + 3390 + ant_value_t js_mksym_well_known(ant_t *js, const char *desc) { 3391 + ant_value_t sym = js_mksym(js, desc); 3392 + if (is_err(sym)) return sym; 3393 + ant_symbol_heap_t *ptr = (ant_symbol_heap_t *)(uintptr_t)vdata(sym); 3394 + if (ptr) ptr->flags |= SYM_FLAG_WELL_KNOWN; 3395 + return sym; 3387 3396 } 3388 3397 3389 3398 static inline ant_symbol_heap_t *sym_ptr(ant_value_t v) { ··· 3445 3454 const char *js_sym_key(ant_value_t sym) { 3446 3455 if (vtype(sym) != T_SYMBOL) return NULL; 3447 3456 ant_t *js = rt->js; 3448 - if (!(sym_get_flags(js, sym) & SYM_FLAG_GLOBAL)) return NULL; 3457 + uint32_t flags = sym_get_flags(js, sym); 3458 + if (!(flags & SYM_FLAG_GLOBAL) || (flags & SYM_FLAG_WELL_KNOWN)) return NULL; 3449 3459 return (const char *)sym_get_key_ptr(js, sym); 3450 3460 } 3451 3461
+1 -1
src/modules/symbol.c
··· 221 221 gc_register_root(&js->sym.array_iterator_proto); 222 222 gc_register_root(&js->sym.string_iterator_proto); 223 223 224 - #define INIT_SYM(name, desc) g_##name = js_mksym(js, desc); 224 + #define INIT_SYM(name, desc) g_##name = js_mksym_well_known(js, desc); 225 225 WELLKNOWN_SYMBOLS(INIT_SYM) 226 226 #undef INIT_SYM 227 227