|
Lines 188-193
Link Here
|
| 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 |
|
|
|
191 |
import com.ibm.icu.text.MessageFormat; |
| 192 |
|
| 191 |
/** |
193 |
/** |
| 192 |
* The AST instruction compiler generates a sequence |
194 |
* The AST instruction compiler generates a sequence |
| 193 |
* of instructions (InstructionSequence) from a |
195 |
* of instructions (InstructionSequence) from a |
|
Lines 441-452
Link Here
|
| 441 |
|
443 |
|
| 442 |
if (expression instanceof MethodInvocation) { |
444 |
if (expression instanceof MethodInvocation) { |
| 443 |
IMethodBinding methodBinding= (IMethodBinding)((MethodInvocation)expression).getName().resolveBinding(); |
445 |
IMethodBinding methodBinding= (IMethodBinding)((MethodInvocation)expression).getName().resolveBinding(); |
| 444 |
if ("void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
446 |
if (methodBinding != null && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
| 445 |
pop= false; |
447 |
pop= false; |
| 446 |
} |
448 |
} |
| 447 |
} else if (expression instanceof SuperMethodInvocation) { |
449 |
} else if (expression instanceof SuperMethodInvocation) { |
| 448 |
IMethodBinding methodBinding= (IMethodBinding)((SuperMethodInvocation)expression).getName().resolveBinding(); |
450 |
IMethodBinding methodBinding= (IMethodBinding)((SuperMethodInvocation)expression).getName().resolveBinding(); |
| 449 |
if ("void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
451 |
if (methodBinding != null && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$ |
| 450 |
pop= false; |
452 |
pop= false; |
| 451 |
} |
453 |
} |
| 452 |
} else if (expression instanceof VariableDeclarationExpression) { |
454 |
} else if (expression instanceof VariableDeclarationExpression) { |
|
Lines 593-599
Link Here
|
| 593 |
public void endVisit(ArrayAccess node) { |
595 |
public void endVisit(ArrayAccess node) { |
| 594 |
if (!isActive() || hasErrors()) |
596 |
if (!isActive() || hasErrors()) |
| 595 |
return; |
597 |
return; |
| 596 |
if (unBoxing(node.getIndex().resolveTypeBinding())) { |
598 |
ITypeBinding typeBinding = node.getIndex().resolveTypeBinding(); |
|
|
599 |
if (typeBinding != null && unBoxing(typeBinding)) { |
| 597 |
// un-box the index, if required |
600 |
// un-box the index, if required |
| 598 |
storeInstruction(); |
601 |
storeInstruction(); |
| 599 |
} |
602 |
} |
|
Lines 1522-1531
Link Here
|
| 1522 |
|
1525 |
|
| 1523 |
ArrayType arrayType= node.getType(); |
1526 |
ArrayType arrayType= node.getType(); |
| 1524 |
|
1527 |
|
| 1525 |
if (isALocalType(arrayType.resolveBinding().getElementType())) { |
1528 |
ITypeBinding binding = resolveTypeBinding(arrayType); |
|
|
1529 |
if (binding != null && isALocalType(binding.getElementType())) { |
| 1526 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Local_type_array_instance_creation_cannot_be_used_in_an_evaluation_expression_29); |
1530 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Local_type_array_instance_creation_cannot_be_used_in_an_evaluation_expression_29); |
| 1527 |
setHasError(true); |
1531 |
setHasError(true); |
| 1528 |
return true; |
1532 |
return false; |
| 1529 |
} |
1533 |
} |
| 1530 |
|
1534 |
|
| 1531 |
push(new ArrayAllocation(arrayType.getDimensions(), node.dimensions().size(), node.getInitializer() != null, fCounter)); |
1535 |
push(new ArrayAllocation(arrayType.getDimensions(), node.dimensions().size(), node.getInitializer() != null, fCounter)); |
|
Lines 1541-1551
Link Here
|
| 1541 |
return false; |
1545 |
return false; |
| 1542 |
} |
1546 |
} |
| 1543 |
|
1547 |
|
| 1544 |
ITypeBinding typeBinding= node.resolveTypeBinding(); |
1548 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 1545 |
int dimension= typeBinding.getDimensions(); |
1549 |
if (typeBinding != null) { |
| 1546 |
String signature= getTypeSignature(typeBinding.getElementType()); |
1550 |
int dimension= typeBinding.getDimensions(); |
| 1547 |
|
1551 |
String signature= getTypeSignature(typeBinding.getElementType()); |
| 1548 |
push(new ArrayInitializerInstruction(signature, node.expressions().size(), dimension, fCounter)); |
1552 |
push(new ArrayInitializerInstruction(signature, node.expressions().size(), dimension, fCounter)); |
|
|
1553 |
} |
| 1549 |
|
1554 |
|
| 1550 |
return true; |
1555 |
return true; |
| 1551 |
} |
1556 |
} |
|
Lines 1557-1567
Link Here
|
| 1557 |
if (!isActive()) { |
1562 |
if (!isActive()) { |
| 1558 |
return false; |
1563 |
return false; |
| 1559 |
} |
1564 |
} |
| 1560 |
ITypeBinding arrayTypeBinding= node.resolveBinding(); |
1565 |
ITypeBinding arrayTypeBinding= resolveTypeBinding(node); |
| 1561 |
int dimension= arrayTypeBinding.getDimensions(); |
1566 |
if (arrayTypeBinding != null) { |
| 1562 |
String signature= getTypeSignature(arrayTypeBinding.getElementType()); |
1567 |
int dimension= arrayTypeBinding.getDimensions(); |
| 1563 |
|
1568 |
String signature= getTypeSignature(arrayTypeBinding.getElementType()); |
| 1564 |
push(new PushArrayType(signature, dimension, fCounter)); |
1569 |
push(new PushArrayType(signature, dimension, fCounter)); |
|
|
1570 |
} |
| 1565 |
|
1571 |
|
| 1566 |
return false; |
1572 |
return false; |
| 1567 |
} |
1573 |
} |
|
Lines 1575-1581
Link Here
|
| 1575 |
} |
1581 |
} |
| 1576 |
setHasError(true); |
1582 |
setHasError(true); |
| 1577 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Assert_statement_cannot_be_used_in_an_evaluation_expression_3); |
1583 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Assert_statement_cannot_be_used_in_an_evaluation_expression_3); |
| 1578 |
return true; |
1584 |
return false; |
| 1579 |
} |
1585 |
} |
| 1580 |
|
1586 |
|
| 1581 |
/** |
1587 |
/** |
|
Lines 1598-1603
Link Here
|
| 1598 |
char2 = opToken.charAt(2); |
1604 |
char2 = opToken.charAt(2); |
| 1599 |
} |
1605 |
} |
| 1600 |
|
1606 |
|
|
|
1607 |
ITypeBinding rightBinding = resolveTypeBinding(rightHandSide); |
| 1608 |
if (rightBinding == null) { |
| 1609 |
return false; |
| 1610 |
} |
| 1611 |
ITypeBinding leftBinding = resolveTypeBinding(leftHandSide); |
| 1612 |
if (leftBinding == null) { |
| 1613 |
return false; |
| 1614 |
} |
| 1601 |
if (variableTypeId == Instruction.T_Object) { |
1615 |
if (variableTypeId == Instruction.T_Object) { |
| 1602 |
// If the variable is an object, the value may need to be boxed for |
1616 |
// If the variable is an object, the value may need to be boxed for |
| 1603 |
// the simple assignment. |
1617 |
// the simple assignment. |
|
Lines 1616-1623
Link Here
|
| 1616 |
if (char0 == '=') { |
1630 |
if (char0 == '=') { |
| 1617 |
|
1631 |
|
| 1618 |
boolean storeRequired= false; |
1632 |
boolean storeRequired= false; |
| 1619 |
if (rightHandSide.resolveTypeBinding().isPrimitive()) { |
1633 |
if (rightBinding.isPrimitive()) { |
| 1620 |
boxing(leftHandSide.resolveTypeBinding(), rightHandSide.resolveTypeBinding()); |
1634 |
boxing(leftBinding, rightBinding); |
| 1621 |
storeRequired= true; |
1635 |
storeRequired= true; |
| 1622 |
} |
1636 |
} |
| 1623 |
rightHandSide.accept(this); |
1637 |
rightHandSide.accept(this); |
|
Lines 1629-1635
Link Here
|
| 1629 |
boolean unrecognized = false; |
1643 |
boolean unrecognized = false; |
| 1630 |
|
1644 |
|
| 1631 |
|
1645 |
|
| 1632 |
boxing(leftHandSide.resolveTypeBinding(), rightHandSide.resolveTypeBinding()); |
1646 |
boxing(leftBinding, rightBinding); |
| 1633 |
|
1647 |
|
| 1634 |
switch (char0) { |
1648 |
switch (char0) { |
| 1635 |
case '=': // equal |
1649 |
case '=': // equal |
|
Lines 1685-1696
Link Here
|
| 1685 |
return false; |
1699 |
return false; |
| 1686 |
} |
1700 |
} |
| 1687 |
|
1701 |
|
| 1688 |
unBoxing(leftHandSide.resolveTypeBinding()); |
1702 |
unBoxing(leftBinding); |
| 1689 |
push(new Dup()); |
1703 |
push(new Dup()); |
| 1690 |
storeInstruction(); // dupe |
1704 |
storeInstruction(); // dupe |
| 1691 |
storeInstruction(); // un-boxing |
1705 |
storeInstruction(); // un-boxing |
| 1692 |
|
1706 |
|
| 1693 |
boolean storeRequired= unBoxing(rightHandSide.resolveTypeBinding()); |
1707 |
boolean storeRequired= unBoxing(rightBinding); |
| 1694 |
rightHandSide.accept(this); |
1708 |
rightHandSide.accept(this); |
| 1695 |
if (storeRequired) { |
1709 |
if (storeRequired) { |
| 1696 |
storeInstruction(); // un-boxing |
1710 |
storeInstruction(); // un-boxing |
|
Lines 1760-1766
Link Here
|
| 1760 |
} |
1774 |
} |
| 1761 |
|
1775 |
|
| 1762 |
leftHandSide.accept(this); |
1776 |
leftHandSide.accept(this); |
| 1763 |
boolean storeRequired= unBoxing(rightHandSide.resolveTypeBinding()); |
1777 |
boolean storeRequired= unBoxing(rightBinding); |
| 1764 |
rightHandSide.accept(this); |
1778 |
rightHandSide.accept(this); |
| 1765 |
if (storeRequired) { |
1779 |
if (storeRequired) { |
| 1766 |
storeInstruction(); |
1780 |
storeInstruction(); |
|
Lines 1840-1859
Link Here
|
| 1840 |
|
1854 |
|
| 1841 |
Type type= node.getType(); |
1855 |
Type type= node.getType(); |
| 1842 |
int typeId= getTypeId(type); |
1856 |
int typeId= getTypeId(type); |
| 1843 |
ITypeBinding typeBinding= type.resolveBinding(); |
1857 |
ITypeBinding typeBinding= resolveTypeBinding(type); |
| 1844 |
|
|
|
| 1845 |
String baseTypeSignature; |
| 1846 |
int dimension= typeBinding.getDimensions(); |
| 1847 |
|
| 1848 |
if (typeBinding.isArray()) { |
| 1849 |
typeBinding= typeBinding.getElementType(); |
| 1850 |
} |
| 1851 |
|
1858 |
|
| 1852 |
baseTypeSignature= getTypeName(typeBinding); |
1859 |
if (typeBinding != null) { |
| 1853 |
|
1860 |
String baseTypeSignature; |
| 1854 |
push(new Cast(typeId, baseTypeSignature, dimension, fCounter)); |
1861 |
int dimension= typeBinding.getDimensions(); |
| 1855 |
|
1862 |
if (typeBinding.isArray()) { |
| 1856 |
node.getExpression().accept(this); |
1863 |
typeBinding= typeBinding.getElementType(); |
|
|
1864 |
} |
| 1865 |
baseTypeSignature= getTypeName(typeBinding); |
| 1866 |
push(new Cast(typeId, baseTypeSignature, dimension, fCounter)); |
| 1867 |
node.getExpression().accept(this); |
| 1868 |
} |
| 1857 |
|
1869 |
|
| 1858 |
return false; |
1870 |
return false; |
| 1859 |
} |
1871 |
} |
|
Lines 1867-1873
Link Here
|
| 1867 |
} |
1879 |
} |
| 1868 |
setHasError(true); |
1880 |
setHasError(true); |
| 1869 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Catch_clause_cannot_be_used_in_an_evaluation_expression_6); |
1881 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Catch_clause_cannot_be_used_in_an_evaluation_expression_6); |
| 1870 |
return true; |
1882 |
return false; |
| 1871 |
} |
1883 |
} |
| 1872 |
|
1884 |
|
| 1873 |
/** |
1885 |
/** |
|
Lines 1898-1905
Link Here
|
| 1898 |
} |
1910 |
} |
| 1899 |
|
1911 |
|
| 1900 |
IMethodBinding methodBinding= node.resolveConstructorBinding(); |
1912 |
IMethodBinding methodBinding= node.resolveConstructorBinding(); |
|
|
1913 |
if (methodBinding == null) { |
| 1914 |
setHasError(true); |
| 1915 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_1, new String[]{node.toString()})); |
| 1916 |
return false; |
| 1917 |
} |
| 1901 |
ITypeBinding typeBinding= methodBinding.getDeclaringClass(); |
1918 |
ITypeBinding typeBinding= methodBinding.getDeclaringClass(); |
| 1902 |
ITypeBinding enclosingTypeBinding= typeBinding.getDeclaringClass(); |
|
|
| 1903 |
|
1919 |
|
| 1904 |
boolean isInstanceMemberType= typeBinding.isMember() && ! Modifier.isStatic(typeBinding.getModifiers()); |
1920 |
boolean isInstanceMemberType= typeBinding.isMember() && ! Modifier.isStatic(typeBinding.getModifiers()); |
| 1905 |
|
1921 |
|
|
Lines 1915-1927
Link Here
|
| 1915 |
|
1931 |
|
| 1916 |
|
1932 |
|
| 1917 |
if (hasErrors()) { |
1933 |
if (hasErrors()) { |
| 1918 |
return true; |
1934 |
return false; |
| 1919 |
} |
1935 |
} |
| 1920 |
|
1936 |
|
| 1921 |
int paramCount= methodBinding.getParameterTypes().length; |
1937 |
int paramCount= methodBinding.getParameterTypes().length; |
| 1922 |
|
1938 |
|
| 1923 |
String enclosingTypeSignature= null; |
1939 |
String enclosingTypeSignature= null; |
|
|
1940 |
ITypeBinding enclosingTypeBinding= null; |
| 1924 |
if (isInstanceMemberType) { |
1941 |
if (isInstanceMemberType) { |
|
|
1942 |
enclosingTypeBinding= typeBinding.getDeclaringClass(); |
| 1943 |
if (enclosingTypeBinding == null) { |
| 1944 |
setHasError(true); |
| 1945 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_2, new String[]{typeBinding.getQualifiedName()})); |
| 1946 |
return false; |
| 1947 |
} |
| 1925 |
enclosingTypeSignature= getTypeSignature(enclosingTypeBinding); |
1948 |
enclosingTypeSignature= getTypeSignature(enclosingTypeBinding); |
| 1926 |
paramCount++; |
1949 |
paramCount++; |
| 1927 |
} |
1950 |
} |
|
Lines 1946-1952
Link Here
|
| 1946 |
if (Modifier.isStatic(((MethodDeclaration)parent).getModifiers())) { |
1969 |
if (Modifier.isStatic(((MethodDeclaration)parent).getModifiers())) { |
| 1947 |
setHasError(true); |
1970 |
setHasError(true); |
| 1948 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Must_explicitly_qualify_the_allocation_with_an_instance_of_the_enclosing_type_33); |
1971 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Must_explicitly_qualify_the_allocation_with_an_instance_of_the_enclosing_type_33); |
| 1949 |
return true; |
1972 |
return false; |
| 1950 |
} |
1973 |
} |
| 1951 |
|
1974 |
|
| 1952 |
push(new PushThis(getEnclosingLevel(node, enclosingTypeBinding))); |
1975 |
push(new PushThis(getEnclosingLevel(node, enclosingTypeBinding))); |
|
Lines 2048-2056
Link Here
|
| 2048 |
push(new NoOp(fCounter)); |
2071 |
push(new NoOp(fCounter)); |
| 2049 |
|
2072 |
|
| 2050 |
|
2073 |
|
| 2051 |
ITypeBinding typeBinding= node.getExpression().resolveTypeBinding(); |
2074 |
ITypeBinding typeBinding= resolveTypeBinding(node.getExpression()); |
|
|
2075 |
if (typeBinding == null) { |
| 2076 |
return false; |
| 2077 |
} |
| 2052 |
Type paramType= node.getParameter().getType(); |
2078 |
Type paramType= node.getParameter().getType(); |
| 2053 |
ITypeBinding paramBinding = paramType.resolveBinding(); |
2079 |
ITypeBinding paramBinding = resolveTypeBinding(paramType); |
|
|
2080 |
if (paramBinding == null) { |
| 2081 |
return false; |
| 2082 |
} |
| 2054 |
String typeSignature= getTypeSignature(paramBinding); |
2083 |
String typeSignature= getTypeSignature(paramBinding); |
| 2055 |
int paramTypeId= getTypeId(paramType); |
2084 |
int paramTypeId= getTypeId(paramType); |
| 2056 |
boolean isParamPrimitiveType= paramTypeId != Instruction.T_Object && paramTypeId != Instruction.T_String; |
2085 |
boolean isParamPrimitiveType= paramTypeId != Instruction.T_Object && paramTypeId != Instruction.T_String; |
|
Lines 2316-2323
Link Here
|
| 2316 |
int rightTypeId; |
2345 |
int rightTypeId; |
| 2317 |
boolean unbox = false; |
2346 |
boolean unbox = false; |
| 2318 |
// for == and != un-box when at least operand is primitive (otherwise compare the objects) |
2347 |
// for == and != un-box when at least operand is primitive (otherwise compare the objects) |
|
|
2348 |
ITypeBinding leftBinding = resolveTypeBinding(leftOperand); |
| 2349 |
if (leftBinding == null) { |
| 2350 |
return false; |
| 2351 |
} |
| 2352 |
ITypeBinding rightBinding = resolveTypeBinding(rightOperand); |
| 2353 |
if (rightBinding == null) { |
| 2354 |
return false; |
| 2355 |
} |
| 2319 |
if ((char0 == '=' || char0 == '!') && char1 == '=') { |
2356 |
if ((char0 == '=' || char0 == '!') && char1 == '=') { |
| 2320 |
unbox = leftOperand.resolveTypeBinding().isPrimitive() || rightOperand.resolveTypeBinding().isPrimitive(); |
2357 |
unbox = leftBinding.isPrimitive() || rightBinding.isPrimitive(); |
| 2321 |
} else { |
2358 |
} else { |
| 2322 |
unbox = true; |
2359 |
unbox = true; |
| 2323 |
} |
2360 |
} |
|
Lines 2485-2491
Link Here
|
| 2485 |
} |
2522 |
} |
| 2486 |
|
2523 |
|
| 2487 |
if (hasErrors()) { |
2524 |
if (hasErrors()) { |
| 2488 |
return true; |
2525 |
return false; |
| 2489 |
} |
2526 |
} |
| 2490 |
|
2527 |
|
| 2491 |
iterator = extendedOperands.iterator(); |
2528 |
iterator = extendedOperands.iterator(); |
|
Lines 2497-2503
Link Here
|
| 2497 |
ConditionalJump[] conditionalJumps= new ConditionalJump[operatorNumber]; |
2534 |
ConditionalJump[] conditionalJumps= new ConditionalJump[operatorNumber]; |
| 2498 |
int[] conditionalJumpAddresses = new int[operatorNumber]; |
2535 |
int[] conditionalJumpAddresses = new int[operatorNumber]; |
| 2499 |
|
2536 |
|
| 2500 |
boolean storeRequired= unBoxing(leftOperand.resolveTypeBinding()); |
2537 |
boolean storeRequired= unBoxing(leftBinding); |
| 2501 |
leftOperand.accept(this); |
2538 |
leftOperand.accept(this); |
| 2502 |
if (storeRequired) { |
2539 |
if (storeRequired) { |
| 2503 |
storeInstruction(); |
2540 |
storeInstruction(); |
|
Lines 2509-2515
Link Here
|
| 2509 |
push(conditionalJump); |
2546 |
push(conditionalJump); |
| 2510 |
storeInstruction(); |
2547 |
storeInstruction(); |
| 2511 |
|
2548 |
|
| 2512 |
storeRequired= unBoxing(rightOperand.resolveTypeBinding()); |
2549 |
storeRequired= unBoxing(rightBinding); |
| 2513 |
rightOperand.accept(this); |
2550 |
rightOperand.accept(this); |
| 2514 |
if (storeRequired) { |
2551 |
if (storeRequired) { |
| 2515 |
storeInstruction(); |
2552 |
storeInstruction(); |
|
Lines 2522-2528
Link Here
|
| 2522 |
push(conditionalJump); |
2559 |
push(conditionalJump); |
| 2523 |
storeInstruction(); |
2560 |
storeInstruction(); |
| 2524 |
Expression operand= (Expression) iterator.next(); |
2561 |
Expression operand= (Expression) iterator.next(); |
| 2525 |
storeRequired= unBoxing(operand.resolveTypeBinding()); |
2562 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
|
|
2563 |
if (typeBinding == null) { |
| 2564 |
return false; |
| 2565 |
} |
| 2566 |
storeRequired= unBoxing(typeBinding); |
| 2526 |
operand.accept(this); |
2567 |
operand.accept(this); |
| 2527 |
if (storeRequired) { |
2568 |
if (storeRequired) { |
| 2528 |
storeInstruction(); |
2569 |
storeInstruction(); |
|
Lines 2548-2561
Link Here
|
| 2548 |
|
2589 |
|
| 2549 |
boolean storeRequired= false; |
2590 |
boolean storeRequired= false; |
| 2550 |
if (unbox) { |
2591 |
if (unbox) { |
| 2551 |
storeRequired= unBoxing(leftOperand.resolveTypeBinding()); |
2592 |
storeRequired= unBoxing(leftBinding); |
| 2552 |
} |
2593 |
} |
| 2553 |
leftOperand.accept(this); |
2594 |
leftOperand.accept(this); |
| 2554 |
if (storeRequired) { |
2595 |
if (storeRequired) { |
| 2555 |
storeInstruction(); |
2596 |
storeInstruction(); |
| 2556 |
} |
2597 |
} |
| 2557 |
if (unbox) { |
2598 |
if (unbox) { |
| 2558 |
storeRequired= unBoxing(rightOperand.resolveTypeBinding()); |
2599 |
storeRequired= unBoxing(rightBinding); |
| 2559 |
} |
2600 |
} |
| 2560 |
rightOperand.accept(this); |
2601 |
rightOperand.accept(this); |
| 2561 |
if (storeRequired) { |
2602 |
if (storeRequired) { |
|
Lines 2566-2572
Link Here
|
| 2566 |
for (int i= 1; i < operatorNumber; i ++) { |
2607 |
for (int i= 1; i < operatorNumber; i ++) { |
| 2567 |
Expression operand= (Expression) iterator.next(); |
2608 |
Expression operand= (Expression) iterator.next(); |
| 2568 |
if (unbox) { |
2609 |
if (unbox) { |
| 2569 |
storeRequired= unBoxing(operand.resolveTypeBinding()); |
2610 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
|
|
2611 |
if (typeBinding == null) { |
| 2612 |
return false; |
| 2613 |
} |
| 2614 |
storeRequired= unBoxing(typeBinding); |
| 2570 |
} |
2615 |
} |
| 2571 |
operand.accept(this); |
2616 |
operand.accept(this); |
| 2572 |
if (storeRequired) { |
2617 |
if (storeRequired) { |
|
Lines 2682-2697
Link Here
|
| 2682 |
} |
2727 |
} |
| 2683 |
|
2728 |
|
| 2684 |
if (hasErrors()) { |
2729 |
if (hasErrors()) { |
| 2685 |
return true; |
2730 |
return false; |
| 2686 |
} |
2731 |
} |
| 2687 |
|
2732 |
|
| 2688 |
if (containsALocalType(methodBinding)) { |
2733 |
if (containsALocalType(methodBinding)) { |
| 2689 |
setHasError(true); |
2734 |
setHasError(true); |
| 2690 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
2735 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
| 2691 |
} |
2736 |
return false; |
| 2692 |
|
|
|
| 2693 |
if (hasErrors()) { |
| 2694 |
return true; |
| 2695 |
} |
2737 |
} |
| 2696 |
|
2738 |
|
| 2697 |
int paramCount = methodBinding.getParameterTypes().length; |
2739 |
int paramCount = methodBinding.getParameterTypes().length; |
|
Lines 2736-2742
Link Here
|
| 2736 |
int argCount = arguments.size(); |
2778 |
int argCount = arguments.size(); |
| 2737 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
2779 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
| 2738 |
int paramCount = parameterTypes.length; |
2780 |
int paramCount = parameterTypes.length; |
| 2739 |
if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == ((Expression)arguments.get(argCount - 1)).resolveTypeBinding().getDimensions())) { |
2781 |
ITypeBinding lastArgBinding = null; |
|
|
2782 |
if (methodBinding.isVarargs()) { |
| 2783 |
Expression lastArg = (Expression)arguments.get(argCount - 1); |
| 2784 |
lastArgBinding = resolveTypeBinding(lastArg); |
| 2785 |
if (lastArgBinding == null) { |
| 2786 |
return; |
| 2787 |
} |
| 2788 |
} |
| 2789 |
if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == lastArgBinding.getDimensions())) { |
| 2740 |
// if this method is a varargs, and if the method is invoked using the varargs syntax |
2790 |
// if this method is a varargs, and if the method is invoked using the varargs syntax |
| 2741 |
// (multiple arguments) and not an array |
2791 |
// (multiple arguments) and not an array |
| 2742 |
Iterator iterator= arguments.iterator(); |
2792 |
Iterator iterator= arguments.iterator(); |
|
Lines 2930-2937
Link Here
|
| 2930 |
if (!isActive()) { |
2980 |
if (!isActive()) { |
| 2931 |
return false; |
2981 |
return false; |
| 2932 |
} |
2982 |
} |
| 2933 |
ITypeBinding typeBinding = node.resolveBinding(); |
2983 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 2934 |
push(new PushType(getTypeName(typeBinding))); |
2984 |
if (typeBinding != null) { |
|
|
2985 |
push(new PushType(getTypeName(typeBinding))); |
| 2986 |
} |
| 2935 |
return false; |
2987 |
return false; |
| 2936 |
} |
2988 |
} |
| 2937 |
|
2989 |
|
|
Lines 2976-2982
Link Here
|
| 2976 |
default: |
3028 |
default: |
| 2977 |
setHasError(true); |
3029 |
setHasError(true); |
| 2978 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
3030 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
| 2979 |
break; |
3031 |
return false; |
| 2980 |
} |
3032 |
} |
| 2981 |
push(new Value(fCounter)); |
3033 |
push(new Value(fCounter)); |
| 2982 |
push(new Dup()); |
3034 |
push(new Dup()); |
|
Lines 2984-2995
Link Here
|
| 2984 |
storeInstruction(); // value |
3036 |
storeInstruction(); // value |
| 2985 |
push(new DupX1()); |
3037 |
push(new DupX1()); |
| 2986 |
storeInstruction(); // dup_x1 |
3038 |
storeInstruction(); // dup_x1 |
| 2987 |
unBoxing(operand.resolveTypeBinding()); |
3039 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
|
|
3040 |
if (typeBinding == null) { |
| 3041 |
return false; |
| 3042 |
} |
| 3043 |
unBoxing(typeBinding); |
| 2988 |
storeInstruction(); // un-boxing |
3044 |
storeInstruction(); // un-boxing |
| 2989 |
push(new PushInt(1)); |
3045 |
push(new PushInt(1)); |
| 2990 |
storeInstruction(); // push 1 |
3046 |
storeInstruction(); // push 1 |
| 2991 |
storeInstruction(); // operator |
3047 |
storeInstruction(); // operator |
| 2992 |
boxing(operand.resolveTypeBinding(), null); |
3048 |
boxing(typeBinding, null); |
| 2993 |
storeInstruction(); // boxing |
3049 |
storeInstruction(); // boxing |
| 2994 |
storeInstruction(); // assignment |
3050 |
storeInstruction(); // assignment |
| 2995 |
push(new Pop(assignmentInstruction.getSize() + 1)); |
3051 |
push(new Pop(assignmentInstruction.getSize() + 1)); |
|
Lines 3008-3014
Link Here
|
| 3008 |
default: |
3064 |
default: |
| 3009 |
setHasError(true); |
3065 |
setHasError(true); |
| 3010 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
3066 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken); |
| 3011 |
break; |
3067 |
return false; |
| 3012 |
} |
3068 |
} |
| 3013 |
|
3069 |
|
| 3014 |
return true; |
3070 |
return true; |
|
Lines 3039-3044
Link Here
|
| 3039 |
|
3095 |
|
| 3040 |
int expressionUnBoxedTypeId= getUnBoxedTypeId(operand); |
3096 |
int expressionUnBoxedTypeId= getUnBoxedTypeId(operand); |
| 3041 |
|
3097 |
|
|
|
3098 |
ITypeBinding typeBinding = resolveTypeBinding(operand); |
| 3099 |
if (typeBinding == null) { |
| 3100 |
return false; |
| 3101 |
} |
| 3042 |
if (char1 == '\0') { |
3102 |
if (char1 == '\0') { |
| 3043 |
switch (char0) { |
3103 |
switch (char0) { |
| 3044 |
case '+': // unary plus |
3104 |
case '+': // unary plus |
|
Lines 3056-3065
Link Here
|
| 3056 |
default: |
3116 |
default: |
| 3057 |
setHasError(true); |
3117 |
setHasError(true); |
| 3058 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
3118 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
| 3059 |
break; |
3119 |
return false; |
| 3060 |
} |
3120 |
} |
| 3061 |
|
3121 |
|
| 3062 |
unBoxing(operand.resolveTypeBinding()); |
3122 |
unBoxing(typeBinding); |
| 3063 |
operand.accept(this); |
3123 |
operand.accept(this); |
| 3064 |
storeInstruction(); // un-boxing |
3124 |
storeInstruction(); // un-boxing |
| 3065 |
|
3125 |
|
|
Lines 3070-3076
Link Here
|
| 3070 |
|
3130 |
|
| 3071 |
operand.accept(this); |
3131 |
operand.accept(this); |
| 3072 |
|
3132 |
|
| 3073 |
boxing(operand.resolveTypeBinding(), null); |
3133 |
boxing(typeBinding, null); |
| 3074 |
|
3134 |
|
| 3075 |
switch (char1) { |
3135 |
switch (char1) { |
| 3076 |
case '+': |
3136 |
case '+': |
|
Lines 3082-3091
Link Here
|
| 3082 |
default: |
3142 |
default: |
| 3083 |
setHasError(true); |
3143 |
setHasError(true); |
| 3084 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
3144 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
| 3085 |
break; |
3145 |
return false; |
| 3086 |
} |
3146 |
} |
| 3087 |
|
3147 |
|
| 3088 |
unBoxing(operand.resolveTypeBinding()); |
3148 |
unBoxing(typeBinding); |
| 3089 |
push(new Dup()); |
3149 |
push(new Dup()); |
| 3090 |
storeInstruction(); // dupe |
3150 |
storeInstruction(); // dupe |
| 3091 |
storeInstruction(); // un-boxing |
3151 |
storeInstruction(); // un-boxing |
|
Lines 3142-3147
Link Here
|
| 3142 |
if (unrecognized) { |
3202 |
if (unrecognized) { |
| 3143 |
setHasError(true); |
3203 |
setHasError(true); |
| 3144 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
3204 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken); |
|
|
3205 |
return false; |
| 3145 |
} |
3206 |
} |
| 3146 |
|
3207 |
|
| 3147 |
return true; |
3208 |
return true; |
|
Lines 3154-3161
Link Here
|
| 3154 |
if (!isActive()) { |
3215 |
if (!isActive()) { |
| 3155 |
return false; |
3216 |
return false; |
| 3156 |
} |
3217 |
} |
| 3157 |
ITypeBinding typeBinding = node.resolveBinding(); |
3218 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 3158 |
push(new PushPrimitiveType(getTypeName(typeBinding))); |
3219 |
if (typeBinding != null) { |
|
|
3220 |
push(new PushPrimitiveType(getTypeName(typeBinding))); |
| 3221 |
} |
| 3159 |
return false; |
3222 |
return false; |
| 3160 |
} |
3223 |
} |
| 3161 |
|
3224 |
|
|
Lines 3171-3184
Link Here
|
| 3171 |
return true; |
3234 |
return true; |
| 3172 |
} |
3235 |
} |
| 3173 |
|
3236 |
|
| 3174 |
IBinding binding = node.resolveBinding(); |
3237 |
IBinding binding = resolveBinding(node); |
|
|
3238 |
if (binding == null) { |
| 3239 |
return false; |
| 3240 |
} |
| 3175 |
switch (binding.getKind()) { |
3241 |
switch (binding.getKind()) { |
| 3176 |
case IBinding.TYPE: |
3242 |
case IBinding.TYPE: |
| 3177 |
node.getName().accept(this); |
3243 |
node.getName().accept(this); |
| 3178 |
break; |
3244 |
break; |
| 3179 |
case IBinding.VARIABLE: |
3245 |
case IBinding.VARIABLE: |
| 3180 |
SimpleName fieldName= node.getName(); |
3246 |
SimpleName fieldName= node.getName(); |
| 3181 |
IVariableBinding fieldBinding= (IVariableBinding) fieldName.resolveBinding(); |
3247 |
IVariableBinding fieldBinding= (IVariableBinding) resolveBinding(fieldName); |
|
|
3248 |
if (fieldBinding == null) { |
| 3249 |
return false; |
| 3250 |
} |
| 3182 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
3251 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
| 3183 |
String fieldId = fieldName.getIdentifier(); |
3252 |
String fieldId = fieldName.getIdentifier(); |
| 3184 |
|
3253 |
|
|
Lines 3206-3213
Link Here
|
| 3206 |
if (!isActive()) { |
3275 |
if (!isActive()) { |
| 3207 |
return false; |
3276 |
return false; |
| 3208 |
} |
3277 |
} |
| 3209 |
ITypeBinding typeBinding = node.resolveBinding(); |
3278 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 3210 |
push(new PushType(getTypeName(typeBinding))); |
3279 |
if (typeBinding != null) { |
|
|
3280 |
push(new PushType(getTypeName(typeBinding))); |
| 3281 |
} |
| 3211 |
return false; |
3282 |
return false; |
| 3212 |
} |
3283 |
} |
| 3213 |
|
3284 |
|
|
Lines 3234-3247
Link Here
|
| 3234 |
return true; |
3305 |
return true; |
| 3235 |
} |
3306 |
} |
| 3236 |
|
3307 |
|
| 3237 |
IBinding binding = node.resolveBinding(); |
3308 |
IBinding binding = resolveBinding(node); |
| 3238 |
|
|
|
| 3239 |
String variableId = node.getIdentifier(); |
| 3240 |
if (binding == null) { |
3309 |
if (binding == null) { |
| 3241 |
setHasError(true); |
|
|
| 3242 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_binding_null_for__17 + variableId); |
| 3243 |
return true; |
3310 |
return true; |
| 3244 |
} |
3311 |
} |
|
|
3312 |
String variableId = node.getIdentifier(); |
| 3245 |
|
3313 |
|
| 3246 |
switch (binding.getKind()) { |
3314 |
switch (binding.getKind()) { |
| 3247 |
case IBinding.TYPE: |
3315 |
case IBinding.TYPE: |
|
Lines 3282-3290
Link Here
|
| 3282 |
return false; |
3350 |
return false; |
| 3283 |
} |
3351 |
} |
| 3284 |
|
3352 |
|
| 3285 |
ITypeBinding typeBinding = node.resolveBinding(); |
3353 |
ITypeBinding typeBinding = resolveTypeBinding(node); |
| 3286 |
push(new PushType(getTypeName(typeBinding))); |
3354 |
if (typeBinding != null) { |
| 3287 |
|
3355 |
push(new PushType(getTypeName(typeBinding))); |
|
|
3356 |
} |
| 3288 |
return false; |
3357 |
return false; |
| 3289 |
} |
3358 |
} |
| 3290 |
|
3359 |
|
|
Lines 3303-3317
Link Here
|
| 3303 |
if (!isActive()) { |
3372 |
if (!isActive()) { |
| 3304 |
return false; |
3373 |
return false; |
| 3305 |
} |
3374 |
} |
| 3306 |
ITypeBinding typeBinding= node.getType().resolveBinding(); |
3375 |
ITypeBinding typeBinding= resolveTypeBinding(node.getType()); |
| 3307 |
int typeDimension= typeBinding.getDimensions(); |
3376 |
if (typeBinding != null) { |
| 3308 |
if (typeDimension != 0) { |
3377 |
int typeDimension= typeBinding.getDimensions(); |
| 3309 |
typeBinding= typeBinding.getElementType(); |
3378 |
if (typeDimension != 0) { |
| 3310 |
} |
3379 |
typeBinding= typeBinding.getElementType(); |
| 3311 |
Expression initializer= node.getInitializer(); |
3380 |
} |
| 3312 |
push(new LocalVariableCreation(node.getName().getIdentifier(), getTypeSignature(typeBinding), typeDimension, typeBinding.isPrimitive(), initializer != null, fCounter)); |
3381 |
Expression initializer= node.getInitializer(); |
| 3313 |
if (initializer != null) { |
3382 |
push(new LocalVariableCreation(node.getName().getIdentifier(), getTypeSignature(typeBinding), typeDimension, typeBinding.isPrimitive(), initializer != null, fCounter)); |
| 3314 |
initializer.accept(this); |
3383 |
if (initializer != null) { |
|
|
3384 |
initializer.accept(this); |
| 3385 |
} |
| 3315 |
} |
3386 |
} |
| 3316 |
return false; |
3387 |
return false; |
| 3317 |
} |
3388 |
} |
|
Lines 3350-3356
Link Here
|
| 3350 |
} |
3421 |
} |
| 3351 |
|
3422 |
|
| 3352 |
SimpleName fieldName= node.getName(); |
3423 |
SimpleName fieldName= node.getName(); |
| 3353 |
IVariableBinding fieldBinding= (IVariableBinding) fieldName.resolveBinding(); |
3424 |
IVariableBinding fieldBinding= (IVariableBinding) resolveBinding(fieldName); |
|
|
3425 |
if (fieldBinding == null) { |
| 3426 |
return false; |
| 3427 |
} |
| 3354 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
3428 |
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass(); |
| 3355 |
String fieldId = fieldName.getIdentifier(); |
3429 |
String fieldId = fieldName.getIdentifier(); |
| 3356 |
|
3430 |
|
|
Lines 3361-3368
Link Here
|
| 3361 |
int superLevel= 1; |
3435 |
int superLevel= 1; |
| 3362 |
int enclosingLevel= 0; |
3436 |
int enclosingLevel= 0; |
| 3363 |
if (qualifier != null) { |
3437 |
if (qualifier != null) { |
| 3364 |
superLevel= getSuperLevel(qualifier.resolveTypeBinding(), declaringTypeBinding); |
3438 |
ITypeBinding typeBinding = resolveTypeBinding(qualifier); |
| 3365 |
enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding()); |
3439 |
if (typeBinding == null) { |
|
|
3440 |
return false; |
| 3441 |
} |
| 3442 |
superLevel= getSuperLevel(typeBinding, declaringTypeBinding); |
| 3443 |
ITypeBinding binding = (ITypeBinding)resolveBinding(qualifier); |
| 3444 |
if (binding == null) { |
| 3445 |
return false; |
| 3446 |
} |
| 3447 |
enclosingLevel= getEnclosingLevel(node, binding); |
| 3366 |
} |
3448 |
} |
| 3367 |
push(new PushFieldVariable(fieldId, superLevel, fCounter)); |
3449 |
push(new PushFieldVariable(fieldId, superLevel, fCounter)); |
| 3368 |
push(new PushThis(enclosingLevel)); |
3450 |
push(new PushThis(enclosingLevel)); |
|
Lines 3382-3396
Link Here
|
| 3382 |
return false; |
3464 |
return false; |
| 3383 |
} |
3465 |
} |
| 3384 |
|
3466 |
|
| 3385 |
IMethodBinding methodBinding = (IMethodBinding) node.getName().resolveBinding(); |
3467 |
IMethodBinding methodBinding = (IMethodBinding) resolveBinding(node.getName()); |
|
|
3468 |
if (methodBinding == null) { |
| 3469 |
return false; |
| 3470 |
} |
| 3386 |
|
3471 |
|
| 3387 |
if (containsALocalType(methodBinding)) { |
3472 |
if (containsALocalType(methodBinding)) { |
| 3388 |
setHasError(true); |
3473 |
setHasError(true); |
| 3389 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
3474 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32); |
| 3390 |
} |
3475 |
return false; |
| 3391 |
|
|
|
| 3392 |
if (hasErrors()) { |
| 3393 |
return true; |
| 3394 |
} |
3476 |
} |
| 3395 |
|
3477 |
|
| 3396 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
3478 |
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
|
Lines 3405-3411
Link Here
|
| 3405 |
push(new SendMessage(selector, signature, paramCount, getTypeSignature(methodBinding.getDeclaringClass()), fCounter)); |
3487 |
push(new SendMessage(selector, signature, paramCount, getTypeSignature(methodBinding.getDeclaringClass()), fCounter)); |
| 3406 |
int enclosingLevel= 0; |
3488 |
int enclosingLevel= 0; |
| 3407 |
if (qualifier != null) { |
3489 |
if (qualifier != null) { |
| 3408 |
enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding()); |
3490 |
ITypeBinding typeBinding = (ITypeBinding)resolveBinding(qualifier); |
|
|
3491 |
if (typeBinding == null) { |
| 3492 |
return false; |
| 3493 |
} |
| 3494 |
enclosingLevel= getEnclosingLevel(node, typeBinding); |
| 3409 |
} |
3495 |
} |
| 3410 |
push(new PushThis(enclosingLevel)); |
3496 |
push(new PushThis(enclosingLevel)); |
| 3411 |
storeInstruction(); |
3497 |
storeInstruction(); |
|
Lines 3413-3419
Link Here
|
| 3413 |
|
3499 |
|
| 3414 |
List arguments = node.arguments(); |
3500 |
List arguments = node.arguments(); |
| 3415 |
int argCount = arguments.size(); |
3501 |
int argCount = arguments.size(); |
| 3416 |
if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == ((Expression)arguments.get(argCount - 1)).resolveTypeBinding().getDimensions())) { |
3502 |
ITypeBinding lastArgBinding = null; |
|
|
3503 |
if (methodBinding.isVarargs()) { |
| 3504 |
lastArgBinding = resolveTypeBinding((Expression)arguments.get(argCount - 1)); |
| 3505 |
if (lastArgBinding == null) { |
| 3506 |
return false; |
| 3507 |
} |
| 3508 |
} |
| 3509 |
if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == lastArgBinding.getDimensions())) { |
| 3417 |
// 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 |
| 3418 |
// (multiple arguments) and not an array |
3511 |
// (multiple arguments) and not an array |
| 3419 |
Iterator iterator= arguments.iterator(); |
3512 |
Iterator iterator= arguments.iterator(); |
|
Lines 3606-3612
Link Here
|
| 3606 |
Name qualifier= node.getQualifier(); |
3699 |
Name qualifier= node.getQualifier(); |
| 3607 |
int enclosingLevel= 0; |
3700 |
int enclosingLevel= 0; |
| 3608 |
if (qualifier != null) { |
3701 |
if (qualifier != null) { |
| 3609 |
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); |
| 3610 |
} |
3707 |
} |
| 3611 |
push(new PushThis(enclosingLevel)); |
3708 |
push(new PushThis(enclosingLevel)); |
| 3612 |
|
3709 |
|
|
Lines 3633-3639
Link Here
|
| 3633 |
} |
3730 |
} |
| 3634 |
setHasError(true); |
3731 |
setHasError(true); |
| 3635 |
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); |
| 3636 |
return true; |
3733 |
return false; |
| 3637 |
} |
3734 |
} |
| 3638 |
|
3735 |
|
| 3639 |
/** |
3736 |
/** |
|
Lines 3715-3730
Link Here
|
| 3715 |
ASTNode parent= node.getParent(); |
3812 |
ASTNode parent= node.getParent(); |
| 3716 |
switch (parent.getNodeType()) { |
3813 |
switch (parent.getNodeType()) { |
| 3717 |
case ASTNode.VARIABLE_DECLARATION_EXPRESSION: |
3814 |
case ASTNode.VARIABLE_DECLARATION_EXPRESSION: |
| 3718 |
varTypeBinding= ((VariableDeclarationExpression)parent).getType().resolveBinding(); |
3815 |
varTypeBinding= resolveTypeBinding(((VariableDeclarationExpression)parent).getType()); |
| 3719 |
break; |
3816 |
break; |
| 3720 |
case ASTNode.VARIABLE_DECLARATION_STATEMENT: |
3817 |
case ASTNode.VARIABLE_DECLARATION_STATEMENT: |
| 3721 |
varTypeBinding= ((VariableDeclarationStatement)parent).getType().resolveBinding(); |
3818 |
varTypeBinding= resolveTypeBinding(((VariableDeclarationStatement)parent).getType()); |
| 3722 |
break; |
3819 |
break; |
| 3723 |
default: |
3820 |
default: |
| 3724 |
setHasError(true); |
3821 |
setHasError(true); |
| 3725 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Error_in_type_declaration_statement); |
3822 |
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Error_in_type_declaration_statement); |
| 3726 |
return false; |
3823 |
return false; |
| 3727 |
} |
3824 |
} |
|
|
3825 |
if (varTypeBinding == null) { |
| 3826 |
return false; |
| 3827 |
} |
| 3728 |
int typeDimension= varTypeBinding.getDimensions(); |
3828 |
int typeDimension= varTypeBinding.getDimensions(); |
| 3729 |
ITypeBinding elementBinding = varTypeBinding; |
3829 |
ITypeBinding elementBinding = varTypeBinding; |
| 3730 |
if (typeDimension != 0) { |
3830 |
if (typeDimension != 0) { |
|
Lines 3788-3793
Link Here
|
| 3788 |
|
3888 |
|
| 3789 |
private int getTypeId(Expression expression) { |
3889 |
private int getTypeId(Expression expression) { |
| 3790 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
3890 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
|
|
3891 |
if (typeBinding == null) { |
| 3892 |
return Instruction.T_undefined; |
| 3893 |
} |
| 3791 |
String typeName = typeBinding.getQualifiedName(); |
3894 |
String typeName = typeBinding.getQualifiedName(); |
| 3792 |
if (typeBinding.isPrimitive()) { |
3895 |
if (typeBinding.isPrimitive()) { |
| 3793 |
return getPrimitiveTypeId(typeName); |
3896 |
return getPrimitiveTypeId(typeName); |
|
Lines 3800-3805
Link Here
|
| 3800 |
|
3903 |
|
| 3801 |
private int getUnBoxedTypeId(Expression expression) { |
3904 |
private int getUnBoxedTypeId(Expression expression) { |
| 3802 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
3905 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
|
|
3906 |
if (typeBinding == null) { |
| 3907 |
return Instruction.T_undefined; |
| 3908 |
} |
| 3803 |
String typeName = typeBinding.getQualifiedName(); |
3909 |
String typeName = typeBinding.getQualifiedName(); |
| 3804 |
if (typeBinding.isPrimitive()) { |
3910 |
if (typeBinding.isPrimitive()) { |
| 3805 |
return getPrimitiveTypeId(typeName); |
3911 |
return getPrimitiveTypeId(typeName); |
|
Lines 3833-3839
Link Here
|
| 3833 |
return getPrimitiveTypeId(((PrimitiveType)type).getPrimitiveTypeCode().toString()); |
3939 |
return getPrimitiveTypeId(((PrimitiveType)type).getPrimitiveTypeCode().toString()); |
| 3834 |
} else if (type.isSimpleType()) { |
3940 |
} else if (type.isSimpleType()) { |
| 3835 |
SimpleType simpleType = (SimpleType) type; |
3941 |
SimpleType simpleType = (SimpleType) type; |
| 3836 |
if ("java.lang.String".equals(simpleType.getName())){ //$NON-NLS-1$ |
3942 |
if ("java.lang.String".equals(simpleType.getName().getFullyQualifiedName())){ //$NON-NLS-1$ |
| 3837 |
return Instruction.T_String; |
3943 |
return Instruction.T_String; |
| 3838 |
} |
3944 |
} |
| 3839 |
return Instruction.T_Object; |
3945 |
return Instruction.T_Object; |
|
Lines 3902-3905
Link Here
|
| 3902 |
} |
4008 |
} |
| 3903 |
return Instruction.T_undefined; |
4009 |
return Instruction.T_undefined; |
| 3904 |
} |
4010 |
} |
|
|
4011 |
|
| 4012 |
/** |
| 4013 |
* Resolves and returns the type binding from the given expression reporting an error |
| 4014 |
* if the binding is <code>null</code>. |
| 4015 |
* |
| 4016 |
* @param expression expression to resolve type binding for |
| 4017 |
* @return type binding or <code>null</code> if not available |
| 4018 |
*/ |
| 4019 |
private ITypeBinding resolveTypeBinding(Expression expression) { |
| 4020 |
ITypeBinding typeBinding = expression.resolveTypeBinding(); |
| 4021 |
if (typeBinding == null) { |
| 4022 |
setHasError(true); |
| 4023 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{expression.toString()})); |
| 4024 |
} |
| 4025 |
return typeBinding; |
| 4026 |
} |
| 4027 |
|
| 4028 |
/** |
| 4029 |
* Resolves and returns the type binding for the give type reporting an error |
| 4030 |
* if the binding is <code>null</code>. |
| 4031 |
* |
| 4032 |
* @param type type to resolve binding for |
| 4033 |
* @return type binding or <code>null</code> if not available |
| 4034 |
*/ |
| 4035 |
private ITypeBinding resolveTypeBinding(Type type) { |
| 4036 |
ITypeBinding typeBinding = type.resolveBinding(); |
| 4037 |
if (typeBinding == null) { |
| 4038 |
setHasError(true); |
| 4039 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{type.toString()})); |
| 4040 |
} |
| 4041 |
return typeBinding; |
| 4042 |
} |
| 4043 |
|
| 4044 |
/** |
| 4045 |
* Resolves and returns the binding for the given name reporting an error |
| 4046 |
* if the binding is <code>null</code>. |
| 4047 |
* |
| 4048 |
* @param name name to resolve binding for |
| 4049 |
* @return binding or <code>null</code> if not available |
| 4050 |
*/ |
| 4051 |
private IBinding resolveBinding(Name name) { |
| 4052 |
IBinding binding = name.resolveBinding(); |
| 4053 |
if (binding == null) { |
| 4054 |
setHasError(true); |
| 4055 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_5, new String[]{name.getFullyQualifiedName()})); |
| 4056 |
} |
| 4057 |
return binding; |
| 4058 |
} |
| 4059 |
|
| 4060 |
/** |
| 4061 |
* Resolves and returns the type binding for the given name reporting an error |
| 4062 |
* if the binding is <code>null</code>. |
| 4063 |
* |
| 4064 |
* @param name name to resolve type binding for |
| 4065 |
* @return type binding or <code>null</code> if not available |
| 4066 |
*/ |
| 4067 |
private ITypeBinding resolveTypeBinding(Name name) { |
| 4068 |
ITypeBinding typeBinding = name.resolveTypeBinding(); |
| 4069 |
if (typeBinding == null) { |
| 4070 |
setHasError(true); |
| 4071 |
addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{name.getFullyQualifiedName()})); |
| 4072 |
} |
| 4073 |
return typeBinding; |
| 4074 |
} |
| 3905 |
} |
4075 |
} |