Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.saxonica.codegen
Class ExpressionCompiler

    java.lang.Object
      com.saxonica.codegen.ExpressionCompiler

Direct Known Subclasses:
  ContextItemCompiler, ErrorCompiler, ErrorExpressionCompiler, IfExpressionCompiler, LiteralCompiler, ParentNodeExpressionCompiler, PushExpressionCompiler, RootExpressionCompiler, SequenceExpressionCompiler, SingletonExpressionCompiler, ToBooleanCompiler, TraceCompiler

    public abstract class ExpressionCompiler

extends Object

This abstract class represents the compiler (that is, Java code generator) for a particular kind of expression on the expression tree. The expression compiler is called by the `CompilerService` working its way down the expression tree in a top down fashion: there is a one-to-one correspondence between the classes implementing the expression on the expression tree and the compiler object used to generate Java code fragments. Various methods are supplied to compile expressions; exactly one of them is called, depending on the context in which the expression appears.

Constructor Summary
`ExpressionCompiler()`

Method Summary
`void` | `compileAsLoop(CompilerService compiler, Expression expr, LoopAction action)` Compile an expression in the form of a loop.
`void` | `compileAsLoopWithContext(CompilerService compiler, Expression expr, LoopAction action)` Compile an expression in the form of a loop, maintaining the current context while iterating.
`abstract void` | `compilePush(CompilerService compiler, Expression exp)` Generate Java code to execute the expression in push mode, that is, code to write events to the current output Receiver
`abstract String` | `compileToCharSequence(CompilerService compiler, Expression expr)` Generate Java code to evaluate the expression as a CharSequence
`abstract String` | `compileToEffectiveBooleanValue(CompilerService compiler, Expression expr, ReturnAction options)` Generate Java code to evaluate the effective boolean value of the expression
`abstract String` | `compileToItem(CompilerService compiler, Expression exp)` Generate Java code to evaluate the expression as an Item
`abstract String` | `compileToIterator(CompilerService compiler, Expression exp)` Generate Java code to evaluate the expression as a SequenceIterator
`String` | `compileToValueRepresentation(CompilerService compiler, Expression expr)` Generate Java code to evaluate the expression as a ValueRepresentation

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ExpressionCompiler

    public ExpressionCompiler()

Method Detail

### compilePush

    public abstract void compilePush(CompilerService compiler,
                                     Expression exp)

  Generate Java code to execute the expression in push mode, that is, code to write events to the current output Receiver

  Parameters:
    `compiler` - the compiler service
    `exp` - the expression to be compiled

### compileToItem

    public abstract String compileToItem(CompilerService compiler,
                                         Expression exp)

  Generate Java code to evaluate the expression as an Item

  Parameters:
    `compiler` - the compiler service
    `exp` - the expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared) which will be of class `Item`, and which will hold the value of the expression at run-time (or hold null, representing an empty sequence).

### compileToIterator

    public abstract String compileToIterator(CompilerService compiler,
                                             Expression exp)

  Generate Java code to evaluate the expression as a SequenceIterator

  Parameters:
    `compiler` - the compiler service
    `exp` - the expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared) which will be of class `SequenceIterator`, and which at run-time will hold an iterator over the the value of the expression

### compileToEffectiveBooleanValue

    public abstract String compileToEffectiveBooleanValue(CompilerService compiler,
                                                          Expression expr,
                                                          ReturnAction options)

  Generate Java code to evaluate the effective boolean value of the expression

  Parameters:
    `compiler` - the compiler service
    `expr` - the expression to be compiled
    `options` - indicates how the result is to be returned
  Returns:
    the result depends on the supplied value of the options argument. If options is a JavaDeclaration, the code must declare a Java variable and return the name of this variable. If options is a JavaAssignment, the code must assign the value to an existing Java variable. If options is a Return, the code must generate a return statement that returns the value of the boolean (in which case the result of this method is null).

### compileToCharSequence

    public abstract String compileToCharSequence(CompilerService compiler,
                                                 Expression expr)

  Generate Java code to evaluate the expression as a CharSequence

  Parameters:
    `compiler` - the compiler service
    `expr` - the expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared, or a string literal) which will be of class `CharSequence`, and which will hold the string value of the expression at run-time

### compileToValueRepresentation

    public String compileToValueRepresentation(CompilerService compiler,
                                               Expression expr)

  Generate Java code to evaluate the expression as a ValueRepresentation

  Parameters:
    `compiler` - the compiler service
    `expr` - the expression to be compiled
  Returns:
    a simple Java expression (usually the name of a variable that has been declared) which will be of class `ValueRepresentation`, and which at run-time will hold the value of the expression

### compileAsLoop

    public void compileAsLoop(CompilerService compiler,
                              Expression expr,
                              LoopAction action)

  Compile an expression in the form of a loop. This generates Java code that loops over the items in the result of the expression; the body of the loop is constructed by a callback to the supplied LoopAction (which will handle nested expressions)

  Parameters:
    `compiler` - the CompilerService
    `expr` - the expression to be compiled
    `action` - the action to be taken to compile code that processes each item in the sequence returned by the expression

### compileAsLoopWithContext

    public void compileAsLoopWithContext(CompilerService compiler,
                                         Expression expr,
                                         LoopAction action)

  Compile an expression in the form of a loop, maintaining the current context while iterating. This generates Java code that loops over the items in the result of the expression; the body of the loop is constructed by a callback to the supplied LoopAction (which will handle nested expressions)

  Parameters:
    `compiler` - the CompilerService
    `expr` - the expression to be compiled
    `action` - the action to be taken to process each item in the sequence returned by the expression

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) Michael H. Kay. All rights reserved.