| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 this._cachedTypeClasses = {}; | 109 this._cachedTypeClasses = {}; |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * @type {!Object.<string, !Runtime.ModuleDescriptor>} | 112 * @type {!Object.<string, !Runtime.ModuleDescriptor>} |
| 113 */ | 113 */ |
| 114 this._descriptorsMap = {}; | 114 this._descriptorsMap = {}; |
| 115 for (var i = 0; i < descriptors.length; ++i) | 115 for (var i = 0; i < descriptors.length; ++i) |
| 116 this._descriptorsMap[descriptors[i]["name"]] = descriptors[i]; | 116 this._descriptorsMap[descriptors[i]["name"]] = descriptors[i]; |
| 117 } | 117 } |
| 118 | 118 |
| 119 /** | |
| 120 * @param {string} moduleName | |
| 121 * @return {!Worker} | |
| 122 */ | |
| 123 Runtime.startWorker = function(moduleName) | |
| 124 { | |
| 125 return new Worker(moduleName + "/_module.js"); | |
| 126 } | |
| 127 | |
| 128 Runtime.prototype = { | 119 Runtime.prototype = { |
| 129 /** | 120 /** |
| 130 * @param {!Array.<string>} configuration | 121 * @param {!Array.<string>} configuration |
| 131 */ | 122 */ |
| 132 registerModules: function(configuration) | 123 registerModules: function(configuration) |
| 133 { | 124 { |
| 134 for (var i = 0; i < configuration.length; ++i) | 125 for (var i = 0; i < configuration.length; ++i) |
| 135 this.registerModule(configuration[i]); | 126 this.registerModule(configuration[i]); |
| 136 }, | 127 }, |
| 137 | 128 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 Error.stackTraceLimit = 50; | 427 Error.stackTraceLimit = 50; |
| 437 console.assert(false, "Module " + this._name + " is loaded from itse
lf: " + new Error().stack); | 428 console.assert(false, "Module " + this._name + " is loaded from itse
lf: " + new Error().stack); |
| 438 Error.stackTraceLimit = oldStackTraceLimit; | 429 Error.stackTraceLimit = oldStackTraceLimit; |
| 439 return; | 430 return; |
| 440 } | 431 } |
| 441 | 432 |
| 442 this._isLoading = true; | 433 this._isLoading = true; |
| 443 var dependencies = this._descriptor.dependencies; | 434 var dependencies = this._descriptor.dependencies; |
| 444 for (var i = 0; dependencies && i < dependencies.length; ++i) | 435 for (var i = 0; dependencies && i < dependencies.length; ++i) |
| 445 this._manager.loadModule(dependencies[i]); | 436 this._manager.loadModule(dependencies[i]); |
| 446 if (this._descriptor.scripts) | 437 var scripts = this._descriptor.scripts; |
| 447 loadScript(this._name + "/_module.js"); | 438 for (var i = 0; scripts && i < scripts.length; ++i) |
| 439 loadScript(this._name + "/" + scripts[i]); |
| 448 this._isLoading = false; | 440 this._isLoading = false; |
| 449 this._loaded = true; | 441 this._loaded = true; |
| 450 } | 442 } |
| 451 } | 443 } |
| 452 | 444 |
| 453 /** | 445 /** |
| 454 * @constructor | 446 * @constructor |
| 455 * @param {!Runtime.Module} module | 447 * @param {!Runtime.Module} module |
| 456 * @param {!Runtime.ExtensionDescriptor} descriptor | 448 * @param {!Runtime.ExtensionDescriptor} descriptor |
| 457 */ | 449 */ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 this._instance = new constructorFunction(); | 515 this._instance = new constructorFunction(); |
| 524 } | 516 } |
| 525 return this._instance; | 517 return this._instance; |
| 526 } | 518 } |
| 527 } | 519 } |
| 528 | 520 |
| 529 /** | 521 /** |
| 530 * @type {!Runtime} | 522 * @type {!Runtime} |
| 531 */ | 523 */ |
| 532 var runtime; | 524 var runtime; |
| OLD | NEW |