List of usage examples for org.eclipse.jdt.core.dom PrefixExpression resolveTypeBinding
public final ITypeBinding resolveTypeBinding()
From source file:ca.mcgill.cs.swevo.ppa.inference.PrefixInferenceStrategy.java
License:Open Source License
private void processOperators(PrefixExpression node, TypeFact newFact) { ITypeBinding newType = null;//w w w.j a v a 2 s .c o m Expression exp = node.getOperand(); boolean isPrimary = newFact != null && indexer.getMainIndex(node).equals(newFact.getIndex()); boolean isSafe = indexer.isSafe(exp) || (newFact != null && !isPrimary); if (node.getOperator() != PrefixExpression.Operator.NOT) { if (isPrimary && !isSafe) { ITypeBinding newBinding = newFact.getNewType(); ITypeBinding oldBinding = exp.resolveTypeBinding(); TypeFact typeFact = new TypeFact(indexer.getMainIndex(exp), oldBinding, TypeFact.UNKNOWN, newBinding, TypeFact.SUBTYPE, TypeFact.UNARY_STRATEGY); ppaEngine.reportTypeFact(typeFact); newType = newBinding; } else if (!isSafe) { ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", exp); ITypeBinding oldBinding = exp.resolveTypeBinding(); TypeFact typeFact = new TypeFact(indexer.getMainIndex(exp), oldBinding, TypeFact.UNKNOWN, newBinding, TypeFact.SUBTYPE, TypeFact.UNARY_STRATEGY); ppaEngine.reportTypeFact(typeFact); newType = newBinding; } } else if (!isSafe) { ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", exp); ITypeBinding oldBinding = exp.resolveTypeBinding(); TypeFact typeFact = new TypeFact(indexer.getMainIndex(exp), oldBinding, TypeFact.UNKNOWN, newBinding, TypeFact.SUBTYPE, TypeFact.UNARY_STRATEGY); ppaEngine.reportTypeFact(typeFact); newType = newBinding; } if (newType != null && !isPrimary) { ITypeBinding oldBinding = node.resolveTypeBinding(); TypeFact typeFact = new TypeFact(indexer.getMainIndex(node), oldBinding, TypeFact.UNKNOWN, newType, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY); ppaEngine.reportTypeFact(typeFact); // report new type for this expression. // fix this expression. } else if (isPrimary) { if (newType != null) { ppaEngine.getRegistry().fixUnary(node, newType); } else if (newFact != null) { ppaEngine.getRegistry().fixUnary(node, newFact.getNewType()); } } }
From source file:com.google.devtools.j2cpp.types.BindingMapBuilder.java
License:Open Source License
@Override public boolean visit(PrefixExpression node) { put(node, node.resolveTypeBinding()); return true; }