Class SLType

java.lang.Object
com.oracle.truffle.sl.runtime.SLType
All Implemented Interfaces:
com.oracle.truffle.api.interop.TruffleObject

public final class SLType extends Object implements com.oracle.truffle.api.interop.TruffleObject
The builtin type definitions for SimpleLanguage. SL has no custom types, so it is not possible for a guest program to create new instances of SLType.

The isInstance type checks are declared using an functional interface and are expressed using the interoperability libraries. The advantage of this is type checks automatically work for foreign values or primitive values like byte or short.

The class implements the interop contracts for InteropLibrary.isMetaObject(Object) and InteropLibrary.isMetaInstance(Object, Object). The latter allows other languages and tools to perform type checks using types of simple language.

In order to assign types to guest language values, SL values implement InteropLibrary.getMetaObject(Object). The interop contracts for primitive values cannot be overriden, so in order to assign meta-objects to primitive values, the primitive values are assigned using language views. See SLLanguage.getLanguageView(com.oracle.truffle.sl.runtime.SLContext, java.lang.Object).

  • Field Details

    • NUMBER

      public static final SLType NUMBER
    • NULL

      public static final SLType NULL
    • STRING

      public static final SLType STRING
    • BOOLEAN

      public static final SLType BOOLEAN
    • OBJECT

      public static final SLType OBJECT
    • FUNCTION

      public static final SLType FUNCTION
    • PRECEDENCE

      public static final SLType[] PRECEDENCE
  • Method Details

    • isInstance

      public boolean isInstance(Object value, com.oracle.truffle.api.interop.InteropLibrary interop)
      Checks whether this type is of a certain instance. If used on fast-paths it is required to cast SLType to a constant.
    • getName

      public Object getName()
    • toString

      public String toString()
      Overrides:
      toString in class Object