Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.core
Class SourceMapping

    java.lang.Object
      avrora.core.SourceMapping

Direct Known Subclasses:
  LabelMapping

public abstract class SourceMapping
extends java.lang.Object

The `SourceMapping` class embodies the concept of mapping machine code level addresses and constructions in the `Program` class back to a source code program, either in assembly language (labels), or a high-level programming lagnguage like C. This class is used by the simulator to report information about the program in a higher-level way more readibly understandable, for example to report calls / returns between functions by their names rather than their machine code addresses.

Nested Class Summary
`class` | `SourceMapping.Location` The `Location` class represents a location in the program; either named by a label, or an unnamed integer address.

Field Summary
`static java.util.Comparator` | `LOCATION_COMPARATOR` The `LOCATION_COMPARATOR` comparator is used in order to sort locations in the program from lowest address to highest address.
`protected Program` | `program` The `program` field stores a reference to the program for this source mapping.

Constructor Summary
`SourceMapping(Program p)` The constructor for the `SourceMapping` base class creates a new instance of source mapping information for the specified program.

Method Summary
`abstract int` | `getAddress(java.lang.String name)` The `getAddress()` method translates a source level name into a machine-code level address.
`abstract SourceMapping.Location` | `getLocation(java.lang.String name)`
`abstract java.lang.String` | `getName(int address)` The `getName()` method translates a code address into a name that is more useful to the user, such as a label, a location in a method, a location in a module and the source line, etc.
`Program` | `getProgram()` The `getProgram()` class returns a reference to the program for which this class provides source information.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### program

    protected final Program program

  The `program` field stores a reference to the program for this source mapping.

### LOCATION_COMPARATOR

    public static java.util.Comparator LOCATION_COMPARATOR

  The `LOCATION_COMPARATOR` comparator is used in order to sort locations in the program from lowest address to highest address.

Constructor Detail

### SourceMapping

    public SourceMapping(Program p)

  The constructor for the `SourceMapping` base class creates a new instance of source mapping information for the specified program. The mapping is tied to the program throughout its lifetime.

Parameters:
  `p` - the program to create the source mapping for

Method Detail

### getName

    public abstract java.lang.String getName(int address)

  The `getName()` method translates a code address into a name that is more useful to the user, such as a label, a location in a method, a location in a module and the source line, etc.

  Parameters:
    `address` - the address of an instruction in the program
  Returns:
    a string representation of the address; e.g. a label

### getAddress

    public abstract int getAddress(java.lang.String name)

  The `getAddress()` method translates a source level name into a machine-code level address. For example, the name might represent the beginning of a method or a label in an assembly program. If the name is not known in the program, this method should return -1.

  Parameters:
    `name` - the name of some program entity as a string
  Returns:
    the address of that program entity as a byte address in the code of the program; -1 if the name is not present in this program

### getProgram

    public Program getProgram()

  The `getProgram()` class returns a reference to the program for which this class provides source information.

  Returns:
    the program associated with this source mapping

### getLocation

    public abstract SourceMapping.Location getLocation(java.lang.String name)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD