001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010:
011: package de.uka.ilkd.key.java.expression.literal;
012:
013: import de.uka.ilkd.key.java.NameAbstractionTable;
014: import de.uka.ilkd.key.java.PrettyPrinter;
015: import de.uka.ilkd.key.java.Services;
016: import de.uka.ilkd.key.java.SourceElement;
017: import de.uka.ilkd.key.java.abstraction.KeYJavaType;
018: import de.uka.ilkd.key.java.abstraction.PrimitiveType;
019: import de.uka.ilkd.key.java.expression.Literal;
020: import de.uka.ilkd.key.java.visitor.Visitor;
021: import de.uka.ilkd.key.util.ExtList;
022:
023: /**
024: * Long literal.
025: * @author <TT>AutoDoc</TT>
026: */
027:
028: public class LongLiteral extends Literal {
029:
030: /**
031: * Textual representation of the value.
032: */
033:
034: protected final String value;
035:
036: /**
037: * Long literal.
038: * @param value a long value.
039: */
040:
041: public LongLiteral(long value) {
042: this .value = "" + value + 'L';
043: }
044:
045: /**
046: * Long literal.
047: * @param children a list with children(comments)
048: * @param value a string.
049: */
050:
051: public LongLiteral(ExtList children, String value) {
052: super (children);
053: this .value = (value.endsWith("L") || value.endsWith("l")) ? value
054: : (value + 'L');
055: }
056:
057: /**
058: * Long literal.
059: * @param value a string.
060: */
061:
062: public LongLiteral(String value) {
063: this .value = (value.endsWith("L") || value.endsWith("l")) ? value
064: : (value + 'L');
065: }
066:
067: /** tests if equals
068: */
069: public boolean equalsModRenaming(SourceElement o,
070: NameAbstractionTable nat) {
071: if (!(o instanceof LongLiteral)) {
072: return false;
073: }
074: return ((LongLiteral) o).getValue().equals(getValue());
075: }
076:
077: public int hashCode() {
078: int result = 17;
079: result = 37 * result + getValue().hashCode();
080: return result;
081: }
082:
083: public boolean equals(Object o) {
084: return super .equals(o);
085: }
086:
087: /**
088: * Get value.
089: * @return the string.
090: */
091:
092: public String getValue() {
093: return value;
094: }
095:
096: /** calls the corresponding method of a visitor in order to
097: * perform some action/transformation on this element
098: * @param v the Visitor
099: */
100: public void visit(Visitor v) {
101: v.performActionOnLongLiteral(this );
102: }
103:
104: public void prettyPrint(PrettyPrinter p) throws java.io.IOException {
105: p.printLongLiteral(this );
106: }
107:
108: public KeYJavaType getKeYJavaType(Services javaServ) {
109: return javaServ.getJavaInfo().getKeYJavaType(
110: PrimitiveType.JAVA_LONG);
111: }
112:
113: }
|