private Node translateSJInbranch(SJInbranch ib, QQ qq) { StringBuilder translation = new StringBuilder("{ "); Collection<Object> mapping = new LinkedList<Object>(); String labVar = UniqueID.newID(SJ_INBRANCH_LABEL_FIELD_PREFIX); translation.append("%T %s = %E; "); mapping.add(qq.parseType(SJ_LABEL_CLASS)); mapping.add(labVar); mapping.add(ib.inlabel()); for (Iterator<SJInbranchCase> i = ib.branchCases().iterator(); i.hasNext(); ) { SJInbranchCase ibc = i.next(); translation.append("if (%s.equals(%E)) { %LS } "); mapping.add(labVar); mapping.add(sjnf.StringLit(ib.position(), ibc.label().labelValue())); mapping.add(ibc.statements()); if (i.hasNext()) { translation.append("else "); } } translation.append("else { throw new SJIOException(\"Unexpected inbranch label: \" + %s); }"); mapping.add(labVar); // FIXME: need a final else case to better handle, if runtime monitoring is disabled, // non-sj-compatibility mode and in case of malicious peers. translation.append('}'); return qq.parseStmt(translation.toString(), mapping.toArray()); }
private String getRecursionBooleanName(Iterable<String> sjnames, SJLabel lab) { StringBuilder bname = new StringBuilder(SJ_RECURSION_PREFIX); for (String sjname : sjnames) { bname.append(sjname).append('_'); } return bname + lab.labelValue(); }