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 b6fe9f38 authored by Tony Licata's avatar Tony Licata

Converted remaining builtins into Truffle nodes.

parent 5712ca62
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.ProloGraalLanguage;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.parser.ProloGraalParserImpl;
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 com.oracle.truffle.api.source.Source;
import java.io.File;
import java.nio.charset.Charset;
......@@ -19,7 +22,7 @@ import java.util.stream.Collectors;
* @author Tony Licata
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalConsultBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalConsultBuiltin extends ProloGraalBuiltinClause {
private final ProloGraalContext context; // we keep the context for the copy method
private ProloGraalVariable arg; //The variable A in consult(A). We keep it to use it in the execute method
......@@ -70,10 +73,23 @@ public final class ProloGraalConsultBuiltin extends ProloGraalBuiltinClause {
}
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalConsultBuiltin(context);
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalConsultBuiltinNodeGen.create(context, ProloGraalConsultHeadNodeGen.create(getHead().copy(new HashMap<>()), context, new ProloGraalSimpleTermNode(headArgs.get(0))));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalConsultHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
......
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.ProloGraalLanguage;
import ch.heiafr.prolograal.nodes.*;
import ch.heiafr.prolograal.parser.ProloGraalParserImpl;
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 com.oracle.truffle.api.source.Source;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Class representing the consult/1 predicate.
......@@ -17,7 +19,7 @@ import java.util.stream.Collectors;
* @author Tony Licata
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalConsultStringBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalConsultStringBuiltin extends ProloGraalBuiltinClause {
private final ProloGraalContext context; // we keep the context for the copy method
private ProloGraalVariable arg; //The variable A in consult(A). We keep it to use it in the execute method
......@@ -54,10 +56,23 @@ public final class ProloGraalConsultStringBuiltin extends ProloGraalBuiltinClaus
}
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalConsultStringBuiltin(context);
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalConsultStringBuiltinNodeGen.create(context, ProloGraalConsultStringHeadNodeGen.create(getHead().copy(new HashMap<>()), context, new ProloGraalSimpleTermNode(headArgs.get(0))));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalConsultStringHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
......@@ -66,8 +81,8 @@ public final class ProloGraalConsultStringBuiltin extends ProloGraalBuiltinClaus
*/
public static ProloGraalTerm createStandardHead(Map<ProloGraalVariable,ProloGraalVariable> variables) {
ProloGraalStructure head = new ProloGraalStructure(variables);
ProloGraalAtom consultAtom = new ProloGraalAtom(variables,"consultstring");
head.setFunctor(consultAtom);
ProloGraalAtom consultStringAtom = new ProloGraalAtom(variables,"consultstring");
head.setFunctor(consultStringAtom);
ProloGraalVariable arg = new ProloGraalVariable(variables, "A");
head.addSubterm(arg);
return head;
......
......@@ -2,12 +2,10 @@ 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;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.NodeUtil;
......@@ -35,15 +33,9 @@ public abstract class ProloGraalIsBuiltin extends ProloGraalBuiltinClause {
// create the head of this clause
// since we do not need custom unification, a simple structure is enough
ProloGraalStructure head = new ProloGraalStructure(getVariables());
head.setFunctor(new ProloGraalAtom(getVariables(), "is"));
// we create and store the variables to access them more easily later in the execute method
arg = new ProloGraalVariable(getVariables(), "_");
head.addSubterm(arg);
arg2 = new ProloGraalVariable(getVariables(), "op");
head.addSubterm(arg2);
ProloGraalStructure head = createStandardHead(getVariables()).asStructure();
arg = head.getArguments().get(0).asVariable();
arg2 = head.getArguments().get(1).asVariable();
setHead(head);
}
......@@ -130,4 +122,21 @@ public abstract class ProloGraalIsBuiltin extends ProloGraalBuiltinClause {
public ProloGraalTerm<?> getHead(){
return ((ProloGraalIsHeadNode)NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
* Build a standard ProloGraalTerm that would tipically be the head of the builtin, with variables instead of "real args".
* @return a new ProloGraalTerm representing the head of the builtin
*/
public static ProloGraalTerm createStandardHead(Map<ProloGraalVariable,ProloGraalVariable> variables) {
ProloGraalStructure head = new ProloGraalStructure(variables);
head.setFunctor(new ProloGraalAtom(variables, "is"));
// we create and store the variables to access them more easily later in the execute method
ProloGraalVariable arg = new ProloGraalVariable(variables, "_");
head.addSubterm(arg);
ProloGraalVariable arg2 = new ProloGraalVariable(variables, "op");
head.addSubterm(arg2);
return head;
}
}
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.nodes.ProloGraalNoTraceHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalNoTraceHeadNodeGen;
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.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
/**
* Class representing the trace/0 predicate.
......@@ -12,13 +17,13 @@ import java.util.HashMap;
* @author Tony Licata
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalNotraceBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalNoTraceBuiltin extends ProloGraalBuiltinClause {
private final PrintWriter writer; // used for outputting
private final ProloGraalContext context; // we keep the context to use it later
private static final String TRACE_OFF_TEXT = "The debugger is switched off\n";
public static final String TRACE_OFF_TEXT = "The debugger is switched off\n";
public ProloGraalNotraceBuiltin(ProloGraalContext context) {
public ProloGraalNoTraceBuiltin(ProloGraalContext context) {
super(new HashMap<>());
// get printer from context
this.writer = new PrintWriter(context.getOutput(), true);
......@@ -42,10 +47,32 @@ public final class ProloGraalNotraceBuiltin extends ProloGraalBuiltinClause {
return new ProloGraalSuccess(getVariables());
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalNotraceBuiltin(context);
return ProloGraalNoTraceBuiltinNodeGen.create(context, ProloGraalNoTraceHeadNodeGen.create(getHead().copy(new HashMap<>()),context));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalNoTraceHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
* Build a standard ProloGraalTerm that would tipically be the head of the builtin, with variables instead of "real args".
* @return a new ProloGraalTerm representing the head of the builtin
*/
public static ProloGraalTerm createStandardHead(Map<ProloGraalVariable,ProloGraalVariable> variables) {
ProloGraalStructure traceStructure = new ProloGraalStructure(variables);
ProloGraalAtom head = new ProloGraalAtom(variables,"notrace");
traceStructure.setFunctor(head);
return traceStructure;
}
}
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;
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;
......
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.nodes.ProloGraalTraceHeadNode;
import ch.heiafr.prolograal.nodes.ProloGraalTraceHeadNodeGen;
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.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
/**
* Class representing the trace/0 predicate.
......@@ -12,11 +17,11 @@ import java.util.HashMap;
* @author Tony Licata
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalTraceBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalTraceBuiltin extends ProloGraalBuiltinClause {
private final PrintWriter writer; // used for outputting
private final ProloGraalContext context; // we keep the context to use it later
private static final String TRACE_ON_TEXT = "The debugger will first creep -- showing everything (trace)";
public static final String TRACE_ON_TEXT = "The debugger will first creep -- showing everything (trace)";
public ProloGraalTraceBuiltin(ProloGraalContext context) {
super(new HashMap<>());
......@@ -42,10 +47,32 @@ public final class ProloGraalTraceBuiltin extends ProloGraalBuiltinClause {
return new ProloGraalSuccess(getVariables());
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalTraceBuiltin(context);
return ProloGraalTraceBuiltinNodeGen.create(context, ProloGraalTraceHeadNodeGen.create(getHead().copy(new HashMap<>()),context));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalTraceHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
* Build a standard ProloGraalTerm that would tipically be the head of the builtin, with variables instead of "real args".
* @return a new ProloGraalTerm representing the head of the builtin
*/
public static ProloGraalTerm createStandardHead(Map<ProloGraalVariable,ProloGraalVariable> variables) {
ProloGraalStructure traceStructure = new ProloGraalStructure(variables);
ProloGraalAtom head = new ProloGraalAtom(variables,"trace");
traceStructure.setFunctor(head);
return traceStructure;
}
}
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;
......@@ -36,22 +34,14 @@ public abstract class ProloGraalUseInterpreterBuiltin extends ProloGraalBuiltinC
setHead(useInterpreterStructure);
}
/**
* Launch an interpreter
*/
@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() {
......
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.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -12,7 +16,7 @@ import java.util.Map;
* @author Martin Spoto
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalVarBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalVarBuiltin extends ProloGraalBuiltinClause {
/**
* Class representing the head of this predicate.
......@@ -35,8 +39,8 @@ public final class ProloGraalVarBuiltin extends ProloGraalBuiltinClause {
*/
@Override
public boolean unify(ProloGraalTerm<?> other) {
if (other instanceof ProloGraalStructure) {
ProloGraalStructure struct = (ProloGraalStructure) other;
if (other.isStructure()) {
ProloGraalStructure struct = other.asStructure();
if (struct.getFunctor().equals(getFunctor()) && struct.getArity() == 1) {
return struct.getArguments().get(0).getRootValue() instanceof ProloGraalVariable;
}
......@@ -63,9 +67,30 @@ public final class ProloGraalVarBuiltin extends ProloGraalBuiltinClause {
return new ProloGraalSuccess(getVariables());
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the custom head
@Override
public ProloGraalClause copy() {
return new ProloGraalVarBuiltin();
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalVarBuiltinNodeGen.create(ProloGraalVarHeadNodeGen.create(getHead().copy(new HashMap<>()), new ProloGraalSimpleTermNode(headArgs.get(0))));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalVarHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
* Build a standard ProloGraalTerm that would tipically be the head of the builtin, with variables instead of "real args".
* @return a new ProloGraalTerm representing the head of the builtin
*/
public static ProloGraalTerm createStandardHead(Map<ProloGraalVariable,ProloGraalVariable> variables) {
return new VarPredicateHead(variables);
}
}
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.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Class representing the write/1(X) predicate.
......@@ -12,25 +17,23 @@ import java.util.HashMap;
* @author Martin Spoto
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalWriteBuiltin extends ProloGraalBuiltinClause {
public abstract class ProloGraalWriteBuiltin extends ProloGraalBuiltinClause {
private final ProloGraalContext context;
private final PrintWriter writer; // used for outputting
private final ProloGraalContext context; // we keep the context for the copy method
private ProloGraalVariable arg; // the variable X in write(X). We keep it to print it after the unification process
public ProloGraalWriteBuiltin(ProloGraalContext context) {
super(new HashMap<>());
this.context = context;
// get printer from context
this.writer = new PrintWriter(context.getOutput(), true);
this.context = context;
// create the head of this clause
// since we do not need custom unification, a simple structure is enough
ProloGraalStructure head = new ProloGraalStructure(getVariables());
head.setFunctor(new ProloGraalAtom(getVariables(), "write"));
// we create and store the variable to access it more easily later in the execute method
arg = new ProloGraalVariable(getVariables(), "_");
head.addSubterm(arg);
ProloGraalStructure head = createStandardHead(getVariables()).asStructure();
arg = head.getArguments().get(0).asVariable();
setHead(head);
}
......@@ -49,10 +52,38 @@ public final class ProloGraalWriteBuiltin extends ProloGraalBuiltinClause {
return new ProloGraalSuccess(getVariables());
}
@Specialization
public ProloGraalBoolean returnHead(VirtualFrame frame, ProloGraalBoolean head){
return head;
}
// override the default copy so we do not lose the built-in status
@Override
public ProloGraalClause copy() {
return new ProloGraalWriteBuiltin(context);
ProloGraalTerm copiedHead = copyHead();
List<ProloGraalTerm<?>> headArgs = copiedHead.asStructure().getArguments();
return ProloGraalWriteBuiltinNodeGen.create(context, ProloGraalWriteHeadNodeGen.create(getHead().copy(new HashMap<>()), context, new ProloGraalSimpleTermNode(headArgs.get(0))));
}
// override getHead method to handle AST node head
@Override
public ProloGraalTerm<?> getHead(){
return ((ProloGraalWriteHeadNode) NodeUtil.findNodeChildren(this).get(0)).getValue();
}
/**
* Build a standard ProloGraalTerm that would tipically be the head of the builtin, with variables instead of "real args".
* @return a new ProloGraalTerm representing the head of the builtin
*/
public static ProloGraalTerm createStandardHead(Map<ProloGraalVariable,ProloGraalVariable> variables) {
// create the head of this clause
// since we do not need custom unification, a simple structure is enough
ProloGraalStructure head = new ProloGraalStructure(variables);
head.setFunctor(new ProloGraalAtom(variables, "write"));
// we create and store the variable to access it more easily later in the execute method
ProloGraalVariable arg = new ProloGraalVariable(variables, "_");
head.addSubterm(arg);
return head;
}
}
package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.ProloGraalLanguage;
import ch.heiafr.prolograal.builtins.predicates.ProloGraalRealTimeBuiltin;
import ch.heiafr.prolograal.parser.ProloGraalParserImpl;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
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 com.oracle.truffle.api.source.Source;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@NodeInfo(shortName = "ProloGraalConsultHeadNode")
public abstract class ProloGraalConsultHeadNode extends ProloGraalUnaryHeadNode {
private final ProloGraalContext context;
public ProloGraalConsultHeadNode(ProloGraalTerm<?> value, ProloGraalContext context) {
super(value);
this.context = context;
}
@Specialization
@CompilerDirectives.TruffleBoundary
public ProloGraalBoolean returnValue(ProloGraalTerm arg) {
if(arg.isAtom()){
String filename = ((ProloGraalAtom) arg).getName();
File loadedFile = new File(filename);
if(loadedFile.exists()) {
String fileContent;
try {
fileContent = Files.readAllLines(loadedFile.toPath(), Charset.forName("UTF-8")).stream().collect(Collectors.joining("\n"));
}catch (Exception e){
System.out.println("could not read file "+filename);
return new ProloGraalFailure();
}
Source source = Source.newBuilder(ProloGraalLanguage.ID, fileContent, null).build();
//we filter clauses to remove goal lists from returned clauses
List<ProloGraalClause> clauses = ProloGraalParserImpl.parseClauses(source).stream().filter(proloGraalClause -> proloGraalClause.getHead() != null).collect(Collectors.toList());
context.getRuntime().addProloGraalClauses(clauses);
return new ProloGraalSuccess();
}else{
System.out.println("file "+filename+" does not exist");
return new ProloGraalFailure();
}
}else{
System.out.println("consult/1 predicate takes an atom as argument.");
return new ProloGraalFailure();
}
}
@Override
public ProloGraalBuiltinHeadNode copyBuiltin(Map<ProloGraalVariable, ProloGraalVariable> variables){
List<Node> childrens = NodeUtil.findNodeChildren(this);
ProloGraalTermNode child = (ProloGraalTermNode) childrens.get(0);
return ProloGraalConsultHeadNodeGen.create(value.copy(variables), context, child.copyTermNode(variables));
}
}
package ch.heiafr.prolograal.nodes;
import ch.heiafr.prolograal.ProloGraalLanguage;
import ch.heiafr.prolograal.parser.ProloGraalParserImpl;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
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 com.oracle.truffle.api.source.Source;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@NodeInfo(shortName = "ProloGraalConsultStringHeadNode")
public abstract class ProloGraalConsultStringHeadNode extends ProloGraalUnaryHeadNode {
private final ProloGraalContext context;
public ProloGraalConsultStringHeadNode(ProloGraalTerm<?> value, ProloGraalContext context) {
super(value);
this.context = context;
}
@Specialization
@CompilerDirectives.TruffleBoundary
public ProloGraalBoolean returnValue(ProloGraalTerm arg) {
if(arg.isAtom()){
String consultContentString = ((ProloGraalAtom) arg).getName();
Source source = Source.newBuilder(ProloGraalLanguage.ID, consultContentString, null).build();
//we filter clauses to remove goal lists from returned clauses
List<ProloGraalClause> clauses = ProloGraalParserImpl.parseClauses(source);
context.getRuntime().addProloGraalClauses(clauses);
return new ProloGraalSuccess();
}else{
System.out.println("consultstring/1 predicate takes an atom as argument.");
return new ProloGraalFailure();
}
}
@Override
public ProloGraalBuiltinHeadNode copyBuiltin(Map<ProloGraalVariable, ProloGraalVariable> variables){
List<Node> childrens = NodeUtil.findNodeChildren(this);
ProloGraalTermNode child = (ProloGraalTermNode) childrens.get(0);
return ProloGraalConsultStringHeadNodeGen.create(value.copy(variables), context, child.copyTermNode(variables));
}
}