use of org.spoofax.interpreter.stratego.Strategy in project nabl by metaborg.
the class ScopeGraphContextPrimitive method call.
@Override
public final boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) throws InterpreterException {
final Object contextObj = env.contextObject();
if (contextObj == null) {
logger.warn("Context is null.");
return false;
}
if (!(contextObj instanceof IScopeGraphContext)) {
throw new InterpreterException("Context does not implement IScopeGraphContext");
}
final IScopeGraphContext<?> context = (IScopeGraphContext<?>) env.contextObject();
List<IStrategoTerm> termArgs = Arrays.asList(tvars);
Optional<? extends IStrategoTerm> result;
try (IClosableLock lock = context.guard()) {
result = call(context, env.current(), termArgs, env.getFactory());
}
return result.map(t -> {
env.setCurrent(t);
return true;
}).orElse(false);
}
Aggregations