1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 10:25:32 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-11-15 14:27:31 -08:00
parent 1e824bb514
commit 1e3fc49c45
2 changed files with 33 additions and 23 deletions

View file

@ -91,6 +91,7 @@ public class Value implements IValue {
fResolvedUnknown= resolvedUnknowns; fResolvedUnknown= resolvedUnknowns;
fMap= map; fMap= map;
} }
public void nextSeperator() throws UnknownValueException { public void nextSeperator() throws UnknownValueException {
final char[] expression = fExpression; final char[] expression = fExpression;
final int len = expression.length; final int len = expression.length;
@ -400,7 +401,8 @@ public class Value implements IValue {
* Returns a {@code Number} for numerical values or a {@code String}, otherwise. * Returns a {@code Number} for numerical values or a {@code String}, otherwise.
* @throws UnknownValueException * @throws UnknownValueException
*/ */
private static Object evaluate(IASTExpression e, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException { private static Object evaluate(IASTExpression e, Map<String, Integer> unknownSigs,
List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
if (maxdepth < 0 || e == null) if (maxdepth < 0 || e == null)
throw UNKNOWN_EX; throw UNKNOWN_EX;
@ -433,7 +435,8 @@ public class Value implements IValue {
final IASTExpression pe = cexpr.getPositiveResultExpression(); final IASTExpression pe = cexpr.getPositiveResultExpression();
Object po= pe == null ? o : evaluate(pe, unknownSigs, unknowns, maxdepth); Object po= pe == null ? o : evaluate(pe, unknownSigs, unknowns, maxdepth);
Object neg= evaluate(cexpr.getNegativeResultExpression(), unknownSigs, unknowns, maxdepth); Object neg= evaluate(cexpr.getNegativeResultExpression(), unknownSigs, unknowns, maxdepth);
return "" + CONDITIONAL_CHAR + SEPARATOR + o.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$ return "" + CONDITIONAL_CHAR + SEPARATOR + o.toString() + SEPARATOR + po.toString() + //$NON-NLS-1$
SEPARATOR + neg.toString();
} }
if (e instanceof IASTIdExpression) { if (e instanceof IASTIdExpression) {
IBinding b= ((IASTIdExpression) e).getName().resolvePreBinding(); IBinding b= ((IASTIdExpression) e).getName().resolvePreBinding();
@ -483,7 +486,8 @@ public class Value implements IValue {
/** /**
* Extract a value off a binding. * Extract a value off a binding.
*/ */
private static Object evaluateBinding(IBinding b, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException { private static Object evaluateBinding(IBinding b, Map<String, Integer> unknownSigs,
List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
if (b instanceof IType) { if (b instanceof IType) {
throw UNKNOWN_EX; throw UNKNOWN_EX;
} }
@ -510,7 +514,8 @@ public class Value implements IValue {
throw UNKNOWN_EX; throw UNKNOWN_EX;
} }
private static Object createReference(ICPPUnknownBinding unknown, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns) { private static Object createReference(ICPPUnknownBinding unknown,
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns) {
String sig= getSignatureForUnknown(unknown); String sig= getSignatureForUnknown(unknown);
Integer idx= unknownSigs.get(sig); Integer idx= unknownSigs.get(sig);
if (idx == null) { if (idx == null) {
@ -521,7 +526,8 @@ public class Value implements IValue {
return "" + REFERENCE_CHAR + idx.toString(); //$NON-NLS-1$ return "" + REFERENCE_CHAR + idx.toString(); //$NON-NLS-1$
} }
private static Object evaluateValue(IValue cv, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns) throws UnknownValueException { private static Object evaluateValue(IValue cv, Map<String, Integer> unknownSigs,
List<ICPPUnknownBinding> unknowns) throws UnknownValueException {
if (cv == Value.UNKNOWN) if (cv == Value.UNKNOWN)
throw UNKNOWN_EX; throw UNKNOWN_EX;
@ -564,7 +570,9 @@ public class Value implements IValue {
return buf.toString(); return buf.toString();
} }
private static Object evaluateUnaryExpression(IASTUnaryExpression ue, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException { private static Object evaluateUnaryExpression(IASTUnaryExpression ue,
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth)
throws UnknownValueException {
final int unaryOp= ue.getOperator(); final int unaryOp= ue.getOperator();
if (unaryOp == IASTUnaryExpression.op_sizeof) { if (unaryOp == IASTUnaryExpression.op_sizeof) {
@ -626,7 +634,8 @@ public class Value implements IValue {
} }
private static Object evaluateBinaryExpression(IASTBinaryExpression be, private static Object evaluateBinaryExpression(IASTBinaryExpression be,
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException { Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth)
throws UnknownValueException {
final Object o1= evaluate(be.getOperand1(), unknownSigs, unknowns, maxdepth); final Object o1= evaluate(be.getOperand1(), unknownSigs, unknowns, maxdepth);
final Object o2= evaluate(be.getOperand2(), unknownSigs, unknowns, maxdepth); final Object o2= evaluate(be.getOperand2(), unknownSigs, unknowns, maxdepth);
@ -634,7 +643,8 @@ public class Value implements IValue {
return combineBinary(op, o1, o2); return combineBinary(op, o1, o2);
} }
private static Object combineBinary(final int op, final Object o1, final Object o2) throws UnknownValueException { private static Object combineBinary(final int op, final Object o1, final Object o2)
throws UnknownValueException {
if (o1 instanceof Number && o2 instanceof Number) { if (o1 instanceof Number && o2 instanceof Number) {
long v1= ((Number) o1).longValue(); long v1= ((Number) o1).longValue();
long v2= ((Number) o2).longValue(); long v2= ((Number) o2).longValue();
@ -721,7 +731,8 @@ public class Value implements IValue {
return "" + BINARY_OP_CHAR + op + SEPARATOR + o1.toString() + SEPARATOR + o2.toString(); //$NON-NLS-1$ return "" + BINARY_OP_CHAR + op + SEPARATOR + o1.toString() + SEPARATOR + o2.toString(); //$NON-NLS-1$
} }
public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns, ICPPTemplateParameterMap map, int maxdepth) { public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns,
ICPPTemplateParameterMap map, int maxdepth) {
try { try {
Map<String, Integer> unknownSigs= new HashMap<String, Integer>(); Map<String, Integer> unknownSigs= new HashMap<String, Integer>();
List<ICPPUnknownBinding> unknown= new ArrayList<ICPPUnknownBinding>(); List<ICPPUnknownBinding> unknown= new ArrayList<ICPPUnknownBinding>();
@ -783,7 +794,8 @@ public class Value implements IValue {
} }
return po; return po;
} }
return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$ return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + //$NON-NLS-1$
po.toString() + SEPARATOR + neg.toString();
case REFERENCE_CHAR: case REFERENCE_CHAR:
int num= parseNonNegative(buf, idx + 1); int num= parseNonNegative(buf, idx + 1);
final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown; final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown;

View file

@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/** /**
* @author Emanuel Graf IFS * @author Emanuel Graf IFS
*
*/ */
public class OffsetHelper { public class OffsetHelper {
@ -35,7 +34,8 @@ public class OffsetHelper {
} else { } else {
offset = location.asFileLocation().getNodeOffset(); offset = location.asFileLocation().getNodeOffset();
} }
if(offset < nodeStart) nodeStart = offset; if (offset < nodeStart)
nodeStart = offset;
} }
} else { } else {
nodeStart = node.getFileLocation().getNodeOffset(); nodeStart = node.getFileLocation().getNodeOffset();
@ -62,7 +62,6 @@ public class OffsetHelper {
} }
} else { } else {
IASTFileLocation loc = node.getFileLocation(); IASTFileLocation loc = node.getFileLocation();
fileOffset = loc.getNodeOffset(); fileOffset = loc.getNodeOffset();
length = loc.getNodeLength(); length = loc.getNodeLength();
} }
@ -75,7 +74,7 @@ public class OffsetHelper {
} }
public static int getLengthIncludingComment(IASTNode node) { public static int getLengthIncludingComment(IASTNode node) {
return OffsetHelper.getEndOffsetIncludingComments(node) - OffsetHelper.getOffsetIncludingComment(node); return getEndOffsetIncludingComments(node) - getOffsetIncludingComment(node);
} }
public static int getNodeOffset(ASTNode node) { public static int getNodeOffset(ASTNode node) {
@ -93,5 +92,4 @@ public class OffsetHelper {
public static int getEndingLineNumber(IASTNode node) { public static int getEndingLineNumber(IASTNode node) {
return node.getFileLocation().getEndingLineNumber(); return node.getFileLocation().getEndingLineNumber();
} }
} }