Skip to content

Commit

Permalink
improved code from prev commit #2329
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Aug 9, 2023
1 parent 81b7fee commit ac8c659
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ public abstract class JsFunction implements ProxyObject {

public static final Object LOCK = new Object();

protected final Value value;
protected final CharSequence source;
protected final Value value;

protected JsFunction(Value v) {
this.value = v;
source = "(" + value.getSourceLocation().getCharacters() + ")";
this.value = v;
}

public static ProxyExecutable wrap(Value value) {
Expand Down Expand Up @@ -85,14 +83,16 @@ public boolean removeMember(String key) {
protected static class Executable extends JsFunction implements ProxyExecutable {

private final boolean lock;
private final String source;

protected Executable(Value value) {
this(value, false);
}

protected Executable(Value value, boolean lock) {
super(value);
super(value);
this.lock = lock;
source = "(" + value.getSourceLocation().getCharacters() + ")";
}

@Override
Expand All @@ -111,7 +111,7 @@ public Object execute(Value... args) {
if (je == null || je.context.equals(value.getContext())) {
return new JsValue(value.execute(newArgs)).value;
}
Value attached = je.evalForValue("(" + source + ")");
Value attached = je.evalForValue(source);
return new JsValue(attached.execute(newArgs)).value;
}

Expand Down

0 comments on commit ac8c659

Please sign in to comment.