Scriptable threadScope = global.unregisterScope();
Context cx = Context.getCurrentContext();  Object threadScope = cx.getThreadLocal("threadscope"); cx.removeThreadLocal("threadscope");
    private synchronized void evaluate (TypeInfo type, Resource code) {        Scriptable threadScope = global.unregisterScope();        String sourceName = code.getName();        Reader reader = null;        try {            // get the current context            Context cx = Context.getCurrentContext();            Scriptable op = type.objProto;            // do the update, evaluating the file            if (sourceName.endsWith(".js")) {                reader = new InputStreamReader(code.getInputStream());                cx.evaluateReader(op, reader, sourceName, 1, null);            } else if (sourceName.endsWith(".hac")) {                reader = new StringReader(HacHspConverter.convertHac(code));                cx.evaluateReader(op, reader, sourceName, 0, null);            } else if (sourceName.endsWith(".hsp")) {                reader = new StringReader(HacHspConverter.convertHsp(code));                cx.evaluateReader(op, reader, sourceName, 0, null);                reader = new StringReader(HacHspConverter.convertHspAsString(code));                cx.evaluateReader(op, reader, sourceName, 0, null);            }        } catch (Exception e) {            app.logError("Error parsing file " + sourceName,  e);            // mark prototype as broken            if (type.error == null) {                type.error = e.getMessage();                if (type.error == null || e instanceof EcmaError) {                    type.error = e.toString();                }                if ("global".equals(type.frameworkProto.getLowerCaseName())) {                    globalError = type.error;                }                wrappercache.clear();            }            // e.printStackTrace();        } finally {            if (reader != null) {                try {                    reader.close();                } catch (IOException ignore) {                    // shouldn't happen                }            }            if (threadScope != null) {                global.registerScope(threadScope);            }        }    }