MCPcopy Create free account
hub / github.com/aardappel/lobster / VectorOrObjectToString

Function VectorOrObjectToString

dev/src/vmdata.cpp:544–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544void VectorOrObjectToString(VM &vm, string &sd, PrintPrefs &pp, char openb, char closeb,
545 iint len, iint width, const Value *elems, bool is_vector,
546 std::function<const TypeInfo &(iint)> getti) {
547 sd += openb;
548 if (pp.indent) sd += '\n';
549 auto start_size = sd.size();
550 pp.cur_indent += pp.indent;
551 auto Indent = [&]() {
552 for (int i = 0; i < pp.cur_indent; i++) sd += ' ';
553 };
554 for (iint i = 0; i < len; i++) {
555 if (i) {
556 sd += ',';
557 sd += (pp.indent ? '\n' : ' ');
558 }
559 if (pp.indent) Indent();
560 if (iint(sd.size() - start_size) > pp.budget) {
561 sd += "....";
562 break;
563 }
564 auto &ti = getti(i);
565 if (pp.depth || !RTIsRef(ti.t)) {
566 PrintPrefs subpp(pp.depth - 1, pp.budget - iint(sd.size() - start_size), true,
567 pp.decimals);
568 subpp.indent = pp.indent;
569 subpp.cur_indent = pp.cur_indent;
570 if (RTIsStruct(ti.t)) {
571 vm.StructToString(sd, subpp, ti, elems + i * width);
572 if (!is_vector) i += ti.len - 1;
573 } else {
574 elems[i].ToString(vm, sd, ti, subpp);
575 }
576 } else {
577 sd += "..";
578 }
579 }
580 pp.cur_indent -= pp.indent;
581 if (pp.indent) { sd += '\n'; Indent(); }
582 sd += closeb;
583}
584
585void LObject::ToString(VM &vm, string &sd, PrintPrefs &pp) {
586 if (CycleCheck(sd, pp)) return;

Callers 2

ToStringMethod · 0.85
StructToStringMethod · 0.85

Calls 5

RTIsRefFunction · 0.85
RTIsStructFunction · 0.85
sizeMethod · 0.45
StructToStringMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected