avrora.syntax
Class Expr.RelativeAddress

java.lang.Object
  extended byavrora.syntax.ASTNode
      extended byavrora.syntax.Expr
          extended byavrora.syntax.Expr.RelativeAddress
Enclosing class:
Expr

public static class Expr.RelativeAddress
extends Expr

The RelativeAddress class represents an expression that is derived from the addition (or subtraction) of a constant to the current byte address. This occurs in the GAS formats and Objdump.


Nested Class Summary
 
Nested classes inherited from class avrora.syntax.Expr
Expr.BinOp, Expr.CharLiteral, Expr.Constant, Expr.Func, Expr.RelativeAddress, Expr.StringLiteral, Expr.Term, Expr.UnOp, Expr.Variable
 
Field Summary
 AbstractToken dot
           
 AbstractToken num
           
 AbstractToken op
           
 
Constructor Summary
Expr.RelativeAddress(AbstractToken d, AbstractToken o, AbstractToken n)
           
 
Method Summary
 int evaluate(int currentByteAddress, Context c)
          The evaluate() method computes the value of the expression in this context and returns its value.
 AbstractToken getLeftMostToken()
          The getLeftMostToken() method gets the first token associated with the abstract syntax tree node.
 AbstractToken getRightMostToken()
          The getRightMostToken() method gets the last token associated with the abstract syntax tree node.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dot

public final AbstractToken dot

op

public final AbstractToken op

num

public final AbstractToken num
Constructor Detail

Expr.RelativeAddress

public Expr.RelativeAddress(AbstractToken d,
                            AbstractToken o,
                            AbstractToken n)
Method Detail

getLeftMostToken

public AbstractToken getLeftMostToken()
Description copied from class: ASTNode
The getLeftMostToken() method gets the first token associated with the abstract syntax tree node.

Specified by:
getLeftMostToken in class ASTNode
Returns:
an AbstractToken instance representing the first token that is a part of this syntactic item.

getRightMostToken

public AbstractToken getRightMostToken()
Description copied from class: ASTNode
The getRightMostToken() method gets the last token associated with the abstract syntax tree node.

Specified by:
getRightMostToken in class ASTNode
Returns:
an AbstractToken instance representing the last token that is a part of this syntactic item.

toString

public java.lang.String toString()

evaluate

public int evaluate(int currentByteAddress,
                    Context c)
The evaluate() method computes the value of the expression in this context and returns its value. Since this is a relative address, it simply evaluates the offset and adds it to the current address in the program and returns that value.

Specified by:
evaluate in class Expr
Parameters:
currentByteAddress - the current byte address within the program
c - the context in which to evaluate this expression
Returns:
the value of the expression as a 32-bit integer