01: /******************************************************************
02: * File: GenericChoiceFrame.java
03: * Created by: Dave Reynolds
04: * Created on: 07-Aug-2003
05: *
06: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
07: * [See end of file]
08: * $Id: GenericChoiceFrame.java,v 1.7 2008/01/02 12:06:17 andy_seaborne Exp $
09: *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.impl;
10:
11: /**
12: * Core properties of choice frames used use to represent the OR state of
13: * the backtracking search. Specific variants of this need to preserve additional
14: * choice state.
15: * <p>
16: * This is used in the inner loop of the interpreter and so is a pure data structure
17: * not an abstract data type and assumes privileged access to the interpreter state.
18: * </p>
19: *
20: * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
21: * @version $Revision: 1.7 $ on $Date: 2008/01/02 12:06:17 $
22: */
23: public class GenericChoiceFrame extends FrameObject {
24:
25: /** The environment frame describing the state of the AND tree at this choice point */
26: EnvironmentFrame envFrame;
27:
28: /** The top of the trail stack at the time of the call */
29: int trailIndex;
30:
31: /** The continuation program counter offet in the parent clause's byte code */
32: int cpc;
33:
34: /** The continuation argument counter offset in the parent clause's arg stream */
35: int cac;
36:
37: /**
38: * Initialize a choice point to preserve the current context of the given intepreter
39: * and then call the given set of predicates.
40: * @param interpreter the LPInterpreter whose state is to be preserved
41: */
42: public void init(LPInterpreter interpreter) {
43: envFrame = interpreter.envFrame;
44: trailIndex = interpreter.trail.size();
45: }
46:
47: /**
48: * Set the continuation point for this frame.
49: */
50: public void setContinuation(int pc, int ac) {
51: cpc = pc;
52: cac = ac;
53: }
54:
55: }
56:
57: /*
58: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
59: All rights reserved.
60:
61: Redistribution and use in source and binary forms, with or without
62: modification, are permitted provided that the following conditions
63: are met:
64:
65: 1. Redistributions of source code must retain the above copyright
66: notice, this list of conditions and the following disclaimer.
67:
68: 2. Redistributions in binary form must reproduce the above copyright
69: notice, this list of conditions and the following disclaimer in the
70: documentation and/or other materials provided with the distribution.
71:
72: 3. The name of the author may not be used to endorse or promote products
73: derived from this software without specific prior written permission.
74:
75: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
76: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
77: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
78: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
79: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
80: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
81: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
82: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
83: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
84: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85: */
|