/** * ext is loaded function definitions define them as public * * @param ext * @param q */ void definePublic(Extension ext, Query q) { definePublic(ext, q, true); }
/** * ext is loaded function definitions define them as public * * @param ext * @param q */ void definePublic(Extension ext, Query q) { definePublic(ext, q, true); }
void definePublic(Function fun, Query q) { definePublic(fun, q, true); }
void definePublic(Function fun, Query q) { definePublic(fun, q, true); }
/** * isDefine = true means export to Interpreter Use case: Transformation * st:profile does not export to Interpreter hence it uses isDefine = false */ public void definePublic(Extension ext, Query q, boolean isDefine) { for (FunMap m : ext.getMaps()) { for (Expr exp : m.values()) { Function e = (Function) exp; definePublic(e, q, isDefine); } } }
/** * isDefine = true means export to Interpreter Use case: Transformation * st:profile does not export to Interpreter hence it uses isDefine = false */ public void definePublic(Extension ext, Query q, boolean isDefine) { for (FunMap m : ext.getMaps()) { for (Expr exp : m.values()) { Function e = (Function) exp; definePublic(e, q, isDefine); } } }
public boolean getLinkedFunction(String label) { if (! isLinkedFunction()){ return false; } String path = NSManager.namespace(label); if (loaded.containsKey(path)) { return true; } logger.info("Load Linked Function: " + label); loaded.put(path, path); Query imp = sparql.parseQuery(path); if (imp != null && imp.hasDefinition()) { // loaded functions are exported in Interpreter definePublic(imp.getExtension(), imp); return true; } return false; }
public boolean getLinkedFunction(String label) { if (! isLinkedFunction()){ return false; } String path = NSManager.namespace(label); if (loaded.containsKey(path)) { return true; } logger.info("Load Linked Function: " + label); loaded.put(path, path); Query imp = sparql.parseQuery(path); if (imp != null && imp.hasDefinition()) { // loaded functions are exported in Interpreter definePublic(imp.getExtension(), imp); return true; } return false; }
/** * Define function into Extension Export into Interpreter */ void define(ASTExtension aext, Query q) { Extension ext = q.getCreateExtension(); DatatypeHierarchy dh = new DatatypeHierarchy(); if (q.isDebug()) dh.setDebug(true); ext.setHierarchy(dh); for (ASTFunMap m : aext.getMaps()) { for (Function exp : m.values()) { ext.define(exp); if (exp.isPublic()) { definePublic(exp, q); } } } }
/** * Define function into Extension Export into Interpreter */ void define(ASTExtension aext, Query q) { Extension ext = q.getCreateExtension(); DatatypeHierarchy dh = new DatatypeHierarchy(); if (q.isDebug()) dh.setDebug(true); ext.setHierarchy(dh); for (ASTFunMap m : aext.getMaps()) { for (Function exp : m.values()) { ext.define(exp); if (exp.isPublic()) { definePublic(exp, q); } } } }
tr.definePublic(qprofile.getExtension(), qprofile, false); for (Query t : qe.getTemplates()) { t.addExtension(qprofile.getExtension());
/** * templates share profile function definitions * function st:optimize(){} : run TransformerVisitor to optimize template */ public void profile() { Query profile = getTemplate(STL_PROFILE); if (profile != null) { if (profile.getExtension() != null) { // share profile function definitions in templates fr.inria.corese.compiler.parser.Transformer tr = fr.inria.corese.compiler.parser.Transformer.create(); tr.definePublic(profile.getExtension(), profile, false); TransformerVisitor tv = new TransformerVisitor(profile.getExtension().get(Transformer.STL_OPTIMIZE) != null); for (Query t : getTemplates()) { t.addExtension(profile.getExtension()); tv.visit(t); } for (Query t : getNamedTemplates()) { t.addExtension(profile.getExtension()); tv.visit(t); } } } }