/** * Translates this constructor or method into intermediate Kitten code. This amounts to * translating its body with a continuation containing a {@code return} bytecode. This way, if a * method does not have an explicit {@code return} statement, it is automatically put at its end. * * @param done the set of code signatures that have been already translated */ public void translate(Set<ClassMemberSignature> done) { if (done.add(sig)) { this.process(sig.getDefiningClass(), done); // we translate the body of the constructor or // method with a block containing RETURN as continuation. This way, // all methods returning void and // with some missing return command are correctly // terminated anyway. If the method is not void, this // precaution is useless since we know that every execution path // ends with a return command, as guaranteed by // checkForDeadCode() (see typeCheck() in MethodDeclaration.java) sig.setCode(getBody().translate(sig, new Block(new RETURN(VoidType.INSTANCE)))); // we translate all methods and constructors that are referenced // from the code we have generated translateReferenced(sig.getCode(), done, new HashSet<Block>()); } }