Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2010-01-12 07:53:10 -0500
committerMarkus Schorn2010-01-12 07:53:10 -0500
commit15a9ac904e99c85d98719c05f0506324068fe58c (patch)
tree199597e133d0178f84c5dc29f9b355618aa4aea7 /lrparser/org.eclipse.cdt.core.lrparser
parente3f899b9fc4135430e17fa1164337a8d295762c9 (diff)
downloadorg.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/org.eclipse.cdt.core.lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Enumeration.java39
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 86cc2ccff8..47b97f648a 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;
+ }
}

Back to the top