
com.thesett.aima.logic.fol.bytecode.BaseCodeMachine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logic Show documentation
Show all versions of logic Show documentation
Rich syntax trees and parsers for working with first order logic.
/*
* 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.bytecode;
import java.nio.ByteBuffer;
import com.thesett.aima.logic.fol.LinkageException;
import com.thesett.aima.logic.fol.VariableAndFunctorInterner;
import com.thesett.common.util.SizeableList;
import com.thesett.common.util.doublemaps.SymbolTable;
import com.thesett.common.util.visitor.Acceptor;
/**
* BaseCodeMachine is a base for deriving abstract machines that hold executable code in a byte buffer, and use a
* compiled entity type that can provide an instruction listing, and an encoder over that type of instructions to
* provide a set of basic operations for dealing with encoding of the byte code into the machine, and tracking callable
* entry points into the code.
*
*
CRC Card
* Responsibilities Collaborations
* Accept byte code into the machine.
* Resolve an interned name onto a call point.
* Allow a call point for a procedure to be reserved.
* Provide a byte buffer and current insertion point for new code.
*
*
* @author Rupert Smith
* @todo No garbage collection of replaced call points is done. Should eventually remove unused code, and compact the
* still in use code buffer. Compacting the buffer is not straightforward as call points will need to be
* translated. Either keep track of all call points within the code buffer and translate them on compaction, or
* when a code buffer is to be garbage collected, simply create a new one and re-insert all live procedures into
* the new buffer.
*/
public abstract class BaseCodeMachine, C extends InstructionListing> extends BaseMachine
implements CodeMachine© 2015 - 2025 Weber Informatics LLC | Privacy Policy