use of com.github.anba.es6draft.ast.NumericLiteral in project es6draft by anba.
the class SwitchStatementGenerator method intSwitchEntries.
private static long[] intSwitchEntries(List<SwitchClause> clauses, boolean hasDefault) {
long[] entries = new long[clauses.size() - (hasDefault ? 1 : 0)];
for (int i = 0, j = 0, size = clauses.size(); i < size; ++i) {
Expression expr = clauses.get(i).getExpression();
if (expr != null) {
int value;
if (expr instanceof NumericLiteral) {
value = ((NumericLiteral) expr).intValue();
} else {
value = -((NumericLiteral) ((UnaryExpression) expr).getOperand()).intValue();
}
entries[j++] = Entry(value, i);
}
}
// sort values in ascending order
Arrays.sort(entries);
return entries;
}
Aggregations