當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.compileReader方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.Context.compileReader方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.compileReader方法的具體用法?Java Context.compileReader怎麽用?Java Context.compileReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.Context的用法示例。


在下文中一共展示了Context.compileReader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testJsApi

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
public void testJsApi() throws Exception {
    Context cx = Context.enter();
    cx.setOptimizationLevel(-1);
    Script script = cx.compileReader(new InputStreamReader(
            Bug482203.class.getResourceAsStream("conttest.js")), 
            "", 1, null);
    Scriptable scope = cx.initStandardObjects();
    script.exec(cx, scope);
    for(;;)
    {
        Object cont = ScriptableObject.getProperty(scope, "c");
        if(cont == null)
        {
            break;
        }
        ((Callable)cont).call(cx, scope, scope, new Object[] { null });
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:19,代碼來源:Bug482203.java

示例2: testJavaApi

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
public void testJavaApi() throws Exception {
    Context cx = Context.enter();
    try {
     cx.setOptimizationLevel(-1);
     Script script = cx.compileReader(new InputStreamReader(
             Bug482203.class.getResourceAsStream("conttest.js")), 
             "", 1, null);
     Scriptable scope = cx.initStandardObjects();
     cx.executeScriptWithContinuations(script, scope);
     for(;;)
     {
         Object cont = ScriptableObject.getProperty(scope, "c");
         if(cont == null)
         {
             break;
         }
         cx.resumeContinuation(cont, scope, null);
     }
    } finally {
    	Context.exit();
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:23,代碼來源:Bug482203.java

示例3: getModuleScript

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
public ModuleScript getModuleScript(Context cx, String moduleId,
        URI moduleUri, URI baseUri, Scriptable paths) throws Exception
{
    final CachedModuleScript cachedModule1 = getLoadedModule(moduleId);
    final Object validator1 = getValidator(cachedModule1);
    final ModuleSource moduleSource = (moduleUri == null)
            ? moduleSourceProvider.loadSource(moduleId, paths, validator1)
            : moduleSourceProvider.loadSource(moduleUri, baseUri, validator1);
    if(moduleSource == ModuleSourceProvider.NOT_MODIFIED) {
        return cachedModule1.getModule();
    }
    if(moduleSource == null) {
        return null;
    }
    final Reader reader = moduleSource.getReader();
    try {
        final int idHash = moduleId.hashCode();
        synchronized(loadLocks[(idHash >>> loadLockShift) & loadLockMask]) {
            final CachedModuleScript cachedModule2 = getLoadedModule(moduleId);
            if(cachedModule2 != null) {
                if(!equal(validator1, getValidator(cachedModule2))) {
                    return cachedModule2.getModule();
                }
            }
            final URI sourceUri = moduleSource.getUri();
            final ModuleScript moduleScript = new ModuleScript(
                    cx.compileReader(reader, sourceUri.toString(), 1,
                            moduleSource.getSecurityDomain()),
                    sourceUri, moduleSource.getBase());
            putLoadedModule(moduleId, moduleScript,
                    moduleSource.getValidator());
            return moduleScript;
        }
    }
    finally {
        reader.close();
    }
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:39,代碼來源:CachingModuleScriptProviderBase.java

示例4: getModuleScript

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
public ModuleScript getModuleScript(Context cx, String moduleId, 
        URI moduleUri, Scriptable paths) throws Exception
{
    final CachedModuleScript cachedModule1 = getLoadedModule(moduleId);
    final Object validator1 = getValidator(cachedModule1);
    final ModuleSource moduleSource = (moduleUri == null)
            ? moduleSourceProvider.loadSource(moduleId, paths, validator1)
            : moduleSourceProvider.loadSource(moduleUri, validator1);
    if(moduleSource == ModuleSourceProvider.NOT_MODIFIED) {
        return cachedModule1.getModule();
    }
    if(moduleSource == null) {
        return null;
    }
    final Reader reader = moduleSource.getReader();
    try {
        final int idHash = moduleId.hashCode();
        synchronized(loadLocks[(idHash >>> loadLockShift) & loadLockMask]) {
            final CachedModuleScript cachedModule2 = getLoadedModule(moduleId);
            if(cachedModule2 != null) {
                if(!equal(validator1, getValidator(cachedModule2))) {
                    return cachedModule2.getModule();
                }
            }
            final URI sourceUri = moduleSource.getUri();
            final ModuleScript moduleScript = new ModuleScript(
                    cx.compileReader(reader, sourceUri.toString(), 1,
                            moduleSource.getSecurityDomain()),
                    sourceUri, moduleSource.getBase());
            putLoadedModule(moduleId, moduleScript,
                    moduleSource.getValidator());
            return moduleScript;
        }
    }
    finally {
        reader.close();
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:39,代碼來源:CachingModuleScriptProviderBase.java


注:本文中的org.mozilla.javascript.Context.compileReader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。