From fc970ff208bc827d9046849eca560f097c1844cf Mon Sep 17 00:00:00 2001 From: Yuta Imaya Date: Tue, 4 Dec 2012 17:58:36 +0900 Subject: [PATCH] for advanced optimizations --- action.js | 50 -- bitmap.js | 65 -- build.xml | 68 ++ canvas.js | 10 - closure-primitives/base.js | 1488 +++++++++++++++++++++++++++++++++++++ closure-primitives/depswriter.py | 202 +++++ closure-primitives/source.py | 114 +++ closure-primitives/source.pyc | Bin 0 -> 3350 bytes closure-primitives/treescan.py | 78 ++ closure-primitives/treescan.pyc | Bin 0 -> 1932 bytes console.js | 5 + dict.js | 14 - display.js | 38 - ibit.js | 168 ----- loader.js | 94 --- main.js | 45 -- memory.js | 14 - movieclip.js | 220 ------ shape.js | 21 - src/action.js | 58 ++ src/bitmap.js | 72 ++ src/canvas.js | 13 + src/dict.js | 21 + src/display.js | 45 ++ event.js => src/event.js | 14 +- src/ibit.js | 174 +++++ src/loader.js | 103 +++ src/main.js | 58 ++ src/memory.js | 21 + src/movieclip.js | 230 ++++++ src/shape.js | 30 + src/string.js | 69 ++ src/swf/cxform.js | 57 ++ src/swf/fillstyles.js | 57 ++ src/swf/gradient.js | 34 + src/swf/header.js | 23 + src/swf/linestyles.js | 33 + src/swf/matrix.js | 43 ++ src/swf/rect.js | 23 + src/swf/rgba.js | 30 + src/swf/shaperecords.js | 132 ++++ src/swf/tag.js | 52 ++ src/swf/tag/definebitsjpeg.js | 25 + src/swf/tag/defineshape.js | 32 + src/swf/tag/doaction.js | 19 + src/swf/tag/jpegtables.js | 19 + src/swf/tag/placeobject.js | 46 ++ src/swf/tag/setbackgroundcolor.js | 21 + src/swf/tag/showframe.js | 17 + string.js | 59 -- swf/cxform.js | 50 -- swf/fillstyles.js | 47 -- swf/gradient.js | 24 - swf/header.js | 19 - swf/linestyles.js | 25 - swf/matrix.js | 37 - swf/rect.js | 15 - swf/rgba.js | 21 - swf/shaperecords.js | 124 ---- swf/tag.js | 38 - swf/tag/definebitsjpeg.js | 20 - swf/tag/defineshape.js | 23 - swf/tag/doaction.js | 14 - swf/tag/jpegtables.js | 14 - swf/tag/placeobject.js | 39 - swf/tag/setbackgroundcolor.js | 17 - swf/tag/showframe.js | 12 - 67 files changed, 3522 insertions(+), 1341 deletions(-) delete mode 100644 action.js delete mode 100644 bitmap.js create mode 100644 build.xml delete mode 100644 canvas.js create mode 100644 closure-primitives/base.js create mode 100755 closure-primitives/depswriter.py create mode 100755 closure-primitives/source.py create mode 100644 closure-primitives/source.pyc create mode 100755 closure-primitives/treescan.py create mode 100644 closure-primitives/treescan.pyc create mode 100644 console.js delete mode 100644 dict.js delete mode 100644 display.js delete mode 100644 ibit.js delete mode 100644 loader.js delete mode 100644 main.js delete mode 100644 memory.js delete mode 100644 movieclip.js delete mode 100644 shape.js create mode 100644 src/action.js create mode 100644 src/bitmap.js create mode 100644 src/canvas.js create mode 100644 src/dict.js create mode 100644 src/display.js rename event.js => src/event.js (56%) create mode 100644 src/ibit.js create mode 100644 src/loader.js create mode 100644 src/main.js create mode 100644 src/memory.js create mode 100644 src/movieclip.js create mode 100644 src/shape.js create mode 100644 src/string.js create mode 100644 src/swf/cxform.js create mode 100644 src/swf/fillstyles.js create mode 100644 src/swf/gradient.js create mode 100644 src/swf/header.js create mode 100644 src/swf/linestyles.js create mode 100644 src/swf/matrix.js create mode 100644 src/swf/rect.js create mode 100644 src/swf/rgba.js create mode 100644 src/swf/shaperecords.js create mode 100644 src/swf/tag.js create mode 100644 src/swf/tag/definebitsjpeg.js create mode 100644 src/swf/tag/defineshape.js create mode 100644 src/swf/tag/doaction.js create mode 100644 src/swf/tag/jpegtables.js create mode 100644 src/swf/tag/placeobject.js create mode 100644 src/swf/tag/setbackgroundcolor.js create mode 100644 src/swf/tag/showframe.js delete mode 100644 string.js delete mode 100644 swf/cxform.js delete mode 100644 swf/fillstyles.js delete mode 100644 swf/gradient.js delete mode 100644 swf/header.js delete mode 100644 swf/linestyles.js delete mode 100644 swf/matrix.js delete mode 100644 swf/rect.js delete mode 100644 swf/rgba.js delete mode 100644 swf/shaperecords.js delete mode 100644 swf/tag.js delete mode 100644 swf/tag/definebitsjpeg.js delete mode 100644 swf/tag/defineshape.js delete mode 100644 swf/tag/doaction.js delete mode 100644 swf/tag/jpegtables.js delete mode 100644 swf/tag/placeobject.js delete mode 100644 swf/tag/setbackgroundcolor.js delete mode 100644 swf/tag/showframe.js diff --git a/action.js b/action.js deleted file mode 100644 index 78bc9cf..0000000 --- a/action.js +++ /dev/null @@ -1,50 +0,0 @@ -(function(global) { - var FlappAction= function() { - this.actionRecord = null; - }; - FlappAction.exec = function(tag, movieClip, rootMovieClip) { - console.debug("FlappAction.exec"); - var actionsBit = new FlappIBit(); - actionsBit.input(tag.actions); - var code = 0; - var stack = []; - while (code = actionsBit.ui8()) { - if (code < 0x80) { - switch (code) { - case 0x06: // Play - movieClip.play(); - break; - case 0x07: // Stop - movieClip.stop(); - break; - case 0x1d: // SetVariables - movieClip.setVariable(stack.pop(), stack.pop()); - break; - default: - console.debug("FlappActiom: not implemented yet. code=0x%02x", code); - break; - } - } else { - var actionLength = actionsBit.input(tag.actions); - var nextActionOffset = actionsBit.getBytePos() + actionLength; - switch (code) { - case 0x81: // GotoFrame - movieClip.gotoFrame(actionsBit.si16()); - break; - case 0x83: // GetURL - // - break; - case 0x8c: // GoToLabel - movieClip.gotoLabel(actionsBit.strN(actionLength)); - break; - //case 0x96: // Push - default: - console.debug("FlappActiom: not implemented yet. code=0x%02x", code); - break; - } - actionsBit.setPos(nextActionOffset, 0); - } - } - }; - global.FlappAction = FlappAction; -})(this); diff --git a/bitmap.js b/bitmap.js deleted file mode 100644 index 5aec7f1..0000000 --- a/bitmap.js +++ /dev/null @@ -1,65 +0,0 @@ -(function(global) { - var FlappBitmap = function() { - ; - }; - FlappBitmap.prototype = { - - }; - FlappBitmap.jpegChunkOffsets = function(jpegData) { - var offsetTable = {}; - var ibit = new FlappIBit(); - while (ibit.HasNext(2)) { - var marker = ibit.ui16be(); - var offset = ibit.getBytePos(); - switch (marker) { - case 0xFFD8: // SOI - case 0xFFD9: // EOI - break; - case 0xFFDA: // SOS + [RST] + EOI - length = ibit.len() - offset; - offsetTable[marker] = [offset, length] - break; - default: - length = ibit.ui16be() + 2; - offsetTable[marker] = [offset, length] - - break; - } - } - return offsetTable; - } - - FlappBitmap.toJpeg = function(swfJpeg, jpegTables) { - var offsetTable = FlappBitmap.jpegChunkOffsets(swfJpeg); - var hasDQT = (0xFFDB in offsetTable)?true:false; - if (hasDQT === false) { - var offsetTable2 = FlappBitmap.jpegChunkOffsets(jpegTables); - } - var jpegArray = [0xFF, 0xD8]; // SOI - // APP0, SOF0, DQT, DHT, SOS - var jpegOrder = [0xFFE0, 0xFFC0, 0xFFDB, 0xFFC4, 0xFFDA]; - for (var i = 0, l = jpegOrder; i < l ; i++) { - var marker = jpegOrder[i]; - var swfJpegOffset = (marker in offsetTable)?true:false; - if (swfJpegOffset) { - var entry = offsetTable[marker]; - } else { - var entry = offsetTable2[marker]; - } - var offset = entry[0]; - var enfoffset = offset + entry[1]; - for (j = offset; j < enfoffset ; j++) { - if (swfJpegOffset) { - jpegArray.join(swfJpeg[j]); - } else { - jpegArray.join(jpegTables[j]); - } - } - } - return FlappString.ArrayToString(jpegArray).join(''); - }; - FlappBitmap.toPng = function(lossless) { - ; - }; - global.FlappBitmap = FlappBitmap; -})(this); diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..c95c9c5 --- /dev/null +++ b/build.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/canvas.js b/canvas.js deleted file mode 100644 index fb23db2..0000000 --- a/canvas.js +++ /dev/null @@ -1,10 +0,0 @@ -(function(global) { - var FlappCanvas = function(canvas) { - this.canvas = canvas; - this.ctx = canvas.getContext('2d'); - }; - FlappCanvas.prototype = { - - } - global.FlappCanvas = FlappCanvas; -})(this); diff --git a/closure-primitives/base.js b/closure-primitives/base.js new file mode 100644 index 0000000..8793073 --- /dev/null +++ b/closure-primitives/base.js @@ -0,0 +1,1488 @@ +// Copyright 2006 The Closure Library Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS-IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @fileoverview Bootstrap for the Google JS Library (Closure). + * + * In uncompiled mode base.js will write out Closure's deps file, unless the + * global CLOSURE_NO_DEPS is set to true. This allows projects to + * include their own deps file(s) from different locations. + * + * + * @provideGoog + */ + + +/** + * @define {boolean} Overridden to true by the compiler when --closure_pass + * or --mark_as_compiled is specified. + */ +var COMPILED = false; + + +/** + * Base namespace for the Closure library. Checks to see goog is + * already defined in the current scope before assigning to prevent + * clobbering if base.js is loaded more than once. + * + * @const + */ +var goog = goog || {}; // Identifies this file as the Closure base. + + +/** + * Reference to the global context. In most cases this will be 'window'. + */ +goog.global = this; + + +/** + * @define {boolean} DEBUG is provided as a convenience so that debugging code + * that should not be included in a production js_binary can be easily stripped + * by specifying --define goog.DEBUG=false to the JSCompiler. For example, most + * toString() methods should be declared inside an "if (goog.DEBUG)" conditional + * because they are generally used for debugging purposes and it is difficult + * for the JSCompiler to statically determine whether they are used. + */ +goog.DEBUG = true; + + +/** + * @define {string} LOCALE defines the locale being used for compilation. It is + * used to select locale specific data to be compiled in js binary. BUILD rule + * can specify this value by "--define goog.LOCALE=" as JSCompiler + * option. + * + * Take into account that the locale code format is important. You should use + * the canonical Unicode format with hyphen as a delimiter. Language must be + * lowercase, Language Script - Capitalized, Region - UPPERCASE. + * There are few examples: pt-BR, en, en-US, sr-Latin-BO, zh-Hans-CN. + * + * See more info about locale codes here: + * http://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers + * + * For language codes you should use values defined by ISO 693-1. See it here + * http://www.w3.org/WAI/ER/IG/ert/iso639.htm. There is only one exception from + * this rule: the Hebrew language. For legacy reasons the old code (iw) should + * be used instead of the new code (he), see http://wiki/Main/IIISynonyms. + */ +goog.LOCALE = 'en'; // default to en + + +/** + * Creates object stubs for a namespace. The presence of one or more + * goog.provide() calls indicate that the file defines the given + * objects/namespaces. Build tools also scan for provide/require statements + * to discern dependencies, build dependency files (see deps.js), etc. + * @see goog.require + * @param {string} name Namespace provided by this file in the form + * "goog.package.part". + */ +goog.provide = function(name) { + if (!COMPILED) { + // Ensure that the same namespace isn't provided twice. This is intended + // to teach new developers that 'goog.provide' is effectively a variable + // declaration. And when JSCompiler transforms goog.provide into a real + // variable declaration, the compiled JS should work the same as the raw + // JS--even when the raw JS uses goog.provide incorrectly. + if (goog.isProvided_(name)) { + throw Error('Namespace "' + name + '" already declared.'); + } + delete goog.implicitNamespaces_[name]; + + var namespace = name; + while ((namespace = namespace.substring(0, namespace.lastIndexOf('.')))) { + if (goog.getObjectByName(namespace)) { + break; + } + goog.implicitNamespaces_[namespace] = true; + } + } + + goog.exportPath_(name); +}; + + +/** + * Marks that the current file should only be used for testing, and never for + * live code in production. + * @param {string=} opt_message Optional message to add to the error that's + * raised when used in production code. + */ +goog.setTestOnly = function(opt_message) { + if (COMPILED && !goog.DEBUG) { + opt_message = opt_message || ''; + throw Error('Importing test-only code into non-debug environment' + + opt_message ? ': ' + opt_message : '.'); + } +}; + + +if (!COMPILED) { + + /** + * Check if the given name has been goog.provided. This will return false for + * names that are available only as implicit namespaces. + * @param {string} name name of the object to look for. + * @return {boolean} Whether the name has been provided. + * @private + */ + goog.isProvided_ = function(name) { + return !goog.implicitNamespaces_[name] && !!goog.getObjectByName(name); + }; + + /** + * Namespaces implicitly defined by goog.provide. For example, + * goog.provide('goog.events.Event') implicitly declares + * that 'goog' and 'goog.events' must be namespaces. + * + * @type {Object} + * @private + */ + goog.implicitNamespaces_ = {}; +} + + +/** + * Builds an object structure for the provided namespace path, + * ensuring that names that already exist are not overwritten. For + * example: + * "a.b.c" -> a = {};a.b={};a.b.c={}; + * Used by goog.provide and goog.exportSymbol. + * @param {string} name name of the object that this file defines. + * @param {*=} opt_object the object to expose at the end of the path. + * @param {Object=} opt_objectToExportTo The object to add the path to; default + * is |goog.global|. + * @private + */ +goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { + var parts = name.split('.'); + var cur = opt_objectToExportTo || goog.global; + + // Internet Explorer exhibits strange behavior when throwing errors from + // methods externed in this manner. See the testExportSymbolExceptions in + // base_test.html for an example. + if (!(parts[0] in cur) && cur.execScript) { + cur.execScript('var ' + parts[0]); + } + + // Certain browsers cannot parse code in the form for((a in b); c;); + // This pattern is produced by the JSCompiler when it collapses the + // statement above into the conditional loop below. To prevent this from + // happening, use a for-loop and reserve the init logic as below. + + // Parentheses added to eliminate strict JS warning in Firefox. + for (var part; parts.length && (part = parts.shift());) { + if (!parts.length && goog.isDef(opt_object)) { + // last part and we have an object; use it + cur[part] = opt_object; + } else if (cur[part]) { + cur = cur[part]; + } else { + cur = cur[part] = {}; + } + } +}; + + +/** + * Returns an object based on its fully qualified external name. If you are + * using a compilation pass that renames property names beware that using this + * function will not find renamed properties. + * + * @param {string} name The fully qualified name. + * @param {Object=} opt_obj The object within which to look; default is + * |goog.global|. + * @return {?} The value (object or primitive) or, if not found, null. + */ +goog.getObjectByName = function(name, opt_obj) { + var parts = name.split('.'); + var cur = opt_obj || goog.global; + for (var part; part = parts.shift(); ) { + if (goog.isDefAndNotNull(cur[part])) { + cur = cur[part]; + } else { + return null; + } + } + return cur; +}; + + +/** + * Globalizes a whole namespace, such as goog or goog.lang. + * + * @param {Object} obj The namespace to globalize. + * @param {Object=} opt_global The object to add the properties to. + * @deprecated Properties may be explicitly exported to the global scope, but + * this should no longer be done in bulk. + */ +goog.globalize = function(obj, opt_global) { + var global = opt_global || goog.global; + for (var x in obj) { + global[x] = obj[x]; + } +}; + + +/** + * Adds a dependency from a file to the files it requires. + * @param {string} relPath The path to the js file. + * @param {Array} provides An array of strings with the names of the objects + * this file provides. + * @param {Array} requires An array of strings with the names of the objects + * this file requires. + */ +goog.addDependency = function(relPath, provides, requires) { + if (!COMPILED) { + var provide, require; + var path = relPath.replace(/\\/g, '/'); + var deps = goog.dependencies_; + for (var i = 0; provide = provides[i]; i++) { + deps.nameToPath[provide] = path; + if (!(path in deps.pathToNames)) { + deps.pathToNames[path] = {}; + } + deps.pathToNames[path][provide] = true; + } + for (var j = 0; require = requires[j]; j++) { + if (!(path in deps.requires)) { + deps.requires[path] = {}; + } + deps.requires[path][require] = true; + } + } +}; + + + + +// NOTE(nnaze): The debug DOM loader was included in base.js as an orignal +// way to do "debug-mode" development. The dependency system can sometimes +// be confusing, as can the debug DOM loader's asyncronous nature. +// +// With the DOM loader, a call to goog.require() is not blocking -- the +// script will not load until some point after the current script. If a +// namespace is needed at runtime, it needs to be defined in a previous +// script, or loaded via require() with its registered dependencies. +// User-defined namespaces may need their own deps file. See http://go/js_deps, +// http://go/genjsdeps, or, externally, DepsWriter. +// http://code.google.com/closure/library/docs/depswriter.html +// +// Because of legacy clients, the DOM loader can't be easily removed from +// base.js. Work is being done to make it disableable or replaceable for +// different environments (DOM-less JavaScript interpreters like Rhino or V8, +// for example). See bootstrap/ for more information. + + +/** + * @define {boolean} Whether to enable the debug loader. + * + * If enabled, a call to goog.require() will attempt to load the namespace by + * appending a script tag to the DOM (if the namespace has been registered). + * + * If disabled, goog.require() will simply assert that the namespace has been + * provided (and depend on the fact that some outside tool correctly ordered + * the script). + */ +goog.ENABLE_DEBUG_LOADER = true; + + +/** + * Implements a system for the dynamic resolution of dependencies + * that works in parallel with the BUILD system. Note that all calls + * to goog.require will be stripped by the JSCompiler when the + * --closure_pass option is used. + * @see goog.provide + * @param {string} name Namespace to include (as was given in goog.provide()) + * in the form "goog.package.part". + */ +goog.require = function(name) { + + // if the object already exists we do not need do do anything + // TODO(arv): If we start to support require based on file name this has + // to change + // TODO(arv): If we allow goog.foo.* this has to change + // TODO(arv): If we implement dynamic load after page load we should probably + // not remove this code for the compiled output + if (!COMPILED) { + if (goog.isProvided_(name)) { + return; + } + + if (goog.ENABLE_DEBUG_LOADER) { + var path = goog.getPathFromDeps_(name); + if (path) { + goog.included_[path] = true; + goog.writeScripts_(); + return; + } + } + + var errorMessage = 'goog.require could not find: ' + name; + if (goog.global.console) { + goog.global.console['error'](errorMessage); + } + + + throw Error(errorMessage); + + } +}; + + +/** + * Path for included scripts + * @type {string} + */ +goog.basePath = ''; + + +/** + * A hook for overriding the base path. + * @type {string|undefined} + */ +goog.global.CLOSURE_BASE_PATH; + + +/** + * Whether to write out Closure's deps file. By default, + * the deps are written. + * @type {boolean|undefined} + */ +goog.global.CLOSURE_NO_DEPS; + + +/** + * A function to import a single script. This is meant to be overridden when + * Closure is being run in non-HTML contexts, such as web workers. It's defined + * in the global scope so that it can be set before base.js is loaded, which + * allows deps.js to be imported properly. + * + * The function is passed the script source, which is a relative URI. It should + * return true if the script was imported, false otherwise. + */ +goog.global.CLOSURE_IMPORT_SCRIPT; + + +/** + * Null function used for default values of callbacks, etc. + * @return {void} Nothing. + */ +goog.nullFunction = function() {}; + + +/** + * The identity function. Returns its first argument. + * + * @param {*=} opt_returnValue The single value that will be returned. + * @param {...*} var_args Optional trailing arguments. These are ignored. + * @return {?} The first argument. We can't know the type -- just pass it along + * without type. + * @deprecated Use goog.functions.identity instead. + */ +goog.identityFunction = function(opt_returnValue, var_args) { + return opt_returnValue; +}; + + +/** + * When defining a class Foo with an abstract method bar(), you can do: + * + * Foo.prototype.bar = goog.abstractMethod + * + * Now if a subclass of Foo fails to override bar(), an error + * will be thrown when bar() is invoked. + * + * Note: This does not take the name of the function to override as + * an argument because that would make it more difficult to obfuscate + * our JavaScript code. + * + * @type {!Function} + * @throws {Error} when invoked to indicate the method should be + * overridden. + */ +goog.abstractMethod = function() { + throw Error('unimplemented abstract method'); +}; + + +/** + * Adds a {@code getInstance} static method that always return the same instance + * object. + * @param {!Function} ctor The constructor for the class to add the static + * method to. + */ +goog.addSingletonGetter = function(ctor) { + ctor.getInstance = function() { + if (ctor.instance_) { + return ctor.instance_; + } + if (goog.DEBUG) { + // NOTE: JSCompiler can't optimize away Array#push. + goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor; + } + return ctor.instance_ = new ctor; + }; +}; + + +/** + * All singleton classes that have been instantiated, for testing. Don't read + * it directly, use the {@code goog.testing.singleton} module. The compiler + * removes this variable if unused. + * @type {!Array.} + * @private + */ +goog.instantiatedSingletons_ = []; + + +if (!COMPILED && goog.ENABLE_DEBUG_LOADER) { + /** + * Object used to keep track of urls that have already been added. This + * record allows the prevention of circular dependencies. + * @type {Object} + * @private + */ + goog.included_ = {}; + + + /** + * This object is used to keep track of dependencies and other data that is + * used for loading scripts + * @private + * @type {Object} + */ + goog.dependencies_ = { + pathToNames: {}, // 1 to many + nameToPath: {}, // 1 to 1 + requires: {}, // 1 to many + // used when resolving dependencies to prevent us from + // visiting the file twice + visited: {}, + written: {} // used to keep track of script files we have written + }; + + + /** + * Tries to detect whether is in the context of an HTML document. + * @return {boolean} True if it looks like HTML document. + * @private + */ + goog.inHtmlDocument_ = function() { + var doc = goog.global.document; + return typeof doc != 'undefined' && + 'write' in doc; // XULDocument misses write. + }; + + + /** + * Tries to detect the base path of the base.js script that bootstraps Closure + * @private + */ + goog.findBasePath_ = function() { + if (goog.global.CLOSURE_BASE_PATH) { + goog.basePath = goog.global.CLOSURE_BASE_PATH; + return; + } else if (!goog.inHtmlDocument_()) { + return; + } + var doc = goog.global.document; + var scripts = doc.getElementsByTagName('script'); + // Search backwards since the current script is in almost all cases the one + // that has base.js. + for (var i = scripts.length - 1; i >= 0; --i) { + var src = scripts[i].src; + var qmark = src.lastIndexOf('?'); + var l = qmark == -1 ? src.length : qmark; + if (src.substr(l - 7, 7) == 'base.js') { + goog.basePath = src.substr(0, l - 7); + return; + } + } + }; + + + /** + * Imports a script if, and only if, that script hasn't already been imported. + * (Must be called at execution time) + * @param {string} src Script source. + * @private + */ + goog.importScript_ = function(src) { + var importScript = goog.global.CLOSURE_IMPORT_SCRIPT || + goog.writeScriptTag_; + if (!goog.dependencies_.written[src] && importScript(src)) { + goog.dependencies_.written[src] = true; + } + }; + + + /** + * The default implementation of the import function. Writes a script tag to + * import the script. + * + * @param {string} src The script source. + * @return {boolean} True if the script was imported, false otherwise. + * @private + */ + goog.writeScriptTag_ = function(src) { + if (goog.inHtmlDocument_()) { + var doc = goog.global.document; + doc.write( + '