}
private FastSwitchType getHomogeneousSwitchType(List<Node> whenNodes) {
FastSwitchType foundType = null;
Outer: for (Node node : whenNodes) {
WhenNode whenNode = (WhenNode)node;
if (whenNode.getExpressionNodes() instanceof ArrayNode) {
ArrayNode arrayNode = (ArrayNode)whenNode.getExpressionNodes();
for (Node maybeFixnum : arrayNode.childNodes()) {
if (maybeFixnum instanceof FixnumNode) {
FixnumNode fixnumNode = (FixnumNode)maybeFixnum;
long value = fixnumNode.getValue();
if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
if (foundType != null && foundType != FastSwitchType.FIXNUM) return null;
if (foundType == null) foundType = FastSwitchType.FIXNUM;
continue;
} else {
return null;
}
} else {
return null;
}
}
} else if (whenNode.getExpressionNodes() instanceof FixnumNode) {
FixnumNode fixnumNode = (FixnumNode)whenNode.getExpressionNodes();
long value = fixnumNode.getValue();
if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
if (foundType != null && foundType != FastSwitchType.FIXNUM) return null;
if (foundType == null) foundType = FastSwitchType.FIXNUM;
continue;
} else {
return null;
}
} else if (whenNode.getExpressionNodes() instanceof StrNode) {
StrNode strNode = (StrNode)whenNode.getExpressionNodes();
if (strNode.getValue().length() == 1) {
if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_STRING) return null;
if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_STRING;
continue;
} else {
if (foundType != null && foundType != FastSwitchType.STRING) return null;
if (foundType == null) foundType = FastSwitchType.STRING;
continue;
}
} else if (whenNode.getExpressionNodes() instanceof SymbolNode) {
SymbolNode symbolNode = (SymbolNode)whenNode.getExpressionNodes();
if (symbolNode.getName().length() == 1) {
if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL) return null;
if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_SYMBOL;
continue;