/*
Only ScriptX related ProgIds are supported.
964054
function (sProgId) {
            var a = new Object();
            var b = new Object();
            var c = new Object();
            var d = new Object();

            module.factory.GetComponentVersion(sProgId, a, b, c, d);
            return a[0] + "." + b[0] + "." + c[0] + "." + d[0];
        }
996275
private static void setScriptVarImpl(String scriptName, String key, String value) {	
		validateKey(key);
		
		Map<String, String> scVars = scriptVars
				.computeIfAbsent(scriptName, k -> Collections.synchronizedMap(new HashMap<String, String>()));
		
		if (value == null) {
			scVars.remove(key);
		} else {
			validateValueLength(value);
			if (scVars.size() > MAX_SCRIPT_VARS) {
				throw new IllegalArgumentException("Maximum number of script variables reached: " + MAX_SCRIPT_VARS);
			}
			scVars.put(key, value);
		}
	}
577006
private Object getScriptResult(String script, ScriptEngine engine) throws ScriptException {
        String scriptToExecute = script.substring(script.indexOf(":") + 1);
        return engine.eval(scriptToExecute);
    }
1154943
protected final void registStaticScript(Class<? extends T> scriptClass)
	{
		try {
			boolean isAbstractOrInterface = Modifier.isAbstract(scriptClass.getModifiers())
					|| Modifier.isInterface(scriptClass.getModifiers());// 是否是抽象类
			if(isAbstractOrInterface)
			{
				throw new UnsupportedOperationException(scriptClass +"can not newInstance");
			}
			T script = scriptClass.newInstance();
			int code=script.getMessageCode();
			Class<? extends T> old=staticCodeMap.get(code);
			staticCodeMap.put(code,scriptClass);
			if(old==null)
			{
				_log.info("regist Static codeScript,code="+code+"(0x"+Integer.toHexString(code)+"),class="+scriptClass);
			}else
			{
				_log.info("regist Static codeScript,code="+code+"(0x"+Integer.toHexString(code)+"),class="+scriptClass+",Override script="+old);
			}
		} catch (Exception e) {
			_log.error(e.getMessage(),e);
		}
	}
623564
public void setScriptSig(Script scriptSig) {
        this.scriptSig = new WeakReference<>(checkNotNull(scriptSig));
        // TODO: This should all be cleaned up so we have a consistent internal representation.
        setScriptBytes(scriptSig.getProgram());
    }
865906
private static String addScriptDirectives(Element scriptElement) throws IOException, DocumentTemplateException {
    String scriptReplacement = "";

    List scriptParts = parseScriptParts(scriptElement.getValue());
    for (int index = 0; index < scriptParts.size(); index++) {
      ScriptPart scriptPart = (ScriptPart) scriptParts.get(index);
      if (scriptPart.getLocation() == null) {
        scriptReplacement = scriptPart.getText();
      }
      else {
        Element enclosingElement = findEnclosingElement(scriptElement, scriptPart.getLocation());
        if (scriptPart.isTagAttribute()) {
          String[] nameValue = scriptPart.getText().split("=", 2);
          if (nameValue.length != 2) {
            throw new DocumentTemplateException("script error: # attribute name=value not found");
          }

          String attributeNamespace = enclosingElement.getNamespaceURI();
          if (nameValue[0].contains(":")) {
            String prefix = nameValue[0].split(":")[0];
            if (!prefix.equals(enclosingElement.getNamespacePrefix())) {
              attributeNamespace = XPATH_CONTEXT.lookup(prefix);
              if (attributeNamespace == null) {
                throw new DocumentTemplateException("unsupported attribute namespace: " + prefix);
              }
            }
          }

          enclosingElement.addAttribute(new Attribute(nameValue[0], attributeNamespace, nameValue[1]));
        }
        else {
          ParentNode parent = enclosingElement.getParent();
          int parentIndex = parent.indexOf(enclosingElement);
          if (scriptPart.afterEndTag()) {
            parentIndex++;
          }
          parent.insertChild(newNode(scriptPart.getText()), parentIndex);
        }
      }
    }

    return scriptReplacement;
  }
884939
private static Object jsConstructor(Context cx, Scriptable scope,
                                        Object[] args)
    {
        if (args.length == 0)
            return new NativeArray(0);

        // Only use 1 arg as first element for version 1.2; for
        // any other version (including 1.3) follow ECMA and use it as
        // a length.
        if (cx.getLanguageVersion() == Context.VERSION_1_2) {
            return new NativeArray(args);
        }
        Object arg0 = args[0];
        if (args.length > 1 || !(arg0 instanceof Number)) {
            return new NativeArray(args);
        }
        long len = ScriptRuntime.toUint32(arg0);
        if (len != ((Number)arg0).doubleValue()) {
            String msg = ScriptRuntime.getMessage0("msg.arraylength.bad");
            throw ScriptRuntime.constructError("RangeError", msg);
        }
        return new NativeArray(len);
    }
1335651
private void RunScript(InteractiveObject interactiveObject, String functionName, Object[] parameters) {
        boolean complete = false;
        if ( V8JavaScriptEngine) {
            GVRJavascriptV8File gvrJavascriptV8File = interactiveObject.getScriptObject().getGVRJavascriptV8File();
            String paramString = "var params =[";
            for (int i = 0; i < parameters.length; i++ ) {
                paramString += (parameters[i] + ", ");
            }
            paramString = paramString.substring(0, (paramString.length()-2)) + "];";

            final GVRJavascriptV8File gvrJavascriptV8FileFinal = gvrJavascriptV8File;
            final InteractiveObject interactiveObjectFinal = interactiveObject;
            final String functionNameFinal = functionName;
            final Object[] parametersFinal = parameters;
            final String paramStringFinal = paramString;
            gvrContext.runOnGlThread(new Runnable() {
                @Override
                public void run() {
                    RunScriptThread (gvrJavascriptV8FileFinal, interactiveObjectFinal, functionNameFinal, parametersFinal, paramStringFinal);
                }
            });
        }  // end V8JavaScriptEngine
        else {
            // Mozilla Rhino engine
            GVRJavascriptScriptFile gvrJavascriptFile = interactiveObject.getScriptObject().getGVRJavascriptScriptFile();

            complete = gvrJavascriptFile.invokeFunction(functionName, parameters);
            if (complete) {
                // The JavaScript (JS) ran.  Now get the return
                // values (saved as X3D data types such as SFColor)
                //  stored in 'localBindings'.
                //  Then call SetResultsFromScript() to set the GearVR values
                Bindings localBindings = gvrJavascriptFile.getLocalBindings();
                SetResultsFromScript(interactiveObject, localBindings);
            } else {
                Log.e(TAG, "Error in SCRIPT node '" +  interactiveObject.getScriptObject().getName() +
                        "' running Rhino Engine JavaScript function '" + functionName + "'");
            }
        }
    }
590998
function copyScript (script) {
    fs.copySync(path.join(__dirname, script), path.join(appScriptsPath, script))
  }
421666
public static CompiledScript compile(String script) throws ScriptRuntimeException {
		try {
			return compile(getJavaScriptEngine(), script);
		} catch (ScriptException e) {
			throw new ScriptRuntimeException(e);
		}
	}
89661
@Override
	public CompiledScript compile(String script) throws ScriptException {
		return ((Compilable) engine).compile(script);
	}
906302
function getSoleInlineScript(eligibleScripts) {
  var i, len,
      script = null;
  eligibleScripts = eligibleScripts || scripts;
  for (i = 0, len = eligibleScripts.length; i < len; i++) {
    if (!eligibleScripts[i].hasAttribute("src")) {
      if (script) {
        script = null;
        break;
      }
      script = eligibleScripts[i];
    }
  }
  return script;
}
562172
function getInlineScriptFromCallerSource(callerFnSource, eligibleScripts) {
  var i, inlineScriptText,
      script = null,
      callerSourceText = normalizeWhitespace(callerFnSource);

  eligibleScripts = eligibleScripts || scripts;

  if (callerFnSource && callerSourceText) {
    for (i = eligibleScripts.length; i--; ) {
      // Only look at inline scripts
      if (!eligibleScripts[i].hasAttribute("src")) {
        inlineScriptText = normalizeWhitespace(eligibleScripts[i].text);
        if (inlineScriptText.indexOf(callerSourceText) !== -1) {
          // If more than one match is found, don't return any
          if (script) {
            script = null;
            break;
          }
          script = eligibleScripts[i];
        }
      }
    }
  }

  return script;
}
724883
public static void executeScriptResources( File scriptsDir ) throws IOException {

		if( scriptsDir.isDirectory()) {
			List<File> scriptFiles = Utils.listAllFiles( scriptsDir );
			Logger logger = Logger.getLogger( AgentUtils.class.getName());

			for( File script : scriptFiles) {
				if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) {
					script.setExecutable( true );
					String[] command = { script.getAbsolutePath()};
					try {
						ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null );

					} catch( InterruptedException e ) {
						Utils.logException( logger, e );
					}
				}
			}
		}
	}
1061420
public static final int getScript(int codepoint){
        if (codepoint >= UCharacter.MIN_VALUE & codepoint <= UCharacter.MAX_VALUE) {
            int scriptX=UCharacterProperty.INSTANCE.getAdditional(codepoint, 0)&UCharacterProperty.SCRIPT_X_MASK;
            if(scriptX<UCharacterProperty.SCRIPT_X_WITH_COMMON) {
                return scriptX;
            } else if(scriptX<UCharacterProperty.SCRIPT_X_WITH_INHERITED) {
                return UScript.COMMON;
            } else if(scriptX<UCharacterProperty.SCRIPT_X_WITH_OTHER) {
                return UScript.INHERITED;
            } else {
                return UCharacterProperty.INSTANCE.m_scriptExtensions_[scriptX&UCharacterProperty.SCRIPT_MASK_];
            }
        }else{
            throw new IllegalArgumentException(Integer.toString(codepoint));
        }
    }
180905
function genModuleDeps(scriptPath) {
  var provideMap = new ProvideMap_();
  var requireMap = new RequireMap_();
  scanFiles([scriptPath], provideMap, requireMap);
  var dumpValues = function(map) {
    var results = [];
    map.forEach(function(value, key) {
      results = results.concat(value);
    });
    return results;
  };

  var relativePath = pathMod.join('../..', scriptPath);
  if (osMod.platform().indexOf('win') != -1) {
    relativePath = relativePath.replace(/\\/g, '\\\\');
  }

  var provide = provideMap.getAllProvides();
  var require = requireMap.getAllRequires();
  return 'goog.addDependency("' + relativePath + '", ' +
      JSON.stringify(dumpValues(provide)) + ', ' +
      JSON.stringify(dumpValues(require)) + ', true);';
}
558000
function supportsEventPageXY() {
    if (!document.createEvent) {
      return false;
    }
    var ev = document.createEvent('MouseEvent');
    return ev != null && 'pageX' in ev;
  }