if (size != 0 && size != base.stack.size()) {
if (conditionalTail) {
// transfer condition operands to the created node
// [non-condition] [condition]
Node created = createNodeAfter(base);
for (int i = 0; i < size; i++) {
OperandCondition condition = (OperandCondition) base.stack.pollLast();
// disconnect from base node
base.disconnect(condition.then);
base.disconnect(condition.elze);
// connect from created node
created.connect(condition.then);
created.connect(condition.elze);
// transfer operand
created.stack.addFirst(condition);
}
// connect from base to created
base.connect(created);
} else if (conditionalHead) {
// transfer non-condition operands to the created node
// [condition] [non-condition]
Node created = createNodeAfter(base);
// transfer operand
for (int i = 0; i < start; i++) {
created.stack.addFirst(base.stack.pollLast());
}
// search non-conditional operand's transition
Set<Node> transitions = new HashSet(base.outgoing);
for (OperandCondition condition : conditions) {
transitions.remove(condition.then);
}
for (Node transition : transitions) {
// disconnect from base
base.disconnect(transition);
// connect from created
created.connect(transition);
}
// connect from base to created
base.connect(created);
// connect from created to next
created.connect(base.destination == null ? created.destination : base.destination);
}
}
}