Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright The Sett Ltd, 2005 to 2014.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.thesett.aima.logic.fol.wam.compiler;
 
 
WAMCompiledClause is a clause, that belongs to an WAMCompiledPredicate. Compiled instructions added to the clause fall through onto the parent predicate, and are not held on the compiled clause itself. The compiled clause has a label, which identifies its position within the parent predicate.

CRC Card
Responsibilities Collaborations
Forward added instructions onto the parent predicate.
Hold a label as a position marker for the clause within its containing predicate.

Author(s):
Rupert Smith
 
 public class WAMCompiledClause extends Clause<Functor>
 {
    
The parent predicate to which this compiled clause belongs.
 
     private final WAMCompiledPredicate parent;

    
The interned name of this clauses label.
 
     int label;

    
Indicates that this has been added to a parent predicate already.
 
     private boolean addedToParent = false;

    
Creates a clause within a parent predicate.

Parameters:
parent The parent predicate.
 
     public WAMCompiledClause(WAMCompiledPredicate parent)
     {
         super(nullnull);
         this. = parent;
     }

    
Adds a conjunctive body functor, or head functor, to this clause, along with the instructions that implement it.

Parameters:
body A conjunctive body functor to add to this clause.
instructions A list of instructions to add to the body.
 
     public void addInstructions(Functor bodySizeableList<WAMInstructioninstructions)
     {
         int oldLength;
 
         if (this. == null)
         {
             oldLength = 0;
             this. = new Functor[1];
         }
         else
         {
             oldLength = this..length;
             this. = Arrays.copyOf(this.oldLength + 1);
         }
 
         this.[oldLength] = body;
 
         addInstructionsAndThisToParent(instructions);
     }

    
Adds some instructions sequentially, after any existing instructions, to the clause.

Parameters:
instructions The instructions to add to the clause.
 
     public void addInstructions(SizeableList<WAMInstructioninstructions)
     {
         addInstructionsAndThisToParent(instructions);
     }

    
Adds some instructions to the parent predicate, and also adds this as a clause on the parent, if it has not already been added.

Parameters:
instructions The instructions to add.
    private void addInstructionsAndThisToParent(SizeableList<WAMInstructioninstructions)
    {
        if (!)
        {
            .addInstructions(thisinstructions);
             = true;
        }
        else
        {
            .addInstructions(instructions);
        }
    }
New to GrepCode? Check out our FAQ X