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

Side by Side Diff: src/messages.cc

Issue 3970005: Make Failure inherit from MaybeObject instead of Object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright 2006-2008 the V8 project authors. All rights reserved. 2 // Copyright 2006-2008 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 Handle<Object> callback_data(listener.get(1)); 145 Handle<Object> callback_data(listener.get(1));
146 callback(api_message_obj, v8::Utils::ToLocal(callback_data)); 146 callback(api_message_obj, v8::Utils::ToLocal(callback_data));
147 } 147 }
148 } 148 }
149 } 149 }
150 150
151 151
152 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 152 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
153 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); 153 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage");
154 Handle<JSFunction> fun = 154 Handle<JSFunction> fun =
155 Handle<JSFunction>( 155 Handle<JSFunction>(JSFunction::cast(
156 JSFunction::cast(Top::builtins()->GetProperty(*fmt_str))); 156 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str)));
157 Object** argv[1] = { data.location() }; 157 Object** argv[1] = { data.location() };
158 158
159 bool caught_exception; 159 bool caught_exception;
160 Handle<Object> result = 160 Handle<Object> result =
161 Execution::TryCall(fun, Top::builtins(), 1, argv, &caught_exception); 161 Execution::TryCall(fun, Top::builtins(), 1, argv, &caught_exception);
162 162
163 if (caught_exception || !result->IsString()) { 163 if (caught_exception || !result->IsString()) {
164 return Factory::LookupAsciiSymbol("<error>"); 164 return Factory::LookupAsciiSymbol("<error>");
165 } 165 }
166 Handle<String> result_string = Handle<String>::cast(result); 166 Handle<String> result_string = Handle<String>::cast(result);
167 // A string that has been obtained from JS code in this way is 167 // A string that has been obtained from JS code in this way is
168 // likely to be a complicated ConsString of some sort. We flatten it 168 // likely to be a complicated ConsString of some sort. We flatten it
169 // here to improve the efficiency of converting it to a C string and 169 // here to improve the efficiency of converting it to a C string and
170 // other operations that are likely to take place (see GetLocalizedMessage 170 // other operations that are likely to take place (see GetLocalizedMessage
171 // for example). 171 // for example).
172 FlattenString(result_string); 172 FlattenString(result_string);
173 return result_string; 173 return result_string;
174 } 174 }
175 175
176 176
177 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 177 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
178 HandleScope scope; 178 HandleScope scope;
179 return GetMessage(data)->ToCString(DISALLOW_NULLS); 179 return GetMessage(data)->ToCString(DISALLOW_NULLS);
180 } 180 }
181 181
182 182
183 } } // namespace v8::internal 183 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698