int creation = 0;
ETuple2 tup;
if ((tup=ETuple2.cast(node_arg)) != null) {
node = tup.elem1.testAtom();
ESmall sm = tup.elem2.testSmall();
if (node == null || sm==null || !is_node_name_atom(node))
throw ERT.badarg(node_arg, cid_arg, type_arg);
creation = sm.value;
} else if ((node=node_arg.testAtom()) != null && is_node_name_atom(node)) {
// ok
} else {
throw ERT.badarg(node_arg, cid_arg, type_arg);
}
/** first arg is ok */
EInternalPort port = cid_arg.testInternalPort();
if (port == null) {
throw ERT.badarg(node_arg, cid_arg, type_arg);
}
ETuple t = type_arg.testTuple();
if (t.arity() != 4) {
throw ERT.badarg(node_arg, cid_arg, type_arg);
}
ESmall flags = t.elm(1).testSmall();
ESmall version = t.elm(2).testSmall();
if (flags == null || version == null) {
throw ERT.badarg(node_arg, cid_arg, type_arg);
}
EPeer n = EPeer.get_or_create(node, creation, port, flags.value, version.value);