public static ScriptNode parseVariables( Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain ) { // Interpreter compiler = new Interpreter(); CompilerEnvirons evn = new CompilerEnvirons(); // evn.setLanguageVersion(Context.VERSION_1_5); evn.setOptimizationLevel( -1 ); evn.setGeneratingSource( true ); evn.setGenerateDebugInfo( true ); ErrorReporter errorReporter = new ToolErrorReporter( false ); Parser p = new Parser( evn, errorReporter ); ScriptNode tree = p.parse( source, "", 0 ); // IOException new NodeTransformer().transform( tree ); // Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null); return tree; } }
public static ScriptNode parseVariables( Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain ) { // Interpreter compiler = new Interpreter(); CompilerEnvirons evn = new CompilerEnvirons(); // evn.setLanguageVersion(Context.VERSION_1_5); evn.setOptimizationLevel( -1 ); evn.setGeneratingSource( true ); evn.setGenerateDebugInfo( true ); ErrorReporter errorReporter = new ToolErrorReporter( false ); Parser p = new Parser( evn, errorReporter ); ScriptNode tree = p.parse( source, "", 0 ); // IOException new NodeTransformer().transform( tree ); // Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null); return tree; } }
public Main() { reporter = new ToolErrorReporter(true); compilerEnv = new CompilerEnvirons(); compilerEnv.setErrorReporter(reporter); compiler = new ClassCompiler(compilerEnv); }
public Main() { reporter = new ToolErrorReporter(true); compilerEnv = new CompilerEnvirons(); compilerEnv.setErrorReporter(reporter); compiler = new ClassCompiler(compilerEnv); }
/** * Initialize the context. */ private ScriptableObject createContext(final ScriptableObject initialScope) { final Context context = getContext(); context.setOptimizationLevel(-1); // TODO redirect errors from System.err to LOG.error() context.setErrorReporter(new ToolErrorReporter(false)); context.setLanguageVersion(Context.VERSION_1_8); InputStream script = null; final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope); try { script = getClass().getResourceAsStream("commons.js"); context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null); } catch (final IOException e) { throw new RuntimeException("Problem while evaluationg commons script.", e); } finally { IOUtils.closeQuietly(script); } return scriptCommon; }
/** * @throws Exception Likely if YUI is present, and not ShrinkSafe */ public ShrinkSafeCompressor() throws Exception { // This should fail if ShrinkSafe is not in classpath try { global = Main.getGlobal(); ToolErrorReporter errorReporter = new ToolErrorReporter(false, global.getErr()); Main.shellContextFactory.setErrorReporter(errorReporter); // Do a trial compression to check compressJavaScript(""); } catch (NoClassDefFoundError ex) { throw new InstantiationException("Could not setup ShrinkSafeCompressor because a class is missing, assuming shrinksafe.jar and js.jar are not in the classpath."); } catch (Exception ex) { Loggers.STARTUP.error("ShrinkSafeCompressor startup", ex); throw new InstantiationException("Could not setup ShrinkSafeCompressor, assuming shrinksafe.jar and js.jar are not in the classpath. Exception caught was " + ex); } }
/** * Initialize the context. */ private ScriptableObject createContext(final ScriptableObject initialScope) { final Context context = getContext(); context.setOptimizationLevel(-1); // TODO redirect errors from System.err to LOG.error() context.setErrorReporter(new ToolErrorReporter(false)); context.setLanguageVersion(Context.VERSION_1_8); InputStream script = null; final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope); try { script = new AutoCloseInputStream(getClass().getResourceAsStream("commons.js")); context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null); } catch (final IOException e) { throw new RuntimeException("Problem while evaluationg commons script.", e); } finally { IOUtils.closeQuietly(script); } return scriptCommon; }
protected Context enterContext() { Context context = Context.enter(); context.setOptimizationLevel(-1); // TODO redirect errors from System.err to LOG.error() context.setErrorReporter(new ToolErrorReporter(false)); context.setLanguageVersion(Context.VERSION_1_8); return context; }
String resultString = ""; ErrorReporter savedErrorReporter = cx.getErrorReporter(); cx.setErrorReporter(new ToolErrorReporter(false, this.getErr())); try { testCount++;
String resultString = ""; ErrorReporter savedErrorReporter = cx.getErrorReporter(); cx.setErrorReporter(new ToolErrorReporter(false, this.getErr())); try { testCount++;
String resultString = ""; ErrorReporter savedErrorReporter = cx.getErrorReporter(); cx.setErrorReporter(new ToolErrorReporter(false, this.getErr())); try { testCount++;
/** * Execute the given arguments, but don't System.exit at the end. */ public static int exec(String origArgs[]) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); String[] args = processOptions(origArgs); if (processStdin) { fileList.add(null); } if (!global.initialized) { global.init(shellContextFactory); } IProxy iproxy = new IProxy(IProxy.PROCESS_FILES); iproxy.args = args; shellContextFactory.call(iproxy); return exitCode; }
/** * Execute the given arguments, but don't System.exit at the end. */ public static int exec(String origArgs[]) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); String[] args = processOptions(origArgs); if (processStdin) fileList.add(null); if (!global.initialized) { global.init(shellContextFactory); } IProxy iproxy = new IProxy(IProxy.PROCESS_FILES); iproxy.args = args; shellContextFactory.call(iproxy); return exitCode; }
/** * Execute the given arguments, but don't System.exit at the end. */ public static int exec(String origArgs[]) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); String[] args = processOptions(origArgs); if (processStdin) { fileList.add(null); } if (!global.initialized) { global.init(shellContextFactory); } IProxy iproxy = new IProxy(IProxy.PROCESS_FILES); iproxy.args = args; shellContextFactory.call(iproxy); return exitCode; }
public static void main(String[] args) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); IProxy iproxy = new IProxy(IProxy.PROCESS_FILES, processOptions(args)); global.init(shellContextFactory); shellContextFactory.call(iproxy); }
private int exec(String[] args) { R = new ToolErrorReporter(true, System.err); int arg_count = process_options(args); if (arg_count == 0) { option_error(ToolErrorReporter.getMessage( "msg.idswitch.no_file_argument")); return -1; } if (arg_count > 1) { option_error(ToolErrorReporter.getMessage( "msg.idswitch.too_many_arguments")); return -1; } P = new CodePrinter(); P.setIndentStep(4); P.setIndentTabSize(0); try { process_file(args[0]); } catch (IOException ex) { print_error(ToolErrorReporter.getMessage( "msg.idswitch.io_error", ex.toString())); return -1; } catch (EvaluatorException ex) { return -1; } return 0; }
private int exec(String[] args) { R = new ToolErrorReporter(true, System.err); int arg_count = process_options(args); if (arg_count == 0) { option_error(ToolErrorReporter.getMessage( "msg.idswitch.no_file_argument")); return -1; } if (arg_count > 1) { option_error(ToolErrorReporter.getMessage( "msg.idswitch.too_many_arguments")); return -1; } P = new CodePrinter(); P.setIndentStep(4); P.setIndentTabSize(0); try { process_file(args[0]); } catch (IOException ex) { print_error(ToolErrorReporter.getMessage( "msg.idswitch.io_error", ex.toString())); return -1; } catch (EvaluatorException ex) { return -1; } return 0; }