| 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public Expr copy(final CompileContext cc, final IntObjectMap<Var> vm) { |
| 284 | final VarScope vsc = new VarScope(); |
| 285 | |
| 286 | final HashMap<Var, Expr> outer = new HashMap<>(); |
| 287 | global.forEach((key, value) -> outer.put(key, value.copy(cc, vm))); |
| 288 | |
| 289 | cc.pushScope(vsc); |
| 290 | try { |
| 291 | final IntObjectMap<Var> innerVars = new IntObjectMap<>(); |
| 292 | vs.copy(cc, innerVars); |
| 293 | |
| 294 | final HashMap<Var, Expr> bindings = new HashMap<>(); |
| 295 | outer.forEach((key, value) -> bindings.put(innerVars.get(key.id), value)); |
| 296 | |
| 297 | final Var[] prms = params.clone(); |
| 298 | final int pl = prms.length; |
| 299 | for(int p = 0; p < pl; p++) prms[p] = innerVars.get(prms[p].id); |
| 300 | |
| 301 | final Expr ex = expr.copy(cc, innerVars); |
| 302 | ex.markTailCalls(null); |
| 303 | return copyType(new Closure(info, ex, prms, anns, cc.vs(), bindings, declType, name)); |
| 304 | } finally { |
| 305 | cc.removeScope(); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | @Override |
| 310 | public Expr inline(final Expr[] exprs, final CompileContext cc) throws QueryException { |