OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "allocation-site-scopes.h" | 8 #include "allocation-site-scopes.h" |
9 #include "api.h" | 9 #include "api.h" |
10 #include "arguments.h" | 10 #include "arguments.h" |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 HeapStringAllocator allocator; | 980 HeapStringAllocator allocator; |
981 StringStream accumulator(&allocator); | 981 StringStream accumulator(&allocator); |
982 ShortPrint(&accumulator); | 982 ShortPrint(&accumulator); |
983 accumulator.OutputToFile(out); | 983 accumulator.OutputToFile(out); |
984 } | 984 } |
985 | 985 |
986 | 986 |
987 void Object::ShortPrint(StringStream* accumulator) { | 987 void Object::ShortPrint(StringStream* accumulator) { |
988 if (IsSmi()) { | 988 if (IsSmi()) { |
989 Smi::cast(this)->SmiPrint(accumulator); | 989 Smi::cast(this)->SmiPrint(accumulator); |
990 } else if (IsFailure()) { | |
991 Failure::cast(this)->FailurePrint(accumulator); | |
992 } else { | 990 } else { |
993 HeapObject::cast(this)->HeapObjectShortPrint(accumulator); | 991 HeapObject::cast(this)->HeapObjectShortPrint(accumulator); |
994 } | 992 } |
995 } | 993 } |
996 | 994 |
997 | 995 |
998 void Smi::SmiPrint(FILE* out) { | 996 void Smi::SmiPrint(FILE* out) { |
999 PrintF(out, "%d", value()); | 997 PrintF(out, "%d", value()); |
1000 } | 998 } |
1001 | 999 |
1002 | 1000 |
1003 void Smi::SmiPrint(StringStream* accumulator) { | 1001 void Smi::SmiPrint(StringStream* accumulator) { |
1004 accumulator->Add("%d", value()); | 1002 accumulator->Add("%d", value()); |
1005 } | 1003 } |
1006 | 1004 |
1007 | 1005 |
1008 void Failure::FailurePrint(StringStream* accumulator) { | |
1009 accumulator->Add("Failure(%p)", reinterpret_cast<void*>(value())); | |
1010 } | |
1011 | |
1012 | |
1013 void Failure::FailurePrint(FILE* out) { | |
1014 PrintF(out, "Failure(%p)", reinterpret_cast<void*>(value())); | |
1015 } | |
1016 | |
1017 | |
1018 // Should a word be prefixed by 'a' or 'an' in order to read naturally in | 1006 // Should a word be prefixed by 'a' or 'an' in order to read naturally in |
1019 // English? Returns false for non-ASCII or words that don't start with | 1007 // English? Returns false for non-ASCII or words that don't start with |
1020 // a capital letter. The a/an rule follows pronunciation in English. | 1008 // a capital letter. The a/an rule follows pronunciation in English. |
1021 // We don't use the BBC's overcorrect "an historic occasion" though if | 1009 // We don't use the BBC's overcorrect "an historic occasion" though if |
1022 // you speak a dialect you may well say "an 'istoric occasion". | 1010 // you speak a dialect you may well say "an 'istoric occasion". |
1023 static bool AnWord(String* str) { | 1011 static bool AnWord(String* str) { |
1024 if (str->length() == 0) return false; // A nothing. | 1012 if (str->length() == 0) return false; // A nothing. |
1025 int c0 = str->Get(0); | 1013 int c0 = str->Get(0); |
1026 int c1 = str->length() > 1 ? str->Get(1) : 0; | 1014 int c1 = str->length() > 1 ? str->Get(1) : 0; |
1027 if (c0 == 'U') { | 1015 if (c0 == 'U') { |
(...skipping 16211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17239 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17227 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17240 static const char* error_messages_[] = { | 17228 static const char* error_messages_[] = { |
17241 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17229 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17242 }; | 17230 }; |
17243 #undef ERROR_MESSAGES_TEXTS | 17231 #undef ERROR_MESSAGES_TEXTS |
17244 return error_messages_[reason]; | 17232 return error_messages_[reason]; |
17245 } | 17233 } |
17246 | 17234 |
17247 | 17235 |
17248 } } // namespace v8::internal | 17236 } } // namespace v8::internal |
OLD | NEW |