
com.thesett.aima.logic.fol.wam.nativemachine.WAMResolvingNativeMachine Maven / Gradle / Ivy
/*
* 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.nativemachine;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Iterator;
import java.util.Set;
import com.thesett.aima.logic.fol.Variable;
import com.thesett.aima.logic.fol.wam.compiler.WAMCallPoint;
import com.thesett.aima.logic.fol.wam.machine.WAMInternalRegisters;
import com.thesett.aima.logic.fol.wam.machine.WAMMemoryLayout;
import com.thesett.aima.logic.fol.wam.machine.WAMResolvingMachine;
import com.thesett.common.error.ImplementationUnavailableException;
import com.thesett.common.error.NotImplementedException;
import com.thesett.common.util.SequenceIterator;
import com.thesett.common.util.doublemaps.SymbolTable;
import com.thesett.common.util.doublemaps.SymbolTableImpl;
/**
* WAMResolvingNativeMachine is a byte code interpreter for WAM implemented externally as native code. The code here is
* a wrapper for the native library. It provides a method to get an instance of this l3 machine that can throw a checked
* exception when the native library is not available.
*
* The other interesting feature of this machine, is that the byte code is passed to the native library in a direct
* byte buffer. The intention is that the compiler (or in the future a loader) outputs compiled code into the machine
* which holds it in a direct byte buffer. No copying accross will be done prior to execution.
*
*
CRC Card
* Responsibilities Collaborations
* Execute compiled WAM programs and queries.
* Provide access to the heap.
*
*
* @author Rupert Smith
*/
public class WAMResolvingNativeMachine extends WAMResolvingMachine
{
/** Used for tracing instruction executions. */
private static final java.util.logging.Logger trace =
java.util.logging.Logger.getLogger("TRACE.WAMResolvingNativeMachine");
/** Defines the initial code area size for the virtual machine. */
private static final int CODE_SIZE = 10000;
/** Used to record whether the native implementation library was successfully loaded. */
private static boolean libraryFound = false;
/** Used to record whether an attempt to load the native library has been made. */
private static boolean libraryLoadAttempted = false;
/**
* Creates a unifying virtual machine for WAM with default heap sizes.
*
* @param symbolTable The symbol table for the machine.
*/
public WAMResolvingNativeMachine(SymbolTable© 2015 - 2025 Weber Informatics LLC | Privacy Policy