| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @param {string} moduleName | 240 * @param {string} moduleName |
| 241 */ | 241 */ |
| 242 _registerModule: function(moduleName) | 242 _registerModule: function(moduleName) |
| 243 { | 243 { |
| 244 if (!this._descriptorsMap[moduleName]) { | 244 if (!this._descriptorsMap[moduleName]) { |
| 245 var content; | 245 var content; |
| 246 // FIXME: This is a temp workaround to avoid core module loading att
empts in the release mode. | 246 // FIXME: This is a temp workaround to avoid core module loading att
empts in the release mode. |
| 247 // It should be removed when the new application loader is implement
ed. | 247 // It should be removed when the new application loader is implement
ed. |
| 248 if (moduleName === "main" || !this._coreModules.hasOwnProperty(modul
eName)) | 248 if (!this._coreModules.hasOwnProperty(moduleName)) |
| 249 content = loadResource(moduleName + "/module.json"); | 249 content = loadResource(moduleName + "/module.json"); |
| 250 else | 250 else |
| 251 content = "{}"; | 251 content = "{}"; |
| 252 | 252 |
| 253 if (!content) | 253 if (!content) |
| 254 throw new Error("Module is not defined: " + moduleName + " " + n
ew Error().stack); | 254 throw new Error("Module is not defined: " + moduleName + " " + n
ew Error().stack); |
| 255 | 255 |
| 256 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("("
+ content + ")")); | 256 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("("
+ content + ")")); |
| 257 module["name"] = moduleName; | 257 module["name"] = moduleName; |
| 258 this._descriptorsMap[moduleName] = module; | 258 this._descriptorsMap[moduleName] = module; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 */ | 517 */ |
| 518 Runtime.Module = function(manager, descriptor) | 518 Runtime.Module = function(manager, descriptor) |
| 519 { | 519 { |
| 520 this._manager = manager; | 520 this._manager = manager; |
| 521 this._descriptor = descriptor; | 521 this._descriptor = descriptor; |
| 522 this._name = descriptor.name; | 522 this._name = descriptor.name; |
| 523 var extensions = /** @type {?Array.<!Runtime.ExtensionDescriptor>}*/ (descri
ptor.extensions); | 523 var extensions = /** @type {?Array.<!Runtime.ExtensionDescriptor>}*/ (descri
ptor.extensions); |
| 524 for (var i = 0; extensions && i < extensions.length; ++i) | 524 for (var i = 0; extensions && i < extensions.length; ++i) |
| 525 this._manager._extensions.push(new Runtime.Extension(this, extensions[i]
)); | 525 this._manager._extensions.push(new Runtime.Extension(this, extensions[i]
)); |
| 526 this._loaded = false; | 526 this._loaded = false; |
| 527 | |
| 528 // FIXME: This is a temp workaround to avoid core module loading attempts in
the release mode. | |
| 529 // It should be removed when the new application loader is implemented. | |
| 530 if (this._manager._coreModules.hasOwnProperty(this._name)) | |
| 531 this._loaded = true; | |
| 532 } | 527 } |
| 533 | 528 |
| 534 Runtime.Module.prototype = { | 529 Runtime.Module.prototype = { |
| 535 /** | 530 /** |
| 536 * @return {string} | 531 * @return {string} |
| 537 */ | 532 */ |
| 538 name: function() | 533 name: function() |
| 539 { | 534 { |
| 540 return this._name; | 535 return this._name; |
| 541 }, | 536 }, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 552 Error.stackTraceLimit = oldStackTraceLimit; | 547 Error.stackTraceLimit = oldStackTraceLimit; |
| 553 return; | 548 return; |
| 554 } | 549 } |
| 555 | 550 |
| 556 this._isLoading = true; | 551 this._isLoading = true; |
| 557 var dependencies = this._descriptor.dependencies; | 552 var dependencies = this._descriptor.dependencies; |
| 558 for (var i = 0; dependencies && i < dependencies.length; ++i) | 553 for (var i = 0; dependencies && i < dependencies.length; ++i) |
| 559 this._manager.loadModule(dependencies[i]); | 554 this._manager.loadModule(dependencies[i]); |
| 560 if (this._descriptor.scripts) { | 555 if (this._descriptor.scripts) { |
| 561 if (Runtime.isReleaseMode()) { | 556 if (Runtime.isReleaseMode()) { |
| 562 loadScript(this._name + ".js"); | 557 // FIXME: This is a temp workaround to avoid core module loading
attempts in the release mode. |
| 558 // It should be removed when the new application loader is imple
mented. |
| 559 if (!this._manager._coreModules.hasOwnProperty(this._name)) |
| 560 loadScript(this._name + ".js"); |
| 563 } else { | 561 } else { |
| 564 var scripts = this._descriptor.scripts; | 562 var scripts = this._descriptor.scripts; |
| 565 for (var i = 0; i < scripts.length; ++i) | 563 for (var i = 0; i < scripts.length; ++i) |
| 566 loadScript(this._name + "/" + scripts[i]); | 564 loadScript(this._name + "/" + scripts[i]); |
| 567 } | 565 } |
| 568 } | 566 } |
| 569 this._isLoading = false; | 567 this._isLoading = false; |
| 570 this._loaded = true; | 568 this._loaded = true; |
| 571 } | 569 } |
| 572 } | 570 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 this._instance = new constructorFunction(); | 642 this._instance = new constructorFunction(); |
| 645 } | 643 } |
| 646 return this._instance; | 644 return this._instance; |
| 647 } | 645 } |
| 648 } | 646 } |
| 649 | 647 |
| 650 /** | 648 /** |
| 651 * @type {!Runtime} | 649 * @type {!Runtime} |
| 652 */ | 650 */ |
| 653 var runtime; | 651 var runtime; |
| OLD | NEW |