private void accept_2_test(BlockVisitor2 vis, Insn.L insn_, int insn_idx) {
TypeMap typeMap = this.map[insn_idx];
int failLabel = decode_labelref(insn_.label, typeMap.exh);
BeamOpcode test = insn_.opcode();
if (insn_ instanceof Insn.LD) { // Handle simple type tests:
Insn.LD insn = (Insn.LD)insn_;
Arg arg = src_arg(insn_idx, insn.dest);
Type test_type = type_tested_for(insn);
if (test_type != null) {
if (insn_.opcode() == BeamOpcode.is_nonempty_list
|| !test_type.equals(arg.type))
vis.visitTest(test, failLabel, arg, test_type);
return;
}
}
switch (test) {
case is_function2: {
Insn.LDS insn = (Insn.LDS) insn_;
vis.visitTest(test, failLabel,
dest_arg(insn_idx, insn.dest),
src_arg(insn_idx,insn.src),
EFUN_TYPE);
break;
}
case is_eq_exact:
/* hack to convert types ... */
case is_lt:
case is_ge:
case is_ne_exact:
case is_ne:
case is_eq: {
Insn.LSS insn = (Insn.LSS) insn_;
Arg[] args = new Arg[] {
src_arg(insn_idx, insn.src1),
src_arg(insn_idx, insn.src2) };
Type outType = Type.VOID_TYPE;
Type t1 = getType(typeMap, insn.src1);
Type t2 = getType(typeMap, insn.src2);
if (t1.equals(EOBJECT_TYPE) && !t2.equals(EOBJECT_TYPE)) {
outType = t2;
}
if (t2.equals(EOBJECT_TYPE) && !t1.equals(EOBJECT_TYPE)) {
outType = t1;
}
vis.visitTest(test, failLabel, args, outType);
break;
}
case test_arity: {
Insn.LDI insn = (Insn.LDI) insn_;
int arity = insn.i;
Arg reg = src_arg(insn_idx, insn.dest);
vis.visitTest(test, failLabel, reg, arity,
getTupleType(arity));
break;
}
case bs_start_match2:
case bs_get_utf8:
case bs_get_utf16:
case bs_get_utf32: {
Insn.LDIID insn = (Insn.LDIID) insn_;
vis.visitBitStringTest(test, failLabel,
src_arg(insn_idx, insn.dest),
insn.i4,
dest_arg(insn_idx, insn.dest5));
break;
}
case bs_match_string: {
Insn.LDBi insn = (Insn.LDBi) insn_;
vis.visitBitStringTest(test, failLabel,
src_arg(insn_idx, insn.dest),
insn.bin.value);
break;
}
case bs_get_integer2:
case bs_get_float2:
case bs_get_binary2: {
Insn.LDISIID insn = (Insn.LDISIID) insn_;
vis.visitBitStringTest(test, failLabel,
src_arg(insn_idx, insn.dest),
src_arg(insn_idx, insn.src4),
insn.i5,
insn.i6,
dest_arg(insn_idx, insn.dest7));
break;
}
case bs_skip_bits2: {
Insn.LDSII insn = (Insn.LDSII) insn_;
vis.visitBitStringTest(test, failLabel,
src_arg(insn_idx, insn.dest),
src_arg(insn_idx, insn.src3),
insn.i4,
insn.i5);
break;
}
case bs_test_unit:
case bs_test_tail2: {
Insn.LDI insn = (Insn.LDI) insn_;
vis.visitBitStringTest(test, failLabel,
src_arg(insn_idx, insn.dest),
insn.i);
break;
}
case bs_skip_utf8:
case bs_skip_utf16:
case bs_skip_utf32: {
Insn.LDII insn = (Insn.LDII) insn_;
vis.visitBitStringTest(test, failLabel,
src_arg(insn_idx, insn.dest),
insn.i4);
break;
}
default:
throw new Error("unhandled test: " + insn_.toSymbolic() +
" at index " + insn_idx +
" // " + test + ":" + test.ordinal());
}//switch
}