[bigint] Implement BigIntShortPrint
For an improved debugging experience. Bug: v8:6791 Change-Id: Id4f7fea47036e4520e7b24edf34f210b664672bc Reviewed-on: https://chromium-review.googlesource.com/699427 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#48272}
This commit is contained in:
parent
f701d99ba9
commit
d96463a2bf
@ -3424,6 +3424,12 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
|
||||
os << '>';
|
||||
break;
|
||||
}
|
||||
case BIGINT_TYPE: {
|
||||
os << "<BigInt ";
|
||||
BigInt::cast(this)->BigIntShortPrint(os);
|
||||
os << ">";
|
||||
break;
|
||||
}
|
||||
case JS_PROXY_TYPE:
|
||||
os << "<JSProxy>";
|
||||
break;
|
||||
|
@ -196,6 +196,17 @@ void BigInt::Initialize(int length, bool zero_initialize) {
|
||||
}
|
||||
}
|
||||
|
||||
void BigInt::BigIntShortPrint(std::ostream& os) {
|
||||
if (sign()) os << "-";
|
||||
int len = length();
|
||||
if (len == 0) {
|
||||
os << "0";
|
||||
return;
|
||||
}
|
||||
if (len > 1) os << "...";
|
||||
os << digit(0);
|
||||
}
|
||||
|
||||
// Private helpers for public methods.
|
||||
|
||||
Handle<BigInt> BigInt::AbsoluteAdd(Handle<BigInt> x, Handle<BigInt> y,
|
||||
|
@ -51,6 +51,7 @@ class BigInt : public HeapObject {
|
||||
DECL_CAST(BigInt)
|
||||
DECL_VERIFIER(BigInt)
|
||||
DECL_PRINTER(BigInt)
|
||||
void BigIntShortPrint(std::ostream& os);
|
||||
|
||||
// TODO(jkummerow): Do we need {synchronized_length} for GC purposes?
|
||||
DECL_INT_ACCESSORS(length)
|
||||
|
Loading…
Reference in New Issue
Block a user