| OLD | NEW |
| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { | 135 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { |
| 136 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); | 136 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); |
| 137 Handle<JSFunction> fun = | 137 Handle<JSFunction> fun = |
| 138 Handle<JSFunction>( | 138 Handle<JSFunction>( |
| 139 JSFunction::cast( | 139 JSFunction::cast( |
| 140 Top::security_context_builtins()->GetProperty(*fmt_str))); | 140 Top::builtins()->GetProperty(*fmt_str))); |
| 141 Object** argv[1] = { data.location() }; | 141 Object** argv[1] = { data.location() }; |
| 142 | 142 |
| 143 bool caught_exception; | 143 bool caught_exception; |
| 144 Handle<Object> result = | 144 Handle<Object> result = |
| 145 Execution::TryCall(fun, Top::security_context_builtins(), 1, argv, | 145 Execution::TryCall(fun, Top::builtins(), 1, argv, |
| 146 &caught_exception); | 146 &caught_exception); |
| 147 | 147 |
| 148 if (caught_exception || !result->IsString()) { | 148 if (caught_exception || !result->IsString()) { |
| 149 return Factory::LookupAsciiSymbol("<error>"); | 149 return Factory::LookupAsciiSymbol("<error>"); |
| 150 } | 150 } |
| 151 Handle<String> result_string = Handle<String>::cast(result); | 151 Handle<String> result_string = Handle<String>::cast(result); |
| 152 // A string that has been obtained from JS code in this way is | 152 // A string that has been obtained from JS code in this way is |
| 153 // likely to be a complicated ConsString of some sort. We flatten it | 153 // likely to be a complicated ConsString of some sort. We flatten it |
| 154 // here to improve the efficiency of converting it to a C string and | 154 // here to improve the efficiency of converting it to a C string and |
| 155 // other operations that are likely to take place (see GetLocalizedMessage | 155 // other operations that are likely to take place (see GetLocalizedMessage |
| 156 // for example). | 156 // for example). |
| 157 FlattenString(result_string); | 157 FlattenString(result_string); |
| 158 return result_string; | 158 return result_string; |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { | 162 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { |
| 163 HandleScope scope; | 163 HandleScope scope; |
| 164 return GetMessage(data)->ToCString(DISALLOW_NULLS); | 164 return GetMessage(data)->ToCString(DISALLOW_NULLS); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 } } // namespace v8::internal | 168 } } // namespace v8::internal |
| OLD | NEW |