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

Side by Side Diff: src/messages.cc

Issue 11597007: Rename LookupSymbol calls to use Utf8 or OneByte in names. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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/liveedit.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 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 } 55 }
56 56
57 57
58 Handle<JSMessageObject> MessageHandler::MakeMessageObject( 58 Handle<JSMessageObject> MessageHandler::MakeMessageObject(
59 const char* type, 59 const char* type,
60 MessageLocation* loc, 60 MessageLocation* loc,
61 Vector< Handle<Object> > args, 61 Vector< Handle<Object> > args,
62 Handle<String> stack_trace, 62 Handle<String> stack_trace,
63 Handle<JSArray> stack_frames) { 63 Handle<JSArray> stack_frames) {
64 Handle<String> type_handle = FACTORY->LookupAsciiSymbol(type); 64 Handle<String> type_handle = FACTORY->LookupUtf8Symbol(type);
65 Handle<FixedArray> arguments_elements = 65 Handle<FixedArray> arguments_elements =
66 FACTORY->NewFixedArray(args.length()); 66 FACTORY->NewFixedArray(args.length());
67 for (int i = 0; i < args.length(); i++) { 67 for (int i = 0; i < args.length(); i++) {
68 arguments_elements->set(i, *args[i]); 68 arguments_elements->set(i, *args[i]);
69 } 69 }
70 Handle<JSArray> arguments_handle = 70 Handle<JSArray> arguments_handle =
71 FACTORY->NewJSArrayWithElements(arguments_elements); 71 FACTORY->NewJSArrayWithElements(arguments_elements);
72 72
73 int start = 0; 73 int start = 0;
74 int end = 0; 74 int end = 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 if (isolate->has_scheduled_exception()) { 143 if (isolate->has_scheduled_exception()) {
144 isolate->clear_scheduled_exception(); 144 isolate->clear_scheduled_exception();
145 } 145 }
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 150
151 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 151 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
152 Handle<String> fmt_str = FACTORY->LookupAsciiSymbol("FormatMessage"); 152 Handle<String> fmt_str =
153 FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("FormatMessage"));
153 Handle<JSFunction> fun = 154 Handle<JSFunction> fun =
154 Handle<JSFunction>( 155 Handle<JSFunction>(
155 JSFunction::cast( 156 JSFunction::cast(
156 Isolate::Current()->js_builtins_object()-> 157 Isolate::Current()->js_builtins_object()->
157 GetPropertyNoExceptionThrown(*fmt_str))); 158 GetPropertyNoExceptionThrown(*fmt_str)));
158 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); 159 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
159 Handle<Object> argv[] = { Handle<Object>(message->type()), 160 Handle<Object> argv[] = { Handle<Object>(message->type()),
160 Handle<Object>(message->arguments()) }; 161 Handle<Object>(message->arguments()) };
161 162
162 bool caught_exception; 163 bool caught_exception;
163 Handle<Object> result = 164 Handle<Object> result =
164 Execution::TryCall(fun, 165 Execution::TryCall(fun,
165 Isolate::Current()->js_builtins_object(), 166 Isolate::Current()->js_builtins_object(),
166 ARRAY_SIZE(argv), 167 ARRAY_SIZE(argv),
167 argv, 168 argv,
168 &caught_exception); 169 &caught_exception);
169 170
170 if (caught_exception || !result->IsString()) { 171 if (caught_exception || !result->IsString()) {
171 return FACTORY->LookupAsciiSymbol("<error>"); 172 return FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("<error>"));
172 } 173 }
173 Handle<String> result_string = Handle<String>::cast(result); 174 Handle<String> result_string = Handle<String>::cast(result);
174 // A string that has been obtained from JS code in this way is 175 // A string that has been obtained from JS code in this way is
175 // likely to be a complicated ConsString of some sort. We flatten it 176 // likely to be a complicated ConsString of some sort. We flatten it
176 // here to improve the efficiency of converting it to a C string and 177 // here to improve the efficiency of converting it to a C string and
177 // other operations that are likely to take place (see GetLocalizedMessage 178 // other operations that are likely to take place (see GetLocalizedMessage
178 // for example). 179 // for example).
179 FlattenString(result_string); 180 FlattenString(result_string);
180 return result_string; 181 return result_string;
181 } 182 }
182 183
183 184
184 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( 185 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage(
185 Handle<Object> data) { 186 Handle<Object> data) {
186 HandleScope scope; 187 HandleScope scope;
187 return GetMessage(data)->ToCString(DISALLOW_NULLS); 188 return GetMessage(data)->ToCString(DISALLOW_NULLS);
188 } 189 }
189 190
190 191
191 } } // namespace v8::internal 192 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/liveedit.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698