Java Javascript Mozilla Library runWithOptimizationLevel(final ContextAction action, final int optimizationLevel)

Here you can find the source of runWithOptimizationLevel(final ContextAction action, final int optimizationLevel)

Description

Runs the provided action at the given optimization level

License

Apache License

Declaration

public static void runWithOptimizationLevel(final ContextAction action, final int optimizationLevel) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.ContextFactory;

public class Main {
    /**/*from w w w. j av a  2 s .  co  m*/
     * Runs the provided action at the given optimization level
     */
    public static void runWithOptimizationLevel(final ContextAction action, final int optimizationLevel) {
        runWithOptimizationLevel(new ContextFactory(), action, optimizationLevel);
    }

    /**
     * Runs the provided action at the given optimization level
     */
    public static void runWithOptimizationLevel(final ContextFactory contextFactory, final ContextAction action,
            final int optimizationLevel) {
        final Context cx = contextFactory.enterContext();
        try {
            cx.setOptimizationLevel(optimizationLevel);
            action.run(cx);
        } finally {
            Context.exit();
        }
    }
}

Related

  1. parentOfAnyTypes(AstNode node, Set types, boolean isStrict)
  2. parentOfType(AstNode node, Class type)
  3. prototypeCast(Scriptable s, Class type)
  4. removeLinkFromXhtml(Object xhtml, String link)
  5. runWithAllOptimizationLevels(final ContextAction action)
  6. scriptableObjectToString(Object scriptObject)
  7. stringToNumber(CharSequence string)
  8. stringValue(String name, Scriptable scope)
  9. toInt(Object obj, int defaultValue)