(ExecutionContext context, Object self, Object... args)
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public Object call(ExecutionContext context, Object self, Object... args) { |
| 31 | boolean direct = false; |
| 32 | if (context.getFunctionReference() != null) { |
| 33 | if (context.getFunctionReference() instanceof Reference) { |
| 34 | Reference ref = (Reference) context.getFunctionReference(); |
| 35 | if (ref.getBase() instanceof EnvironmentRecord) { |
| 36 | direct = ref.getReferencedName().equals("eval"); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | Object code = args[0]; |
| 41 | if (code instanceof String) { |
| 42 | try { |
| 43 | Runner runner = context.getRuntime().newRunner(); |
| 44 | final ExecutionContext parent = context.getParent(); |
| 45 | parent.inEval(true); |
| 46 | Object result = runner.withContext(parent) |
| 47 | .forceStrict(parent.isStrict() && direct) |
| 48 | .directEval(direct) |
| 49 | .withSource((String) code) |
| 50 | .evaluate(); |
| 51 | if (result == null) { |
| 52 | return Types.UNDEFINED; |
| 53 | } |
| 54 | return result; |
| 55 | } catch (LexerException e) { |
| 56 | throw new ThrowException(context, context.createSyntaxError(e.getMessage())); |
| 57 | } catch (ParserException e) { |
| 58 | throw new ThrowException(context, context.createSyntaxError(e.getMessage())); |
| 59 | } |
| 60 | } else { |
| 61 | return code; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public void setFileName() { |
nothing calls this directly
no test coverage detected