From a79b6ad81c7d19e33778073b1d55421d82e9e4ea Mon Sep 17 00:00:00 2001 From: sjfink Date: Fri, 9 Nov 2007 15:53:51 +0000 Subject: [PATCH] support LongConstant git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1994 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../src/com/ibm/wala/logic/IntConstant.java | 2 - .../src/com/ibm/wala/logic/LongConstant.java | 55 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 com.ibm.wala.core/src/com/ibm/wala/logic/LongConstant.java diff --git a/com.ibm.wala.core/src/com/ibm/wala/logic/IntConstant.java b/com.ibm.wala.core/src/com/ibm/wala/logic/IntConstant.java index da3996b7d..db5a30b59 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/logic/IntConstant.java +++ b/com.ibm.wala.core/src/com/ibm/wala/logic/IntConstant.java @@ -10,8 +10,6 @@ *******************************************************************************/ package com.ibm.wala.logic; - - public class IntConstant extends AbstractConstant { private final int val; diff --git a/com.ibm.wala.core/src/com/ibm/wala/logic/LongConstant.java b/com.ibm.wala.core/src/com/ibm/wala/logic/LongConstant.java new file mode 100644 index 000000000..38b2d5c85 --- /dev/null +++ b/com.ibm.wala.core/src/com/ibm/wala/logic/LongConstant.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.wala.logic; + +public class LongConstant extends AbstractConstant { + private final long val; + + protected LongConstant(long val) { + this.val = val; + } + + public static LongConstant make(long val) { + return new LongConstant(val); + } + + public long getVal() { + return val; + } + + @Override + public String toString() { + return String.valueOf(val); + } + + + @Override + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = (int) (PRIME * result + val); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final LongConstant other = (LongConstant) obj; + if (val != other.val) + return false; + return true; + } +}