MCPcopy Create free account
hub / github.com/dynjs/dynjs / call

Method call

src/main/java/org/dynjs/runtime/builtins/Eval.java:29–63  ·  view source on GitHub ↗
(ExecutionContext context, Object self, Object... args)

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 15

getBaseMethod · 0.95
getReferencedNameMethod · 0.95
inEvalMethod · 0.95
withContextMethod · 0.95
isStrictMethod · 0.95
getFunctionReferenceMethod · 0.80
newRunnerMethod · 0.80
directEvalMethod · 0.80
evaluateMethod · 0.65
createSyntaxErrorMethod · 0.65
getRuntimeMethod · 0.45
getParentMethod · 0.45

Tested by

no test coverage detected