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.

remove unused print_prototype

-83
-83
src/ant.c
··· 1525 1525 return strstring(js, value, buf, len); 1526 1526 } 1527 1527 1528 - static size_t print_prototype(struct js *js, jsval_t proto_val, char *buf, size_t len, bool *first) { 1529 - size_t n = 0; 1530 - 1531 - int ref = get_circular_ref(proto_val); 1532 - if (ref) { 1533 - if (!*first) n += cpy(buf + n, len - n, ",\n", 2); 1534 - *first = false; 1535 - n += add_indent(buf + n, len - n, stringify_indent); 1536 - n += ref > 0 ? (size_t) snprintf(buf + n, len - n, "[Prototype]: [Circular *%d]", ref) : cpy(buf + n, len - n, "[Prototype]: [Circular]", 23); 1537 - return n; 1538 - } 1539 - 1540 - push_stringify(proto_val); 1541 - 1542 - bool has_proto_props = false; 1543 - jsoff_t proto_next = loadoff(js, (jsoff_t) vdata(proto_val)) & ~(3U | FLAGMASK); 1544 - 1545 - while (proto_next < js->brk && proto_next != 0) { 1546 - jsoff_t pheader = loadoff(js, proto_next); 1547 - if (is_slot_prop(pheader)) { proto_next = next_prop(pheader); continue; } 1548 - 1549 - jsoff_t pkoff = loadoff(js, proto_next + (jsoff_t) sizeof(proto_next)); 1550 - jsoff_t pklen = offtolen(loadoff(js, pkoff)); 1551 - const char *pkstr = (const char *) &js->mem[pkoff + sizeof(jsoff_t)]; 1552 - 1553 - const char *tag_key = get_toStringTag_sym_key(); 1554 - size_t tag_key_len = strlen(tag_key); 1555 - if (!streq(pkstr, pklen, STR_PROTO, STR_PROTO_LEN) && !streq(pkstr, pklen, "constructor", 11) && !streq(pkstr, pklen, tag_key, tag_key_len)) { 1556 - has_proto_props = true; 1557 - break; 1558 - } 1559 - proto_next = next_prop(pheader); 1560 - } 1561 - 1562 - if (!*first) n += cpy(buf + n, len - n, ",\n", 2); 1563 - *first = false; 1564 - n += add_indent(buf + n, len - n, stringify_indent); 1565 - 1566 - if (has_proto_props) { 1567 - n += cpy(buf + n, len - n, "[Prototype]: {\n", 15); 1568 - stringify_indent++; 1569 - 1570 - bool proto_first = true; 1571 - proto_next = loadoff(js, (jsoff_t) vdata(proto_val)) & ~(3U | FLAGMASK); 1572 - while (proto_next < js->brk && proto_next != 0) { 1573 - jsoff_t pheader = loadoff(js, proto_next); 1574 - if (is_slot_prop(pheader)) { proto_next = next_prop(pheader); continue; } 1575 - 1576 - jsoff_t pkoff = loadoff(js, proto_next + (jsoff_t) sizeof(proto_next)); 1577 - jsval_t pval = loadval(js, proto_next + (jsoff_t) (sizeof(proto_next) + sizeof(pkoff))); 1578 - 1579 - jsoff_t pklen = offtolen(loadoff(js, pkoff)); 1580 - const char *pkstr = (const char *) &js->mem[pkoff + sizeof(jsoff_t)]; 1581 - 1582 - const char *tag_key = get_toStringTag_sym_key(); 1583 - size_t tag_key_len = strlen(tag_key); 1584 - if ( 1585 - !streq(pkstr, pklen, STR_PROTO, STR_PROTO_LEN) && 1586 - !streq(pkstr, pklen, "constructor", 11) && 1587 - !streq(pkstr, pklen, tag_key, tag_key_len) 1588 - ) { 1589 - if (!proto_first) n += cpy(buf + n, len - n, ",\n", 2); 1590 - proto_first = false; 1591 - n += add_indent(buf + n, len - n, stringify_indent); 1592 - n += strkey(js, mkval(T_STR, pkoff), buf + n, len - n); 1593 - n += cpy(buf + n, len - n, ": ", 2); 1594 - n += tostr(js, pval, buf + n, len - n); 1595 - } 1596 - proto_next = next_prop(pheader); 1597 - } 1598 - 1599 - stringify_indent--; 1600 - n += cpy(buf + n, len - n, "\n", 1); 1601 - n += add_indent(buf + n, len - n, stringify_indent); 1602 - n += cpy(buf + n, len - n, "}", 1); 1603 - } else { 1604 - n += cpy(buf + n, len - n, "[Prototype]: {}", 15); 1605 - } 1606 - 1607 - pop_stringify(); 1608 - return n; 1609 - } 1610 - 1611 1528 static bool is_small_object(struct js *js, jsval_t obj, int *prop_count) { 1612 1529 int count = 0; 1613 1530 bool has_nested = false;