private static void renderList(OtpErlangList list, XValueTextRenderer renderer) { int i; renderer.renderSpecialSymbol("["); for (i = 0; i < list.arity(); i++) { if (i > 0) { renderer.renderSpecialSymbol(", "); } renderObject(list.elementAt(i), renderer); } // Improper lists have a lastTail OtpErlangObject lastTail = list.getLastTail(); if (lastTail != null) { // Improper lists need to render the head tail joiner, `|`, explicitly renderer.renderSpecialSymbol(" | "); renderObject(lastTail, renderer); } renderer.renderSpecialSymbol("]"); }
@Override public OtpErlangObject getLastTail() { return parent.getLastTail(); }
@Override public Object clone() { try { return new OtpErlangList(elements(), getLastTail()); } catch (final OtpErlangException e) { throw new AssertionError(this); } }
final OtpErlangObject otherTail = l.getLastTail(); if (getLastTail() == null && otherTail == null) { return true; if (getLastTail() == null) { return false; return getLastTail().equals(l.getLastTail());
@Override public <T> boolean match(final OtpErlangObject term, final T bindings) { if (!(term instanceof OtpErlangList)) { return false; } final OtpErlangList that = (OtpErlangList) term; final int thisArity = this.arity(); final int thatArity = that.arity(); final OtpErlangObject thisTail = this.getLastTail(); final OtpErlangObject thatTail = that.getLastTail(); if (thisTail == null) { if (thisArity != thatArity || thatTail != null) { return false; } } else { if (thisArity > thatArity) { return false; } } for (int i = 0; i < thisArity; i++) { if (!elementAt(i).match(that.elementAt(i), bindings)) { return false; } } if (thisTail == null) { return true; } return thisTail.match(that.getNthTail(thisArity), bindings); }
@Override protected int doHashCode() { final OtpErlangObject.Hash hash = new OtpErlangObject.Hash(4); final int a = arity(); if (a == 0) { return (int) 3468870702L; } for (int i = 0; i < a; i++) { hash.combine(elementAt(i).hashCode()); } final OtpErlangObject t = getLastTail(); if (t != null) { final int h = t.hashCode(); hash.combine(h, h); } return hash.valueOf(); }