/** * Create a representation of a range from <code>min</code> to <code>max</code>. If <code> * min > max</code>, the bound is considered to be unbounded. * * @param min the lower bound * @param max the upper bound */ public static Bound create(long min, long max) { if (min > max) return noBound; IntegerType intType = Machine.currentMachine.getIntegerCalcType(); Literal lit0 = LiteralMap.put(min, intType); Literal litn = LiteralMap.put(max, intType); return create(lit0, litn); }
private Bound(long min, long max, long numberOfElements, int flags) { IntegerType intType = Machine.currentMachine.getIntegerCalcType(); this.min = LiteralMap.put(min, intType); this.minValue = min; this.max = LiteralMap.put(max, intType); this.maxValue = max; this.numberOfElements = numberOfElements; this.flags = flags; }
public Object doEvaluate(Object leftOperand, Object rightOperand) throws Exception { LiteralMap literalMap = (LiteralMap) leftOperand; Entry literalEntry = (Entry) rightOperand; try { literalMap.put(literalEntry.getKey(), literalEntry.getValue()); return literalMap; } catch (UnsupportedOperationException e) { // 当Map不支持put方法时,即unmodified Map newMap = new HashMap(); newMap.putAll(literalMap); newMap.put(literalEntry.getKey(), literalEntry.getValue()); return newMap; } }
/** * Create a representation of a range from min to max. * * @param min is the lower bound * @param max is the upper bound */ public static Bound create(Expression min, Expression max) { if (max == null) { if (min == null) return noBound; max = LiteralMap.put(0x7ffffff, Machine.currentMachine.getIntegerCalcType()); } if (bounds != null) { int n = bounds.size(); for (int i = 0; i < n; i++) { Bound ta = bounds.elementAt(i); if (!min.equivalent(ta.min)) continue; if (!max.equivalent(ta.max)) continue; return ta; } } Bound a = new Bound(min, max); return a; }