Class SLFunction

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

public final class SLFunction extends Object implements com.oracle.truffle.api.interop.TruffleObject
Represents a SL function. On the Truffle level, a callable element is represented by a call target. This class encapsulates a call target, and adds version support: functions in SL can be redefined, i.e. changed at run time. When a function is redefined, the call target managed by this function object is changed (and callTarget is therefore not a final field).

Function redefinition is expected to be rare, therefore optimized call nodes want to speculate that the call target is stable. This is possible with the help of a Truffle Assumption: a call node can keep the call target returned by getCallTarget() cached until the assumption returned by getCallTargetStable() is valid.

The callTarget can be null. To ensure that only one SLFunction instance per name exists, the SLFunctionRegistry creates an instance also when performing name lookup. A function that has been looked up, i.e., used, but not defined, has a call target that encapsulates a SLUndefinedFunctionRootNode.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SLFunction(com.oracle.truffle.api.strings.TruffleString name, com.oracle.truffle.api.RootCallTarget callTarget)
     
    protected
    SLFunction(SLLanguage language, com.oracle.truffle.api.strings.TruffleString name)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.oracle.truffle.api.RootCallTarget
     
    com.oracle.truffle.api.Assumption
     
    com.oracle.truffle.api.strings.TruffleString
     
    protected void
    setCallTarget(com.oracle.truffle.api.RootCallTarget callTarget)
     
    This method is, e.g., called when using a function literal in a string concatenation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • SLFunction

      protected SLFunction(SLLanguage language, com.oracle.truffle.api.strings.TruffleString name)
    • SLFunction

      protected SLFunction(com.oracle.truffle.api.strings.TruffleString name, com.oracle.truffle.api.RootCallTarget callTarget)
  • Method Details

    • getName

      public com.oracle.truffle.api.strings.TruffleString getName()
    • setCallTarget

      protected void setCallTarget(com.oracle.truffle.api.RootCallTarget callTarget)
    • getCallTarget

      public com.oracle.truffle.api.RootCallTarget getCallTarget()
    • getCallTargetStable

      public com.oracle.truffle.api.Assumption getCallTargetStable()
    • toString

      public String toString()
      This method is, e.g., called when using a function literal in a string concatenation. So changing it has an effect on SL programs.
      Overrides:
      toString in class Object