| 26 | import org.dynjs.runtime.linker.DynJSBootstrapper; |
| 27 | |
| 28 | public class ExpressionStatement extends AbstractStatement { |
| 29 | |
| 30 | private final Expression expr; |
| 31 | private final CallSite get; |
| 32 | |
| 33 | public ExpressionStatement(final Expression expr) { |
| 34 | this.expr = expr; |
| 35 | this.get = DynJSBootstrapper.factory().createGet( expr.getPosition() ); |
| 36 | } |
| 37 | |
| 38 | public Position getPosition() { |
| 39 | return this.expr.getPosition(); |
| 40 | } |
| 41 | |
| 42 | public Expression getExpr() { |
| 43 | return this.expr; |
| 44 | } |
| 45 | |
| 46 | public int getSizeMetric() { |
| 47 | return this.expr.getSizeMetric() + 1; |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public Completion interpret(ExecutionContext context) { |
| 52 | Expression expr = getExpr(); |
| 53 | if (expr instanceof FunctionDeclaration) { |
| 54 | return(Completion.createNormal()); |
| 55 | } else { |
| 56 | return(Completion.createNormal(getValue(this.get, context, expr.interpret(context)))); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | public String dump(String indent) { |
| 61 | return super.dump(indent) + this.expr.dump(" " + indent); |
| 62 | } |
| 63 | |
| 64 | public List<FunctionDeclaration> getFunctionDeclarations() { |
| 65 | return this.expr.getFunctionDeclarations(); |
| 66 | } |
| 67 | |
| 68 | public Object accept(Object context, CodeVisitor visitor, boolean strict) { |
| 69 | return visitor.visit(context, this, strict); |
| 70 | } |
| 71 | |
| 72 | public String toIndentedString(String indent) { |
| 73 | return indent + this.expr.toString(); |
| 74 | } |
| 75 | } |
nothing calls this directly
no outgoing calls
no test coverage detected