Interface StructuredSleigh.LVal

All Superinterfaces:
StructuredSleigh.RVal
All Known Subinterfaces:
StructuredSleigh.Var
Enclosing class:
StructuredSleigh

protected static interface StructuredSleigh.LVal extends StructuredSleigh.RVal
A value which can be used on either side of an assignment
  • Method Details

    • cast

      Description copied from interface: StructuredSleigh.RVal
      Cast the value to the given type

      This functions like a C-style pointer cast. There are no implied operations or conversions. Notably, casting between integers and floats is just a re-interpretation of the underlying bits.

      Specified by:
      cast in interface StructuredSleigh.RVal
      Parameters:
      type - the type
      Returns:
      a handle to the resulting value
    • field

      Generate a field offset

      This departs subtly from expected C semantics. This value's type is assumed to be a pointer to a Composite. That type is retrieved and the field located. This then generates unsigned addition of that field offset to this value. The type of the result is a pointer to the type of the field. The C equivalent is "&(val->field)". Essentially, it's just address computation. Note that this operator will fail if the type is not a pointer. It cannot be used directly on the Composite type.

      TODO: Allow direct use on the composite type? Some mechanism for dealing with bitfields? Bitfields cannot really work if this is just pointer manipulation. If it's also allowed to manipulate raw bytes of a composite, then bitfield access could work. Assignment would be odd, but doable. The inputs would be the composite-typed value, the field name, and the desired field value. The output would be the resulting composite-typed value. For large structures, though, we'd like to manipulate the least number of bytes possible, since they'll likely need to be written back out to target memory.

      Parameters:
      name - the name of the field
      Returns:
      a handle to the resulting value
    • index

      Generate an array index

      This departs subtly from expected C semantics. This value's type is assumed to be a pointer to the element type. The size of the element type is computed, and this generates unsigned multiplcation of the index and size, then addition to this value. The type of the result is the same as this value's type. The C equivalent is "&(val[index])". Essentially, it's just address computation. Note that this operator will fail if the type is not a pointer. It cannot be used on an Array type.

      TODO: Allow use of Array type? While it's possible for authors to specify pointer types for their variables, the types of fields they access may not be under their control. In particular, between field(String) and index(RVal), we ought to support accessing fixed-length array fields.

      Parameters:
      index - the operand to use as the index into the array
      Returns:
      a handle to the resulting value
    • index

      StructuredSleigh.LVal index(long index)
      Generate an array index
      Parameters:
      index - the immediate to use as the index into the array
      Returns:
      a handle to the resulting value
      See Also:
    • set

      Assign this value
      Parameters:
      rhs - the value to assign
      Returns:
      a handle to the resulting value
    • set

      Assign this value
      Parameters:
      rhs - the immediate value to assign
      Returns:
      a handle to the resulting value
    • addiTo

      Generate in-place integer addition
      Parameters:
      rhs - the second operand
      Returns:
      a handle to the resulting value
    • addiTo

      StructuredSleigh.StmtWithVal addiTo(long rhs)
      Generate in-place integer addition
      Parameters:
      rhs - the second operand
      Returns:
      a handle to the resulting value
    • inc

      Generate an in-place increment (by 1)
      Returns:
      a handle to the resulting value