|
Lines 187-193
Link Here
|
| 187 |
import org.eclipse.jdt.internal.debug.eval.ast.instructions.Value; |
187 |
import org.eclipse.jdt.internal.debug.eval.ast.instructions.Value; |
| 188 |
import org.eclipse.jdt.internal.debug.eval.ast.instructions.XorAssignmentOperator; |
188 |
import org.eclipse.jdt.internal.debug.eval.ast.instructions.XorAssignmentOperator; |
| 189 |
import org.eclipse.jdt.internal.debug.eval.ast.instructions.XorOperator; |
189 |
import org.eclipse.jdt.internal.debug.eval.ast.instructions.XorOperator; |
| 190 |
|
190 |
import com.ibm.icu.text.MessageFormat; |
| 191 |
/** |
191 |
/** |
| 192 |
* The AST instruction compiler generates a sequence |
192 |
* The AST instruction compiler generates a sequence |
| 193 |
* of instructions (InstructionSequence) from a |
193 |
* of instructions (InstructionSequence) from a |
|
Lines 441-452
Link Here
|
| 441 |
|
441 |
|
| 442 |
if (expression instanceof MethodInvocation) { |
442 |
if (expression instanceof MethodInvocation) { |
| 443 |
IMethodBinding methodBinding= (IMethodBinding)((MethodInvocation)expression).getName().resolveBinding(); |
443 |
IMethodBinding methodBinding= (IMethodBinding)((MethodInvocation)expression).getName().resolveBinding(); |
| 444 |
if ("void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
444 |
if (methodBinding != null && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
| 445 |
pop= false; |
445 |
pop= false; |
| 446 |
} |
446 |
} |
| 447 |
} else if (expression instanceof SuperMethodInvocation) { |
447 |
} else if (expression instanceof SuperMethodInvocation) { |
| 448 |
IMethodBinding methodBinding= (IMethodBinding)((SuperMethodInvocation)expression).getName().resolveBinding(); |
448 |
IMethodBinding methodBinding= (IMethodBinding)((SuperMethodInvocation)expression).getName().resolveBinding(); |
| 449 |
if ("void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
449 |
if (methodBinding != null && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
| 450 |
pop= false; |
450 |
pop= false; |
| 451 |
} |
451 |
} |
| 452 |
} else if (expression instanceof VariableDeclarationExpression) { |
452 |
} else if (expression instanceof VariableDeclarationExpression) { |
|
Lines 590-596
Link Here
|
| 590 |
public void endVisit(ArrayAccess node) { |
590 |
public void endVisit(ArrayAccess node) { |
| 591 |
if (!isActive() || hasErrors()) |
591 |
if (!isActive() || hasErrors()) |
| 592 |
return; |
592 |
return; |
| 593 |
storeInstruction(); |
593 |
ITypeBinding typeBinding = node.getIndex().resolveTypeBinding(); |
|
|
594 |
if (typeBinding != null) { |
| 595 |
storeInstruction(); |
| 596 |
} |
| 594 |
} |
597 |
} |
| 595 |
|
598 |
|
| 596 |
/** |
599 |
/** |
|
Lines 1515-1524
Link Here
|
| 1515 |
|
1518 |
|
| 1516 |
ArrayType arrayType= node.getType(); |
1519 |
ArrayType arrayType= node.getType(); |
| 1517 |
|
1520 |
|
| 1518 |
if (isALocalType(arrayType.resolveBinding().getElementType())) { |
1521 |
ITypeBinding binding = resolveTypeBinding(arrayType); |
|
|
1522 |
if (binding != null && isALocalType(arrayType.resolveBinding().getElementType())) { |
| 1519 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Local_type_array_instance_creation_cannot_be_used_in_an_evaluation_expression_29); |
1523 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Local_type_array_instance_creation_cannot_be_used_in_an_evaluation_expression_29); |
| 1520 |
setHasError(true); |
1524 |
setHasError(true); |
| 1521 |
return true; |
1525 |
return false; |
| 1522 |
} |
1526 |
} |
| 1523 |
|
1527 |
|
| 1524 |
push(new ArrayAllocation(arrayType.getDimensions(), node.dimensions().size(), node.getInitializer() != null, fCounter)); |
1528 |
push(new ArrayAllocation(arrayType.getDimensions(), node.dimensions().size(), node.getInitializer() != null, fCounter)); |
|
Lines 1534-1545
Link Here
|
| 1534 |
return false; |
1538 |
return false; |
| 1535 |
} |
1539 |
} |
| 1536 |
|
1540 |
|
| 1537 |
ITypeBinding typeBinding= node.resolveTypeBinding(); |
1541 |
ITypeBinding typeBinding= resolveTypeBinding(node); |
| 1538 |
int dimension= typeBinding.getDimensions(); |
1542 |
if (typeBinding != null) { |
| 1539 |
String signature= getTypeSignature(typeBinding.getElementType()); |
1543 |
int dimension = typeBinding.getDimensions(); |
| 1540 |
|
1544 |
String signature = getTypeSignature(typeBinding.getElementType()); |
| 1541 |
push(new ArrayInitializerInstruction(signature, node.expressions().size(), dimension, fCounter)); |
|
|
| 1542 |
|
1545 |
|
|
|
1546 |
push(new ArrayInitializerInstruction(signature, node.expressions() |
| 1547 |
.size(), dimension, fCounter)); |
| 1548 |
} |
| 1543 |
return true; |
1549 |
return true; |
| 1544 |
} |
1550 |
} |
| 1545 |
|
1551 |
|
|
Lines 1550-1561
Link Here
|
| 1550 |
if (!isActive()) { |
1556 |
if (!isActive()) { |
| 1551 |
return false; |
1557 |
return false; |
| 1552 |
} |
1558 |
} |
| 1553 |
ITypeBinding arrayTypeBinding= node.resolveBinding(); |
1559 |
ITypeBinding arrayTypeBinding= resolveTypeBinding(node); |
| 1554 |
int dimension= arrayTypeBinding.getDimensions(); |
1560 |
if (arrayTypeBinding != null) { |
| 1555 |
String signature= getTypeSignature(arrayTypeBinding.getElementType()); |
1561 |
int dimension = arrayTypeBinding.getDimensions(); |
| 1556 |
|
1562 |
String signature = getTypeSignature(arrayTypeBinding |
| 1557 |
push(new PushArrayType(signature, dimension, fCounter)); |
1563 |
.getElementType()); |
| 1558 |
|
1564 |
|
|
|
1565 |
push(new PushArrayType(signature, dimension, fCounter)); |
| 1566 |
} |
| 1559 |
return false; |
1567 |
return false; |
| 1560 |
} |
1568 |
} |
| 1561 |
|
1569 |
|
|
Lines 1568-1574
Link Here
|
| 1568 |
} |
1576 |
} |
| 1569 |
setHasError(true); |
1577 |
setHasError(true); |
| 1570 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Assert_statement_cannot_be_used_in_an_evaluation_expression_3); |
1578 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Assert_statement_cannot_be_used_in_an_evaluation_expression_3); |
| 1571 |
return true; |
1579 |
return false; |
| 1572 |
} |
1580 |
} |
| 1573 |
|
1581 |
|
| 1574 |
/** |
1582 |
/** |
|
Lines 1591-1596
Link Here
|
| 1591 |
char2 = opToken.charAt(2); |
1599 |
char2 = opToken.charAt(2); |
| 1592 |
} |
1600 |
} |
| 1593 |
|
1601 |
|
|
|
1602 |
ITypeBinding rightBinding = resolveTypeBinding(rightHandSide); |
| 1603 |
if (rightBinding == null) { |
| 1604 |
return false; |
| 1605 |
} |
| 1606 |
ITypeBinding leftBinding = resolveTypeBinding(leftHandSide); |
| 1607 |
if (leftBinding == null) { |
| 1608 |
return false; |
| 1609 |
} |
| 1594 |
if (variableTypeId == Instruction.T_Object) { |
1610 |
if (variableTypeId == Instruction.T_Object) { |
| 1595 |
// If the variable is an object, the value may need to be boxed for |
1611 |
// If the variable is an object, the value may need to be boxed for |
| 1596 |
// the simple assignment. |
1612 |
// the simple assignment. |
|
Lines 1609-1616
Link Here
|
| 1609 |
if (char0 == '=') { |
1625 |
if (char0 == '=') { |
| 1610 |
|
1626 |
|
| 1611 |
boolean storeRequired= false; |
1627 |
boolean storeRequired= false; |
| 1612 |
if (rightHandSide.resolveTypeBinding().isPrimitive()) { |
1628 |
if (rightBinding.isPrimitive()) { |
| 1613 |
boxing(leftHandSide.resolveTypeBinding(), rightHandSide.resolveTypeBinding()); |
1629 |
boxing(leftBinding, rightBinding); |
| 1614 |
storeRequired= true; |
1630 |
storeRequired= true; |
| 1615 |
} |
1631 |
} |
| 1616 |
rightHandSide.accept(this); |
1632 |
rightHandSide.accept(this); |
|
Lines 1622-1628
Link Here
|
| 1622 |
boolean unrecognized = false; |
1638 |
boolean unrecognized = false; |
| 1623 |
|
1639 |
|
| 1624 |
|
1640 |
|
| 1625 |
boxing(leftHandSide.resolveTypeBinding(), rightHandSide.resolveTypeBinding()); |
1641 |
boxing(leftBinding, rightBinding); |
| 1626 |
|
1642 |
|
| 1627 |
switch (char0) { |
1643 |
switch (char0) { |
| 1628 |
case '=': // equal |
1644 |
case '=': // equal |
|
Lines 1678-1689
Link Here
|
| 1678 |
return false; |
1694 |
return false; |
| 1679 |
} |
1695 |
} |
| 1680 |
|
1696 |
|
| 1681 |
unBoxing(leftHandSide.resolveTypeBinding()); |
1697 |
unBoxing(leftBinding); |
| 1682 |
push(new Dup()); |
1698 |
push(new Dup()); |
| 1683 |
storeInstruction(); // dupe |
1699 |
storeInstruction(); // dupe |
| 1684 |
storeInstruction(); // un-boxing |
1700 |
storeInstruction(); // un-boxing |
| 1685 |
|
1701 |
|
| 1686 |
boolean storeRequired= unBoxing(rightHandSide.resolveTypeBinding()); |
1702 |
boolean storeRequired= unBoxing(rightBinding); |
| 1687 |
rightHandSide.accept(this); |
1703 |
rightHandSide.accept(this); |
| 1688 |
if (storeRequired) { |
1704 |
if (storeRequired) { |
| 1689 |
storeInstruction(); // un-boxing |
1705 |
storeInstruction(); // un-boxing |
|
Lines 1753-1759
Link Here
|
| 1753 |
} |
1769 |
} |
| 1754 |
|
1770 |
|
| 1755 |
leftHandSide.accept(this); |
1771 |
leftHandSide.accept(this); |
| 1756 |
boolean storeRequired= unBoxing(rightHandSide.resolveTypeBinding()); |
1772 |
boolean storeRequired= unBoxing(rightBinding); |
| 1757 |
rightHandSide.accept(this); |
1773 |
rightHandSide.accept(this); |
| 1758 |
if (storeRequired) { |
1774 |
if (storeRequired) { |
| 1759 |
storeInstruction(); |
1775 |
storeInstruction(); |
|
Lines 1833-1852
Link Here
|
| 1833 |
|
1849 |
|
| 1834 |
Type type= node.getType(); |
1850 |
Type type= node.getType(); |
| 1835 |
int typeId= getTypeId(type); |
1851 |
int typeId= getTypeId(type); |
| 1836 |
ITypeBinding typeBinding= type.resolveBinding(); |
|
|
| 1837 |
|
| 1838 |
String baseTypeSignature; |
| 1839 |
int dimension= typeBinding.getDimensions(); |
| 1840 |
|
| 1841 |
if (typeBinding.isArray()) { |
| 1842 |
typeBinding= typeBinding.getElementType(); |
| 1843 |
} |
| 1844 |
|
1852 |
|
| 1845 |
baseTypeSignature= getTypeName(typeBinding); |
1853 |
ITypeBinding typeBinding= resolveTypeBinding(type); |
| 1846 |
|
1854 |
|
| 1847 |
push(new Cast(typeId, baseTypeSignature, dimension, fCounter)); |
1855 |
if (typeBinding != null) { |
| 1848 |
|
1856 |
|
| 1849 |
node.getExpression().accept(this); |
1857 |
String baseTypeSignature; |
|
|
1858 |
int dimension = typeBinding.getDimensions(); |
| 1859 |
|
| 1860 |
if (typeBinding.isArray()) { |
| 1861 |
typeBinding = typeBinding.getElementType(); |
| 1862 |
} |
| 1863 |
baseTypeSignature = getTypeName(typeBinding); |
| 1864 |
push(new Cast(typeId, baseTypeSignature, dimension, fCounter)); |
| 1865 |
node.getExpression().accept(this); |
| 1866 |
} |
| 1850 |
|
1867 |
|
| 1851 |
return false; |
1868 |
return false; |
| 1852 |
} |
1869 |
} |
|
Lines 1860-1866
Link Here
|
| 1860 |
} |
1877 |
} |
| 1861 |
setHasError(true); |
1878 |
setHasError(true); |
| 1862 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Catch_clause_cannot_be_used_in_an_evaluation_expression_6); |
1879 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Catch_clause_cannot_be_used_in_an_evaluation_expression_6); |
| 1863 |
return true; |
1880 |
return false; |
| 1864 |
} |
1881 |
} |
| 1865 |
|
1882 |
|
| 1866 |
/** |
1883 |
/** |
|
Lines 1891-1898
Link Here
|
| 1891 |
} |
1908 |
} |
| 1892 |
|
1909 |
|
| 1893 |
IMethodBinding methodBinding= node.resolveConstructorBinding(); |
1910 |
IMethodBinding methodBinding= node.resolveConstructorBinding(); |
|
|
1911 |
if (methodBinding == null) { |
| 1912 |
setHasError(true); |
| 1913 |
addErrorMessage(MessageFormat.format( |
| 1914 |
EvaluationEngineMessages.ASTInstructionCompiler_1, |
| 1915 |
new String[] { node.toString() })); |
| 1916 |
return false; |
| 1917 |
} |
| 1894 |
ITypeBinding typeBinding= methodBinding.getDeclaringClass(); |
1918 |
ITypeBinding typeBinding= methodBinding.getDeclaringClass(); |
| 1895 |
ITypeBinding enclosingTypeBinding= typeBinding.getDeclaringClass(); |
|
|
| 1896 |
|
1919 |
|
| 1897 |
boolean isInstanceMemberType= typeBinding.isMember() && ! Modifier.isStatic(typeBinding.getModifiers()); |
1920 |
boolean isInstanceMemberType= typeBinding.isMember() && ! Modifier.isStatic(typeBinding.getModifiers()); |
| 1898 |
|
1921 |
|
|
Lines 1908-1920
Link Here
|
| 1908 |
|
1931 |
|
| 1909 |
|
1932 |
|
| 1910 |
if (hasErrors()) { |
1933 |
if (hasErrors()) { |
| 1911 |
return true; |
1934 |
return false; |
| 1912 |
} |
1935 |
} |
| 1913 |
|
1936 |
|
| 1914 |
int argCount= methodBinding.getParameterTypes().length; |
1937 |
int argCount= methodBinding.getParameterTypes().length; |
| 1915 |
|
1938 |
ITypeBinding enclosingTypeBinding= null; |
| 1916 |
String enclosingTypeSignature= null; |
1939 |
String enclosingTypeSignature= null; |
| 1917 |
if (isInstanceMemberType) { |
1940 |
if (isInstanceMemberType) { |
|
|
1941 |
enclosingTypeBinding = typeBinding.getDeclaringClass(); |
| 1942 |
if (enclosingTypeBinding == null) { |
| 1943 |
setHasError(true); |
| 1944 |
addErrorMessage(MessageFormat.format( |
| 1945 |
EvaluationEngineMessages.ASTInstructionCompiler_2, |
| 1946 |
new String[] { typeBinding.getQualifiedName() })); |
| 1947 |
return false; |
| 1948 |
} |
| 1918 |
enclosingTypeSignature= getTypeSignature(enclosingTypeBinding); |
1949 |
enclosingTypeSignature= getTypeSignature(enclosingTypeBinding); |
| 1919 |
argCount++; |
1950 |
argCount++; |
| 1920 |
} |
1951 |
} |
|
Lines 1939-1945
Link Here
|
| 1939 |
if (Modifier.isStatic(((MethodDeclaration)parent).getModifiers())) { |
1970 |
if (Modifier.isStatic(((MethodDeclaration)parent).getModifiers())) { |
| 1940 |
setHasError(true); |
1971 |
setHasError(true); |
| 1941 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Must_explicitly_qualify_the_allocation_with_an_instance_of_the_enclosing_type_33); |
1972 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Must_explicitly_qualify_the_allocation_with_an_instance_of_the_enclosing_type_33); |
| 1942 |
return true; |
1973 |
return false; |
| 1943 |
} |
1974 |
} |
| 1944 |
|
1975 |
|
| 1945 |
push(new PushThis(getEnclosingLevel(node, enclosingTypeBinding))); |
1976 |
push(new PushThis(getEnclosingLevel(node, enclosingTypeBinding))); |
|
Lines 2043-2051
Link Here
|
| 2043 |
push(new NoOp(fCounter)); |
2074 |
push(new NoOp(fCounter)); |
| 2044 |
|
2075 |
|
| 2045 |
|
2076 |
|
| 2046 |
ITypeBinding typeBinding= node.getExpression().resolveTypeBinding(); |
2077 |
ITypeBinding typeBinding = resolveTypeBinding(node.getExpression()); |
| 2047 |
Type paramType= node.getParameter().getType(); |
2078 |
if (typeBinding == null) { |
| 2048 |
ITypeBinding paramBinding = paramType.resolveBinding(); |
2079 |
return false; |
|
|
2080 |
} |
| 2081 |
Type paramType = node.getParameter().getType(); |
| 2082 |
ITypeBinding paramBinding = resolveTypeBinding(paramType); |
| 2083 |
if (paramBinding == null) { |
| 2084 |
return false; |
| 2085 |
} |
| 2049 |
String typeSignature= getTypeSignature(paramBinding); |
2086 |
String typeSignature= getTypeSignature(paramBinding); |
| 2050 |
int paramTypeId= getTypeId(paramType); |
2087 |
int paramTypeId= getTypeId(paramType); |
| 2051 |
boolean isParamPrimitiveType= paramTypeId != Instruction.T_Object && paramTypeId != Instruction.T_String; |
2088 |
boolean isParamPrimitiveType= paramTypeId != Instruction.T_Object && paramTypeId != Instruction.T_String; |
|
Lines 2309-2316
Link Here
|
| 2309 |
Expression rightOperand= node.getRightOperand(); |
2346 |
Expression rightOperand= node.getRightOperand(); |
| 2310 |
int leftTypeId; |
2347 |
int leftTypeId; |
| 2311 |
int rightTypeId; |
2348 |
int rightTypeId; |
|
|
2349 |
ITypeBinding leftBinding = resolveTypeBinding(leftOperand); |
| 2350 |
if (leftBinding == null) { |
| 2351 |
return false; |
| 2352 |
} |
| 2353 |
ITypeBinding rightBinding = resolveTypeBinding(rightOperand); |
| 2354 |
if (rightBinding == null) { |
| 2355 |
return false; |
| 2356 |
} |
| 2312 |
// == case, do not un-box, if the two operands are objects |
2357 |
// == case, do not un-box, if the two operands are objects |
| 2313 |
boolean unbox= char0 != '=' || leftOperand.resolveTypeBinding().isPrimitive() || rightOperand.resolveTypeBinding().isPrimitive(); |
2358 |
boolean unbox= char0 != '=' || leftBinding.isPrimitive() || rightBinding.isPrimitive(); |
| 2314 |
if (unbox) { |
2359 |
if (unbox) { |
| 2315 |
leftTypeId= getUnBoxedTypeId(leftOperand); |
2360 |
leftTypeId= getUnBoxedTypeId(leftOperand); |
| 2316 |
rightTypeId = getUnBoxedTypeId(rightOperand); |
2361 |
rightTypeId = getUnBoxedTypeId(rightOperand); |
|
Lines 2475-2481
Link Here
|
| 2475 |
} |
2520 |
} |
| 2476 |
|
2521 |
|
| 2477 |
if (hasErrors()) { |
2522 |
if (hasErrors()) { |
| 2478 |
return true; |
2523 |
return false; |
| 2479 |
} |
2524 |
} |
| 2480 |
|
2525 |
|
| 2481 |
iterator = extendedOperands.iterator(); |
2526 |
iterator = extendedOperands.iterator(); |
|
Lines 2487-2493
Link Here
|
| 2487 |
ConditionalJump[] conditionalJumps= new ConditionalJump[operatorNumber]; |
2532 |
ConditionalJump[] conditionalJumps= new ConditionalJump[operatorNumber]; |
| 2488 |
int[] conditionalJumpAddresses = new int[operatorNumber]; |
2533 |
int[] conditionalJumpAddresses = new int[operatorNumber]; |
| 2489 |
|
2534 |
|
| 2490 |
boolean storeRequired= unBoxing(leftOperand.resolveTypeBinding()); |
2535 |
boolean storeRequired= unBoxing(leftBinding); |
| 2491 |
leftOperand.accept(this); |
2536 |
leftOperand.accept(this); |
| 2492 |
if (storeRequired) { |
2537 |
if (storeRequired) { |
| 2493 |
storeInstruction(); |
2538 |
storeInstruction(); |
|
Lines 2499-2505
Link Here
|
| 2499 |
push(conditionalJump); |
2544 |
push(conditionalJump); |
| 2500 |
storeInstruction(); |
2545 |
storeInstruction(); |
| 2501 |
|
2546 |
|
| 2502 |
storeRequired= unBoxing(rightOperand.resolveTypeBinding()); |
2547 |
storeRequired= unBoxing(rightBinding); |
| 2503 |
rightOperand.accept(this); |
2548 |
rightOperand.accept(this); |
| 2504 |
if (storeRequired) { |
2549 |
if (storeRequired) { |
| 2505 |
storeInstruction(); |
2550 |
storeInstruction(); |
|
Lines 2512-2518
Link Here
|
| 2512 |
push(conditionalJump); |
2557 |
push(conditionalJump); |
| 2513 |
storeInstruction(); |
2558 |
storeInstruction(); |
| 2514 |
Expression operand= (Expression) iterator.next(); |
2559 |
Expression operand= (Expression) iterator.next(); |
| 2515 |
storeRequired= unBoxing(operand.resolveTypeBinding()); |
2560 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
|
|
2561 |
if (typeBinding == null) { |
| 2562 |
return false; |
| 2563 |
} |
| 2564 |
storeRequired = unBoxing(typeBinding); |
| 2516 |
operand.accept(this); |
2565 |
operand.accept(this); |
| 2517 |
if (storeRequired) { |
2566 |
if (storeRequired) { |
| 2518 |
storeInstruction(); |
2567 |
storeInstruction(); |
|
Lines 2538-2551
Link Here
|
| 2538 |
|
2587 |
|
| 2539 |
boolean storeRequired= false; |
2588 |
boolean storeRequired= false; |
| 2540 |
if (unbox) { |
2589 |
if (unbox) { |
| 2541 |
storeRequired= unBoxing(leftOperand.resolveTypeBinding()); |
2590 |
storeRequired= unBoxing(leftBinding); |
| 2542 |
} |
2591 |
} |
| 2543 |
leftOperand.accept(this); |
2592 |
leftOperand.accept(this); |
| 2544 |
if (storeRequired) { |
2593 |
if (storeRequired) { |
| 2545 |
storeInstruction(); |
2594 |
storeInstruction(); |
| 2546 |
} |
2595 |
} |
| 2547 |
if (unbox) { |
2596 |
if (unbox) { |
| 2548 |
storeRequired= unBoxing(rightOperand.resolveTypeBinding()); |
2597 |
storeRequired= unBoxing(rightBinding); |
| 2549 |
} |
2598 |
} |
| 2550 |
rightOperand.accept(this); |
2599 |
rightOperand.accept(this); |
| 2551 |
if (storeRequired) { |
2600 |
if (storeRequired) { |
|
Lines 2556-2562
Link Here
|
| 2556 |
for (int i= 1; i < operatorNumber; i ++) { |
2605 |
for (int i= 1; i < operatorNumber; i ++) { |
| 2557 |
Expression operand= (Expression) iterator.next(); |
2606 |
Expression operand= (Expression) iterator.next(); |
| 2558 |
if (unbox) { |
2607 |
if (unbox) { |
| 2559 |
storeRequired= unBoxing(operand.resolveTypeBinding()); |
2608 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
|
|
2609 |
if (typeBinding == null) { |
| 2610 |
return false; |
| 2611 |
} |
| 2612 |
storeRequired= unBoxing(typeBinding); |
| 2560 |
} |
2613 |
} |
| 2561 |
operand.accept(this); |
2614 |
operand.accept(this); |
| 2562 |
if (storeRequired) { |
2615 |
if (storeRequired) { |
|
Lines 2672-2687
Link Here
|
| 2672 |
} |
2725 |
} |
| 2673 |
|
2726 |
|
| 2674 |
if (hasErrors()) { |
2727 |
if (hasErrors()) { |
| 2675 |
return true; |
2728 |
return false; |
| 2676 |
} |
2729 |
} |
| 2677 |
|
2730 |
|
| 2678 |
if (containsALocalType(methodBinding)) { |
2731 |
if (containsALocalType(methodBinding)) { |
| 2679 |
setHasError(true); |
2732 |
setHasError(true); |
| 2680 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
2733 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
| 2681 |
} |
2734 |
return false; |
| 2682 |
|
|
|
| 2683 |
if (hasErrors()) { |
| 2684 |
return true; |
| 2685 |
} |
2735 |
} |
| 2686 |
|
2736 |
|
| 2687 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
2737 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
|
Lines 2712-2721
Link Here
|
| 2712 |
|
2762 |
|
| 2713 |
List arguments = node.arguments(); |
2763 |
List arguments = node.arguments(); |
| 2714 |
int argCount = arguments.size(); |
2764 |
int argCount = arguments.size(); |
| 2715 |
if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == ((Expression)arguments.get(argCount - 1)).resolveTypeBinding().getDimensions())) { |
2765 |
ITypeBinding lastArgBinding = null; |
| 2716 |
// if this method is a varargs, and if the method is invoked using the varargs syntax |
2766 |
if (methodBinding.isVarargs()) { |
|
|
2767 |
Expression lastArg = (Expression) arguments.get(argCount - 1); |
| 2768 |
lastArgBinding = resolveTypeBinding(lastArg); |
| 2769 |
if (lastArgBinding == null) { |
| 2770 |
return false; |
| 2771 |
} |
| 2772 |
} |
| 2773 |
if (methodBinding.isVarargs() |
| 2774 |
&& !(paramCount == argCount && parameterTypes[paramCount - 1] |
| 2775 |
.getDimensions() == lastArgBinding.getDimensions())) { |
| 2776 |
// if this method is a varargs, and if the method is invoked using |
| 2777 |
// the varargs syntax |
| 2717 |
// (multiple arguments) and not an array |
2778 |
// (multiple arguments) and not an array |
| 2718 |
Iterator iterator= arguments.iterator(); |
2779 |
Iterator iterator = arguments.iterator(); |
| 2719 |
// process the first arguments (no part of the variable argument) |
2780 |
// process the first arguments (no part of the variable argument) |
| 2720 |
for (int i= 0; i < paramCount - 1; i++) { |
2781 |
for (int i= 0; i < paramCount - 1; i++) { |
| 2721 |
Expression argument= (Expression)iterator.next(); |
2782 |
Expression argument= (Expression)iterator.next(); |
|
Lines 2908-2915
Link Here
|
| 2908 |
if (!isActive()) { |
2969 |
if (!isActive()) { |
| 2909 |
return false; |
2970 |
return false; |
| 2910 |
} |
2971 |
} |
| 2911 |
ITypeBinding typeBinding = node.resolveBinding(); |
2972 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 2912 |
push(new PushType(getTypeName(typeBinding))); |
2973 |
if (typeBinding != null) { |
|
|
2974 |
push(new PushType(getTypeName(typeBinding))); |
| 2975 |
} |
| 2913 |
return false; |
2976 |
return false; |
| 2914 |
} |
2977 |
} |
| 2915 |
|
2978 |
|
|
Lines 2954-2960
Link Here
|
| 2954 |
default: |
3017 |
default: |
| 2955 |
setHasError(true); |
3018 |
setHasError(true); |
| 2956 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
3019 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
| 2957 |
break; |
3020 |
return false; |
| 2958 |
} |
3021 |
} |
| 2959 |
push(new Value(fCounter)); |
3022 |
push(new Value(fCounter)); |
| 2960 |
push(new Dup()); |
3023 |
push(new Dup()); |
|
Lines 2962-2973
Link Here
|
| 2962 |
storeInstruction(); // value |
3025 |
storeInstruction(); // value |
| 2963 |
push(new DupX1()); |
3026 |
push(new DupX1()); |
| 2964 |
storeInstruction(); // dup_x1 |
3027 |
storeInstruction(); // dup_x1 |
| 2965 |
unBoxing(operand.resolveTypeBinding()); |
3028 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
|
|
3029 |
if (typeBinding == null) { |
| 3030 |
return false; |
| 3031 |
} |
| 3032 |
unBoxing(typeBinding); |
| 2966 |
storeInstruction(); // un-boxing |
3033 |
storeInstruction(); // un-boxing |
| 2967 |
push(new PushInt(1)); |
3034 |
push(new PushInt(1)); |
| 2968 |
storeInstruction(); // push 1 |
3035 |
storeInstruction(); // push 1 |
| 2969 |
storeInstruction(); // operator |
3036 |
storeInstruction(); // operator |
| 2970 |
boxing(operand.resolveTypeBinding(), null); |
3037 |
boxing(typeBinding, null); |
| 2971 |
storeInstruction(); // boxing |
3038 |
storeInstruction(); // boxing |
| 2972 |
storeInstruction(); // assignment |
3039 |
storeInstruction(); // assignment |
| 2973 |
push(new Pop(assignmentInstruction.getSize() + 1)); |
3040 |
push(new Pop(assignmentInstruction.getSize() + 1)); |
|
Lines 2986-2992
Link Here
|
| 2986 |
default: |
3053 |
default: |
| 2987 |
setHasError(true); |
3054 |
setHasError(true); |
| 2988 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
3055 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
| 2989 |
break; |
3056 |
return false; |
| 2990 |
} |
3057 |
} |
| 2991 |
|
3058 |
|
| 2992 |
return true; |
3059 |
return true; |
|
Lines 3017-3022
Link Here
|
| 3017 |
|
3084 |
|
| 3018 |
int expressionUnBoxedTypeId= getUnBoxedTypeId(operand); |
3085 |
int expressionUnBoxedTypeId= getUnBoxedTypeId(operand); |
| 3019 |
|
3086 |
|
|
|
3087 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
| 3088 |
if (typeBinding == null) { |
| 3089 |
return false; |
| 3090 |
} |
| 3091 |
|
| 3020 |
if (char1 == '\0') { |
3092 |
if (char1 == '\0') { |
| 3021 |
switch (char0) { |
3093 |
switch (char0) { |
| 3022 |
case '+': // unary plus |
3094 |
case '+': // unary plus |
|
Lines 3034-3043
Link Here
|
| 3034 |
default: |
3106 |
default: |
| 3035 |
setHasError(true); |
3107 |
setHasError(true); |
| 3036 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
3108 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
| 3037 |
break; |
3109 |
return false; |
| 3038 |
} |
3110 |
} |
| 3039 |
|
3111 |
|
| 3040 |
unBoxing(operand.resolveTypeBinding()); |
3112 |
unBoxing(typeBinding); |
| 3041 |
operand.accept(this); |
3113 |
operand.accept(this); |
| 3042 |
storeInstruction(); // un-boxing |
3114 |
storeInstruction(); // un-boxing |
| 3043 |
|
3115 |
|
|
Lines 3048-3054
Link Here
|
| 3048 |
|
3120 |
|
| 3049 |
operand.accept(this); |
3121 |
operand.accept(this); |
| 3050 |
|
3122 |
|
| 3051 |
boxing(operand.resolveTypeBinding(), null); |
3123 |
boxing(typeBinding, null); |
| 3052 |
|
3124 |
|
| 3053 |
switch (char1) { |
3125 |
switch (char1) { |
| 3054 |
case '+': |
3126 |
case '+': |
|
Lines 3060-3069
Link Here
|
| 3060 |
default: |
3132 |
default: |
| 3061 |
setHasError(true); |
3133 |
setHasError(true); |
| 3062 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
3134 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
| 3063 |
break; |
3135 |
unBoxing(typeBinding); |
| 3064 |
} |
3136 |
} |
| 3065 |
|
3137 |
|
| 3066 |
unBoxing(operand.resolveTypeBinding()); |
3138 |
unBoxing(typeBinding); |
| 3067 |
push(new Dup()); |
3139 |
push(new Dup()); |
| 3068 |
storeInstruction(); // dupe |
3140 |
storeInstruction(); // dupe |
| 3069 |
storeInstruction(); // un-boxing |
3141 |
storeInstruction(); // un-boxing |
|
Lines 3119-3125
Link Here
|
| 3119 |
|
3191 |
|
| 3120 |
if (unrecognized) { |
3192 |
if (unrecognized) { |
| 3121 |
setHasError(true); |
3193 |
setHasError(true); |
| 3122 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
3194 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
|
|
3195 |
return false; |
| 3123 |
} |
3196 |
} |
| 3124 |
|
3197 |
|
| 3125 |
return true; |
3198 |
return true; |
|
Lines 3132-3139
Link Here
|
| 3132 |
if (!isActive()) { |
3205 |
if (!isActive()) { |
| 3133 |
return false; |
3206 |
return false; |
| 3134 |
} |
3207 |
} |
| 3135 |
ITypeBinding typeBinding = node.resolveBinding(); |
3208 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 3136 |
push(new PushPrimitiveType(getTypeName(typeBinding))); |
3209 |
if (typeBinding != null) { |
|
|
3210 |
push(new PushPrimitiveType(getTypeName(typeBinding))); |
| 3211 |
} |
| 3137 |
return false; |
3212 |
return false; |
| 3138 |
} |
3213 |
} |
| 3139 |
|
3214 |
|
|
Lines 3149-3162
Link Here
|
| 3149 |
return true; |
3224 |
return true; |
| 3150 |
} |
3225 |
} |
| 3151 |
|
3226 |
|
| 3152 |
IBinding binding = node.resolveBinding(); |
3227 |
IBinding binding = resolveBinding(node); |
|
|
3228 |
if (binding == null) { |
| 3229 |
return false; |
| 3230 |
} |
| 3153 |
switch (binding.getKind()) { |
3231 |
switch (binding.getKind()) { |
| 3154 |
case IBinding.TYPE: |
3232 |
case IBinding.TYPE: |
| 3155 |
node.getName().accept(this); |
3233 |
node.getName().accept(this); |
| 3156 |
break; |
3234 |
break; |
| 3157 |
case IBinding.VARIABLE: |
3235 |
case IBinding.VARIABLE: |
| 3158 |
SimpleName fieldName= node.getName(); |
3236 |
SimpleName fieldName= node.getName(); |
| 3159 |
IVariableBinding fieldBinding= (IVariableBinding) fieldName.resolveBinding(); |
3237 |
IVariableBinding fieldBinding = (IVariableBinding) resolveBinding(fieldName); |
|
|
3238 |
if (fieldBinding == null) { |
| 3239 |
return false; |
| 3240 |
} |
| 3160 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
3241 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
| 3161 |
String fieldId = fieldName.getIdentifier(); |
3242 |
String fieldId = fieldName.getIdentifier(); |
| 3162 |
|
3243 |
|
|
Lines 3184-3191
Link Here
|
| 3184 |
if (!isActive()) { |
3265 |
if (!isActive()) { |
| 3185 |
return false; |
3266 |
return false; |
| 3186 |
} |
3267 |
} |
| 3187 |
ITypeBinding typeBinding = node.resolveBinding(); |
3268 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 3188 |
push(new PushType(getTypeName(typeBinding))); |
3269 |
if (typeBinding != null) { |
|
|
3270 |
push(new PushType(getTypeName(typeBinding))); |
| 3271 |
} |
| 3189 |
return false; |
3272 |
return false; |
| 3190 |
} |
3273 |
} |
| 3191 |
|
3274 |
|
|
Lines 3212-3225
Link Here
|
| 3212 |
return true; |
3295 |
return true; |
| 3213 |
} |
3296 |
} |
| 3214 |
|
3297 |
|
| 3215 |
IBinding binding = node.resolveBinding(); |
3298 |
IBinding binding = resolveBinding(node); |
| 3216 |
|
3299 |
|
| 3217 |
String variableId = node.getIdentifier(); |
|
|
| 3218 |
if (binding == null) { |
3300 |
if (binding == null) { |
| 3219 |
setHasError(true); |
|
|
| 3220 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_binding_null_for__17 + variableId); |
| 3221 |
return true; |
3301 |
return true; |
| 3222 |
} |
3302 |
} |
|
|
3303 |
|
| 3304 |
String variableId = node.getIdentifier(); |
| 3223 |
|
3305 |
|
| 3224 |
switch (binding.getKind()) { |
3306 |
switch (binding.getKind()) { |
| 3225 |
case IBinding.TYPE: |
3307 |
case IBinding.TYPE: |
|
Lines 3260-3268
Link Here
|
| 3260 |
return false; |
3342 |
return false; |
| 3261 |
} |
3343 |
} |
| 3262 |
|
3344 |
|
| 3263 |
ITypeBinding typeBinding = node.resolveBinding(); |
3345 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 3264 |
push(new PushType(getTypeName(typeBinding))); |
3346 |
if (typeBinding != null) { |
| 3265 |
|
3347 |
push(new PushType(getTypeName(typeBinding))); |
|
|
3348 |
} |
| 3266 |
return false; |
3349 |
return false; |
| 3267 |
} |
3350 |
} |
| 3268 |
|
3351 |
|
|
Lines 3281-3295
Link Here
|
| 3281 |
if (!isActive()) { |
3364 |
if (!isActive()) { |
| 3282 |
return false; |
3365 |
return false; |
| 3283 |
} |
3366 |
} |
| 3284 |
ITypeBinding typeBinding= node.getType().resolveBinding(); |
3367 |
ITypeBinding typeBinding = resolveTypeBinding(node.getType()); |
| 3285 |
int typeDimension= typeBinding.getDimensions(); |
3368 |
if (typeBinding != null) { |
| 3286 |
if (typeDimension != 0) { |
3369 |
int typeDimension = typeBinding.getDimensions(); |
| 3287 |
typeBinding= typeBinding.getElementType(); |
3370 |
if (typeDimension != 0) { |
| 3288 |
} |
3371 |
typeBinding = typeBinding.getElementType(); |
| 3289 |
Expression initializer= node.getInitializer(); |
3372 |
} |
| 3290 |
push(new LocalVariableCreation(node.getName().getIdentifier(), getTypeSignature(typeBinding), typeDimension, typeBinding.isPrimitive(), initializer != null, fCounter)); |
3373 |
Expression initializer = node.getInitializer(); |
| 3291 |
if (initializer != null) { |
3374 |
push(new LocalVariableCreation(node.getName().getIdentifier(), |
| 3292 |
initializer.accept(this); |
3375 |
getTypeSignature(typeBinding), typeDimension, typeBinding |
|
|
3376 |
.isPrimitive(), initializer != null, fCounter)); |
| 3377 |
if (initializer != null) { |
| 3378 |
initializer.accept(this); |
| 3379 |
} |
| 3293 |
} |
3380 |
} |
| 3294 |
return false; |
3381 |
return false; |
| 3295 |
} |
3382 |
} |
|
Lines 3328-3334
Link Here
|
| 3328 |
} |
3415 |
} |
| 3329 |
|
3416 |
|
| 3330 |
SimpleName fieldName= node.getName(); |
3417 |
SimpleName fieldName= node.getName(); |
| 3331 |
IVariableBinding fieldBinding= (IVariableBinding) fieldName.resolveBinding(); |
3418 |
IVariableBinding fieldBinding = (IVariableBinding) resolveBinding(fieldName); |
|
|
3419 |
if (fieldBinding == null) { |
| 3420 |
return false; |
| 3421 |
} |
| 3332 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
3422 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
| 3333 |
String fieldId = fieldName.getIdentifier(); |
3423 |
String fieldId = fieldName.getIdentifier(); |
| 3334 |
|
3424 |
|
|
Lines 3339-3346
Link Here
|
| 3339 |
int superLevel= 1; |
3429 |
int superLevel= 1; |
| 3340 |
int enclosingLevel= 0; |
3430 |
int enclosingLevel= 0; |
| 3341 |
if (qualifier != null) { |
3431 |
if (qualifier != null) { |
| 3342 |
superLevel= getSuperLevel(qualifier.resolveTypeBinding(), declaringTypeBinding); |
3432 |
ITypeBinding typeBinding = resolveTypeBinding(qualifier); |
| 3343 |
enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding()); |
3433 |
if (typeBinding == null) { |
|
|
3434 |
return false; |
| 3435 |
} |
| 3436 |
superLevel = getSuperLevel(typeBinding, declaringTypeBinding); |
| 3437 |
ITypeBinding binding = (ITypeBinding) resolveBinding(qualifier); |
| 3438 |
if (binding == null) { |
| 3439 |
return false; |
| 3440 |
} |
| 3441 |
enclosingLevel = getEnclosingLevel(node, binding); |
| 3344 |
} |
3442 |
} |
| 3345 |
push(new PushFieldVariable(fieldId, superLevel, fCounter)); |
3443 |
push(new PushFieldVariable(fieldId, superLevel, fCounter)); |
| 3346 |
push(new PushThis(enclosingLevel)); |
3444 |
push(new PushThis(enclosingLevel)); |
|
Lines 3360-3374
Link Here
|
| 3360 |
return false; |
3458 |
return false; |
| 3361 |
} |
3459 |
} |
| 3362 |
|
3460 |
|
| 3363 |
IMethodBinding methodBinding = (IMethodBinding) node.getName().resolveBinding(); |
3461 |
IMethodBinding methodBinding = (IMethodBinding) resolveBinding(node |
|
|
3462 |
.getName()); |
| 3463 |
if (methodBinding == null) { |
| 3464 |
return false; |
| 3465 |
} |
| 3364 |
|
3466 |
|
| 3365 |
if (containsALocalType(methodBinding)) { |
3467 |
if (containsALocalType(methodBinding)) { |
| 3366 |
setHasError(true); |
3468 |
setHasError(true); |
| 3367 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
3469 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
| 3368 |
} |
3470 |
return false; |
| 3369 |
|
|
|
| 3370 |
if (hasErrors()) { |
| 3371 |
return true; |
| 3372 |
} |
3471 |
} |
| 3373 |
|
3472 |
|
| 3374 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
3473 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
|
Lines 3383-3389
Link Here
|
| 3383 |
push(new SendMessage(selector, signature, paramCount, getTypeSignature(methodBinding.getDeclaringClass()), fCounter)); |
3482 |
push(new SendMessage(selector, signature, paramCount, getTypeSignature(methodBinding.getDeclaringClass()), fCounter)); |
| 3384 |
int enclosingLevel= 0; |
3483 |
int enclosingLevel= 0; |
| 3385 |
if (qualifier != null) { |
3484 |
if (qualifier != null) { |
| 3386 |
enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding()); |
3485 |
ITypeBinding typeBinding = (ITypeBinding) resolveBinding(qualifier); |
|
|
3486 |
if (typeBinding == null) { |
| 3487 |
return false; |
| 3488 |
} |
| 3489 |
enclosingLevel= getEnclosingLevel(node, typeBinding); |
| 3387 |
} |
3490 |
} |
| 3388 |
push(new PushThis(enclosingLevel)); |
3491 |
push(new PushThis(enclosingLevel)); |
| 3389 |
storeInstruction(); |
3492 |
storeInstruction(); |
|
Lines 3391-3397
Link Here
|
| 3391 |
|
3494 |
|
| 3392 |
List arguments = node.arguments(); |
3495 |
List arguments = node.arguments(); |
| 3393 |
int argCount = arguments.size(); |
3496 |
int argCount = arguments.size(); |
| 3394 |
if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == ((Expression)arguments.get(argCount - 1)).resolveTypeBinding().getDimensions())) { |
3497 |
|
|
|
3498 |
ITypeBinding lastArgBinding = null; |
| 3499 |
|
| 3500 |
if (methodBinding.isVarargs()) { |
| 3501 |
lastArgBinding = resolveTypeBinding((Expression) arguments |
| 3502 |
.get(argCount - 1)); |
| 3503 |
if (lastArgBinding == null) { |
| 3504 |
return false; |
| 3505 |
} |
| 3506 |
} |
| 3507 |
if (methodBinding.isVarargs() |
| 3508 |
&& !(paramCount == argCount && parameterTypes[paramCount - 1] |
| 3509 |
.getDimensions() == lastArgBinding.getDimensions())) { |
| 3395 |
// if this method is a varargs, and if the method is invoked using the varargs syntax |
3510 |
// if this method is a varargs, and if the method is invoked using the varargs syntax |
| 3396 |
// (multiple arguments) and not an array |
3511 |
// (multiple arguments) and not an array |
| 3397 |
Iterator iterator= arguments.iterator(); |
3512 |
Iterator iterator= arguments.iterator(); |
|
Lines 3584-3590
Link Here
|
| 3584 |
Name qualifier= node.getQualifier(); |
3699 |
Name qualifier= node.getQualifier(); |
| 3585 |
int enclosingLevel= 0; |
3700 |
int enclosingLevel= 0; |
| 3586 |
if (qualifier != null) { |
3701 |
if (qualifier != null) { |
| 3587 |
enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding()); |
3702 |
ITypeBinding binding = (ITypeBinding) resolveBinding(qualifier); |
|
|
3703 |
if (binding == null) { |
| 3704 |
return false; |
| 3705 |
} |
| 3706 |
enclosingLevel = getEnclosingLevel(node, binding); |
| 3588 |
} |
3707 |
} |
| 3589 |
push(new PushThis(enclosingLevel)); |
3708 |
push(new PushThis(enclosingLevel)); |
| 3590 |
|
3709 |
|
|
Lines 3611-3617
Link Here
|
| 3611 |
} |
3730 |
} |
| 3612 |
setHasError(true); |
3731 |
setHasError(true); |
| 3613 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Try_statement_cannot_be_used_in_an_evaluation_expression_23); |
3732 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Try_statement_cannot_be_used_in_an_evaluation_expression_23); |
| 3614 |
return true; |
3733 |
return false; |
| 3615 |
} |
3734 |
} |
| 3616 |
|
3735 |
|
| 3617 |
/** |
3736 |
/** |
|
Lines 3693-3708
Link Here
|
| 3693 |
ASTNode parent= node.getParent(); |
3812 |
ASTNode parent= node.getParent(); |
| 3694 |
switch (parent.getNodeType()) { |
3813 |
switch (parent.getNodeType()) { |
| 3695 |
case ASTNode.VARIABLE_DECLARATION_EXPRESSION: |
3814 |
case ASTNode.VARIABLE_DECLARATION_EXPRESSION: |
| 3696 |
varTypeBinding= ((VariableDeclarationExpression)parent).getType().resolveBinding(); |
3815 |
varTypeBinding= resolveTypeBinding(((VariableDeclarationExpression)parent).getType()); |
| 3697 |
break; |
3816 |
break; |
| 3698 |
case ASTNode.VARIABLE_DECLARATION_STATEMENT: |
3817 |
case ASTNode.VARIABLE_DECLARATION_STATEMENT: |
| 3699 |
varTypeBinding= ((VariableDeclarationStatement)parent).getType().resolveBinding(); |
3818 |
varTypeBinding= resolveTypeBinding(((VariableDeclarationStatement)parent).getType()); |
| 3700 |
break; |
3819 |
break; |
| 3701 |
default: |
3820 |
default: |
| 3702 |
setHasError(true); |
3821 |
setHasError(true); |
| 3703 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Error_in_type_declaration_statement); |
3822 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Error_in_type_declaration_statement); |
| 3704 |
return false; |
3823 |
return false; |
| 3705 |
} |
3824 |
} |
|
|
3825 |
if (varTypeBinding == null) { |
| 3826 |
return false; |
| 3827 |
} |
| 3706 |
int typeDimension= varTypeBinding.getDimensions(); |
3828 |
int typeDimension= varTypeBinding.getDimensions(); |
| 3707 |
ITypeBinding elementBinding = varTypeBinding; |
3829 |
ITypeBinding elementBinding = varTypeBinding; |
| 3708 |
if (typeDimension != 0) { |
3830 |
if (typeDimension != 0) { |
|
Lines 3766-3771
Link Here
|
| 3766 |
|
3888 |
|
| 3767 |
private int getTypeId(Expression expression) { |
3889 |
private int getTypeId(Expression expression) { |
| 3768 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
3890 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
|
|
3891 |
if (typeBinding == null) { |
| 3892 |
return Instruction.T_undefined; |
| 3893 |
} |
| 3769 |
String typeName = typeBinding.getQualifiedName(); |
3894 |
String typeName = typeBinding.getQualifiedName(); |
| 3770 |
if (typeBinding.isPrimitive()) { |
3895 |
if (typeBinding.isPrimitive()) { |
| 3771 |
return getPrimitiveTypeId(typeName); |
3896 |
return getPrimitiveTypeId(typeName); |
|
Lines 3778-3783
Link Here
|
| 3778 |
|
3903 |
|
| 3779 |
private int getUnBoxedTypeId(Expression expression) { |
3904 |
private int getUnBoxedTypeId(Expression expression) { |
| 3780 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
3905 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
|
|
3906 |
if (typeBinding == null) { |
| 3907 |
return Instruction.T_undefined; |
| 3908 |
} |
| 3781 |
String typeName = typeBinding.getQualifiedName(); |
3909 |
String typeName = typeBinding.getQualifiedName(); |
| 3782 |
if (typeBinding.isPrimitive()) { |
3910 |
if (typeBinding.isPrimitive()) { |
| 3783 |
return getPrimitiveTypeId(typeName); |
3911 |
return getPrimitiveTypeId(typeName); |
|
Lines 3880-3883
Link Here
|
| 3880 |
} |
4008 |
} |
| 3881 |
return Instruction.T_undefined; |
4009 |
return Instruction.T_undefined; |
| 3882 |
} |
4010 |
} |
|
|
4011 |
|
| 4012 |
|
| 4013 |
/** |
| 4014 |
* Resolves and returns the type binding from the given expression reporting an error |
| 4015 |
* if the binding is <code>null</code>. |
| 4016 |
* |
| 4017 |
* @param expression expression to resolve type binding for |
| 4018 |
* @return type binding or <code>null</code> if not available |
| 4019 |
*/ |
| 4020 |
private ITypeBinding resolveTypeBinding(Expression expression) { |
| 4021 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
| 4022 |
if (typeBinding == null) { |
| 4023 |
setHasError(true); |
| 4024 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{expression.toString()})); |
| 4025 |
} |
| 4026 |
return typeBinding; |
| 4027 |
} |
| 4028 |
|
| 4029 |
/** |
| 4030 |
* Resolves and returns the type binding for the give type reporting an error |
| 4031 |
* if the binding is <code>null</code>. |
| 4032 |
* |
| 4033 |
* @param type type to resolve binding for |
| 4034 |
* @return type binding or <code>null</code> if not available |
| 4035 |
*/ |
| 4036 |
private ITypeBinding resolveTypeBinding(Type type) { |
| 4037 |
ITypeBinding typeBinding = type.resolveBinding(); |
| 4038 |
if (typeBinding == null) { |
| 4039 |
setHasError(true); |
| 4040 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{type.toString()})); |
| 4041 |
} |
| 4042 |
return typeBinding; |
| 4043 |
} |
| 4044 |
|
| 4045 |
/** |
| 4046 |
* Resolves and returns the binding for the given name reporting an error |
| 4047 |
* if the binding is <code>null</code>. |
| 4048 |
* |
| 4049 |
* @param name name to resolve binding for |
| 4050 |
* @return binding or <code>null</code> if not available |
| 4051 |
*/ |
| 4052 |
private IBinding resolveBinding(Name name) { |
| 4053 |
IBinding binding = name.resolveBinding(); |
| 4054 |
if (binding == null) { |
| 4055 |
setHasError(true); |
| 4056 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_5, new String[]{name.getFullyQualifiedName()})); |
| 4057 |
} |
| 4058 |
return binding; |
| 4059 |
} |
| 4060 |
|
| 4061 |
/** |
| 4062 |
* Resolves and returns the type binding for the given name reporting an error |
| 4063 |
* if the binding is <code>null</code>. |
| 4064 |
* |
| 4065 |
* @param name name to resolve type binding for |
| 4066 |
* @return type binding or <code>null</code> if not available |
| 4067 |
*/ |
| 4068 |
private ITypeBinding resolveTypeBinding(Name name) { |
| 4069 |
ITypeBinding typeBinding = name.resolveTypeBinding(); |
| 4070 |
if (typeBinding == null) { |
| 4071 |
setHasError(true); |
| 4072 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{name.getFullyQualifiedName()})); |
| 4073 |
} |
| 4074 |
return typeBinding; |
| 4075 |
} |
| 3883 |
} |
4076 |
} |