register init (again)

This commit is contained in:
Vítor Santos Costa 2015-07-06 11:54:33 +01:00
parent 2cf9902dfe
commit 421dee6881
8 changed files with 109 additions and 83 deletions

View File

@ -1,83 +0,0 @@
#define YAP_CPP_INTERFACE 1
#include "yapi.hh"
#include "SWI-Stream.h"
YAPPredicate::YAPPredicate(const char *s, Term &tout, yhandle_t &vnames) throw (int) {
CACHE_REGS
BACKUP_MACHINE_REGS();
yhandle_t yvnames = Yap_InitSlot();
Term tout = Yap_StringToTerm(s, strlen(s), Yap_DefaultEncoding(), yvnames, 1200);
if (tout == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
ap = getPred( tout );
RECOVER_MACHINE_REGS();
}
YAPPredicate::YAPPredicate(YAPAtom at) {
CACHE_REGS
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity) {
CACHE_REGS
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,CurrentModule));
} else {LogUpdate
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
}
/// auxiliary routine to find a predicate in the current module.
PredEntry *YAPPredicate::getPred( Term t, Term* &outp ) {
CACHE_REGS
Term m = CurrentModule ;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) {
ap = (PredEntry *)NULL;
outp = (Term *)NULL;
}
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
if (outp) outp = (Term *)NULL;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE));
outp = HR;
HR[0] = RepPair(t)[0];
HR[1] = m;
HR+=2;
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
ap = (PredEntry *)NULL;
outp = (Term *)NULL;
} else {
ap = RepPredProp(PredPropByFunc(f, m));
outp = RepAppl(t)+1;
}
}
{ REGS_LOG( "done H= %p, outp=%p", HR, outp) ; }
return ap;
}
YAPPredicate::YAPPredicate(YAPFunctor f) {
CACHE_REGS
ap = RepPredProp(PredPropByFunc(f.f,CurrentModule));
}
int YAPPredicate::call(YAPTerm t[])
{
YAPQuery q = YAPQuery(*this, t);
int ret;
BACKUP_MACHINE_REGS();
ret = q.next();
q.cut();
q.close();
RECOVER_MACHINE_REGS();
return ret;
}

View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,14 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,24 @@
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,20 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-06-27T18:26:00
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui

7
os/x.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "x.h"
x::x()
{
}

11
os/x.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef X_H
#define X_H
class x
{
public:
x();
};
#endif // X_H