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.

add hidden function property check to internal property check

+20 -12
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.2.1.10') 77 + version_conf.set('ANT_VERSION', '0.2.1.11') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+19 -11
src/ant.c
··· 632 632 static jsoff_t free_list_allocate(size_t size); 633 633 static jsoff_t lkp(struct js *js, jsval_t obj, const char *buf, size_t len); 634 634 static jsoff_t lkp_interned(struct js *js, jsval_t obj, const char *search_intern, size_t len); 635 + static inline const char *get_koff_intern(jsoff_t koff); 635 636 636 637 static jsval_t js_import_stmt(struct js *js); 637 638 static jsval_t js_export_stmt(struct js *js); ··· 1714 1715 } 1715 1716 1716 1717 static bool is_internal_prop(const char *key, jsoff_t klen) { 1717 - if (klen < 5) return false; 1718 - if (key[0] != '_') { 1719 - if (klen == 9 && key == INTERN_PROTOTYPE) return true; 1720 - if (klen == 11 && key == INTERN_CONSTRUCTOR) return true; 1721 - return false; 1722 - } 1723 - if (key[1] != '_') return false; 1718 + if (klen < 2) return false; 1719 + if (key[0] != '_' || key[1] != '_') return false; 1724 1720 if (klen >= 9 && key[2] == 's' && key[3] == 'y' && key[4] == 'm' && key[5] == '_' && key[klen-1] == '_' && key[klen-2] == '_') return true; 1725 1721 return true; 1726 1722 } 1727 1723 1724 + static bool is_hidden_func_prop(const char *key, jsoff_t koff, jsoff_t klen) { 1725 + if (klen == 4 && memcmp(key, "name", 4) == 0) return true; 1726 + if (klen == 8 && memcmp(key, "__getter", 8) == 0) return true; 1727 + if (key[0] == '_' && key[1] == '_') return true; 1728 + 1729 + const char *interned = get_koff_intern(koff); 1730 + if (interned) { 1731 + if (interned == INTERN_PROTOTYPE || interned == INTERN_CONSTRUCTOR) return true; 1732 + if (interned == get_toStringTag_sym_key()) return true; 1733 + } 1734 + 1735 + return false; 1736 + } 1737 + 1728 1738 static size_t strfunc_ctor(struct js *js, jsval_t func_obj, char *buf, size_t len) { 1729 1739 int ref = get_circular_ref(func_obj); 1730 1740 if (ref) return ref > 0 ? (size_t) snprintf(buf, len, "[Circular *%d]", ref) : cpy(buf, len, "[Circular]", 10); ··· 1737 1747 jsoff_t next = loadoff(js, (jsoff_t) vdata(func_obj)) & ~(3U | CONSTMASK | ARRMASK); 1738 1748 while (next < js->brk && next != 0) { 1739 1749 jsoff_t koff = loadoff(js, next + (jsoff_t) sizeof(next)); 1740 - jsval_t val = loadval(js, next + (jsoff_t) (sizeof(next) + sizeof(koff))); 1741 - 1742 1750 jsoff_t klen = offtolen(loadoff(js, koff)); 1743 1751 const char *kstr = (const char *) &js->mem[koff + sizeof(jsoff_t)]; 1744 1752 1745 - const char *func_tag_key = get_toStringTag_sym_key(); 1746 - if (!is_internal_prop(kstr, klen) && !streq(kstr, klen, "name", 4) && !streq(kstr, klen, func_tag_key, strlen(func_tag_key)) && !streq(kstr, klen, "__getter", 8)) { 1753 + if (!is_hidden_func_prop(kstr, koff, klen)) { 1754 + jsval_t val = loadval(js, next + (jsoff_t) (sizeof(next) + sizeof(koff))); 1747 1755 if (!first) n += cpy(buf + n, len - n, ",\n", 2); 1748 1756 first = false; 1749 1757 n += add_indent(buf + n, len - n, stringify_indent);