| 5 | public class CodeExtract { |
| 6 | |
| 7 | public static class Field { |
| 8 | |
| 9 | public Field(int size, int shift) { |
| 10 | this(size, shift, 0); |
| 11 | } |
| 12 | |
| 13 | public Field(int size, int shift, int offset) { |
| 14 | this.size = size; |
| 15 | this.shift = shift; |
| 16 | this.mask = size_to_mask(size); |
| 17 | this.offset = offset; |
| 18 | } |
| 19 | |
| 20 | public int extract(int codepoint) { |
| 21 | return ((codepoint >>> shift) & mask) - offset; |
| 22 | } |
| 23 | |
| 24 | public boolean check(int x) { |
| 25 | return ((x + offset) & ~mask) == 0; |
| 26 | } |
| 27 | |
| 28 | public int encode(int x) { |
| 29 | return (x + offset) << shift; |
| 30 | } |
| 31 | |
| 32 | public int clear(int codepoint) { |
| 33 | return codepoint & ~(mask << shift); |
| 34 | } |
| 35 | |
| 36 | public int max() { |
| 37 | return mask - offset; |
| 38 | } |
| 39 | |
| 40 | public final int size; |
| 41 | private final int shift; |
| 42 | private final int mask; |
| 43 | private final int offset; |
| 44 | |
| 45 | } |
| 46 | |
| 47 | public CodeExtract(Version version, int sizeOp, int sizeA, int sizeB, int sizeC) { |
| 48 | switch(version.instructionformat.get()) { |
nothing calls this directly
no outgoing calls
no test coverage detected