| OLD | NEW |
| 1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // Create a page-level library if necessary. | 173 // Create a page-level library if necessary. |
| 174 Dart_Handle script = Dart_RootLibrary(); | 174 Dart_Handle script = Dart_RootLibrary(); |
| 175 if (Dart_IsNull(script)) { | 175 if (Dart_IsNull(script)) { |
| 176 String scriptUrl = m_originDocument->url().string() + "$script"; | 176 String scriptUrl = m_originDocument->url().string() + "$script"; |
| 177 script = Dart_LoadScript(DartUtilities::stringToDartString(scriptUrl
), Dart_NewStringFromCString(""), 0, 0); | 177 script = Dart_LoadScript(DartUtilities::stringToDartString(scriptUrl
), Dart_NewStringFromCString(""), 0, 0); |
| 178 if (Dart_IsError(script)) | 178 if (Dart_IsError(script)) |
| 179 DartUtilities::reportProblem(m_originDocument, script, scriptUrl
); | 179 DartUtilities::reportProblem(m_originDocument, script, scriptUrl
); |
| 180 } | 180 } |
| 181 ASSERT(!Dart_IsNull(script)); | 181 ASSERT(!Dart_IsNull(script)); |
| 182 | 182 |
| 183 // FIXME(dartbug.com/13460): We need to record the lineOffset and column
Offset. | 183 Dart_Handle libraryUrlHandle = DartUtilities::stringToDartString(url); |
| 184 Dart_Handle library = Dart_LoadLibrary(DartUtilities::stringToDartString
(url), dartSource); | 184 // Test if a previous script already loaded this library. |
| 185 if (Dart_IsError(library)) | 185 Dart_Handle library = Dart_LookupLibrary(libraryUrlHandle); |
| 186 DartUtilities::reportProblem(m_originDocument, library, m_libraryUrl
); | 186 if (Dart_IsError(library)) { |
| 187 // FIXME(dartbug.com/13460): We need to record the lineOffset and co
lumnOffset. |
| 188 library = Dart_LoadLibrary(libraryUrlHandle, dartSource); |
| 189 if (Dart_IsError(library)) |
| 190 DartUtilities::reportProblem(m_originDocument, library, m_librar
yUrl); |
| 191 } |
| 187 | 192 |
| 188 Dart_Handle result = Dart_LibraryImportLibrary(script, library, Dart_Nul
l()); | 193 Dart_Handle result = Dart_LibraryImportLibrary(script, library, Dart_Nul
l()); |
| 189 if (Dart_IsError(result)) | 194 if (Dart_IsError(result)) |
| 190 DartUtilities::reportProblem(m_originDocument, result, m_libraryUrl)
; | 195 DartUtilities::reportProblem(m_originDocument, result, m_libraryUrl)
; |
| 191 } else { | 196 } else { |
| 192 // This is a background isolate. Load as a top-level script. | 197 // This is a background isolate. Load as a top-level script. |
| 193 Dart_Handle script = Dart_LoadScript(DartUtilities::stringToDartString(u
rl), dartSource, lineOffset, 0); | 198 Dart_Handle script = Dart_LoadScript(DartUtilities::stringToDartString(u
rl), dartSource, lineOffset, 0); |
| 194 if (Dart_IsError(script)) | 199 if (Dart_IsError(script)) |
| 195 DartUtilities::reportProblem(m_originDocument, script, m_libraryUrl)
; | 200 DartUtilities::reportProblem(m_originDocument, script, m_libraryUrl)
; |
| 196 } | 201 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // FIXME: try to dig out line number, -1 for now. | 287 // FIXME: try to dig out line number, -1 for now. |
| 283 if (failedUrl.startsWith(String("dart:"))) { | 288 if (failedUrl.startsWith(String("dart:"))) { |
| 284 m_originDocument->logExceptionToConsole(String("The built-in library '")
+ failedUrl + String("' is not available on Dartium."), m_libraryUrl, -1, 0, 0)
; | 289 m_originDocument->logExceptionToConsole(String("The built-in library '")
+ failedUrl + String("' is not available on Dartium."), m_libraryUrl, -1, 0, 0)
; |
| 285 } else { | 290 } else { |
| 286 m_originDocument->logExceptionToConsole(String("Failed to load a file ")
+ failedUrl, m_libraryUrl, -1, 0, 0); | 291 m_originDocument->logExceptionToConsole(String("Failed to load a file ")
+ failedUrl, m_libraryUrl, -1, 0, 0); |
| 287 } | 292 } |
| 288 m_errorEventDispatcher->dispatchErrorEvent(); | 293 m_errorEventDispatcher->dispatchErrorEvent(); |
| 289 } | 294 } |
| 290 | 295 |
| 291 } | 296 } |
| OLD | NEW |