use of com.googlecode.prolog_cafe.lang.PrologClassLoader in project gerrit by GerritCodeReview.
the class PrologShell method run.
@Override
public int run() {
banner();
BufferingPrologControl pcl = new BufferingPrologControl();
pcl.setPrologClassLoader(new PrologClassLoader(getClass().getClassLoader()));
pcl.setEnabled(Prolog.Feature.IO, true);
pcl.setEnabled(Prolog.Feature.STATISTICS, true);
pcl.configureUserIO(System.in, System.out, System.err);
pcl.initialize(Prolog.BUILTIN);
for (String file : fileName) {
String path;
try {
path = new File(file).getCanonicalPath();
} catch (IOException e) {
path = new File(file).getAbsolutePath();
}
pcl.execute(Prolog.BUILTIN, "consult", SymbolTerm.create(path));
System.err.println();
System.err.flush();
}
try {
pcl.execute(Prolog.BUILTIN, "cafeteria");
write("% halt\n");
return 0;
} catch (HaltException halt) {
write("% halt(" + halt.getStatus() + ")\n");
return halt.getStatus();
}
}
use of com.googlecode.prolog_cafe.lang.PrologClassLoader in project gerrit by GerritCodeReview.
the class RulesCache method newEmptyMachine.
private BufferingPrologControl newEmptyMachine(ClassLoader cl) {
BufferingPrologControl ctl = new BufferingPrologControl();
ctl.setMaxDatabaseSize(maxDbSize);
ctl.setPrologClassLoader(new PrologClassLoader(new PredicateClassLoader(predicateProviders, cl)));
ctl.setEnabled(EnumSet.allOf(Prolog.Feature.class), false);
List<String> packages = new ArrayList<>();
packages.addAll(PACKAGE_LIST);
for (PredicateProvider predicateProvider : predicateProviders) {
packages.addAll(predicateProvider.getPackages());
}
// Bootstrap the interpreter and ensure there is clean state.
ctl.initialize(packages.toArray(new String[packages.size()]));
return ctl;
}
use of com.googlecode.prolog_cafe.lang.PrologClassLoader in project gerrit by GerritCodeReview.
the class PrologTestCase method newMachine.
private PrologMachineCopy newMachine() {
BufferingPrologControl ctl = new BufferingPrologControl();
ctl.setMaxDatabaseSize(16 * 1024);
ctl.setPrologClassLoader(new PrologClassLoader(getClass().getClassLoader()));
return PrologMachineCopy.save(ctl);
}
Aggregations