/** {@inheritDoc} */ @Override public void toString(StringBuilder out, int indent) { if (indent < 0) { out.append(fun.label); if (args.size() == 0) return; out.append('['); for (int i = 0; i < args.size(); i++) { if (i > 0) out.append(", "); args.get(i).toString(out, -1); } out.append(']'); } else { for (int i = 0; i < indent; i++) { out.append(' '); } out.append("call ") .append(fun) .append(" at position <") .append(fun.pos) .append("> with type=") .append(type) .append('\n'); for (Expr a : args) { a.toString(out, indent + 2); } } }
/** {@inheritDoc} */ @Override public List<? extends Browsable> getSubnodes() { if (args.size() == 0) { Expr b = fun.getBody(); return Util.asList(make(b.pos(), b.span(), b.getHTML(), b.getSubnodes())); } Pos p = pos; if (p == Pos.UNKNOWN) p = span(); Browsable f = make(p, p, (fun.isPred ? "<b>pred</b> " : "<b>fun</b> ") + fun.label, fun.getSubnodes()); Browsable a = make( span(), span(), "<b>" + args.size() + " argument" + (args.size() == 1 ? "</b>" : "s</b>"), args); return Util.asList(f, a); }
/** * Returns true if we can determine the two expressions are equivalent; may sometimes return * false. */ @Override public boolean isSame(Expr obj) { while (obj instanceof ExprUnary && ((ExprUnary) obj).op == ExprUnary.Op.NOOP) obj = ((ExprUnary) obj).sub; if (obj == this) return true; if (!(obj instanceof ExprCall)) return false; ExprCall x = (ExprCall) obj; if (fun != x.fun || args.size() != x.args.size()) return false; for (int i = 0; i < args.size(); i++) if (!args.get(i).isSame(x.args.get(i))) return false; return true; }