+ private static <T> T evaluate(Function function, Object ... args) {
+ return (T)function.applyArray(args);
+ }
+
+ private static <T> T evaluate(RuntimeModule rm, String function, Object ... args) throws ValueNotFound {
+ return evaluate(resolveFunction(rm, function));
+ }
+
+ public static <T> T evaluate(String module, String function, Object ... args) throws ValueNotFound {
+ return evaluate(resolveRuntimeModule(module), function, args);
+ }
+
+ public static <T> T evaluateDB(String module, String function, Object ... args) throws DatabaseException {
+ try {
+ RuntimeModule rm = resolveRuntimeModule(module);
+ List<TCon> effects = getEffects(resolveSCLValue(rm, function));
+ Function f = resolveFunction(rm, function);
+ if(effects.contains(Types.WRITE_GRAPH)) {
+ return syncWrite(f, args);
+ } else if(effects.contains(Types.READ_GRAPH)) {
+ return syncRead(f, args);
+ } else {
+ return evaluate(f, args);
+ }
+ } catch (ValueNotFound e) {
+ throw new DatabaseException("SCL Value not found: " + e.name);
+ } catch (Throwable t) {
+ if (t instanceof DatabaseException)
+ throw (DatabaseException) t;
+ throw new DatabaseException(t);
+ }
+ }
+
+ public static <T> T evaluateGraph(String module, String function, ReadGraph graph, Object ... args) throws DatabaseException {