Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: runtime/vm/json_stream.cc

Issue 1387433002: Ensure that service protocol specification and implementation use the correct numeric types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/json_stream.cc
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index f25add71d282187f1f66be75c881ed6fe3293c13..b5da5ddc01066981ab98411afdcf64be1c487cf2 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -292,23 +292,27 @@ void JSONStream::PrintValueBool(bool b) {
void JSONStream::PrintValue(intptr_t i) {
+ EnsureIntegerIsRepresentableInJavaScript(static_cast<int64_t>(i));
PrintCommaIfNeeded();
buffer_.Printf("%" Pd "", i);
}
void JSONStream::PrintValue64(int64_t i) {
+ EnsureIntegerIsRepresentableInJavaScript(i);
PrintCommaIfNeeded();
buffer_.Printf("%" Pd64 "", i);
}
void JSONStream::PrintValueTimeMillis(int64_t millis) {
- PrintValue(static_cast<double>(millis));
+ EnsureIntegerIsRepresentableInJavaScript(millis);
+ PrintValue64(millis);
}
void JSONStream::PrintValueTimeMicros(int64_t micros) {
+ EnsureIntegerIsRepresentableInJavaScript(micros);
PrintValue64(micros);
}
@@ -452,21 +456,19 @@ void JSONStream::PrintPropertyBool(const char* name, bool b) {
void JSONStream::PrintProperty(const char* name, intptr_t i) {
- ASSERT(Utils::IsJavascriptInt(i));
PrintPropertyName(name);
PrintValue(i);
}
void JSONStream::PrintProperty64(const char* name, int64_t i) {
- ASSERT(Utils::IsJavascriptInt64(i));
PrintPropertyName(name);
PrintValue64(i);
}
void JSONStream::PrintPropertyTimeMillis(const char* name, int64_t millis) {
- PrintProperty(name, static_cast<double>(millis));
+ PrintProperty64(name, millis);
}
@@ -620,6 +622,17 @@ bool JSONStream::NeedComma() {
}
+void JSONStream::EnsureIntegerIsRepresentableInJavaScript(int64_t i) {
+#ifdef DEBUG
+ if (!Utils::IsJavascriptInt(i)) {
+ OS::Print("JSONStream::EnsureIntegerIsRepresentableInJavaScript failed on "
+ "%" Pd64 "\n", i);
+ UNREACHABLE();
+ }
+#endif
+}
+
+
void JSONStream::AddEscapedUTF8String(const char* s) {
if (s == NULL) {
return;
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698