use of mb.flowspec.runtime.solver.TFFileInfo in project spoofax by metaborg.
the class AbstractConstraintAnalyzer method getFlowSpecTransferFunctions.
protected Optional<TFFileInfo> getFlowSpecTransferFunctions(ILanguageComponent component) {
TFFileInfo transferFunctions = flowSpecTransferFunctionCache.get(component);
if (transferFunctions != null) {
return Optional.of(transferFunctions);
}
FileObject tfs = resourceService.resolve(component.location(), TRANSFER_FUNCTIONS_FILE);
try {
IStrategoTerm sTerm = termFactory.parseFromString(IOUtils.toString(tfs.getContent().getInputStream(), StandardCharsets.UTF_8));
ITerm term = strategoTerms.fromStratego(sTerm);
transferFunctions = TFFileInfo.match().match(term, PersistentUnifier.Immutable.of()).orElseThrow(() -> new ParseException("Parse error on reading the transfer function file"));
} catch (ParseError | ParseException | IOException e) {
logger.error("Could not read transfer functions file for {}", component);
return Optional.empty();
}
logger.debug("Caching flowspec transfer functions for language {}", component);
flowSpecTransferFunctionCache.put(component, transferFunctions);
return Optional.of(transferFunctions);
}
Aggregations