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

Side by Side Diff: src/string-stream.cc

Issue 10294: * Added d8 flag "--" (alias "--js-arguments") (Closed)
Patch Set: Addressed review comments Created 12 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/string-stream.h ('k') | test/cctest/test-flags.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 PrintObject(obj); 134 PrintObject(obj);
135 break; 135 break;
136 } 136 }
137 case 'i': case 'd': case 'u': case 'x': case 'c': case 'p': { 137 case 'i': case 'd': case 'u': case 'x': case 'c': case 'p': {
138 int value = current.data_.u_int_; 138 int value = current.data_.u_int_;
139 EmbeddedVector<char, 24> formatted; 139 EmbeddedVector<char, 24> formatted;
140 OS::SNPrintF(formatted, temp.start(), value); 140 OS::SNPrintF(formatted, temp.start(), value);
141 Add(formatted.start()); 141 Add(formatted.start());
142 break; 142 break;
143 } 143 }
144 case 'f': case 'g': case 'G': case 'e': case 'E': {
145 double value = current.data_.u_double_;
146 EmbeddedVector<char, 28> formatted;
147 OS::SNPrintF(formatted, temp.start(), value);
148 Add(formatted.start());
149 break;
150 }
144 default: 151 default:
145 UNREACHABLE(); 152 UNREACHABLE();
146 break; 153 break;
147 } 154 }
148 } 155 }
149 156
150 // Verify that the buffer is 0-terminated and doesn't contain any 157 // Verify that the buffer is 0-terminated and doesn't contain any
151 // other 0-characters. 158 // other 0-characters.
152 ASSERT(buffer_[length_] == '\0'); 159 ASSERT(buffer_[length_] == '\0');
153 ASSERT(strlen(buffer_) == length_); 160 ASSERT(strlen(buffer_) == length_);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 207
201 208
202 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, 209 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1,
203 FmtElm arg2) { 210 FmtElm arg2) {
204 const char argc = 3; 211 const char argc = 3;
205 FmtElm argv[argc] = { arg0, arg1, arg2 }; 212 FmtElm argv[argc] = { arg0, arg1, arg2 };
206 Add(format, Vector<FmtElm>(argv, argc)); 213 Add(format, Vector<FmtElm>(argv, argc));
207 } 214 }
208 215
209 216
210 SmartPointer<char> StringStream::ToCString() { 217 SmartPointer<const char> StringStream::ToCString() {
211 char* str = NewArray<char>(length_ + 1); 218 char* str = NewArray<char>(length_ + 1);
212 memcpy(str, buffer_, length_); 219 memcpy(str, buffer_, length_);
213 str[length_] = '\0'; 220 str[length_] = '\0';
214 return SmartPointer<char>(str); 221 return SmartPointer<const char>(str);
215 } 222 }
216 223
217 224
218 void StringStream::Log() { 225 void StringStream::Log() {
219 LOG(StringEvent("StackDump", buffer_)); 226 LOG(StringEvent("StackDump", buffer_));
220 } 227 }
221 228
222 229
223 void StringStream::OutputToStdOut() { 230 void StringStream::OutputToStdOut() {
224 // Dump the output to stdout, but make sure to break it up into 231 // Dump the output to stdout, but make sure to break it up into
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 unsigned new_bytes = *bytes * 2; 539 unsigned new_bytes = *bytes * 2;
533 if (new_bytes > size_) { 540 if (new_bytes > size_) {
534 new_bytes = size_; 541 new_bytes = size_;
535 } 542 }
536 *bytes = new_bytes; 543 *bytes = new_bytes;
537 return space_; 544 return space_;
538 } 545 }
539 546
540 547
541 } } // namespace v8::internal 548 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/string-stream.h ('k') | test/cctest/test-flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698