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.isdl.ast
Class BitRangeExpr

    java.lang.Object
      avrora.core.isdl.ast.Expr
          avrora.core.isdl.ast.BitRangeExpr

public class BitRangeExpr
extends Expr

The `BitRangeExpr` class represents an expression whose value is the result of extracting a range of the bits from another expression. In the IR, ranges of bits can be specified for reading and writing, allowing cleaner expression of sub-byte fields. The bounds of these ranges are static: the endpoints must be constants.

Field Summary
`int` | `high_bit` The `high_bit` field represents the highest bit in the range to be extracted, inclusive.
`int` | `low_bit` The `low_bit` field represents the lowest bit in the range to be extracted, inclusive.
`Expr` | `operand` The `operand` field stores a reference to the expression that is the operand of the bit range expression, i.e. the value from which the range of bits will be extracted.

Fields inherited from class avrora.core.isdl.ast.Expr
`PREC_A_ADD, PREC_A_AND, PREC_A_MUL, PREC_A_OR, PREC_A_SHIFT, PREC_A_XOR, PREC_L_AND, PREC_L_EQU, PREC_L_OR, PREC_L_REL, PREC_L_XOR, PREC_TERM, PREC_UN`

Constructor Summary
`BitRangeExpr(Expr o, int l, int h)` The constructor of the `BitRangeExpr` class simply initializes the references to the operands of the bit range expression.
`BitRangeExpr(Expr o, Token l, Token h)` The constructor of the `BitRangeExpr` class simply initializes the references to the operands of the bit range expression.

Method Summary
`Expr` | `accept(CodeRebuilder r, java.lang.Object env)` The `accept()` method implements one half of the visitor pattern for rebuilding of expressions.
`void` | `accept(CodeVisitor v)` The `accept()` method implements one half of the visitor pattern so that client visitors can traverse the syntax tree easily and in an extensible way.
`void` | `accept(ExprVisitor v)` The `accept()` method implements one half of the visitor pattern so that client visitors can traverse the syntax tree easily and in an extensible way.
`int` | `getBitWidth()` The `getBitWidth()` method gets the number of bits needed to represent this value.
`int` | `getPrecedence()` The `getPrecedence()` method gets the binding precedence for this expression.
`boolean` | `isBitRangeExpr()` The `isBitRangeExpr()` method tests whether the expression is an access of a range of bits.
`boolean` | `isConstantExpr()` The `isConstantExpr()` method tests whether this expression is a constant expression (i.e.
`java.lang.String` | `toString()` The `toString()` method recursively converts this expression to a string.

Methods inherited from class avrora.core.isdl.ast.Expr
`innerString, isLiteral, isMap, isVariable, tokenToBool, tokenToInt`

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

Field Detail

### operand

    public final Expr operand

  The `operand` field stores a reference to the expression that is the operand of the bit range expression, i.e. the value from which the range of bits will be extracted.

### low_bit

    public final int low_bit

  The `low_bit` field represents the lowest bit in the range to be extracted, inclusive.

### high_bit

    public final int high_bit

  The `high_bit` field represents the highest bit in the range to be extracted, inclusive.

Constructor Detail

### BitRangeExpr

    public BitRangeExpr(Expr o,
                        Token l,
                        Token h)

  The constructor of the `BitRangeExpr` class simply initializes the references to the operands of the bit range expression.

Parameters:
  `o` - a reference to the expression operand
  `l` - the lowest bit in the range, inclusive
  `h` - the highest bit in the range, inclusive

### BitRangeExpr

    public BitRangeExpr(Expr o,
                        int l,
                        int h)

  The constructor of the `BitRangeExpr` class simply initializes the references to the operands of the bit range expression.

Parameters:
  `o` - a reference to the expression operand
  `l` - the lowest bit in the range, inclusive
  `h` - the highest bit in the range, inclusive

Method Detail

### getBitWidth

    public int getBitWidth()

  The `getBitWidth()` method gets the number of bits needed to represent this value. This is needed in the case of encoding formats, which need to compute the size of an instruction based on the width of its internal fields. For a `BitRangeExpr`, the number of bits required is statically known.

  Overrides:
    `getBitWidth` in class `Expr`
  Returns:
    the number of bits that this expression occupies

### isConstantExpr

    public boolean isConstantExpr()

  The `isConstantExpr()` method tests whether this expression is a constant expression (i.e. it is reducable to a constant and has no references to variables, maps, etc).

  Overrides:
    `isConstantExpr` in class `Expr`
  Returns:
    true if this expression can be evaluated to a constant; false otherwise

### isBitRangeExpr

    public boolean isBitRangeExpr()

  The `isBitRangeExpr()` method tests whether the expression is an access of a range of bits. This is used in pattern matching in some parts of the code.

  Overrides:
    `isBitRangeExpr` in class `Expr`
  Returns:
    true

### accept

    public void accept(ExprVisitor v)

  The `accept()` method implements one half of the visitor pattern so that client visitors can traverse the syntax tree easily and in an extensible way.

  Specified by:
    `accept` in class `Expr`
  Parameters:
    `v` - the visitor to accept

### accept

    public void accept(CodeVisitor v)

  The `accept()` method implements one half of the visitor pattern so that client visitors can traverse the syntax tree easily and in an extensible way.

  Specified by:
    `accept` in class `Expr`
  Parameters:
    `v` - the visitor to accept

### accept

    public Expr accept(CodeRebuilder r,
                       java.lang.Object env)

  The `accept()` method implements one half of the visitor pattern for rebuilding of expressions. This visitor allows code to be slightly modified while only writing visit methods for the parts of the syntax tree affected.

  Specified by:
    `accept` in class `Expr`
  Parameters:
    `r` - the rebuilder to accept
  Returns:
    the result of calling the appropriate `visit()` method of the rebuilder

### toString

    public java.lang.String toString()

  The `toString()` method recursively converts this expression to a string. For binary operations, inner expressions will be nested within parentheses if their precedence is lower than the precedence of the parent expression.

  Returns:
    a string representation of this expression

### getPrecedence

    public int getPrecedence()

  The `getPrecedence()` method gets the binding precedence for this expression. This is used to compute when inner expressions must be nested within parentheses in order to preserve the implied order of evaluation.

  Specified by:
    `getPrecedence` in class `Expr`
  Returns:
    an integer representing the precedence of this expression; higher numbers are higher precedence

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