Access Control is now enabled for Gitlab Pages so you can now restrict Pages to authorized users only. If needed, make your website publicly available : Navigate to your project's Settings > General > Visibility and select Everyone in pages section.

Commit 09352f0d authored by Tony Licata's avatar Tony Licata

Converted real_time/1 and useinterpreter/0 builtins into Truffle nodes,...

Converted real_time/1 and useinterpreter/0 builtins into Truffle nodes, created ProloGraalUnaryHeadNode to handle unary builtin head nodes.
parent d30c339a
......@@ -66,6 +66,10 @@ public class ProloGraalLanguage extends TruffleLanguage<ProloGraalContext> {
protected CallTarget parse(ParsingRequest request) {
Source source = request.getSource();
List<ProloGraalQuery> queries = new ArrayList<>();
ProloGraalContext context = this.getContextReference().get();
//we set the context in the builtin structure, because it need it to initialize useinterpreter/0 builtin
ProloGraalBuiltinStructure.setContext(context);
if (request.getArgumentNames().isEmpty()) {
long time = System.currentTimeMillis();
......@@ -76,7 +80,7 @@ public class ProloGraalLanguage extends TruffleLanguage<ProloGraalContext> {
}
}
ProloGraalRuntime runtime = new ProloGraalRuntime(this.getContextReference().get());
ProloGraalRuntime runtime = new ProloGraalRuntime(context);
RootNode eval = new ProloGraalEvalRootNode(this, runtime, queries);
......
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.ProloGraalTypes;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.nodes.ProloGraalBuiltinHeadNode;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.TypeSystemReference;
......@@ -9,12 +9,13 @@ import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrumentation.GenerateWrapper;
import com.oracle.truffle.api.instrumentation.InstrumentableNode;
import com.oracle.truffle.api.instrumentation.ProbeNode;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.NodeUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* Abstract base class for built-ins.
......@@ -60,4 +61,15 @@ public abstract class ProloGraalBuiltinClause extends ProloGraalClause implement
*/
@Override
public abstract ProloGraalClause copy();
/**
* Copy the current head present in the builtin head node.
* @return the head present in the builtin head node child
*/
protected ProloGraalTerm copyHead(){
List<Node> childrens = NodeUtil.findNodeChildren(this);
ProloGraalTerm head = ((ProloGraalBuiltinHeadNode)childrens.get(0)).getValue();
Map<ProloGraalVariable, ProloGraalVariable> newVars = new HashMap<>();
return head.copy(newVars);
}
}
......@@ -2,6 +2,8 @@ package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.builtins.ProloGraalIsOperators;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.nodes.ProloGraalBuiltinHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalIsHeadNode;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
......@@ -118,12 +120,9 @@ public abstract class ProloGraalIsBuiltin extends ProloGraalBuiltinClause {
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
List<Node> childrens = NodeUtil.findNodeChildren(this);
ProloGraalTerm head = ((ProloGraalBuiltinHeadNode)childrens.get(0)).getValue();
Map<ProloGraalVariable, ProloGraalVariable> newVars = new HashMap<>();
ProloGraalTerm copiedHead = head.copy(newVars);
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalIsBuiltinNodeGen.create(newVars, ProloGraalIsHeadNodeGen.create(copiedHead,new ProloGraalSimpleTermNode(headArgs.get(0)),new ProloGraalSimpleTermNode(headArgs.get(1))));
return ProloGraalIsBuiltinNodeGen.create(copiedHead.getVariables(), ProloGraalIsHeadNodeGen.create(copiedHead,new ProloGraalSimpleTermNode(headArgs.get(0)),new ProloGraalSimpleTermNode(headArgs.get(1))));
}
// override getHead method to handle AST node head
......
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.nodes.ProloGraalBuiltinHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalPolyglotEvalHeadNode;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
......@@ -55,12 +57,9 @@ public abstract class ProloGraalPolyglotEvalBuiltin extends ProloGraalBuiltinCla
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
List<Node> childrens = NodeUtil.findNodeChildren(this);
ProloGraalTerm head = ((ProloGraalBuiltinHeadNode)childrens.get(0)).getValue();
Map<ProloGraalVariable, ProloGraalVariable> newVars = new HashMap<>();
ProloGraalTerm copiedHead = head.copy(newVars);
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalPolyglotEvalBuiltinNodeGen.create(newVars, ProloGraalPolyglotEvalHeadNodeGen.create(copiedHead,new ProloGraalSimpleTermNode(headArgs.get(0)),new ProloGraalSimpleTermNode(headArgs.get(1)),new ProloGraalSimpleTermNode(headArgs.get(2))));
return ProloGraalPolyglotEvalBuiltinNodeGen.create(copiedHead.getVariables(), ProloGraalPolyglotEvalHeadNodeGen.create(copiedHead,new ProloGraalSimpleTermNode(headArgs.get(0)),new ProloGraalSimpleTermNode(headArgs.get(1)),new ProloGraalSimpleTermNode(headArgs.get(2))));
}
// override getHead method to handle AST node head
......
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
* Class representing the var/1(X) built-in predicate.
* Is unifiable only if X is an unbound variable.
* @author Martin Spoto
* Class representing the real_time/1(X) built-in predicate.
* Give the current real time spent since this class was built.
* Will return a success if X unifies with the real_time value.
* @author Tony Licata
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalRealTimeBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalRealTimeBuiltin extends ProloGraalBuiltinClause {
private static final long startTime = System.currentTimeMillis();
public static final long startTime = System.currentTimeMillis();
private ProloGraalVariable arg; // the variable A in real_time(A). We keep it to use it in the execute method
public ProloGraalRealTimeBuiltin() {
......@@ -27,23 +30,28 @@ public final class ProloGraalRealTimeBuiltin extends ProloGraalBuiltinClause {
head.setFunctor(new ProloGraalAtom(getVariables(), "real_time"));
// we create and store the variables to access them more easily later in the execute method
arg = new ProloGraalVariable(getVariables(), "A");
arg = new ProloGraalVariable(getVariables(), "Arg");
head.addSubterm(arg);
setHead(head);
}
@Override
public ProloGraalBoolean executeBuiltin(VirtualFrame frame){
if(arg.isNumber() || arg.isBound() && arg.getRootValue().isVariable())
if(arg.unify(new ProloGraalDoubleNumber(getVariables(),System.currentTimeMillis()-startTime)))
return new ProloGraalSuccess(getVariables());
return new ProloGraalFailure();
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the custom head
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalRealTimeBuiltin();
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalRealTimeBuiltinNodeGen.create(ProloGraalRealTimeHeadNodeGen.create(getHead().copy(new HashMap<>()),new ProloGraalSimpleTermNode(headArgs.get(0))));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalRealTimeHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
}
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.nodes.ProloGraalPolyglotEvalHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalUseInterpreterHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalUseInterpreterHeadNodeGen;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeUtil;
import java.util.HashMap;
......@@ -12,7 +17,7 @@ import java.util.HashMap;
* @author Tony Licata
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalUseInterpreterBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalUseInterpreterBuiltin extends ProloGraalBuiltinClause {
private final ProloGraalContext context; // we keep the context for the copy method
......@@ -23,24 +28,40 @@ public final class ProloGraalUseInterpreterBuiltin extends ProloGraalBuiltinClau
// create the head of this clause
// since we do not need custom unification, a simple structure is enough
ProloGraalStructure useInterpreterStructure = new ProloGraalStructure(getVariables());
ProloGraalAtom head = new ProloGraalAtom(getVariables(),"useinterpreter");
setHead(head);
useInterpreterStructure.setFunctor(head);
setHead(useInterpreterStructure);
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
/**
* Launch an interpreter
*/
/*
@Override
public ProloGraalBoolean executeBuiltin(VirtualFrame frame) {
Truffle.getRuntime().createCallTarget(context.getInterpreterNode()).call();
return new ProloGraalSuccess(getVariables());
}
}*/
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalUseInterpreterBuiltin(context);
return ProloGraalUseInterpreterBuiltinNodeGen.create(context,ProloGraalUseInterpreterHeadNodeGen.create(getHead().copy(new HashMap<>()),context));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalUseInterpreterHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
}
......@@ -8,7 +8,7 @@ import com.oracle.truffle.api.instrumentation.GenerateWrapper;
import com.oracle.truffle.api.instrumentation.InstrumentableNode;
import com.oracle.truffle.api.instrumentation.ProbeNode;
import com.oracle.truffle.api.nodes.NodeInfo;
import java.util.List;
import java.util.Map;
@TypeSystemReference(ProloGraalTypes.class)
......@@ -18,13 +18,6 @@ public abstract class ProloGraalBuiltinHeadNode extends ProloGraalGenericNode im
protected final ProloGraalTerm<?> value;
/*
public ProloGraalBuiltinHeadNode(){
ProloGraalStructure tempVal = new ProloGraalStructure(new HashMap<>());
tempVal.setFunctor(new ProloGraalAtom(new HashMap<>(),"builtinHeadNode"));
value = tempVal;
}*/
public ProloGraalBuiltinHeadNode(ProloGraalBuiltinHeadNode other){
this.value=other.value;
}
......
package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.builtins.predicates.ProloGraalIsBuiltin;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.NodeUtil;
......@@ -15,7 +13,6 @@ import org.graalvm.polyglot.Value;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@NodeInfo(shortName = "ProloGraalPolyglotEvalHeadNode")
public abstract class ProloGraalPolyglotEvalHeadNode extends ProloGraalTernaryHeadNode {
......
package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.builtins.predicates.ProloGraalRealTimeBuiltin;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.NodeUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@NodeInfo(shortName = "ProloGraalUseInterpreterHeadNode")
public abstract class ProloGraalRealTimeHeadNode extends ProloGraalUnaryHeadNode {
public ProloGraalRealTimeHeadNode(ProloGraalTerm<?> value) {
super(value);
}
@Specialization
@CompilerDirectives.TruffleBoundary
public ProloGraalBoolean returnValue(ProloGraalTerm arg) {
System.out.println(arg);
if(arg.isNumber() || arg.isVariable())
if(arg.unify(new ProloGraalDoubleNumber(new HashMap<>(),System.currentTimeMillis()-ProloGraalRealTimeBuiltin.startTime)))
return new ProloGraalSuccess();
return new ProloGraalFailure();
}
@Override
public ProloGraalBuiltinHeadNode copyBuiltin(Map<ProloGraalVariable, ProloGraalVariable> variables){
List<Node> childrens = NodeUtil.findNodeChildren(this);
ProloGraalTermNode child = (ProloGraalTermNode) childrens.get(0);
return ProloGraalRealTimeHeadNodeGen.create(value.copy(variables), child.copyTermNode(variables));
}
}
......@@ -3,9 +3,11 @@ package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.runtime.ProloGraalTerm;
import ch.heiafr.prolograal.runtime.ProloGraalVariable;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import java.util.Map;
@NodeInfo(shortName = "ProloGraalSimpleTermNode")
public class ProloGraalSimpleTermNode extends ProloGraalTermNode {
public ProloGraalSimpleTermNode(ProloGraalTerm value){
......
......@@ -4,7 +4,7 @@ import ch.heiafr.prolograal.runtime.ProloGraalTerm;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.nodes.NodeInfo;
@NodeInfo(shortName = "ProloGraalBinaryHeadNode")
@NodeInfo(shortName = "ProloGraalTernaryHeadNode")
@NodeChild(value = "left", type = ProloGraalTermNode.class)
@NodeChild(value = "center", type = ProloGraalTermNode.class)
@NodeChild(value = "right", type = ProloGraalTermNode.class)
......
package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.runtime.ProloGraalTerm;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.nodes.NodeInfo;
@NodeInfo(shortName = "ProloGraalUnaryHeadNode")
@NodeChild(value = "child", type = ProloGraalTermNode.class)
public abstract class ProloGraalUnaryHeadNode extends ProloGraalBuiltinHeadNode {
public ProloGraalUnaryHeadNode(ProloGraalTerm<?> value) {
super(value);
}
}
package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.builtins.predicates.ProloGraalIsBuiltin;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.NodeUtil;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@NodeInfo(shortName = "ProloGraalUseInterpreterHeadNode")
public abstract class ProloGraalUseInterpreterHeadNode extends ProloGraalBuiltinHeadNode {
private final ProloGraalContext context; // we keep the context for the copy method
public ProloGraalUseInterpreterHeadNode(ProloGraalTerm<?> value, ProloGraalContext context) {
super(value);
this.context = context;
}
@Specialization
@CompilerDirectives.TruffleBoundary
public ProloGraalBoolean returnValue() {
Truffle.getRuntime().createCallTarget(context.getInterpreterNode()).call();
return new ProloGraalSuccess();
}
@Override
public ProloGraalBuiltinHeadNode copyBuiltin(Map<ProloGraalVariable, ProloGraalVariable> variables){
return ProloGraalUseInterpreterHeadNodeGen.create(value.copy(variables), context);
}
}
package ch.heiafr.prolograal.parser;
import ch.heiafr.prolograal.ProloGraalLanguage;
import ch.heiafr.prolograal.builtins.predicates.ProloGraalBuiltinClause;
import ch.heiafr.prolograal.builtins.predicates.ProloGraalIsBuiltin;
import ch.heiafr.prolograal.nodes.ProloGraalBuiltinHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalSimpleTermNode;
import ch.heiafr.prolograal.nodes.ProloGraalTermNode;
import ch.heiafr.prolograal.runtime.*;
......@@ -182,7 +180,7 @@ public class ProloGraalListenerImpl extends ProloGraalBaseListener {
public void exitAtom(ProloGraalParser.AtomContext ctx) {
// if the atom represent a builtin clause, it will be built as it, else, the atom won't change.
//System.out.println(elements.peek());
//buildBuiltin(elements.peek());
buildBuiltin(elements.peek());
}
@Override
......@@ -259,7 +257,9 @@ public class ProloGraalListenerImpl extends ProloGraalBaseListener {
if(ProloGraalBuiltinStructure.getBuiltinsInitializers().containsKey(functor.getName())){
builtinStructure = ProloGraalBuiltinStructure.getBuiltinsInitializers().get(functor.getName()).apply(term);
}else if(ProloGraalIsBuiltin.getOperations().containsKey(functor)){ //if the structure is an is/2 operator (by functor name), build it
builtinStructure = ProloGraalBuiltinStructure.getBuiltinsInitializers().get("isOp").apply(term);
String functorName = functor.getName();
if(term.isStructure()) //we currently not allow use of constants for is/2 builtin (e, pi, tau), currently not working
builtinStructure = ProloGraalBuiltinStructure.getBuiltinsInitializers().get("isOp").apply(term);
}
if(builtinStructure != null){
elements.pop();
......
package ch.heiafr.prolograal.runtime;
import ch.heiafr.prolograal.ProloGraalLanguage;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.nodes.ProloGraalBuiltinHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalIsHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalIsOpTermNode;
import ch.heiafr.prolograal.nodes.ProloGraalPolyglotEvalHeadNode;
import java.util.HashMap;
import java.util.List;
......@@ -11,6 +16,13 @@ public class ProloGraalBuiltinStructure extends ProloGraalStructure{
private final ProloGraalBuiltinHeadNode builtin;
//we save the context statically to use it later in useinterpreter/0 builtin
private static ProloGraalContext context = null;
public static void setContext(ProloGraalContext context){
ProloGraalBuiltinStructure.context = context;
}
public ProloGraalBuiltinStructure(ProloGraalBuiltinHeadNode builtin){
super(new HashMap<>());
this.builtin = builtin;
......@@ -44,7 +56,9 @@ public class ProloGraalBuiltinStructure extends ProloGraalStructure{
private static Map<String, Function<ProloGraalTerm, ProloGraalStructure>> fillBuiltinsInitializers(){
Map<String, Function<ProloGraalTerm, ProloGraalStructure>> initializers = new HashMap<>();
initializers.put("is", ProloGraalBuiltinStructure::initializeIs);
initializers.put("useinterpreter", ProloGraalBuiltinStructure::initializeUseInterpreter);
initializers.put("polyglot_eval", ProloGraalBuiltinStructure::initializePolyglotEval);
initializers.put("real_time", ProloGraalBuiltinStructure::initializeRealTime);
initializers.put("isOp", ProloGraalBuiltinStructure::initializeIsOp);
return initializers;
}
......@@ -68,6 +82,23 @@ public class ProloGraalBuiltinStructure extends ProloGraalStructure{
return new ProloGraalBuiltinStructure(polyglotEvalTerm.asStructure(),polyglotEvalBuiltinHead);
}
public static ProloGraalBuiltinStructure initializeUseInterpreter(ProloGraalTerm useInterpreterTerm){
if( !(useInterpreterTerm.isAtom()) )
return null;
ProloGraalUseInterpreterHeadNode useInterpreterBuiltinHead = ProloGraalUseInterpreterHeadNodeGen.create(useInterpreterTerm, context);
ProloGraalStructure useInterpreterStructure = new ProloGraalStructure(useInterpreterTerm.getVariables());
useInterpreterStructure.setFunctor(useInterpreterTerm.asAtom());
return new ProloGraalBuiltinStructure(useInterpreterStructure,useInterpreterBuiltinHead);
}
public static ProloGraalBuiltinStructure initializeRealTime(ProloGraalTerm realTimeTerm){
if( !(realTimeTerm.isStructure() && realTimeTerm.asStructure().getArity() == 1) )
return null;
List<ProloGraalTerm<?>> realTimeArgs = realTimeTerm.asStructure().getArguments();
ProloGraalRealTimeHeadNode realTimeBuiltinHead = ProloGraalRealTimeHeadNodeGen.create(realTimeTerm,buildTermNodeForIsOp(realTimeArgs.get(0)));
return new ProloGraalBuiltinStructure(realTimeTerm.asStructure(),realTimeBuiltinHead);
}
public static ProloGraalIsOpStructure initializeIsOp(ProloGraalTerm isOpTerm){
if( !(isOpTerm.isStructure() || isOpTerm.isAtom()) )
return null;
......
......@@ -2,6 +2,8 @@ package ch.heiafr.prolograal.runtime;
import ch.heiafr.prolograal.builtins.predicates.*;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.nodes.ProloGraalIsHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalPolyglotEvalHeadNode;
import java.util.*;
......@@ -50,14 +52,10 @@ public final class ProloGraalRuntime {
HashMap<ProloGraalVariable,ProloGraalVariable> isVars = new HashMap<>();
ProloGraalStructure isHead = new ProloGraalStructure(isVars);
isHead.setFunctor(new ProloGraalAtom(isVars, "is"));
ProloGraalVariable isArg = new ProloGraalVariable(isVars, "Left");
isHead.addSubterm(isArg);
ProloGraalVariable isArg2 = new ProloGraalVariable(isVars, "Right");
isHead.addSubterm(isArg2);
......@@ -67,17 +65,12 @@ public final class ProloGraalRuntime {
clauses.put(isBuiltin.getHead(), Collections.singletonList(isBuiltin));
HashMap<ProloGraalVariable,ProloGraalVariable> polyglotEvalVars = new HashMap<>();
ProloGraalStructure polyglotEvalHead = new ProloGraalStructure(polyglotEvalVars);
polyglotEvalHead.setFunctor(new ProloGraalAtom(polyglotEvalVars, "polyglot_eval"));
ProloGraalVariable pEarg1 = new ProloGraalVariable(polyglotEvalVars, "Left");
polyglotEvalHead.addSubterm(pEarg1);
ProloGraalVariable pEarg2 = new ProloGraalVariable(polyglotEvalVars, "Center");
polyglotEvalHead.addSubterm(pEarg2);
ProloGraalVariable pEarg3 = new ProloGraalVariable(polyglotEvalVars, "Right");
polyglotEvalHead.addSubterm(pEarg3);
......@@ -86,7 +79,13 @@ public final class ProloGraalRuntime {
ProloGraalClause polyglotEvalBuiltin = ProloGraalPolyglotEvalBuiltinNodeGen.create(polyglotEvalVars, polyglotEvalHeadNode);
clauses.put(polyglotEvalBuiltin.getHead(), Collections.singletonList(polyglotEvalBuiltin));
ProloGraalClause useinterpreterBuiltin = new ProloGraalUseInterpreterBuiltin(context);
HashMap<ProloGraalVariable,ProloGraalVariable> useInterpreterVars = new HashMap<>();
ProloGraalStructure useInterpreterStructure = new ProloGraalStructure(useInterpreterVars);
useInterpreterStructure.setFunctor(new ProloGraalAtom(useInterpreterVars,"useinterpreter"));
ProloGraalUseInterpreterHeadNode useInterpreterHeadNode = ProloGraalUseInterpreterHeadNodeGen.create(useInterpreterStructure,context);
ProloGraalClause useinterpreterBuiltin = ProloGraalUseInterpreterBuiltinNodeGen.create(context,useInterpreterHeadNode);
clauses.put(useinterpreterBuiltin.getHead(), Collections.singletonList(useinterpreterBuiltin));
ProloGraalClause consultStringBuiltin = new ProloGraalConsultStringBuiltin(context);
......@@ -110,7 +109,15 @@ public final class ProloGraalRuntime {
ProloGraalClause leBuiltin = new ProloGraalLEBuiltin(context);
clauses.put(leBuiltin.getHead(), Collections.singletonList(leBuiltin));
ProloGraalClause realTimeBuiltin = new ProloGraalRealTimeBuiltin();
HashMap<ProloGraalVariable,ProloGraalVariable> realTimeVars = new HashMap<>();
ProloGraalStructure realTimeHead = new ProloGraalStructure(realTimeVars);
realTimeHead.setFunctor(new ProloGraalAtom(realTimeVars, "real_time"));
ProloGraalVariable realTimeArg = new ProloGraalVariable(realTimeVars, "Arg");
realTimeHead.addSubterm(realTimeArg);
ProloGraalRealTimeHeadNode realTimeNode = ProloGraalRealTimeHeadNodeGen.create(realTimeHead, new ProloGraalSimpleTermNode(isArg));
ProloGraalClause realTimeBuiltin = ProloGraalRealTimeBuiltinNodeGen.create(realTimeNode);
clauses.put(realTimeBuiltin.getHead(), Collections.singletonList(realTimeBuiltin));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment