public void addDestroyMethod() { ImMethod m = translator.destroyMethod.getFor(interfaceDef); imClass.getMethods().add(m); List<ClassDef> subClasses = Lists.newArrayList(translator.getInterfaceInstances(interfaceDef)); // set sub methods for (ClassDef sc : subClasses) { ImMethod dm = translator.destroyMethod.getFor(sc); m.getSubMethods().add(dm); } }
private void translateInterfaceFuncDef(FuncDef f) { ImMethod imMeth = translator.getMethodFor(f); ImFunction imFunc = translator.getFuncFor(f); imClass.getMethods().add(imMeth); // translate implementation if (f.attrHasEmptyBody()) { imMeth.setIsAbstract(true); } else { // there is a default implementation imFunc.getBody().addAll(translator.translateStatements(imFunc, f.getBody())); } List<ClassDef> subClasses = Lists.newArrayList(translator.getInterfaceInstances(interfaceDef)); // TODO also add extended interfaces // set sub methods Map<ClassDef, FuncDef> subClasses2 = translator.getClassesWithImplementation(subClasses, f); for (Entry<ClassDef, FuncDef> subE : subClasses2.entrySet()) { ClassDef subC = subE.getKey(); ImmutableCollection<WurstTypeInterface> interfaces = subC.attrImplementedInterfaces(); Map<TypeParamDef, WurstTypeBoundTypeParam> typeBinding = interfaces .stream() .filter(t -> t.getDef() == interfaceDef) .map(t -> t.getTypeArgBinding()) .findFirst() .orElse(Collections.emptyMap()); FuncDef subM = subE.getValue(); ImMethod m = translator.getMethodFor(subM); ImClass mClass = translator.getClassFor(subC); OverrideUtils.addOverride(translator, f, mClass, m, subM, typeBinding); } }