(C context, ISeq form, String name)
| 4533 | } |
| 4534 | |
| 4535 | static Expr parse(C context, ISeq form, String name) { |
| 4536 | ISeq origForm = form; |
| 4537 | FnExpr fn = new FnExpr(tagOf(form)); |
| 4538 | Keyword retkey = Keyword.intern(null, "rettag"); |
| 4539 | Object rettag = RT.get(RT.meta(form), retkey); |
| 4540 | fn.src = form; |
| 4541 | ObjMethod enclosingMethod = (ObjMethod) METHOD.deref(); |
| 4542 | fn.hasEnclosingMethod = enclosingMethod != null; |
| 4543 | if(((IMeta) form.first()).meta() != null) |
| 4544 | { |
| 4545 | fn.onceOnly = RT.booleanCast(RT.get(RT.meta(form.first()), Keyword.intern(null, "once"))); |
| 4546 | // fn.superName = (String) RT.get(RT.meta(form.first()), Keyword.intern(null, "super-name")); |
| 4547 | } |
| 4548 | //fn.thisName = name; |
| 4549 | |
| 4550 | String basename = (enclosingMethod != null ? |
| 4551 | enclosingMethod.objx.name |
| 4552 | : (munge(currentNS().name.name))) + "$"; |
| 4553 | |
| 4554 | Symbol nm = null; |
| 4555 | |
| 4556 | if(RT.second(form) instanceof Symbol) { |
| 4557 | nm = (Symbol) RT.second(form); |
| 4558 | name = nm.name + "__" + RT.nextID(); |
| 4559 | } else { |
| 4560 | if(name == null) |
| 4561 | name = "fn__" + RT.nextID(); |
| 4562 | else if (enclosingMethod != null) |
| 4563 | name += "__" + RT.nextID(); |
| 4564 | } |
| 4565 | |
| 4566 | String simpleName = munge(name).replace(".", "_DOT_"); |
| 4567 | |
| 4568 | fn.name = basename + simpleName; |
| 4569 | fn.internalName = fn.name.replace('.', '/'); |
| 4570 | fn.objtype = Type.getObjectType(fn.internalName); |
| 4571 | ArrayList<String> prims = new ArrayList(); |
| 4572 | try |
| 4573 | { |
| 4574 | Var.pushThreadBindings( |
| 4575 | RT.mapUniqueKeys(CONSTANTS, PersistentVector.EMPTY, |
| 4576 | CONSTANT_IDS, new IdentityHashMap(), |
| 4577 | KEYWORDS, PersistentHashMap.EMPTY, |
| 4578 | VARS, PersistentHashMap.EMPTY, |
| 4579 | KEYWORD_CALLSITES, PersistentVector.EMPTY, |
| 4580 | PROTOCOL_CALLSITES, PersistentVector.EMPTY, |
| 4581 | //VAR_CALLSITES, emptyVarCallSites(), |
| 4582 | NO_RECUR, null |
| 4583 | )); |
| 4584 | |
| 4585 | //arglist might be preceded by symbol naming this fn |
| 4586 | if(nm != null) |
| 4587 | { |
| 4588 | fn.thisName = nm.name; |
| 4589 | form = RT.cons(FN, RT.next(RT.next(form))); |
| 4590 | } |
| 4591 | |
| 4592 | //now (fn [args] body...) or (fn ([args] body...) ([args2] body2...) ...) |
no test coverage detected