diff options
author | Markus Schorn | 2010-01-12 12:53:10 +0000 |
---|---|---|
committer | Markus Schorn | 2010-01-12 12:53:10 +0000 |
commit | 15a9ac904e99c85d98719c05f0506324068fe58c (patch) | |
tree | 199597e133d0178f84c5dc29f9b355618aa4aea7 /lrparser | |
parent | e3f899b9fc4135430e17fa1164337a8d295762c9 (diff) | |
download | org.eclipse.cdt-15a9ac904e99c85d98719c05f0506324068fe58c.tar.gz org.eclipse.cdt-15a9ac904e99c85d98719c05f0506324068fe58c.tar.xz org.eclipse.cdt-15a9ac904e99c85d98719c05f0506324068fe58c.zip |
Bug 231859: Optimization for computing int type of enum.
Diffstat (limited to 'lrparser')
-rw-r--r-- | lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java index 86cc2ccff8f..47b97f648a1 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; +import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.core.runtime.PlatformObject; @@ -112,4 +113,40 @@ public class C99Enumeration extends PlatformObject implements IC99Binding, IEnum } return null; } + + public long getMinValue() { + long minValue = Long.MAX_VALUE; + IEnumerator[] enumerators = getEnumerators(); + for (IEnumerator enumerator : enumerators) { + IValue value = enumerator.getValue(); + if (value != null) { + Long val = value.numericalValue(); + if (val != null) { + long v = val.longValue(); + if (v < minValue) { + minValue = v; + } + } + } + } + return minValue; + } + + public long getMaxValue() { + long maxValue = Long.MIN_VALUE; + IEnumerator[] enumerators = getEnumerators(); + for (IEnumerator enumerator : enumerators) { + IValue value = enumerator.getValue(); + if (value != null) { + Long val = value.numericalValue(); + if (val != null) { + long v = val.longValue(); + if (v > maxValue) { + maxValue = v; + } + } + } + } + return maxValue; + } } |