diff options
| author | student <student@localhost> | 2018-02-12 12:01:53 -0500 |
|---|---|---|
| committer | student <student@localhost> | 2018-02-12 12:01:53 -0500 |
| commit | c25b68c6b24d86b7d1169ad4ec1e619d79a2b38d (patch) | |
| tree | dc9579836d6856cf93ae7f682446a4e69a94e37f /base/src/bjc/dicelang/scl/FloatSCLToken.java | |
| parent | d7af27dab45dd6f82c27519e6b4fd2faa162f884 (diff) | |
Split SCLToken into subclasses.
Instead of one class with a lot of fields whose state varies based on an
enum, we now have a hierarchy of classes that does the same in a more
obvious manner.
Diffstat (limited to 'base/src/bjc/dicelang/scl/FloatSCLToken.java')
| -rw-r--r-- | base/src/bjc/dicelang/scl/FloatSCLToken.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/base/src/bjc/dicelang/scl/FloatSCLToken.java b/base/src/bjc/dicelang/scl/FloatSCLToken.java new file mode 100644 index 0000000..46db4c5 --- /dev/null +++ b/base/src/bjc/dicelang/scl/FloatSCLToken.java @@ -0,0 +1,41 @@ +package bjc.dicelang.scl; + +public class FloatSCLToken extends SCLToken { + /* Used for FLIT */ + public double floatVal; + + public FloatSCLToken(double val) { + super(Type.FLIT); + + floatVal = val; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + long temp; + temp = Double.doubleToLongBits(floatVal); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + FloatSCLToken other = (FloatSCLToken) obj; + if (Double.doubleToLongBits(floatVal) != Double.doubleToLongBits(other.floatVal)) + return false; + return true; + } + + @Override + public String toString() { + return "FloatSCLToken [floatVal=" + floatVal + "]"; + } +} |
