protected Object evaluate ( String script , String scriptName ) { try { Context curCtx = Context . getCurrentContext ( ) ; curCtx . setLanguageVersion ( Context . VERSION_1_8 ) ; return curCtx . evaluateString ( programScope , script , scriptName , 1 , null ) ; } catch ( EcmaError rerr ) { throw new BPjsCodeEvaluationException ( rerr ) ; } catch ( WrappedException wrapped ) { try { throw wrapped . getCause ( ) ; } catch ( BPjsException be ) { throw be ; } catch ( IllegalStateException ise ) { String msg = ise . getMessage ( ) ; if ( msg . contains ( "Cannot capture continuation" ) && msg . contains ( "executeScriptWithContinuations or callFunctionWithContinuations" ) ) { throw new BPjsCodeEvaluationException ( "bp.sync called outside of a b-thread" ) ; } else { throw ise ; } } catch ( Throwable generalException ) { throw new BPjsRuntimeException ( "(Wrapped) Exception evaluating BProgram code: " + generalException . getMessage ( ) , generalException ) ; } } catch ( EvaluatorException evalExp ) { throw new BPjsCodeEvaluationException ( evalExp ) ; } catch ( Exception exp ) { throw new BPjsRuntimeException ( "Error evaluating BProgram code: " + exp . getMessage ( ) , exp ) ; } }
Runs the passed code in the passed scope .