mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
0f13c1b8f1
commit
372f3ef066
34 changed files with 498 additions and 536 deletions
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bnicolle
|
* @author bnicolle
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class IStructureTests extends IntegratedCModelTest {
|
public class IStructureTests extends IntegratedCModelTest {
|
||||||
/**
|
/**
|
||||||
|
@ -229,10 +228,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementUnion = tu.getElement("testUnion1");
|
myElementUnion = tu.getElement("testUnion1");
|
||||||
myElementNonUnion = tu.getElement("testStruct1");
|
myElementNonUnion = tu.getElement("testStruct1");
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
assertNotNull(myElementUnion);
|
assertNotNull(myElementUnion);
|
||||||
assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
|
assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
|
||||||
|
@ -246,6 +243,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
assertNotNull(myStructNonUnion);
|
assertNotNull(myStructNonUnion);
|
||||||
assertFalse(myStructNonUnion.isUnion());
|
assertFalse(myStructNonUnion.isUnion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsStruct() throws CModelException {
|
public void testIsStruct() throws CModelException {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ICElement myElementStruct = null;
|
ICElement myElementStruct = null;
|
||||||
|
@ -253,10 +251,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementStruct = tu.getElement("testStruct1");
|
myElementStruct = tu.getElement("testStruct1");
|
||||||
myElementNonStruct = tu.getElement("testClass1");
|
myElementNonStruct = tu.getElement("testClass1");
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
assertNotNull(myElementStruct);
|
assertNotNull(myElementStruct);
|
||||||
assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
|
assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
|
||||||
|
@ -278,10 +274,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementClass = tu.getElement("testClass1");
|
myElementClass = tu.getElement("testClass1");
|
||||||
myElementNonClass = tu.getElement("testStruct1");
|
myElementNonClass = tu.getElement("testStruct1");
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
assertNotNull(myElementClass);
|
assertNotNull(myElementClass);
|
||||||
assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
|
assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
|
||||||
|
@ -303,10 +297,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementAbstract = tu.getElement("testClass4Abstract");
|
myElementAbstract = tu.getElement("testClass4Abstract");
|
||||||
myElementNonAbstract = tu.getElement("testClass1");
|
myElementNonAbstract = tu.getElement("testClass1");
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
assertNotNull(myElementAbstract);
|
assertNotNull(myElementAbstract);
|
||||||
assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
|
assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
|
||||||
|
@ -333,10 +325,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||||
assertNotNull(myStructDerived);
|
assertNotNull(myStructDerived);
|
||||||
myBaseTypes = myStructDerived.getSuperClassesNames();
|
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] myExpectedBaseTypes = {
|
String[] myExpectedBaseTypes = {
|
||||||
|
@ -372,10 +362,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
|
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
|
||||||
assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
|
assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
|
||||||
}
|
}
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,10 +387,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ICElement myElement = null;
|
ICElement myElement = null;
|
||||||
try {
|
try {
|
||||||
myElement = tu.getElement("testAnonymousStructObject1");
|
myElement = tu.getElement("testAnonymousStructObject1");
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
assertNotNull(myElement);
|
assertNotNull(myElement);
|
||||||
assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
|
assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
|
||||||
|
@ -413,10 +399,8 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ICElement myElement = null;
|
ICElement myElement = null;
|
||||||
try {
|
try {
|
||||||
myElement = tu.getElement("testStruct8");
|
myElement = tu.getElement("testStruct8");
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
assertNotNull(myElement);
|
assertNotNull(myElement);
|
||||||
IStructure myIStruct = (IStructure) myElement;
|
IStructure myIStruct = (IStructure) myElement;
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Jun 3, 2003
|
|
||||||
* by bnicolle
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -33,18 +29,13 @@ import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bnicolle
|
* @author bnicolle
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class IntegratedCModelTest extends BaseTestCase {
|
public abstract class IntegratedCModelTest extends BaseTestCase {
|
||||||
|
|
||||||
private ICProject fCProject;
|
private ICProject fCProject;
|
||||||
private IFile sourceFile;
|
private IFile sourceFile;
|
||||||
private NullProgressMonitor monitor;
|
private NullProgressMonitor monitor;
|
||||||
private boolean structuralParse = false;
|
private boolean structuralParse = false;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public IntegratedCModelTest() {
|
public IntegratedCModelTest() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -113,5 +104,4 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
|
||||||
public void setStructuralParse(boolean structuralParse) {
|
public void setStructuralParse(boolean structuralParse) {
|
||||||
this.structuralParse = structuralParse;
|
this.structuralParse = structuralParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.util;
|
package org.eclipse.cdt.core.parser.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,9 +43,7 @@ public class ObjectMap extends ObjectTable<Object> {
|
||||||
@Override
|
@Override
|
||||||
final public void clear() {
|
final public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
for(int i = 0; i < valueTable.length; i++) {
|
Arrays.fill(valueTable, null);
|
||||||
valueTable[i] = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -417,8 +417,9 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
||||||
copy.fForContentAssist = fForContentAssist;
|
copy.fForContentAssist = fForContentAssist;
|
||||||
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
|
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
|
||||||
|
|
||||||
for (IASTDeclaration declaration : getDeclarations())
|
for (IASTDeclaration declaration : getDeclarations()) {
|
||||||
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
|
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
|
||||||
|
}
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
if (image.length > 1 && image[0] == 'L')
|
if (image.length > 1 && image[0] == 'L')
|
||||||
return Value.create(ExpressionEvaluator.getChar(image, 2));
|
return Value.create(ExpressionEvaluator.getChar(image, 2));
|
||||||
return Value.create(ExpressionEvaluator.getChar(image, 1));
|
return Value.create(ExpressionEvaluator.getChar(image, 1));
|
||||||
} catch (EvalException e1) {
|
} catch (EvalException e) {
|
||||||
return Value.UNKNOWN;
|
return Value.UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
private IValue createIntValue() {
|
private IValue createIntValue() {
|
||||||
try {
|
try {
|
||||||
return Value.create(ExpressionEvaluator.getNumber(getValue()));
|
return Value.create(ExpressionEvaluator.getNumber(getValue()));
|
||||||
} catch (EvalException e1) {
|
} catch (EvalException e) {
|
||||||
return Value.UNKNOWN;
|
return Value.UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,4 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor {
|
||||||
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
|
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
|
||||||
super(declarator);
|
super(declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
|
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
|
||||||
private final ICPPTemplateArgument[] fArguments;
|
private final ICPPTemplateArgument[] fArguments;
|
||||||
|
|
||||||
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap,
|
||||||
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, argMap, type, exceptionSpecs);
|
super(orig, owner, argMap, type, exceptionSpecs);
|
||||||
fArguments = args;
|
fArguments = args;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
*/
|
*/
|
||||||
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
||||||
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
||||||
|
private ObjectMap instances;
|
||||||
private ObjectMap instances = null;
|
|
||||||
|
|
||||||
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(original, owner, argumentMap, type, exceptionSpecs);
|
super(original, owner, argumentMap, type, exceptionSpecs);
|
||||||
|
|
|
@ -23,13 +23,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
*/
|
*/
|
||||||
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
||||||
|
|
||||||
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap,
|
||||||
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, tpmap, args, type, exceptionSpecs);
|
super(orig, owner, tpmap, args, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getVisibility() {
|
public int getVisibility() {
|
||||||
return ((ICPPMethod) getTemplateDefinition()).getVisibility();
|
return ((ICPPMethod) getTemplateDefinition()).getVisibility();
|
||||||
|
@ -40,17 +38,11 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
||||||
return (ICPPClassType) getOwner();
|
return (ICPPClassType) getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVirtual() {
|
public boolean isVirtual() {
|
||||||
return ((ICPPMethod) getTemplateDefinition()).isVirtual();
|
return ((ICPPMethod) getTemplateDefinition()).isVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPureVirtual() {
|
public boolean isPureVirtual() {
|
||||||
return ((ICPPMethod) getTemplateDefinition()).isPureVirtual();
|
return ((ICPPMethod) getTemplateDefinition()).isPureVirtual();
|
||||||
|
@ -61,9 +53,6 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
||||||
return ((ICPPMethod) getTemplateDefinition()).isExplicit();
|
return ((ICPPMethod) getTemplateDefinition()).isExplicit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDestructor() {
|
public boolean isDestructor() {
|
||||||
char[] name = getNameCharArray();
|
char[] name = getNameCharArray();
|
||||||
|
|
|
@ -3041,8 +3041,10 @@ public class CPPSemantics {
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN),
|
ICPPEvaluation[] args = {
|
||||||
((ICPPASTExpression) expr.getOperand()).getEvaluation()};
|
new EvalFixed(type, LVALUE, Value.UNKNOWN),
|
||||||
|
((ICPPASTExpression) expr.getOperand()).getEvaluation()
|
||||||
|
};
|
||||||
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,6 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
if (overload != null)
|
if (overload != null)
|
||||||
return ExpressionTypes.typeFromFunctionCall(overload);
|
return ExpressionTypes.typeFromFunctionCall(overload);
|
||||||
|
|
||||||
|
|
||||||
final ICPPEvaluation arg0 = fArguments[0];
|
final ICPPEvaluation arg0 = fArguments[0];
|
||||||
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
|
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
|
||||||
if (t instanceof ICPPClassType) {
|
if (t instanceof ICPPClassType) {
|
||||||
|
|
|
@ -176,7 +176,8 @@ public class EvalMemberAccess extends CPPEvaluation {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ICPPEvaluation[] args= { new EvalFixed(type, LVALUE, Value.UNKNOWN) };
|
ICPPEvaluation[] args= { new EvalFixed(type, LVALUE, Value.UNKNOWN) };
|
||||||
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType,
|
||||||
|
OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
||||||
if (op == null)
|
if (op == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,9 @@ public class ExpressionEvaluator {
|
||||||
if (LA() == IToken.tQUESTION) {
|
if (LA() == IToken.tQUESTION) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = expression();
|
long r2 = expression();
|
||||||
if (LA() == IToken.tCOLON)
|
if (LA() == IToken.tCOLON) {
|
||||||
consume();
|
consume();
|
||||||
else {
|
} else {
|
||||||
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
|
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
|
||||||
}
|
}
|
||||||
long r3 = conditionalExpression();
|
long r3 = conditionalExpression();
|
||||||
|
@ -139,12 +139,13 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
|
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = relationalExpression();
|
long r2 = relationalExpression();
|
||||||
if (t == IToken.tEQUAL)
|
if (t == IToken.tEQUAL) {
|
||||||
r1 = (r1 == r2) ? 1 : 0;
|
r1 = (r1 == r2) ? 1 : 0;
|
||||||
else
|
} else {
|
||||||
// t == tNOTEQUAL
|
// t == tNOTEQUAL
|
||||||
r1 = (r1 != r2) ? 1 : 0;
|
r1 = (r1 != r2) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +180,13 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
|
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = additiveExpression();
|
long r2 = additiveExpression();
|
||||||
if (t == IToken.tSHIFTL)
|
if (t == IToken.tSHIFTL) {
|
||||||
r1 = r1 << r2;
|
r1 = r1 << r2;
|
||||||
else
|
} else {
|
||||||
// t == tSHIFTR
|
// t == tSHIFTR
|
||||||
r1 = r1 >> r2;
|
r1 = r1 >> r2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,12 +195,13 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
|
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = multiplicativeExpression();
|
long r2 = multiplicativeExpression();
|
||||||
if (t == IToken.tPLUS)
|
if (t == IToken.tPLUS) {
|
||||||
r1 = r1 + r2;
|
r1 = r1 + r2;
|
||||||
else
|
} else {
|
||||||
// t == tMINUS
|
// t == tMINUS
|
||||||
r1 = r1 - r2;
|
r1 = r1 - r2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,13 +210,14 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
|
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = unaryExpression();
|
long r2 = unaryExpression();
|
||||||
if (t == IToken.tSTAR)
|
if (t == IToken.tSTAR) {
|
||||||
r1 = r1 * r2;
|
r1 = r1 * r2;
|
||||||
else if (r2 != 0) {
|
} else if (r2 != 0) {
|
||||||
if (t == IToken.tDIV)
|
if (t == IToken.tDIV) {
|
||||||
r1 = r1 / r2;
|
r1 = r1 / r2;
|
||||||
else
|
} else {
|
||||||
r1 = r1 % r2; //tMOD
|
r1 = r1 % r2; //tMOD
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
|
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Binding for a function parameter in the index.
|
* Binding for a function parameter in the index.
|
||||||
*/
|
*/
|
||||||
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
|
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
|
||||||
|
|
||||||
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
||||||
private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE;
|
private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE;
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
|
@ -138,7 +137,6 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
||||||
return getNodeType();
|
return getNodeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||||
PDOMCParameter p= this;
|
PDOMCParameter p= this;
|
||||||
|
@ -193,7 +191,6 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
||||||
return defValue;
|
return defValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Result of instantiating a class template.
|
* Result of instantiating a class template.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
|
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
|
||||||
|
|
||||||
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
|
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,20 +42,18 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
private static final short ANNOT_IS_DELETED = 9;
|
private static final short ANNOT_IS_DELETED = 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of total number of function parameters (relative to the
|
* Offset of total number of function parameters (relative to the beginning of the record).
|
||||||
* beginning of the record).
|
|
||||||
*/
|
*/
|
||||||
private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE;
|
private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of pointer to the first parameter of this function (relative to
|
* Offset of pointer to the first parameter of this function (relative to the beginning of the record).
|
||||||
* the beginning of the record).
|
|
||||||
*/
|
*/
|
||||||
private static final int FIRST_PARAM = NUM_PARAMS + 4;
|
private static final int FIRST_PARAM = NUM_PARAMS + 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of pointer to the function type record of this function (relative to
|
* Offset of pointer to the function type record of this function (relative to the beginning of the
|
||||||
* the beginning of the record).
|
* record).
|
||||||
*/
|
*/
|
||||||
protected static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
|
protected static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
|
||||||
|
|
||||||
|
@ -86,7 +84,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
private int fRequiredArgCount = -1;
|
private int fRequiredArgCount = -1;
|
||||||
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
||||||
|
|
||||||
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
|
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function,
|
||||||
|
boolean setTypes) throws CoreException, DOMException {
|
||||||
super(linkage, parent, function.getNameCharArray());
|
super(linkage, parent, function.getNameCharArray());
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
||||||
|
@ -376,8 +375,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
int mySM = a.getSignatureHash();
|
int mySM = a.getSignatureHash();
|
||||||
int otherSM = bb.getSignatureHash();
|
int otherSM = bb.getSignatureHash();
|
||||||
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert false;
|
assert false;
|
||||||
|
|
|
@ -98,7 +98,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
db.putRecPtr(record + FIRST_PARAM, 0);
|
db.putRecPtr(record + FIRST_PARAM, 0);
|
||||||
PDOMCPPParameter origPar= null;
|
PDOMCPPParameter origPar= null;
|
||||||
PDOMCPPParameterSpecialization next= null;
|
PDOMCPPParameterSpecialization next= null;
|
||||||
for (int i= length-1; i >= 0; --i) {
|
for (int i= length; --i >= 0;) {
|
||||||
// There may be fewer or less original parameters, because of parameter packs.
|
// There may be fewer or less original parameters, because of parameter packs.
|
||||||
if (i < origAstParams.length - 1) {
|
if (i < origAstParams.length - 1) {
|
||||||
// Normal case
|
// Normal case
|
||||||
|
@ -205,8 +205,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
if (fType == null) {
|
if (fType == null) {
|
||||||
try {
|
try {
|
||||||
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(e);
|
||||||
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Binding for a parameter of a c++ function in the index.
|
* Binding for a parameter of a c++ function in the index.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding {
|
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding {
|
||||||
|
|
||||||
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
||||||
private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE;
|
private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE;
|
||||||
private static final int FLAGS = ANNOTATIONS + 1;
|
private static final int FLAGS = ANNOTATIONS + 1;
|
||||||
|
@ -48,6 +47,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
|
||||||
private static final byte FLAG_DEFAULT_VALUE = 0x1;
|
private static final byte FLAG_DEFAULT_VALUE = 0x1;
|
||||||
|
|
||||||
private final IType fType;
|
private final IType fType;
|
||||||
|
|
||||||
public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) {
|
public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) {
|
||||||
super(linkage, record);
|
super(linkage, record);
|
||||||
fType= type;
|
fType= type;
|
||||||
|
|
|
@ -44,7 +44,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
|
||||||
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
|
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
|
||||||
PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
|
PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
|
||||||
super(linkage, parent, (ICPPSpecialization) astParam, original);
|
super(linkage, parent, (ICPPSpecialization) astParam, original);
|
||||||
fType= null; // this constructor is used for adding parameters to the database, only.
|
fType= null; // This constructor is used for adding parameters to the database, only.
|
||||||
|
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());
|
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Binding for a c++ variable in the index, serves as a base class for fields.
|
* Binding for a c++ variable in the index, serves as a base class for fields.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
||||||
|
|
||||||
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
|
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
|
||||||
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
|
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
|
||||||
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte
|
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte
|
||||||
|
|
Loading…
Add table
Reference in a new issue