Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk
Class UWord

    java.lang.Object
      com.sun.squawk.UWord

    public final class UWord

extends Object

The word type is used by the runtime system and collector to denote machine word-sized quantities. It is used instead of 'int' or 'Object' for coding clarity, machine-portability (it can map to 32 bit and 64 bit integral types) and access to unsigned operations (Java does not have unsigned int types).

This class is known specially by the translator as a `SQUAWKPRIMITIVE` and programming with it requires adhering to the restrictions implied by this attribute. Some of these constraints are imposed to keep the job of the translator simple. All of these constraints are currently enforced by the translator. The constraints are:

- A local variable slot allocated by javac for a Squawk primitive variable must never be used for a value of any other type (including a different Squawk primitive type). This is required as the translator cannot currently de-multiplex reference type slots into disjoint typed slots. This restriction on javac is achieved by declaring all Squawk primitive local variables at the outer most scope (as javac using lexical based scoping for register allocation liveness).
- A Squawk primitive value of type T cannot be assigned to or compared with values of any other type (including `null`) than T.
- A Squawk primitive value of type T cannot be passed as a parameter values of any other type than T. For example, you cannot call T.toString(), or String.valueOf(T). The methods of the classes NativeUnsafe and GC have a special permission to allow Squawk primitive values to passed in place of parameters of type Object.

Only the public methods of this class which do not override any of the methods in java.lang.Object will be available in a `non-hosted` environment. The translator replaces any calls to these methods to native method calls.

This mechanism was largely inspired by the VM_Word class in the Jikes RVM.

Method Summary
`UWord` | `and(UWord word)` Logically AND a word with this word.
`boolean` | `eq(UWord word2)` Determines if this word is equal to a given word.
`static UWord` | `fromPrimitive(int value)` Casts a word expressed as the appropriate Java primitive type for the platform (i.e.
`int` | `hashCode()` Gets a hashcode value for this word which is just the value itself.
`boolean` | `hi(UWord word2)` Determines if this word is higher than a given word.
`boolean` | `hieq(UWord word2)` Determines if this word is higher than or equal to a given word.
`boolean` | `isMax()` Determines if this word is equals to `max`.
`boolean` | `isZero()` Determines if this word is 0.
`boolean` | `lo(UWord word2)` Determines if this word is lower than a given word.
`boolean` | `loeq(UWord word2)` Determines if this word is lower than or equal to a given word.
`static UWord` | `max()` Gets the largest possible machine word.
`boolean` | `ne(UWord word2)` Determines if this word is not equal to a given word.
`UWord` | `or(UWord word)` Logically OR a word with this word.
`int` | `toInt()` Casts a value of type UWord into an int.
`Offset` | `toOffset()` Casts a value of type UWord into an Offset.
`int` | `toPrimitive()` Casts a value of type UWord into the appropriate Java primitive type for the platform (i.e.
`String` | `toString()` Gets a string representation of this word.
`static UWord` | `zero()` Gets the canonical UWord representation of `null`.

Methods inherited from class java.lang.Object
`equals, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### fromPrimitive

    public static UWord fromPrimitive(int value)
                               throws NativePragma

  Casts a word expressed as the appropriate Java primitive type for the platform (i.e. int or long) into a value of type UWord.

  Parameters:
    `value` - a word expressed as an int or long
  Returns:
    the canonical UWord instance for `value`
  Throws:
    `NativePragma`

### toPrimitive

    public int toPrimitive()
                    throws NativePragma

  Casts a value of type UWord into the appropriate Java primitive type for the platform (i.e. int or long). This will cause a fatal error if this cast cannot occur without changing this uword's sign or truncating its magnitude.

  Returns:
    this UWord value as an int or long
  Throws:
    `NativePragma`

### toInt

    public int toInt()
              throws NativePragma

  Casts a value of type UWord into an int. This will cause a fatal error if this UWord value cannot be expressed as a signed 32 bit Java int without changing its sign or truncating its magnitude.

  Returns:
    this UWord value as an int
  Throws:
    `NativePragma`

### toOffset

    public Offset toOffset()
                    throws NativePragma

  Casts a value of type UWord into an Offset. This may cause a change in sign if this word value cannot be expressed as a signed quantity.

  Returns:
    this UWord value as an Offset
  Throws:
    `NativePragma`

### zero

    public static UWord zero()
                      throws NativePragma

  Gets the canonical UWord representation of `null`.

  Returns:
    the canonical UWord representation of `null`
  Throws:
    `NativePragma`

### max

    public static UWord max()
                     throws NativePragma

  Gets the largest possible machine word.

  Returns:
    the largest possible machine word
  Throws:
    `NativePragma`

### or

    public UWord or(UWord word)
             throws NativePragma

  Logically OR a word with this word.

  Parameters:
    `word` - the word to OR this word with
  Returns:
    the result of the OR operation
  Throws:
    `NativePragma`

### and

    public UWord and(UWord word)
              throws NativePragma

  Logically AND a word with this word.

  Parameters:
    `word` - the word to AND this word with
  Returns:
    the result of the AND operation
  Throws:
    `NativePragma`

### isZero

    public boolean isZero()
                   throws NativePragma

  Determines if this word is 0.

  Returns:
    true if this word is 0.
  Throws:
    `NativePragma`

### isMax

    public boolean isMax()
                  throws NativePragma

  Determines if this word is equals to `max`.

  Returns:
    true if this word is equals to `max`
  Throws:
    `NativePragma`

### eq

    public boolean eq(UWord word2)
               throws NativePragma

  Determines if this word is equal to a given word.

  Parameters:
    `word2` - the word to compare this word against
  Returns:
    true if this word is equal to `word2`
  Throws:
    `NativePragma`

### ne

    public boolean ne(UWord word2)
               throws NativePragma

  Determines if this word is not equal to a given word.

  Parameters:
    `word2` - the word to compare this word against
  Returns:
    true if this word is not equal to `word2`
  Throws:
    `NativePragma`

### lo

    public boolean lo(UWord word2)
               throws NativePragma

  Determines if this word is lower than a given word.

  Parameters:
    `word2` - the word to compare this word against
  Returns:
    true if this word is lower than or equals to `word2`
  Throws:
    `NativePragma`

### loeq

    public boolean loeq(UWord word2)
                 throws NativePragma

  Determines if this word is lower than or equal to a given word.

  Parameters:
    `word2` - the word to compare this word against
  Returns:
    true if this word is lower than or equal to `word2`
  Throws:
    `NativePragma`

### hi

    public boolean hi(UWord word2)
               throws NativePragma

  Determines if this word is higher than a given word.

  Parameters:
    `word2` - the word to compare this word against
  Returns:
    true if this word is higher than `word2`
  Throws:
    `NativePragma`

### hieq

    public boolean hieq(UWord word2)
                 throws NativePragma

  Determines if this word is higher than or equal to a given word.

  Parameters:
    `word2` - the word to compare this word against
  Returns:
    true if this word is higher than or equal to `word2`
  Throws:
    `NativePragma`

### hashCode

    public int hashCode()
                 throws HostedPragma

  Gets a hashcode value for this word which is just the value itself.

  Overrides:
    `hashCode` in class `Object`
  Returns:
    the value of this word
  Throws:
    `HostedPragma`
  See Also:
    `Object.equals(java.lang.Object)`, `Hashtable`

### toString

    public String toString()
                    throws HostedPragma

  Gets a string representation of this word.

  Overrides:
    `toString` in class `Object`
  Returns:
    String
  Throws:
    `HostedPragma`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"