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 Detail

      • 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.
    • Method Detail

      • getFunction

        public final Expression getFunction()
      • getArgCount

        public final int getArgCount()
      • setFunction

        public void setFunction​(Expression func)
      • setFunction

        public void setFunction​(Procedure proc)
      • setArgs

        public void setArgs​(Expression[] args)
      • setArg

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

        public final boolean isTailCall()
      • setTailCall

        public final void setTailCall​(boolean tailCall)
      • 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()
      • 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
      • visitArgs

        public void visitArgs​(InlineCalls visitor)
      • 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
      • isInlineable

        public static boolean isInlineable​(Procedure proc)
      • 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.