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

Class AbstractExpression

src/main/java/org/dynjs/parser/ast/AbstractExpression.java:30–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28import org.dynjs.runtime.linker.DynJSBootstrapper;
29
30public abstract class AbstractExpression implements Expression {
31
32 public abstract Position getPosition();
33
34 public String dump(String indent) {
35 String data = dumpData();
36
37 return indent + getClass().getSimpleName() + ":" + getPosition().getLine() + " " +
38 (data != null ? (" (" + data + ")") : "") + "\n";
39 }
40
41 public String dumpData() {
42 return null;
43 }
44
45 public List<FunctionDeclaration> getFunctionDeclarations() {
46 return Collections.emptyList();
47 }
48
49 protected Object getValue(CallSite callSite, ExecutionContext context, Object obj) {
50 if (obj instanceof Reference) {
51 Reference ref = (Reference) obj;
52 String name = ref.getReferencedName();
53 try {
54 Object result = callSite.getTarget().invoke( obj, context, name );
55 return result;
56 } catch (ThrowException e) {
57 throw e;
58 } catch (NoSuchMethodError e) {
59 if (ref.isPropertyReference() && !ref.isUnresolvableReference()) {
60 return Types.UNDEFINED;
61 }
62 throw new ThrowException(context, context.createReferenceError("unable to reference: " + name));
63 } catch (Throwable e) {
64 throw new ThrowException(context, e);
65 }
66 } else {
67 return obj;
68 }
69 }
70
71
72}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected