Mercurial > hg > graal-compiler
changeset 9822:e210293dca77
Generated hashCode and equals for SourceSection. Source is abstract, so just uses identity methods for that.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Sat, 25 May 2013 16:31:05 -0700 |
parents | 32d8115dade8 |
children | 9e6b6d5d6465 |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java |
diffstat | 1 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Sun May 26 00:01:38 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Sat May 25 16:31:05 2013 -0700 @@ -123,4 +123,58 @@ return String.format("%s:%d", source.getName(), startLine); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + charIndex; + result = prime * result + charLength; + result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); + result = prime * result + ((source == null) ? 0 : source.hashCode()); + result = prime * result + startColumn; + result = prime * result + startLine; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof SourceSection)) { + return false; + } + SourceSection other = (SourceSection) obj; + if (charIndex != other.charIndex) { + return false; + } + if (charLength != other.charLength) { + return false; + } + if (identifier == null) { + if (other.identifier != null) { + return false; + } + } else if (!identifier.equals(other.identifier)) { + return false; + } + if (source == null) { + if (other.source != null) { + return false; + } + } else if (!source.equals(other.source)) { + return false; + } + if (startColumn != other.startColumn) { + return false; + } + if (startLine != other.startLine) { + return false; + } + return true; + } + }