* net/loveruby/cflat/type/IntegerType.java: new method #isInDomain, #minValue, #maxValue.

git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3961 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-08-19 06:40:24 +00:00
parent 92afb927cd
commit 8c51d5d1a7
2 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Thu May 8 21:39:49 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/type/IntegerType.java: new method
#isInDomain, #minValue, #maxValue.
Tue May 6 20:42:04 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/CodeGenerator.java

View File

@ -16,6 +16,19 @@ public class IntegerType extends Type {
public boolean isSigned() { return isSigned; }
public boolean isScalar() { return true; }
public long minValue() {
return isSigned ? (long)-Math.pow(2, size * 8 - 1) : 0;
}
public long maxValue() {
return isSigned ? (long)Math.pow(2, size * 8 - 1) - 1
: (long)Math.pow(2, size * 8) - 1;
}
public boolean isInDomain(long i) {
return (minValue() <= i && i <= maxValue());
}
// Use default #equals
//public boolean equals(Object other)