Package gnu.expr

Class ApplyExp

All Implemented Interfaces:
gnu.kawa.format.Printable, Named, SourceLocator, SourceLocator, Locator
Direct Known Subclasses:
CurryExp

public class ApplyExp extends Expression
This class is used to represent "combination" or "application". A function and arguments are evaluated, and then the function applied.
  • Field Details

    • TAILCALL

      public static final int TAILCALL
      See Also:
    • INLINE_IF_CONSTANT

      public static final int INLINE_IF_CONSTANT
      See Also:
    • MAY_CONTAIN_BACK_JUMP

      public static final int MAY_CONTAIN_BACK_JUMP
      See Also:
    • IS_SUPER_INIT

      public static final int IS_SUPER_INIT
      See Also:
    • nextCall

      public ApplyExp nextCall
      The next ApplyExp in ((ReferenceExp)func).binding.firstCall list.
    • firstKeywordArgIndex

      public int firstKeywordArgIndex
      Index of argument for first keyword argument. If zero, no keyword arguments. If non-zero, then firstKeywordArgIndex-1 is the index in the args array of the first keyword.
    • numKeywordArgs

      public int numKeywordArgs
    • firstSpliceArg

      public int firstSpliceArg
      Index of first argument that is a MakeSplice. The value is -1 is no argument is a splice.
  • Constructor Details

  • Method Details

    • getFunction

      public final Expression getFunction()
    • getArgs

      public final Expression[] getArgs()
    • getArgCount

      public final int getArgCount()
    • setFunction

      public void setFunction(Expression func)
    • setFunction

      public void setFunction(Procedure proc)
    • setArgs

      public void setArgs(Expression[] args)
    • getArg

      public Expression getArg(int i)
    • setArg

      public void setArg(int i, Expression arg)
    • isTailCall

      public final boolean isTailCall()
    • setTailCall

      public final void setTailCall(boolean tailCall)
    • setFuncArgs

      public ApplyExp setFuncArgs(Expression func, Expression[] args)
    • setFuncArgs

      public ApplyExp setFuncArgs(Procedure proc, Expression[] args)
    • getFunctionValue

      public final Object getFunctionValue()
      If getFunction() is constant, return its value; otherwise null.
    • adjustSplice

      public void adjustSplice(ApplyExp src, int delta)
      Copy over splice and keyword start indexes.
      Parameters:
      src - orginal ApplyExp (may be the same as this)
      delta - amount to adjust indexes by
    • spliceCount

      public int spliceCount()
    • isSimple

      public boolean isSimple()
    • isSimple

      public boolean isSimple(int min)
    • isSimple

      public boolean isSimple(int min, int max)
    • hasSpliceAllowingKeywords

      public boolean hasSpliceAllowingKeywords()
    • isAppendValues

      public boolean isAppendValues()
    • mustCompile

      protected boolean mustCompile()
      Specified by:
      mustCompile in class Expression
    • apply

      public void apply(CallContext ctx) throws Throwable
      Description copied from class: Expression
      Evaluate the expression. This is named apply rather than eval so it is compatible with the full-tail-call calling convention, and we can stash an Expression in CallContext's proc field. FIXME - are we making use of this?
      Overrides:
      apply in class Expression
      Throws:
      Throwable
    • compile

      public void compile(Compilation comp, Target target)
      Specified by:
      compile in class Expression
    • compile

      public static void compile(ApplyExp exp, Compilation comp, Target target)
    • compileArgsToContext

      public static void compileArgsToContext(ApplyExp exp, Method setupMethod, Compilation comp)
    • deepCopy

      public Expression deepCopy(IdentityHashTable mapper)
      Overrides:
      deepCopy in class Expression
    • visit

      protected <R, D> R visit(ExpVisitor<R,D> visitor, D d)
      Overrides:
      visit in class Expression
    • visitArgs

      public void visitArgs(InlineCalls visitor)
    • visitArgs

      public void visitArgs(InlineCalls visitor, LambdaExp lexp)
    • visitChildren

      protected <R, D> void visitChildren(ExpVisitor<R,D> visitor, D d)
      Overrides:
      visitChildren in class Expression
    • print

      public void print(gnu.kawa.io.OutPort out)
      Specified by:
      print in class Expression
    • side_effects

      public boolean side_effects()
      Description copied from class: Expression
      True if evaluating may have side-effects.
      Overrides:
      side_effects in class Expression
    • calculateType

      protected Type calculateType()
      Overrides:
      calculateType in class Expression
    • isInlineable

      public static boolean isInlineable(Procedure proc)
    • inlineIfConstant

      public final Expression inlineIfConstant(Procedure proc, InlineCalls visitor)
    • inlineIfConstant

      public final Expression inlineIfConstant(Procedure proc, SourceMessages messages)
      Inline this ApplyExp if parameters are constant.
      Parameters:
      proc - the procedure bound to this.func.
      Returns:
      the constant result (as a QuoteExp) if inlining was possible; otherwise this ApplyExp. If applying proc throws an exception, print a warning on walker.messages.
    • toString

      public String toString()
      Overrides:
      toString in class Expression