Class RuleClauseCode

java.lang.Object
org.apache.jena.reasoner.rulesys.impl.RuleClauseCode

public class RuleClauseCode extends Object
Object used to hold the compiled bytecode stream for a single rule clause. This uses a slightly WAM-like code stream but gluing of the clauses together into disjunctions is done in the interpreter loop so a complete predicate is represented as a list of RuleClauseCode objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
    Allocate a new environment frame
    static final byte
    call a built-in operation defined by a rule clause (clauseIndex(
    static final byte
    call a predicate code object (predicateCodeList)
    static final byte
    call a predicate code object with run time indexing (predicateCodeList)
    static final byte
    call a table code object ()
    static final byte
    call a pure triple match (predicate)
    static final byte
    call a table code object from a wildcard ()
    static final byte
    reset an argument to an unbound variable (Ai)
    static final byte
    reset a temp variable to an unbound variable (Ti)
    static final byte
    reset a permanent variable to an unbound variable (Yi)
    static final byte
    fetch constant argument (const, Ai)
    static final byte
    deconstruct a functor argument (functor)
    static final byte
    fetch temporary variable argument (Ti, Ai)
    static final byte
    fetch permanent variable argument, first occurance (Yi, Ai)
    static final byte
    variant on CALL_PREDICATE using the last call optimization, only current used in chain rules
    static final byte
    create a functor object from a rule template (templateFunctor)
    static final int
    The maximum number of argument variables allowed in a single goal Future refactorings will remove this restriction.
    static final int
    The maximum number of permanent variables allowed in a single rule clause.
    static final int
    The maximum number of temporary variables allowed in a single rule clause.
    static final byte
    return from a call, proceeed along AND tree
    static final byte
    put constant value into call parameter (const, Ai)
    static final byte
    put a dereferenced permanent variable into call parameter ready for BUILTIN call (Yi, Ai)
    static final byte
    put permanaent variable into call parameter, first occurance (Yi, Ai)
    static final byte
    put temp variable into call parameter (Ti, Ai)
    static final byte
    put permanaent variable into call parameter (Yi, Ai)
    Dummy code block which just returns
    static final byte
    Test if an argument is bound (Ai)
    static final byte
    Test if an argument is unbound (Ai)
    static final byte
    fetch temporary variable argument, later occurance (Ti, Ai)
    static final byte
    fetch permanent variable argument, later occurance (Yi, Ai)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    compile(LPRuleStore ruleStore)
    Compile the rule into byte code.
    Return the argument vector associated with this clauses' byte codes.
    byte[]
    Return the byte code vector for this clause.
    Return the rule from which this code block was compiled.
    static void
    main(String[] args)
    Debug support - not unit testing.
    void
    Debug helper - list the code to a stream
    int
    termIndex(int pc)
    Translate a program counter offset to the index of the corresponding body term (or -1 if a head term or a dummy rule).
    Print clause as rule for tracing.

    Methods inherited from class java.lang.Object

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

    • GET_CONSTANT

      public static final byte GET_CONSTANT
      fetch constant argument (const, Ai)
      See Also:
    • GET_VARIABLE

      public static final byte GET_VARIABLE
      fetch permanent variable argument, first occurance (Yi, Ai)
      See Also:
    • UNIFY_VARIABLE

      public static final byte UNIFY_VARIABLE
      fetch permanent variable argument, later occurance (Yi, Ai)
      See Also:
    • GET_TEMP

      public static final byte GET_TEMP
      fetch temporary variable argument (Ti, Ai)
      See Also:
    • UNIFY_TEMP

      public static final byte UNIFY_TEMP
      fetch temporary variable argument, later occurance (Ti, Ai)
      See Also:
    • PUT_CONSTANT

      public static final byte PUT_CONSTANT
      put constant value into call parameter (const, Ai)
      See Also:
    • PUT_NEW_VARIABLE

      public static final byte PUT_NEW_VARIABLE
      put permanaent variable into call parameter, first occurance (Yi, Ai)
      See Also:
    • PUT_VARIABLE

      public static final byte PUT_VARIABLE
      put permanaent variable into call parameter (Yi, Ai)
      See Also:
    • PUT_DEREF_VARIABLE

      public static final byte PUT_DEREF_VARIABLE
      put a dereferenced permanent variable into call parameter ready for BUILTIN call (Yi, Ai)
      See Also:
    • PUT_TEMP

      public static final byte PUT_TEMP
      put temp variable into call parameter (Ti, Ai)
      See Also:
    • CALL_PREDICATE

      public static final byte CALL_PREDICATE
      call a predicate code object (predicateCodeList)
      See Also:
    • GET_FUNCTOR

      public static final byte GET_FUNCTOR
      deconstruct a functor argument (functor)
      See Also:
    • CALL_PREDICATE_INDEX

      public static final byte CALL_PREDICATE_INDEX
      call a predicate code object with run time indexing (predicateCodeList)
      See Also:
    • CALL_TRIPLE_MATCH

      public static final byte CALL_TRIPLE_MATCH
      call a pure triple match (predicate)
      See Also:
    • LAST_CALL_PREDICATE

      public static final byte LAST_CALL_PREDICATE
      variant on CALL_PREDICATE using the last call optimization, only current used in chain rules
      See Also:
    • CALL_TABLED

      public static final byte CALL_TABLED
      call a table code object ()
      See Also:
    • CALL_WILD_TABLED

      public static final byte CALL_WILD_TABLED
      call a table code object from a wildcard ()
      See Also:
    • PROCEED

      public static final byte PROCEED
      return from a call, proceeed along AND tree
      See Also:
    • MAKE_FUNCTOR

      public static final byte MAKE_FUNCTOR
      create a functor object from a rule template (templateFunctor)
      See Also:
    • CALL_BUILTIN

      public static final byte CALL_BUILTIN
      call a built-in operation defined by a rule clause (clauseIndex(
      See Also:
    • CLEAR_VARIABLE

      public static final byte CLEAR_VARIABLE
      reset a permanent variable to an unbound variable (Yi)
      See Also:
    • CLEAR_TEMP

      public static final byte CLEAR_TEMP
      reset a temp variable to an unbound variable (Ti)
      See Also:
    • CLEAR_ARG

      public static final byte CLEAR_ARG
      reset an argument to an unbound variable (Ai)
      See Also:
    • ALLOCATE

      public static final byte ALLOCATE
      Allocate a new environment frame
      See Also:
    • TEST_BOUND

      public static final byte TEST_BOUND
      Test if an argument is bound (Ai)
      See Also:
    • TEST_UNBOUND

      public static final byte TEST_UNBOUND
      Test if an argument is unbound (Ai)
      See Also:
    • MAX_PERMANENT_VARS

      public static final int MAX_PERMANENT_VARS
      The maximum number of permanent variables allowed in a single rule clause. Now only relevent for initial holding clause.
      See Also:
    • MAX_ARGUMENT_VARS

      public static final int MAX_ARGUMENT_VARS
      The maximum number of argument variables allowed in a single goal Future refactorings will remove this restriction.
      See Also:
    • MAX_TEMPORARY_VARS

      public static final int MAX_TEMPORARY_VARS
      The maximum number of temporary variables allowed in a single rule clause.
      See Also:
    • returnCodeBlock

      public static RuleClauseCode returnCodeBlock
      Dummy code block which just returns
  • Constructor Details

    • RuleClauseCode

      public RuleClauseCode(Rule rule)
      Constructor.
      Parameters:
      rule - the rule to be compiled
  • Method Details

    • getCode

      public byte[] getCode()
      Return the byte code vector for this clause.
    • getArgs

      public Object[] getArgs()
      Return the argument vector associated with this clauses' byte codes.
    • getRule

      public Rule getRule()
      Return the rule from which this code block was compiled.
    • compile

      public void compile(LPRuleStore ruleStore)
      Compile the rule into byte code.
      Parameters:
      ruleStore - the store of LP rules through which calls to other predicates can be resolved.
    • termIndex

      public int termIndex(int pc)
      Translate a program counter offset to the index of the corresponding body term (or -1 if a head term or a dummy rule).
    • print

      public void print(PrintStream out)
      Debug helper - list the code to a stream
    • toString

      public String toString()
      Print clause as rule for tracing.
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)
      Debug support - not unit testing.