-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the limits immutable. Use the maximum limit constant `0x1_0000_0000` when the upper limit is unspecified, and simplify comparisons accordingly. There is a class which represents limits; change `Table` to reuse it.
- Loading branch information
Showing
5 changed files
with
46 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 19 additions & 7 deletions
26
wasm/src/main/java/com/dylibso/chicory/wasm/types/Limits.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
package com.dylibso.chicory.wasm.types; | ||
|
||
public class Limits { | ||
private final int min; | ||
private final int max; | ||
public static final long LIMIT_MAX = 0x1_0000_0000L; | ||
|
||
public Limits(int min, int max) { | ||
this.min = min; | ||
this.max = max; | ||
private static final Limits UNBOUNDED = new Limits(0); | ||
|
||
private final long min; | ||
private final long max; | ||
|
||
public Limits(long min) { | ||
this(min, LIMIT_MAX); | ||
} | ||
|
||
public Limits(long min, long max) { | ||
this.min = Math.min(Math.max(0, min), LIMIT_MAX); | ||
this.max = Math.min(Math.max(min, max), LIMIT_MAX); | ||
} | ||
|
||
public int min() { | ||
public long min() { | ||
return min; | ||
} | ||
|
||
public int max() { | ||
public long max() { | ||
return max; | ||
} | ||
|
||
public static Limits unbounded() { | ||
return UNBOUNDED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters