(IPersistentVector interfaceSyms, IPersistentVector fieldSyms, Symbol thisSym, String tagName, Symbol className, Symbol typeTag, ISeq methodForms, Object frm, IPersistentMap opts)
| 8559 | } |
| 8560 | |
| 8561 | static ObjExpr build(IPersistentVector interfaceSyms, IPersistentVector fieldSyms, Symbol thisSym, |
| 8562 | String tagName, Symbol className, |
| 8563 | Symbol typeTag, ISeq methodForms, Object frm, IPersistentMap opts) { |
| 8564 | NewInstanceExpr ret = new NewInstanceExpr(null); |
| 8565 | |
| 8566 | ret.src = frm; |
| 8567 | ret.name = className.toString(); |
| 8568 | ret.classMeta = RT.meta(className); |
| 8569 | ret.internalName = ret.name.replace('.', '/'); |
| 8570 | ret.objtype = Type.getObjectType(ret.internalName); |
| 8571 | ret.opts = opts; |
| 8572 | |
| 8573 | if(thisSym != null) |
| 8574 | ret.thisName = thisSym.name; |
| 8575 | |
| 8576 | if(fieldSyms != null) |
| 8577 | { |
| 8578 | IPersistentMap fmap = PersistentHashMap.EMPTY; |
| 8579 | Object[] closesvec = new Object[2 * fieldSyms.count()]; |
| 8580 | for(int i=0;i<fieldSyms.count();i++) |
| 8581 | { |
| 8582 | Symbol sym = (Symbol) fieldSyms.nth(i); |
| 8583 | LocalBinding lb = new LocalBinding(-1, sym, null, |
| 8584 | new MethodParamExpr(tagClass(tagOf(sym))),false,null); |
| 8585 | fmap = fmap.assoc(sym, lb); |
| 8586 | closesvec[i*2] = lb; |
| 8587 | closesvec[i*2 + 1] = lb; |
| 8588 | } |
| 8589 | |
| 8590 | //todo - inject __meta et al into closes - when? |
| 8591 | //use array map to preserve ctor order |
| 8592 | ret.closes = new PersistentArrayMap(closesvec); |
| 8593 | ret.fields = fmap; |
| 8594 | for(int i=fieldSyms.count()-1;i >= 0 && (((Symbol)fieldSyms.nth(i)).name.equals("__meta") |
| 8595 | || ((Symbol)fieldSyms.nth(i)).name.equals("__extmap") |
| 8596 | || ((Symbol)fieldSyms.nth(i)).name.equals("__hash") |
| 8597 | || ((Symbol)fieldSyms.nth(i)).name.equals("__hasheq") |
| 8598 | );--i) |
| 8599 | ret.altCtorDrops++; |
| 8600 | } |
| 8601 | //todo - set up volatiles |
| 8602 | // ret.volatiles = PersistentHashSet.create(RT.seq(RT.get(ret.optionsMap, volatileKey))); |
| 8603 | |
| 8604 | PersistentVector interfaces = PersistentVector.EMPTY; |
| 8605 | for(ISeq s = RT.seq(interfaceSyms);s!=null;s = s.next()) |
| 8606 | { |
| 8607 | Class c = (Class) resolve((Symbol) s.first()); |
| 8608 | if(!c.isInterface()) |
| 8609 | throw new IllegalArgumentException("only interfaces are supported, had: " + c.getName()); |
| 8610 | interfaces = interfaces.cons(c); |
| 8611 | } |
| 8612 | Class superClass = Object.class; |
| 8613 | Map[] mc = gatherMethods(superClass,RT.seq(interfaces)); |
| 8614 | Map overrideables = mc[0]; |
| 8615 | Map covariants = mc[1]; |
| 8616 | ret.mmap = overrideables; |
| 8617 | ret.covariants = covariants; |
| 8618 |
no test coverage detected