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 Address

    java.lang.Object
      com.sun.squawk.Address

    public final class Address

extends Object

The Address class is used to abstract machine addresses. It is used instead of 'int' or 'Object' for coding clarity and machine-portability (it can map to 32 bit and 64 bit integral types).

Variables of type `Address` will never be updated if they correspond with an object that may be moved by the garbage collector. As such, they should never appear in code that may have a collection occur in between the definition and use of the variable. In general, variables of type address should not be used outside of the garbage collector.

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_Address class in the Jikes RVM.

Method Summary
`Address` | `add(int offset)` Adds a 32 bit offset to this address and return the resulting address.
`Address` | `addOffset(Offset offset)` Adds a 32 or 64 bit offset to this address and return the resulting address.
`Address` | `and(UWord word)` Logically AND a word with this address.
`Offset` | `diff(Address address2)` Calculates the offset between this address an another address.
`boolean` | `eq(Address address2)` Determines if this address is equal to a given address.
`static Address` | `fromObject(Object object)` Casts an object reference to an address.
`static Address` | `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 address which is just the address itself.
`boolean` | `hi(Address address2)` Determines if this address is higher than a given address.
`boolean` | `hieq(Address address2)` Determines if this address is higher than or equal to a given address.
`boolean` | `isMax()` Determines if this address is equals to `max`.
`boolean` | `isZero()` Determines if this address is `null`.
`boolean` | `lo(Address address2)` Determines if this address is lower than a given address.
`boolean` | `loeq(Address address2)` Determines if this address is lower than or equal to a given address.
`static Address` | `max()` Gets the largest possible machine address.
`boolean` | `ne(Address address2)` Determines if this address is not equal to a given address.
`Address` | `or(UWord word)` Logically OR a word with this address.
`Address` | `roundDown(int alignment)` Rounds this address down based on a given alignment.
`Address` | `roundDownToWord()` Rounds this address down to a machine word boundary.
`Address` | `roundUp(int alignment)` Rounds this address up based on a given alignment.
`Address` | `roundUpToWord()` Rounds this address up to a machine word boundary.
`Address` | `sub(int offset)` Subtracts a 32 bit offset to this address and return the resulting address.
`Address` | `subOffset(Offset offset)` Subtracts a 32 or 64 bit offset to this address and return the resulting address.
`Object` | `toObject()` Casts this address to an object reference.
`String` | `toString()` Gets a string representation of this address.
`UWord` | `toUWord()` Casts this address to a UWord.
`static Address` | `zero()` Gets the canonical Address representation of `null`.

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

Method Detail

### fromPrimitive

    public static Address 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 Address.

  Parameters:
    `value` - an address expressed as an int or long
  Returns:
    the canonical Address instance for `value`
  Throws:
    `NativePragma`

### fromObject

    public static Address fromObject(Object object)
                              throws NativePragma

  Casts an object reference to an address.

  Parameters:
    `object` - the object reference to cast
  Returns:
    the object reference as an address
  Throws:
    `NativePragma`

### zero

    public static Address zero()
                        throws NativePragma

  Gets the canonical Address representation of `null`.

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

### max

    public static Address max()
                       throws NativePragma

  Gets the largest possible machine address.

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

### toObject

    public Object toObject()
                    throws NativePragma

  Casts this address to an object reference.

  Returns:
    this address as an object reference
  Throws:
    `NativePragma`

### toUWord

    public UWord toUWord()
                  throws NativePragma

  Casts this address to a UWord.

  Returns:
    this address as a UWord
  Throws:
    `NativePragma`

### add

    public Address add(int offset)
                throws NativePragma

  Adds a 32 bit offset to this address and return the resulting address.

  Parameters:
    `offset` - the offset to add
  Returns:
    the result of adding `offset` to this address
  Throws:
    `NativePragma`

### sub

    public Address sub(int offset)
                throws NativePragma

  Subtracts a 32 bit offset to this address and return the resulting address.

  Parameters:
    `offset` - the offset to subract
  Returns:
    the result of subtracting `offset` to this address
  Throws:
    `NativePragma`

### addOffset

    public Address addOffset(Offset offset)
                      throws NativePragma

  Adds a 32 or 64 bit offset to this address and return the resulting address.

  Parameters:
    `offset` - the offset to add
  Returns:
    the result of adding `offset` to this address
  Throws:
    `NativePragma`

### subOffset

    public Address subOffset(Offset offset)
                      throws NativePragma

  Subtracts a 32 or 64 bit offset to this address and return the resulting address.

  Parameters:
    `offset` - the offset to subract
  Returns:
    the result of subtracting `offset` to this address
  Throws:
    `NativePragma`

### or

    public Address or(UWord word)
               throws NativePragma

  Logically OR a word with this address.

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

### and

    public Address and(UWord word)
                throws NativePragma

  Logically AND a word with this address.

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

### diff

    public Offset diff(Address address2)
                throws NativePragma

  Calculates the offset between this address an another address.

  Parameters:
    `address2` - the address to compare this address with
  Returns:
    the offset that must be applied to this address to get `address2`
  Throws:
    `NativePragma`

### isZero

    public boolean isZero()
                   throws NativePragma

  Determines if this address is `null`.

  Returns:
    true if this address is `null`
  Throws:
    `NativePragma`

### isMax

    public boolean isMax()
                  throws NativePragma

  Determines if this address is equals to `max`.

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

### eq

    public boolean eq(Address address2)
               throws NativePragma

  Determines if this address is equal to a given address.

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

### ne

    public boolean ne(Address address2)
               throws NativePragma

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

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

### lo

    public boolean lo(Address address2)
               throws NativePragma

  Determines if this address is lower than a given address.

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

### loeq

    public boolean loeq(Address address2)
                 throws NativePragma

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

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

### hi

    public boolean hi(Address address2)
               throws NativePragma

  Determines if this address is higher than a given address.

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

### hieq

    public boolean hieq(Address address2)
                 throws NativePragma

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

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

### roundUp

    public Address roundUp(int alignment)
                    throws NativePragma

  Rounds this address up based on a given alignment.

  Parameters:
    `alignment` - this address is rounded up to be a multiple of this value
  Returns:
    the new address
  Throws:
    `NativePragma`

### roundUpToWord

    public Address roundUpToWord()
                          throws NativePragma

  Rounds this address up to a machine word boundary.

  Returns:
    the new address
  Throws:
    `NativePragma`

### roundDown

    public Address roundDown(int alignment)
                      throws NativePragma

  Rounds this address down based on a given alignment.

  Parameters:
    `alignment` - this address is rounded down to be a multiple of this value
  Returns:
    the new address
  Throws:
    `NativePragma`

### roundDownToWord

    public Address roundDownToWord()
                            throws NativePragma

  Rounds this address down to a machine word boundary.

  Returns:
    the new address
  Throws:
    `NativePragma`

### hashCode

    public int hashCode()
                 throws HostedPragma

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

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

### toString

    public String toString()
                    throws HostedPragma

  Gets a string representation of this address.

  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
"