Class FieldSlots

java.lang.Object
org.ek9lang.compiler.support.FieldSlots

public final class FieldSlots extends Object
THE field-slot rule: the index of a property in an object's flat field layout, as every back end lays it out and as the IR's LOAD_FIELD/STORE_FIELD/RELEASE_FIELD index states it (Contract 2: the index is the slot). An object holds its super chain's properties first, then its own. A super that is an extern built-in (Exception, Money, ...) declares its state as Java/C struct fields, not EK9 properties, so it contributes its native FOOTPRINT (externFootprint(String)) and the walk stops there.

Use this - never count getProperties() by hand. There were three rules (review A-D2): phase 7 read other.x without the extern footprint, so on a sub-type of Exception it read the C struct's first word; assignment counted only the declaring type's own properties; the native layout counted it right.

  • Method Details

    • externFootprint

      public static OptionalInt externFootprint(String fullyQualifiedTypeName)
      The native footprint of a field-bearing extern base, or empty for a user type or a field-less extern type.
    • externFootprints

      public static Map<String,Integer> externFootprints()
      The immutable footprint map - for the drift test that holds it against the C structs.
    • inheritedSlotCount

      public static int inheritedSlotCount(IAggregateSymbol aggregate)
      The slots an aggregate's super chain occupies before its own properties.
    • indexOf

      public static int indexOf(ISymbol owner, String fieldName)
      The slot of fieldName in an object of owner: the nearest declaration of that property in the chain, at its declaring type's inherited slot count plus its position there. 0 when it is not an EK9 property of the chain (the IR's historical answer for a non-aggregate owner).