mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Replacing strings with char arrays
This commit is contained in:
parent
05fa0e698c
commit
7f0142b2e8
60 changed files with 1978 additions and 1322 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.core.parser.tests.scanner2;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
|
||||
/**
|
||||
|
@ -146,5 +147,16 @@ public class ObjectMapTest extends TestCase {
|
|||
insertContents( map, con );
|
||||
assertContents( map, con );
|
||||
}
|
||||
|
||||
public void testCharArrayUtils() throws Exception{
|
||||
char [] buffer = "A::B::C".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
assertEquals( CharArrayUtils.lastIndexOf( "::".toCharArray(), buffer ), 4 ); //$NON-NLS-1$
|
||||
assertTrue( CharArrayUtils.equals( CharArrayUtils.lastSegment( buffer, "::".toCharArray()), "C".toCharArray() ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
buffer = "A::B::C:foo".toCharArray(); //$NON-NLS-1$
|
||||
assertEquals( CharArrayUtils.lastIndexOf( "::".toCharArray(), buffer ), 4 ); //$NON-NLS-1$
|
||||
assertTrue( CharArrayUtils.equals( CharArrayUtils.lastSegment( buffer, "::".toCharArray()), "C:foo".toCharArray() ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ASTDesignator implements IASTDesignator
|
|||
* @param constantExpression
|
||||
* @param string
|
||||
*/
|
||||
public ASTDesignator(DesignatorKind kind, IASTExpression constantExpression, String fieldName, int fieldOffset )
|
||||
public ASTDesignator(DesignatorKind kind, IASTExpression constantExpression, char[] fieldName, int fieldOffset )
|
||||
{
|
||||
this.fieldName = fieldName;
|
||||
this.constantExpression = constantExpression;
|
||||
|
@ -35,7 +35,7 @@ public class ASTDesignator implements IASTDesignator
|
|||
}
|
||||
|
||||
private int fieldOffset;
|
||||
private final String fieldName;
|
||||
private final char[] fieldName;
|
||||
private final IASTExpression constantExpression;
|
||||
private final DesignatorKind kind;
|
||||
/* (non-Javadoc)
|
||||
|
@ -57,6 +57,9 @@ public class ASTDesignator implements IASTDesignator
|
|||
*/
|
||||
public String fieldName()
|
||||
{
|
||||
return String.valueOf(fieldName);
|
||||
}
|
||||
public char[] fieldNameArray(){
|
||||
return fieldName;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
|
|||
/**
|
||||
* @param scope
|
||||
*/
|
||||
public ASTQualifiedNamedElement(IASTScope scope, String name )
|
||||
public ASTQualifiedNamedElement(IASTScope scope, char[] name )
|
||||
{
|
||||
Stack names = new Stack();
|
||||
IASTScope parent = scope;
|
||||
|
@ -40,7 +40,7 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
|
|||
if (parent instanceof IASTNamespaceDefinition
|
||||
|| parent instanceof IASTClassSpecifier )
|
||||
{
|
||||
names.push(((IASTOffsetableNamedElement)parent).getName());
|
||||
names.push(((IASTOffsetableNamedElement)parent).getName().toCharArray());
|
||||
if( parent instanceof IASTScopedElement )
|
||||
parent = ((IASTScopedElement)parent).getOwnerScope();
|
||||
}
|
||||
|
@ -55,10 +55,10 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
|
|||
}
|
||||
if (names.size() != 0)
|
||||
{
|
||||
qualifiedNames = new String[names.size()];
|
||||
qualifiedNames = new char[names.size()][];
|
||||
int counter = 0;
|
||||
while (!names.empty())
|
||||
qualifiedNames[counter++] = (String)names.pop();
|
||||
qualifiedNames[counter++] = (char[])names.pop();
|
||||
}
|
||||
else
|
||||
qualifiedNames = null;
|
||||
|
@ -67,9 +67,13 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
|
|||
|
||||
public String[] getFullyQualifiedName()
|
||||
{
|
||||
return qualifiedNames;
|
||||
String[] result = new String[qualifiedNames.length ];
|
||||
for( int i = 0; i < qualifiedNames.length; i++ ){
|
||||
result[i] = String.valueOf(qualifiedNames[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private final String[] qualifiedNames;
|
||||
private final char[][] qualifiedNames;
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class BaseASTFactory {
|
|||
if( extension.overrideCreateDesignatorMethod( kind ))
|
||||
return extension.createDesignator( kind, constantExpression, fieldIdentifier, extensionParms );
|
||||
return new ASTDesignator( kind, constantExpression,
|
||||
fieldIdentifier == null ? "" : fieldIdentifier.getImage(), //$NON-NLS-1$
|
||||
fieldIdentifier == null ? new char[0] : fieldIdentifier.getCharImage(), //$NON-NLS-1$
|
||||
fieldIdentifier == null ? -1 : fieldIdentifier.getOffset() );
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
|||
*/
|
||||
public abstract class GCCASTExtension implements IASTFactoryExtension {
|
||||
protected final ParserMode mode;
|
||||
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
protected static final char[] EMPTY_STRING = new char[0]; //$NON-NLS-1$
|
||||
/**
|
||||
* @param mode
|
||||
*/
|
||||
|
@ -116,7 +116,7 @@ public abstract class GCCASTExtension implements IASTFactoryExtension {
|
|||
ASTExpression typeOfExpression = (ASTExpression) extensionParms.get( IASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION );
|
||||
ISymbol s = pst.newSymbol( EMPTY_STRING );
|
||||
s.setTypeInfo( typeOfExpression.getResultType().getResult() );
|
||||
return new ASTGCCSimpleTypeSpecifier( s, isTypename, ( typeName == null ? EMPTY_STRING : typeName.toString()), Collections.EMPTY_LIST, typeOfExpression );
|
||||
return new ASTGCCSimpleTypeSpecifier( s, isTypename, ( typeName == null ? EMPTY_STRING : typeName.toCharArray()), Collections.EMPTY_LIST, typeOfExpression );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
|||
*/
|
||||
public class ASTASMDefinition extends ASTAnonymousDeclaration implements IASTASMDefinition
|
||||
{
|
||||
private final String assembly;
|
||||
private final char[] assembly;
|
||||
/**
|
||||
* @param filename
|
||||
*
|
||||
*/
|
||||
public ASTASMDefinition( IContainerSymbol scope, String assembly, int first, int firstLine, int last , int lastLine, char[] filename )
|
||||
public ASTASMDefinition( IContainerSymbol scope, char[] assembly, int first, int firstLine, int last , int lastLine, char[] filename )
|
||||
{
|
||||
super( scope );
|
||||
this.assembly = assembly;
|
||||
|
@ -39,7 +39,7 @@ public class ASTASMDefinition extends ASTAnonymousDeclaration implements IASTASM
|
|||
*/
|
||||
public String getBody()
|
||||
{
|
||||
return assembly;
|
||||
return String.valueOf( assembly );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier
|
|||
*/
|
||||
public String getParentClassName()
|
||||
{
|
||||
return symbol.getName();
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParentClassSpecifier()
|
||||
|
|
|
@ -146,9 +146,11 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
public char[] getNameArray(){
|
||||
return symbol.getName();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
|
|
@ -26,13 +26,13 @@ public class ASTConstructorMemberInitializer
|
|||
{
|
||||
private final int nameOffset;
|
||||
private final boolean requireNameResolution;
|
||||
private final String name;
|
||||
private final char[] name;
|
||||
private final IASTExpression expression;
|
||||
private List references;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ASTConstructorMemberInitializer( IASTExpression expression, String name, int nameOffset, List references, boolean requireNameResolution )
|
||||
public ASTConstructorMemberInitializer( IASTExpression expression, char[] name, int nameOffset, List references, boolean requireNameResolution )
|
||||
{
|
||||
this.expression = expression;
|
||||
this.name = name;
|
||||
|
@ -52,6 +52,9 @@ public class ASTConstructorMemberInitializer
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return String.valueOf( name );
|
||||
}
|
||||
public char[] getNameArray(){
|
||||
return name;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -55,6 +55,9 @@ public class ASTElaboratedTypeSpecifier extends ASTSymbol implements IASTElabora
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return String.valueOf(getSymbol().getName());
|
||||
}
|
||||
public char[] getNameArray(){
|
||||
return getSymbol().getName();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
@ -116,11 +119,12 @@ public class ASTElaboratedTypeSpecifier extends ASTSymbol implements IASTElabora
|
|||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if( obj == this ) return true;
|
||||
if( obj == null ) return false;
|
||||
if( ! (obj instanceof IASTElaboratedTypeSpecifier )) return false;
|
||||
IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier) obj;
|
||||
if( elab.getClassKind() != getClassKind() ) return false;
|
||||
if( elab.getName() != getName() ) return false;
|
||||
if( !elab.getName().equals( getName() ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ASTEnumerationSpecifier
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getSymbol().getName();
|
||||
return String.valueOf(getSymbol().getName());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ASTEnumerator extends ASTSymbol implements IASTEnumerator
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return symbol.getName();
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
|
|
|
@ -108,7 +108,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return symbol.getName();
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#getReturnType()
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
|||
public class ASTIdExpression extends ASTExpression {
|
||||
|
||||
private ITokenDuple idExpression;
|
||||
private String idExpressionValue;
|
||||
private char[] idExpressionValue;
|
||||
/**
|
||||
* @param kind
|
||||
* @param references
|
||||
|
@ -30,14 +30,14 @@ public class ASTIdExpression extends ASTExpression {
|
|||
public ASTIdExpression(Kind kind, List references, ITokenDuple idExpression) {
|
||||
super(kind, references);
|
||||
this.idExpression = idExpression;
|
||||
idExpressionValue = idExpression.toString();
|
||||
idExpressionValue = idExpression.toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getIdExpression()
|
||||
*/
|
||||
public String getIdExpression() {
|
||||
return idExpressionValue;
|
||||
return String.valueOf( idExpressionValue );
|
||||
}
|
||||
|
||||
public ITokenDuple getIdExpressionTokenDuple()
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
|||
public class ASTLinkageSpecification extends ASTAnonymousDeclaration implements IASTLinkageSpecification
|
||||
{
|
||||
private List declarations = new ArrayList();
|
||||
private final String linkageString;
|
||||
private final char[] linkageString;
|
||||
private final char [] fn;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getFilename()
|
||||
|
@ -41,7 +41,7 @@ public class ASTLinkageSpecification extends ASTAnonymousDeclaration implements
|
|||
* @param filename
|
||||
*
|
||||
*/
|
||||
public ASTLinkageSpecification( IContainerSymbol scope, String linkageString, int startingOffset, int startingLine, char[] filename )
|
||||
public ASTLinkageSpecification( IContainerSymbol scope, char[] linkageString, int startingOffset, int startingLine, char[] filename )
|
||||
{
|
||||
super( scope );
|
||||
this.linkageString = linkageString;
|
||||
|
@ -53,7 +53,7 @@ public class ASTLinkageSpecification extends ASTAnonymousDeclaration implements
|
|||
*/
|
||||
public String getLinkageString()
|
||||
{
|
||||
return linkageString;
|
||||
return String.valueOf(linkageString);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||
|
|
|
@ -20,13 +20,13 @@ import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
|||
*/
|
||||
public class ASTLiteralExpression extends ASTExpression {
|
||||
|
||||
private final String literal;
|
||||
private final char[] literal;
|
||||
|
||||
/**
|
||||
* @param kind
|
||||
* @param references
|
||||
*/
|
||||
public ASTLiteralExpression(Kind kind, List references, String literal) {
|
||||
public ASTLiteralExpression(Kind kind, List references, char[] literal) {
|
||||
super(kind, references);
|
||||
this.literal = literal;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class ASTLiteralExpression extends ASTExpression {
|
|||
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#getLiteralString()
|
||||
*/
|
||||
public String getLiteralString() {
|
||||
return literal;
|
||||
return String.valueOf( literal );
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
|
|
|
@ -231,7 +231,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
ISymbol thisPointer = thisContainer.lookup( ParserSymbolTable.THIS );
|
||||
ISymbol thisClass = ( thisPointer != null ) ? thisPointer.getTypeSymbol() : null;
|
||||
if( thisClass != null && thisClass instanceof IContainerSymbol ){
|
||||
return ((IContainerSymbol) thisClass).prefixLookup( filter, prefix, true, paramList );
|
||||
return ((IContainerSymbol) thisClass).prefixLookup( filter, prefix.toCharArray(), true, paramList );
|
||||
}
|
||||
} catch (ParserSymbolTableException e) {
|
||||
throw new LookupError();
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
|||
public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
|
||||
{
|
||||
|
||||
private final String alias;
|
||||
private final char[] alias;
|
||||
private final IASTNamespaceDefinition namespace;
|
||||
private List references;
|
||||
private final char [] fn;
|
||||
|
@ -44,7 +44,7 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
|
|||
* @param endOffset
|
||||
* @param filename
|
||||
*/
|
||||
public ASTNamespaceAlias(ISymbol s, String alias, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endingLine, List references, char[] filename)
|
||||
public ASTNamespaceAlias(ISymbol s, char[] alias, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endingLine, List references, char[] filename)
|
||||
{
|
||||
super( s );
|
||||
this.alias = alias;
|
||||
|
@ -61,7 +61,7 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
|
|||
*/
|
||||
public String getAlias()
|
||||
{
|
||||
return alias;
|
||||
return String.valueOf(alias);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias#getNamespace()
|
||||
|
@ -97,7 +97,7 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getSymbol().getName();
|
||||
return String.valueOf(getSymbol().getName());
|
||||
}
|
||||
private int startingLineNumber, startingOffset, endingLineNumber, endingOffset, nameStartOffset, nameEndOffset, nameLineNumber;
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ASTNamespaceDefinition
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return symbol.getName();
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -115,9 +115,9 @@ public class ASTNode implements IASTNode {
|
|||
List results = null;
|
||||
try {
|
||||
if( qualification != null ){
|
||||
results = qualification.prefixLookup( filter, prefix, true, paramList );
|
||||
results = qualification.prefixLookup( filter, prefix.toCharArray(), true, paramList );
|
||||
} else {
|
||||
results = thisContainer.prefixLookup( filter, prefix, false, paramList );
|
||||
results = thisContainer.prefixLookup( filter, prefix.toCharArray(), false, paramList );
|
||||
}
|
||||
} catch (ParserSymbolTableException e) {
|
||||
throw new LookupError();
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
|||
public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterDeclaration
|
||||
{
|
||||
private final ASTAbstractDeclaration abstractDeclaration;
|
||||
private final String parameterName;
|
||||
private final char[] parameterName;
|
||||
private final IASTInitializerClause initializerClause;
|
||||
private final char [] fn;
|
||||
/* (non-Javadoc)
|
||||
|
@ -51,7 +51,7 @@ public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterD
|
|||
* @param initializerClause
|
||||
* @param filename
|
||||
*/
|
||||
public ASTParameterDeclaration(ISymbol symbol, boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endingLine, char[] filename )
|
||||
public ASTParameterDeclaration(ISymbol symbol, boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, char[] parameterName, IASTInitializerClause initializerClause, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endingLine, char[] filename )
|
||||
{
|
||||
super( symbol );
|
||||
abstractDeclaration = new ASTAbstractDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp );
|
||||
|
@ -68,6 +68,9 @@ public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterD
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return String.valueOf(parameterName);
|
||||
}
|
||||
public char[] getNameArray(){
|
||||
return parameterName;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -29,14 +29,14 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
|||
private final List refs;
|
||||
private ISymbol symbol;
|
||||
private final boolean isTypename;
|
||||
private final String name;
|
||||
private final char[] name;
|
||||
|
||||
/**
|
||||
* @param s
|
||||
* @param b
|
||||
* @param string
|
||||
*/
|
||||
public ASTSimpleTypeSpecifier(ISymbol s, boolean b, String string, List references )
|
||||
public ASTSimpleTypeSpecifier(ISymbol s, boolean b, char[] string, List references )
|
||||
{
|
||||
this.symbol = s;
|
||||
this.isTypename = b;
|
||||
|
@ -76,7 +76,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
|||
*/
|
||||
public String getTypename()
|
||||
{
|
||||
return name;
|
||||
return String.valueOf(name);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isLong()
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ASTTemplateParameter extends ASTSymbol implements IASTTemplateParam
|
|||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getIdentifier()
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return symbol.getName();
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getDefaultValueIdExpression()
|
||||
|
@ -134,8 +134,12 @@ public class ASTTemplateParameter extends ASTSymbol implements IASTTemplateParam
|
|||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return symbol.getName();
|
||||
return String.valueOf(symbol.getName());
|
||||
}
|
||||
public char[] getNameArray(){
|
||||
return symbol.getName();
|
||||
}
|
||||
|
||||
private int startingLineNumber, startingOffset, endingLineNumber, endingOffset, nameStartOffset, nameEndOffset, nameLineNumber;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingLine()
|
||||
|
|
|
@ -37,10 +37,10 @@ public class ASTTypeId implements IASTTypeId
|
|||
private final boolean isLong;
|
||||
private final boolean isVolatile;
|
||||
private final boolean isConst;
|
||||
private final String signature;
|
||||
private final char[] signature;
|
||||
private ITokenDuple tokenDuple;
|
||||
private final List arrayModifiers;
|
||||
private final String typeName;
|
||||
private final char[] typeName;
|
||||
private final List pointerOps;
|
||||
private final Type kind;
|
||||
private List references = null;
|
||||
|
@ -49,10 +49,10 @@ public class ASTTypeId implements IASTTypeId
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public ASTTypeId( Type kind, ITokenDuple duple, List pointerOps, List arrayMods, String signature,
|
||||
public ASTTypeId( Type kind, ITokenDuple duple, List pointerOps, List arrayMods, char[] signature,
|
||||
boolean isConst, boolean isVolatile, boolean isUnsigned, boolean isSigned, boolean isShort, boolean isLong, boolean isTypeName )
|
||||
{
|
||||
typeName = ( duple == null ) ? "" : duple.toString() ; //$NON-NLS-1$
|
||||
typeName = ( duple == null ) ? "".toCharArray() : duple.toCharArray() ; //$NON-NLS-1$
|
||||
this.tokenDuple = duple;
|
||||
this.kind = kind;
|
||||
this.pointerOps = pointerOps;
|
||||
|
@ -79,7 +79,7 @@ public class ASTTypeId implements IASTTypeId
|
|||
*/
|
||||
public String getTypeOrClassName()
|
||||
{
|
||||
return typeName;
|
||||
return String.valueOf(typeName);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTTypeId#getPointerOperators()
|
||||
|
@ -111,7 +111,7 @@ public class ASTTypeId implements IASTTypeId
|
|||
*/
|
||||
public String getFullSignature()
|
||||
{
|
||||
return signature;
|
||||
return String.valueOf(signature);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ASTTypedef extends ASTSymbol implements IASTTypedefDeclaration
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getSymbol().getName();
|
||||
return String.valueOf(getSymbol().getName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getSymbol().getName();
|
||||
return String.valueOf(getSymbol().getName());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#getInitializerClause()
|
||||
|
|
|
@ -76,6 +76,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
||||
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTDesignator;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ExtensibleSymbolExtension;
|
||||
|
@ -101,6 +102,7 @@ import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.TemplateSymbolExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||
|
||||
|
@ -114,7 +116,8 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
|||
*/
|
||||
public class CompleteParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||
{
|
||||
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
protected static final char[] EMPTY_STRING = new char[0]; //$NON-NLS-1$
|
||||
protected static final char[] THIS = new char[] { 't', 'h', 'i', 's' };
|
||||
private final static ITypeInfo.OperatorExpression SUBSCRIPT;
|
||||
private final static IProblemFactory problemFactory = new ASTProblemFactory();
|
||||
private final ParserMode mode;
|
||||
|
@ -148,7 +151,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
super(extension);
|
||||
pst = new ParserSymbolTable( language, mode );
|
||||
this.mode = mode;
|
||||
filename = EMPTY_STRING.toCharArray();
|
||||
filename = EMPTY_STRING;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -215,11 +218,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return true;
|
||||
}
|
||||
|
||||
private ISymbol lookupElement (IContainerSymbol startingScope, String name, ITypeInfo.eType type, List parameters, LookupType lookupType ) throws ASTSemanticException {
|
||||
private ISymbol lookupElement (IContainerSymbol startingScope, char[] name, ITypeInfo.eType type, List parameters, LookupType lookupType ) throws ASTSemanticException {
|
||||
return lookupElement( startingScope, name, type, parameters, null, lookupType );
|
||||
}
|
||||
|
||||
private ISymbol lookupElement (IContainerSymbol startingScope, String name, ITypeInfo.eType type, List parameters, List arguments, LookupType lookupType ) throws ASTSemanticException {
|
||||
private ISymbol lookupElement (IContainerSymbol startingScope, char[] name, ITypeInfo.eType type, List parameters, List arguments, LookupType lookupType ) throws ASTSemanticException {
|
||||
ISymbol result = null;
|
||||
if( startingScope == null ) return null;
|
||||
try {
|
||||
|
@ -267,11 +270,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return result;
|
||||
}
|
||||
|
||||
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException{
|
||||
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, char[] name, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException{
|
||||
return lookupQualifiedName(startingScope, name, ITypeInfo.t_any, null, 0, references, throwOnError, lookup );
|
||||
}
|
||||
|
||||
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, ITypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException
|
||||
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, char[] name, ITypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException
|
||||
{
|
||||
ISymbol result = null;
|
||||
if( name == null && throwOnError )
|
||||
|
@ -316,7 +319,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
List [] templateArgLists = name.getTemplateIdArgLists();
|
||||
List args = null;
|
||||
int idx = 0;
|
||||
String image = null;
|
||||
char[] image = null;
|
||||
switch( name.getSegmentCount() )
|
||||
{
|
||||
case 0:
|
||||
|
@ -325,7 +328,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
else
|
||||
return null;
|
||||
case 1:
|
||||
image = name.extractNameFromTemplateId();
|
||||
image = name.extractNameFromTemplateId().toCharArray();
|
||||
args = ( templateArgLists != null ) ? getTemplateArgList( templateArgLists[ 0 ] ) : null;
|
||||
result = lookupElement(startingScope, image, type, parameters, args, lookup );
|
||||
|
||||
|
@ -380,7 +383,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
if( t.isPointer() ) break;
|
||||
|
||||
image = t.getImage();
|
||||
image = t.getCharImage();
|
||||
int offset = t.getOffset();
|
||||
|
||||
if( templateArgLists != null && templateArgLists[ idx ] != null ){
|
||||
|
@ -502,7 +505,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
try {
|
||||
usingDirective = ((ASTScope)scope).getContainerSymbol().addUsingDirective( (IContainerSymbol)symbol );
|
||||
} catch (ParserSymbolTableException pste) {
|
||||
handleProblem( pste.createProblemID(), duple.toString(), startingOffset, endingOffset, startingLine, true );
|
||||
handleProblem( pste.createProblemID(), duple.toCharArray(), startingOffset, endingOffset, startingLine, true );
|
||||
}
|
||||
|
||||
ASTUsingDirective using = new ASTUsingDirective( scopeToSymbol(scope), usingDirective, startingOffset, startingLine, endingOffset, endingLine, references, filename );
|
||||
|
@ -516,7 +519,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
* @param duple
|
||||
*/
|
||||
private void setFilename(ITokenDuple duple) {
|
||||
filename = ( duple == null ) ? EMPTY_STRING.toCharArray() : duple.getFilename();
|
||||
filename = ( duple == null ) ? EMPTY_STRING : duple.getFilename();
|
||||
}
|
||||
|
||||
protected IContainerSymbol getScopeToSearchUpon(
|
||||
|
@ -573,24 +576,24 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
try
|
||||
{
|
||||
endResult = scopeToSymbol(scope).addUsingDeclaration( name.getLastToken().getImage(), containerSymbol );
|
||||
endResult = scopeToSymbol(scope).addUsingDeclaration( name.getLastToken().getImage().toCharArray(), containerSymbol );
|
||||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(), name.getLastToken().getImage(), startingOffset, endingOffset, startingLine, true );
|
||||
handleProblem(e.createProblemID(), name.getLastToken().getCharImage(), startingOffset, endingOffset, startingLine, true );
|
||||
}
|
||||
} else
|
||||
try {
|
||||
endResult = scopeToSymbol(scope).addUsingDeclaration(name.getLastToken().getImage());
|
||||
endResult = scopeToSymbol(scope).addUsingDeclaration(name.getLastToken().getImage().toCharArray());
|
||||
} catch (ParserSymbolTableException e) {
|
||||
handleProblem(e.createProblemID(), name.getLastToken().getImage(), startingOffset, endingOffset, startingLine, true );
|
||||
handleProblem(e.createProblemID(), name.getLastToken().getCharImage(), startingOffset, endingOffset, startingLine, true );
|
||||
}
|
||||
|
||||
if( endResult != null )
|
||||
{
|
||||
Iterator i = endResult.getReferencedSymbols().iterator();
|
||||
while( i.hasNext() )
|
||||
addReference( references, createReference( (ISymbol) i.next(), name.getLastToken().getImage(), name.getLastToken().getOffset() ) );
|
||||
addReference( references, createReference( (ISymbol) i.next(), name.getLastToken().getCharImage(), name.getLastToken().getOffset() ) );
|
||||
|
||||
}
|
||||
ASTUsingDeclaration using = new ASTUsingDeclaration( scope, name.getLastToken().getImage(),
|
||||
|
@ -608,7 +611,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
int startingOffset,
|
||||
int startingLine, int endingOffset, int endingLine, char[] fn)
|
||||
{
|
||||
return new ASTASMDefinition( scopeToSymbol(scope), assembly, startingOffset, startingLine, endingOffset, endingLine, fn);
|
||||
return new ASTASMDefinition( scopeToSymbol(scope), assembly.toCharArray(), startingOffset, startingLine, endingOffset, endingLine, fn);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, int, int)
|
||||
|
@ -627,22 +630,22 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
{
|
||||
try
|
||||
{
|
||||
namespaceSymbol = pstScope.qualifiedLookup( identifier );
|
||||
namespaceSymbol = pstScope.qualifiedLookup( identifier.toCharArray() );
|
||||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem( e.createProblemID(), identifier, nameOffset, nameEndOffset, nameLineNumber, true );
|
||||
handleProblem( e.createProblemID(), identifier.toCharArray(), nameOffset, nameEndOffset, nameLineNumber, true );
|
||||
}
|
||||
}
|
||||
|
||||
if( namespaceSymbol != null )
|
||||
{
|
||||
if( namespaceSymbol.getType() != ITypeInfo.t_namespace )
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, identifier, nameOffset, nameEndOffset, nameLineNumber, true );
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, identifier.toCharArray(), nameOffset, nameEndOffset, nameLineNumber, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
namespaceSymbol = pst.newContainerSymbol( identifier, ITypeInfo.t_namespace );
|
||||
namespaceSymbol = pst.newContainerSymbol( identifier.toCharArray(), ITypeInfo.t_namespace );
|
||||
if( identifier.equals( EMPTY_STRING ) )
|
||||
namespaceSymbol.setContainingSymbol( pstScope );
|
||||
else
|
||||
|
@ -724,7 +727,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
String spec,
|
||||
int startingOffset, int startingLine, char[] fn)
|
||||
{
|
||||
return new ASTLinkageSpecification( scopeToSymbol( scope ), spec, startingOffset, startingLine, fn );
|
||||
return new ASTLinkageSpecification( scopeToSymbol( scope ), spec.toCharArray(), startingOffset, startingLine, fn );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ast.ASTClassKind, org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, org.eclipse.cdt.core.parser.ast.IASTTemplate, int, int)
|
||||
|
@ -743,7 +746,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ITypeInfo.eType pstType = classKindToTypeInfo(kind);
|
||||
List references = new ArrayList();
|
||||
|
||||
String newSymbolName = EMPTY_STRING;
|
||||
char[] newSymbolName = EMPTY_STRING;
|
||||
List templateIdArgList = null;
|
||||
boolean isTemplateId = false;
|
||||
|
||||
|
@ -758,7 +761,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
else
|
||||
currentScopeSymbol = (IContainerSymbol) temp;
|
||||
if( currentScopeSymbol == null )
|
||||
handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toString(), containerSymbolName.getFirstToken().getOffset(), containerSymbolName.getLastToken().getEndOffset(), containerSymbolName.getLastToken().getLineNumber(), true );
|
||||
handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toCharArray(), containerSymbolName.getFirstToken().getOffset(), containerSymbolName.getLastToken().getEndOffset(), containerSymbolName.getLastToken().getLineNumber(), true );
|
||||
|
||||
nameToken = name.getLastSegment().getFirstToken();
|
||||
} else {
|
||||
|
@ -771,17 +774,17 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
isTemplateId = (templateIdArgList != null);
|
||||
}
|
||||
|
||||
newSymbolName = nameToken.getImage();
|
||||
newSymbolName = nameToken.getCharImage();
|
||||
}
|
||||
ISymbol classSymbol = null;
|
||||
if( !newSymbolName.equals(EMPTY_STRING) && !isTemplateId ){
|
||||
if( !CharArrayUtils.equals(newSymbolName, EMPTY_STRING) && !isTemplateId ){
|
||||
try
|
||||
{
|
||||
classSymbol = currentScopeSymbol.lookupMemberForDefinition(newSymbolName);
|
||||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED, name.toString(), nameOffset, nameEndOffset, nameLine, true);
|
||||
handleProblem(IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED, name.toCharArray(), nameOffset, nameEndOffset, nameLine, true);
|
||||
}
|
||||
|
||||
if( classSymbol != null && ! classSymbol.isForwardDeclaration() )
|
||||
|
@ -854,17 +857,17 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return list;
|
||||
}
|
||||
|
||||
protected void handleProblem( int id, String attribute ) throws ASTSemanticException
|
||||
protected void handleProblem( int id, char[] attribute ) throws ASTSemanticException
|
||||
{
|
||||
handleProblem( null, id, attribute, -1, -1, -1, true ); //TODO make this right
|
||||
}
|
||||
|
||||
protected void handleProblem( IASTScope scope, int id, String attribute ) throws ASTSemanticException
|
||||
protected void handleProblem( IASTScope scope, int id, char[] attribute ) throws ASTSemanticException
|
||||
{
|
||||
handleProblem( scope, id, attribute, -1, -1, -1, true);
|
||||
}
|
||||
|
||||
protected void handleProblem( int id, String attribute, int startOffset, int endOffset, int lineNumber, boolean isError ) throws ASTSemanticException {
|
||||
protected void handleProblem( int id, char[] attribute, int startOffset, int endOffset, int lineNumber, boolean isError ) throws ASTSemanticException {
|
||||
handleProblem( null, id, attribute, startOffset, endOffset, lineNumber, isError );
|
||||
}
|
||||
|
||||
|
@ -877,10 +880,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
* @param isError TODO
|
||||
* @param filename
|
||||
* @throws ASTSemanticException
|
||||
*/
|
||||
protected void handleProblem( IASTScope scope, int id, String attribute, int startOffset, int endOffset, int lineNumber, boolean isError ) throws ASTSemanticException {
|
||||
*/
|
||||
protected void handleProblem( IASTScope scope, int id, char[] attribute, int startOffset, int endOffset, int lineNumber, boolean isError ) throws ASTSemanticException {
|
||||
IProblem p = problemFactory.createProblem( id,
|
||||
startOffset, endOffset, lineNumber, filename, attribute, !isError, isError );
|
||||
startOffset, endOffset, lineNumber, filename, attribute != null ? String.valueOf(attribute) : null, !isError, isError );
|
||||
|
||||
TraceUtil.outputTrace(logService, "CompleteParseASTFactory - IProblem : ", p, null, null, null ); //$NON-NLS-1$
|
||||
|
||||
|
@ -947,7 +950,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ISymbol symbol = lookupQualifiedName( classSymbol, parentClassName, references, true );
|
||||
|
||||
if( symbol instanceof ITemplateSymbol )
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT, parentClassName.toString(), parentClassName.getStartOffset(), parentClassName.getEndOffset(), parentClassName.getLineNumber(), true);
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT, parentClassName.toCharArray(), parentClassName.getStartOffset(), parentClassName.getEndOffset(), parentClassName.getLineNumber(), true);
|
||||
|
||||
List [] templateArgumentLists = parentClassName.getTemplateIdArgLists();
|
||||
if( templateArgumentLists != null )
|
||||
|
@ -964,7 +967,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
* @param referenceElementName
|
||||
* @return
|
||||
*/
|
||||
protected IASTReference createReference(ISymbol symbol, String referenceElementName, int offset ) throws ASTSemanticException
|
||||
protected IASTReference createReference(ISymbol symbol, char[] referenceElementName, int offset ) throws ASTSemanticException
|
||||
{
|
||||
if( mode != ParserMode.COMPLETE_PARSE )
|
||||
return null;
|
||||
|
@ -1054,14 +1057,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IContainerSymbol containerSymbol = scopeToSymbol(scope);
|
||||
ITypeInfo.eType pstType = ITypeInfo.t_enumeration;
|
||||
|
||||
IDerivableContainerSymbol classSymbol = pst.newDerivableContainerSymbol( name, pstType );
|
||||
IDerivableContainerSymbol classSymbol = pst.newDerivableContainerSymbol( name.toCharArray(), pstType );
|
||||
try
|
||||
{
|
||||
containerSymbol.addSymbol( classSymbol );
|
||||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem( e.createProblemID(), name );
|
||||
handleProblem( e.createProblemID(), name.toCharArray() );
|
||||
}
|
||||
|
||||
ASTEnumerationSpecifier enumSpecifier = new ASTEnumerationSpecifier( classSymbol, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, fn );
|
||||
|
@ -1089,7 +1092,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
setFilename(fn);
|
||||
IContainerSymbol enumerationSymbol = (IContainerSymbol)((ISymbolOwner)enumeration).getSymbol();
|
||||
|
||||
ISymbol enumeratorSymbol = pst.newSymbol( name, ITypeInfo.t_enumerator );
|
||||
ISymbol enumeratorSymbol = pst.newSymbol( name.toCharArray(), ITypeInfo.t_enumerator );
|
||||
try
|
||||
{
|
||||
enumerationSymbol.addSymbol( enumeratorSymbol );
|
||||
|
@ -1097,7 +1100,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
catch (ParserSymbolTableException e1)
|
||||
{
|
||||
if( e1.reason == ParserSymbolTableException.r_InvalidOverload )
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, name, startingOffset, endingOffset, startingLine, true );
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, name.toCharArray(), startingOffset, endingOffset, startingLine, true );
|
||||
// assert false : e1;
|
||||
}
|
||||
ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, enumeration, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endLine, initialValue, fn );
|
||||
|
@ -1129,7 +1132,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
idExpression.toString()
|
||||
);
|
||||
}
|
||||
else if( literal != null && !literal.equals( EMPTY_STRING ))
|
||||
else if( literal != null && !literal.equals( String.valueOf(EMPTY_STRING) ))
|
||||
{
|
||||
TraceUtil.outputTrace(
|
||||
logService,
|
||||
|
@ -1232,7 +1235,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if( constructor != null ){
|
||||
IASTReference reference = null;
|
||||
try {
|
||||
reference = createReference( constructor, duple.toString(), duple.getStartOffset() );
|
||||
reference = createReference( constructor, duple.toCharArray(), duple.getStartOffset() );
|
||||
} catch (ASTSemanticException e2) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1298,9 +1301,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
// go up the scope until you hit a class
|
||||
if (kind == IASTExpression.Kind.PRIMARY_THIS){
|
||||
try{
|
||||
symbol = startingScope.lookup("this"); //$NON-NLS-1$
|
||||
symbol = startingScope.lookup( THIS ); //$NON-NLS-1$
|
||||
}catch (ParserSymbolTableException e){
|
||||
handleProblem( e.createProblemID(), "this"); //$NON-NLS-1$
|
||||
handleProblem( e.createProblemID(), THIS ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
// lookup symbol if it is a function call
|
||||
|
@ -1968,7 +1971,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
getExpressionReferences( expressionList, references );
|
||||
return new ASTConstructorMemberInitializer(
|
||||
expressionList,
|
||||
duple == null ? EMPTY_STRING : duple.toString(),
|
||||
duple == null ? EMPTY_STRING : duple.toCharArray(),
|
||||
duple == null ? 0 : duple.getFirstToken().getOffset(),
|
||||
references, requireReferenceResolution );
|
||||
}
|
||||
|
@ -1991,7 +1994,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
setFilename( typeName );
|
||||
if( extension.overrideCreateSimpleTypeSpecifierMethod( kind ))
|
||||
return extension.createSimpleTypeSpecifier(pst, scope, kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename, isComplex, isImaginary, isGlobal, extensionParms );
|
||||
String typeNameAsString = typeName.toString();
|
||||
char[] typeNameAsString = typeName.toCharArray();
|
||||
if( kind != Type.CLASS_OR_TYPENAME )
|
||||
{
|
||||
IASTSimpleTypeSpecifier query = (IASTSimpleTypeSpecifier) simpleTypeSpecCache.get( typeNameAsString );
|
||||
|
@ -2043,7 +2046,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
continue;
|
||||
}
|
||||
|
||||
String image = current.getImage();
|
||||
char[] image = current.getCharImage();
|
||||
int offset = current.getOffset();
|
||||
|
||||
if( argLists != null && argLists[ idx ] != null ){
|
||||
|
@ -2146,7 +2149,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
){
|
||||
if( parentScope.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier ){
|
||||
//we are trying to define a member of a class for which we only have a forward declaration
|
||||
handleProblem( scope, IProblem.SEMANTICS_RELATED, name.toString(), startOffset, nameEndOffset, startLine, true );
|
||||
handleProblem( scope, IProblem.SEMANTICS_RELATED, name.toCharArray(), startOffset, nameEndOffset, startLine, true );
|
||||
}
|
||||
IASTScope methodParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
|
||||
ITokenDuple newName = name.getLastSegment();
|
||||
|
@ -2175,7 +2178,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
}
|
||||
|
||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.extractNameFromTemplateId(), ITypeInfo.t_function );
|
||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.extractNameFromTemplateId().toCharArray(), ITypeInfo.t_function );
|
||||
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
||||
|
||||
symbol.setHasVariableArgs( hasVariableArguments );
|
||||
|
@ -2194,14 +2197,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
while (p.hasNext()){
|
||||
ASTParameterDeclaration param = (ASTParameterDeclaration)p.next();
|
||||
if( param.getSymbol() == null )
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, param.getName(), param.getNameOffset(), param.getEndingOffset(), param.getStartingLine(), true );
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, param.getNameArray(), param.getNameOffset(), param.getEndingOffset(), param.getStartingLine(), true );
|
||||
functionParameters.add(param.getSymbol().getTypeInfo());
|
||||
}
|
||||
|
||||
IParameterizedSymbol functionDeclaration = null;
|
||||
|
||||
functionDeclaration =
|
||||
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getImage(), ITypeInfo.t_function, functionParameters, 0, null, false, LookupType.FORDEFINITION );
|
||||
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getCharImage(), ITypeInfo.t_function, functionParameters, 0, null, false, LookupType.FORDEFINITION );
|
||||
|
||||
if( functionDeclaration != null && symbol.isType( ITypeInfo.t_function )){
|
||||
previouslyDeclared = true;
|
||||
|
@ -2218,7 +2221,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem( e.createProblemID(), name.toString());
|
||||
handleProblem( e.createProblemID(), name.toCharArray());
|
||||
}
|
||||
} else {
|
||||
symbol = functionDeclaration;
|
||||
|
@ -2355,12 +2358,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
newReferences.add( cache.getReference(r.getOffset(), r.getReferencedElement()));
|
||||
}
|
||||
if( xrefSymbol != null )
|
||||
addReference( newReferences, createReference( xrefSymbol, elab.getName(), elab.getNameOffset()) );
|
||||
addReference( newReferences, createReference( xrefSymbol, elab.getNameArray(), elab.getNameOffset()) );
|
||||
}
|
||||
|
||||
String paramName = EMPTY_STRING;
|
||||
char[] paramName = EMPTY_STRING;
|
||||
if(absDecl instanceof IASTParameterDeclaration){
|
||||
paramName = ((IASTParameterDeclaration)absDecl).getName();
|
||||
paramName = ((ASTParameterDeclaration)absDecl).getNameArray();
|
||||
}
|
||||
|
||||
ISymbol paramSymbol = pst.newSymbol( paramName, type );
|
||||
|
@ -2494,14 +2497,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
nameDuple = nameDuple.getLastSegment();
|
||||
}
|
||||
}
|
||||
String methodName = null;
|
||||
char[] methodName = null;
|
||||
List templateIdArgList = null;
|
||||
//template-id?
|
||||
if( nameDuple.getTemplateIdArgLists() != null ){
|
||||
templateIdArgList = nameDuple.getTemplateIdArgLists()[ 0 ];
|
||||
methodName = nameDuple.extractNameFromTemplateId();
|
||||
methodName = nameDuple.extractNameFromTemplateId().toCharArray();
|
||||
} else {
|
||||
methodName = nameDuple.toString();
|
||||
methodName = nameDuple.toCharArray();
|
||||
}
|
||||
|
||||
symbol = pst.newParameterizedSymbol( methodName, ITypeInfo.t_function );
|
||||
|
@ -2520,16 +2523,16 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
} else {
|
||||
classifier = (IASTClassSpecifier) scope;
|
||||
}
|
||||
String parentName = classifier.getName();
|
||||
char[] parentName = ((ASTClassSpecifier)classifier).getNameArray();
|
||||
|
||||
// check constructor / destructor if no return type
|
||||
if ( returnType.getTypeSpecifier() == null ){
|
||||
if(parentName.indexOf(DOUBLE_COLON) != -1){
|
||||
parentName = parentName.substring(parentName.lastIndexOf(DOUBLE_COLON) + DOUBLE_COLON.length());
|
||||
if(CharArrayUtils.indexOf( DOUBLE_COLON.toCharArray(), parentName ) != -1){
|
||||
parentName = CharArrayUtils.lastSegment( parentName, DOUBLE_COLON.toCharArray() );
|
||||
}
|
||||
if( parentName.equals(methodName) ){
|
||||
if( CharArrayUtils.equals( parentName, methodName) ){
|
||||
isConstructor = true;
|
||||
} else if(methodName.equals( "~" + parentName )){ //$NON-NLS-1$
|
||||
} else if( methodName[0] == '~' && CharArrayUtils.equals( methodName, 1, methodName.length - 1, parentName )){ //$NON-NLS-1$
|
||||
isDestructor = true;
|
||||
}
|
||||
}
|
||||
|
@ -2548,7 +2551,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
while (p.hasNext()){
|
||||
ASTParameterDeclaration param = (ASTParameterDeclaration)p.next();
|
||||
if( param.getSymbol() == null )
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, param.getName(), param.getNameOffset(), param.getEndingOffset(), param.getNameLineNumber(), true );
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, param.getNameArray(), param.getNameOffset(), param.getEndingOffset(), param.getNameLineNumber(), true );
|
||||
functionParameters.add(param.getSymbol().getTypeInfo());
|
||||
}
|
||||
|
||||
|
@ -2571,7 +2574,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ownerScope.getContainingSymbol().isType( ITypeInfo.t_block ) )
|
||||
{
|
||||
//only needs to be previously declared if we are in a local class
|
||||
handleProblem( IProblem.SEMANTIC_ILLFORMED_FRIEND, nameDuple.toString(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber(), true );
|
||||
handleProblem( IProblem.SEMANTIC_ILLFORMED_FRIEND, nameDuple.toCharArray(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber(), true );
|
||||
}
|
||||
|
||||
} else if( functionDeclaration != null && functionDeclaration.isType( isConstructor ? ITypeInfo.t_constructor : ITypeInfo.t_function ) )
|
||||
|
@ -2605,7 +2608,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(), nameDuple.toString(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber(), true );
|
||||
handleProblem(e.createProblemID(), nameDuple.toCharArray(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber(), true );
|
||||
}
|
||||
|
||||
resolveLeftoverConstructorInitializerMembers( symbol, constructorChain );
|
||||
|
@ -2637,7 +2640,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
{
|
||||
ASTConstructorMemberInitializer realInitializer = ((ASTConstructorMemberInitializer)initializer);
|
||||
IDerivableContainerSymbol container = (IDerivableContainerSymbol) symbol.getContainingSymbol();
|
||||
lookupQualifiedName(container, initializer.getName(), ITypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED);
|
||||
lookupQualifiedName(container, realInitializer.getNameArray(), ITypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED);
|
||||
// TODO try and resolve parameter references now in the expression list
|
||||
}
|
||||
}
|
||||
|
@ -2715,9 +2718,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
}
|
||||
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name.getFirstToken().getImage(), abstractDeclaration, references);
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name.getFirstToken().getCharImage(), abstractDeclaration, references);
|
||||
if( newSymbol == null )
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, name.toString() );
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, name.toCharArray() );
|
||||
|
||||
setVariableTypeInfoBits(
|
||||
isAuto,
|
||||
|
@ -2736,7 +2739,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
newSymbol.setIsForwardDeclaration( isStatic || isExtern );
|
||||
boolean previouslyDeclared = false;
|
||||
if(!isStatic){
|
||||
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name.toString(), null, false, LookupType.UNQUALIFIED);
|
||||
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name.toCharArray(), null, false, LookupType.UNQUALIFIED);
|
||||
|
||||
if( variableDeclaration != null && newSymbol.getType() == variableDeclaration.getType() )
|
||||
{
|
||||
|
@ -2760,7 +2763,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(), name.getFirstToken().getImage() );
|
||||
handleProblem(e.createProblemID(), name.getFirstToken().getCharImage() );
|
||||
}
|
||||
|
||||
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, constructorExpression, previouslyDeclared, filename );
|
||||
|
@ -2792,7 +2795,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
Iterator designators = clause.getDesignators();
|
||||
while( designators.hasNext() )
|
||||
{
|
||||
IASTDesignator designator = (IASTDesignator)designators.next();
|
||||
ASTDesignator designator = (ASTDesignator)designators.next();
|
||||
if( designator.getKind() == IASTDesignator.DesignatorKind.FIELD )
|
||||
{
|
||||
ISymbol lookup = null;
|
||||
|
@ -2801,7 +2804,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
try
|
||||
{
|
||||
lookup = ((IContainerSymbol)currentSymbol).lookup( designator.fieldName() );
|
||||
lookup = ((IContainerSymbol)currentSymbol).lookup( designator.fieldName().toCharArray() );
|
||||
}
|
||||
catch (ParserSymbolTableException e){
|
||||
break;
|
||||
|
@ -2813,7 +2816,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
try
|
||||
{
|
||||
if( lookup != null )
|
||||
addReference( clause.getReferences(), createReference( lookup, designator.fieldName(), designator.fieldOffset() ));
|
||||
addReference( clause.getReferences(), createReference( lookup, designator.fieldNameArray(), designator.fieldOffset() ));
|
||||
}
|
||||
catch (ASTSemanticException e1)
|
||||
{
|
||||
|
@ -2861,7 +2864,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
|
||||
protected ISymbol cloneSimpleTypeSymbol(
|
||||
String name,
|
||||
char[] name,
|
||||
IASTAbstractDeclaration abstractDeclaration,
|
||||
List references) throws ASTSemanticException
|
||||
{
|
||||
|
@ -2892,7 +2895,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
symbolToBeCloned = pst.newSymbol(name, ITypeInfo.t_type);
|
||||
symbolToBeCloned.setTypeSymbol(elab.getSymbol());
|
||||
if( elab.getSymbol() != null && references != null )
|
||||
addReference( references, createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
|
||||
addReference( references, createReference( elab.getSymbol(), elab.getNameArray(), elab.getNameOffset()) );
|
||||
}
|
||||
else if ( abstractDeclaration.getTypeSpecifier() instanceof ASTEnumerationSpecifier )
|
||||
{
|
||||
|
@ -2949,7 +2952,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
setFilename( fn );
|
||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||
|
||||
String image = ( name != null ) ? name.toString() : EMPTY_STRING;
|
||||
char[] image = ( name != null ) ? name.toCharArray() : EMPTY_STRING;
|
||||
|
||||
if(references == null)
|
||||
references = new ArrayList();
|
||||
|
@ -3019,7 +3022,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
int startingOffset, int startingLine, char[] fn) throws ASTSemanticException
|
||||
{
|
||||
setFilename(fn);
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY );
|
||||
|
||||
// the lookup requires a list of type infos
|
||||
// instead of a list of IASTParameterDeclaration
|
||||
|
@ -3029,7 +3032,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
try {
|
||||
template.addTemplateParameter( param.getSymbol() );
|
||||
} catch (ParserSymbolTableException e) {
|
||||
handleProblem( e.createProblemID(), param.getName(), startingOffset, -1, startingLine, true );
|
||||
handleProblem( e.createProblemID(), param.getNameArray(), startingOffset, -1, startingLine, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3064,7 +3067,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
}
|
||||
if( kind == ParamKind.TEMPLATE_LIST ){
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( identifier );
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( identifier.toCharArray() );
|
||||
provider.setType( ITypeInfo.t_templateParameter );
|
||||
provider.setTemplateParameterType( ITypeInfo.t_template );
|
||||
template.setTypeInfo( provider.completeConstruction() );
|
||||
|
@ -3074,19 +3077,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
try {
|
||||
template.addTemplateParameter( param.getSymbol() );
|
||||
} catch (ParserSymbolTableException e) {
|
||||
handleProblem( e.createProblemID(), param.getName(), param.getStartingOffset(), param.getEndingOffset(), param.getStartingLine(), true ); //$NON-NLS-1$
|
||||
handleProblem( e.createProblemID(), param.getNameArray(), param.getStartingOffset(), param.getEndingOffset(), param.getStartingLine(), true ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
symbol = template;
|
||||
} else {
|
||||
|
||||
if( kind == ParamKind.CLASS || kind == ParamKind.TYPENAME ){
|
||||
symbol = pst.newSymbol( identifier );
|
||||
symbol = pst.newSymbol( identifier.toCharArray() );
|
||||
provider.setType( ITypeInfo.t_templateParameter );
|
||||
provider.setTemplateParameterType( ITypeInfo.t_typeName );
|
||||
symbol.setTypeInfo( provider.completeConstruction() );
|
||||
} else /*ParamKind.PARAMETER*/ {
|
||||
symbol = cloneSimpleTypeSymbol( parameter.getName(), parameter, null );
|
||||
symbol = cloneSimpleTypeSymbol( ((ASTParameterDeclaration)parameter).getNameArray(), parameter, null );
|
||||
provider.setTemplateParameterType( symbol.getType() );
|
||||
provider.setType( ITypeInfo.t_templateParameter );
|
||||
provider.setTypeSymbol( symbol.getTypeSymbol() );
|
||||
|
@ -3127,7 +3130,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IASTScope scope,
|
||||
int startingOffset, int startingLine, char[] fn)
|
||||
{
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
ITemplateSymbol template = pst.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY );
|
||||
|
||||
ASTTemplateSpecialization ast = new ASTTemplateSpecialization( template, scope, fn );
|
||||
ast.setStartingOffsetAndLineNumber( startingOffset, startingLine );
|
||||
|
@ -3145,17 +3148,17 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
int startingOffset,
|
||||
int startingLine, int nameOffset, int nameEndOffset, int nameLine, char[] fn) throws ASTSemanticException
|
||||
{
|
||||
setFilename( fn );
|
||||
char[] nameArray = name.toCharArray();
|
||||
IContainerSymbol containerSymbol = scopeToSymbol(scope);
|
||||
ISymbol typeSymbol = cloneSimpleTypeSymbol( name, mapping, null );
|
||||
ISymbol typeSymbol = cloneSimpleTypeSymbol( nameArray, mapping, null );
|
||||
|
||||
if( typeSymbol == null )
|
||||
handleProblem( scope, IProblem.SEMANTICS_RELATED, name, nameOffset, nameEndOffset, nameLine, true );
|
||||
handleProblem( scope, IProblem.SEMANTICS_RELATED, nameArray, nameOffset, nameEndOffset, nameLine, true );
|
||||
|
||||
setPointerOperators( typeSymbol, mapping.getPointerOperators(), mapping.getArrayModifiers() );
|
||||
|
||||
if( typeSymbol.getType() != ITypeInfo.t_type ){
|
||||
ISymbol newSymbol = pst.newSymbol( name, ITypeInfo.t_type);
|
||||
ISymbol newSymbol = pst.newSymbol( nameArray, ITypeInfo.t_type);
|
||||
newSymbol.getTypeInfo().setBit( true,ITypeInfo.isTypedef );
|
||||
newSymbol.setTypeSymbol( typeSymbol );
|
||||
typeSymbol = newSymbol;
|
||||
|
@ -3183,7 +3186,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(), name );
|
||||
handleProblem(e.createProblemID(), nameArray );
|
||||
}
|
||||
ASTTypedef d = new ASTTypedef( typeSymbol, mapping, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, filename );
|
||||
attachSymbolExtension(typeSymbol, d, true );
|
||||
|
@ -3212,7 +3215,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ITypeInfo.eType pstType = classKindToTypeInfo(kind);
|
||||
List references = new ArrayList();
|
||||
IToken nameToken = name.getFirstToken();
|
||||
String newSymbolName = EMPTY_STRING;
|
||||
char[] newSymbolName = EMPTY_STRING;
|
||||
List templateIdArgList = null;
|
||||
boolean isTemplateId = false;
|
||||
if (name.getSegmentCount() != 1) // qualified name
|
||||
|
@ -3227,7 +3230,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
if (currentScopeSymbol == null)
|
||||
handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND,
|
||||
containerSymbolName.toString(), containerSymbolName
|
||||
containerSymbolName.toCharArray(), containerSymbolName
|
||||
.getFirstToken().getOffset(),
|
||||
containerSymbolName.getLastToken().getEndOffset(),
|
||||
containerSymbolName.getLastToken().getLineNumber(), true);
|
||||
|
@ -3239,7 +3242,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
isTemplateId = true;
|
||||
templateIdArgList = array[array.length - 1];
|
||||
}
|
||||
newSymbolName = nameToken.getImage();
|
||||
newSymbolName = nameToken.getCharImage();
|
||||
ISymbol checkSymbol = null;
|
||||
if (!isTemplateId) {
|
||||
try {
|
||||
|
@ -3251,7 +3254,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
newSymbolName);
|
||||
}
|
||||
} catch (ParserSymbolTableException e) {
|
||||
handleProblem(e.createProblemID(), nameToken.getImage(),
|
||||
handleProblem(e.createProblemID(), nameToken.getCharImage(),
|
||||
nameToken.getOffset(), nameToken.getEndOffset(),
|
||||
nameToken.getLineNumber(), true);
|
||||
}
|
||||
|
@ -3267,13 +3270,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
try {
|
||||
currentScopeSymbol.addTemplateId(checkSymbol, args);
|
||||
} catch (ParserSymbolTableException e) {
|
||||
handleProblem(e.createProblemID(), nameToken.getImage(),
|
||||
handleProblem(e.createProblemID(), nameToken.getCharImage(),
|
||||
nameToken.getOffset(), nameToken.getEndOffset(),
|
||||
nameToken.getLineNumber(), true);
|
||||
}
|
||||
} else {
|
||||
handleProblem(IProblem.SEMANTIC_INVALID_TEMPLATE, nameToken
|
||||
.getImage());
|
||||
.getCharImage());
|
||||
}
|
||||
checkSymbol = ((ASTTemplateInstantiation) scope)
|
||||
.getInstanceSymbol();
|
||||
|
@ -3291,7 +3294,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
currentScopeSymbol.addTemplateId(checkSymbol, args);
|
||||
}
|
||||
} catch (ParserSymbolTableException e1) {
|
||||
handleProblem(e1.createProblemID(), nameToken.getImage(),
|
||||
handleProblem(e1.createProblemID(), nameToken.getCharImage(),
|
||||
nameToken.getOffset(), nameToken.getEndOffset(),
|
||||
nameToken.getLineNumber(), true);
|
||||
}
|
||||
|
@ -3302,6 +3305,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
.getLineNumber(), endOffset, endingLine,
|
||||
references, isForewardDecl, filename);
|
||||
attachSymbolExtension(checkSymbol, elab, !isForewardDecl);
|
||||
return elab;
|
||||
} else if (isFriend) {
|
||||
((IDerivableContainerSymbol) originalScope).addFriend(checkSymbol);
|
||||
}
|
||||
|
@ -3355,9 +3359,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ISymbol namespaceSymbol = lookupQualifiedName( startingSymbol, alias, references, true );
|
||||
|
||||
if( namespaceSymbol.getType() != ITypeInfo.t_namespace )
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, alias.toString(), startingOffset, endOffset, startingLine, true );
|
||||
handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, alias.toCharArray(), startingOffset, endOffset, startingLine, true );
|
||||
|
||||
ISymbol newSymbol = pst.newContainerSymbol( identifier, ITypeInfo.t_namespace );
|
||||
ISymbol newSymbol = pst.newContainerSymbol( identifier.toCharArray(), ITypeInfo.t_namespace );
|
||||
newSymbol.setForwardSymbol( namespaceSymbol );
|
||||
|
||||
try
|
||||
|
@ -3366,11 +3370,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem( e.createProblemID(), identifier, startingOffset, endOffset, startingLine, true );
|
||||
handleProblem( e.createProblemID(), identifier.toCharArray(), startingOffset, endOffset, startingLine, true );
|
||||
}
|
||||
|
||||
ASTNamespaceAlias astAlias = new ASTNamespaceAlias(
|
||||
newSymbol, alias.toString(), (IASTNamespaceDefinition)namespaceSymbol.getASTExtension().getPrimaryDeclaration(),
|
||||
newSymbol, alias.toCharArray(), (IASTNamespaceDefinition)namespaceSymbol.getASTExtension().getPrimaryDeclaration(),
|
||||
startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endOffset, endingLine, references, filename );
|
||||
attachSymbolExtension( newSymbol, astAlias, true );
|
||||
return astAlias;
|
||||
|
@ -3452,7 +3456,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
public IASTParameterDeclaration createParameterDeclaration(boolean isConst, boolean isVolatile, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endingLine, char[] fn)
|
||||
{
|
||||
setFilename(fn);
|
||||
return new ASTParameterDeclaration( null, isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endingLine, filename );
|
||||
return new ASTParameterDeclaration( null, isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName.toCharArray(), initializerClause, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endingLine, filename );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -3468,7 +3472,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return check;
|
||||
}
|
||||
ASTTypeId result =
|
||||
new ASTTypeId( kind, name, pointerOps, arrayMods, completeSignature,
|
||||
new ASTTypeId( kind, name, pointerOps, arrayMods, completeSignature.toCharArray(),
|
||||
isConst, isVolatile, isUnsigned, isSigned, isShort, isLong, isTypename );
|
||||
result.setTypeSymbol( createSymbolForTypeId( scope, result ) );
|
||||
if( kind != Type.CLASS_OR_TYPENAME )
|
||||
|
@ -3527,7 +3531,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if( typeSymbol == null /*|| typeSymbol.getType() == TypeInfo.t_type*/ )
|
||||
{
|
||||
freeReferences( refs );
|
||||
handleProblem( scope, IProblem.SEMANTIC_INVALID_TYPE, id.getTypeOrClassName() );
|
||||
handleProblem( scope, IProblem.SEMANTIC_INVALID_TYPE, id.getTypeOrClassName().toCharArray() );
|
||||
}
|
||||
result.setTypeSymbol( typeSymbol );
|
||||
typeId.addReferences( refs, cache );
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ExpressionFactory {
|
|||
public static ASTExpression createExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor, List references )
|
||||
{
|
||||
if( !literal.equals( "") && idExpression == null ) //$NON-NLS-1$
|
||||
return new ASTLiteralExpression( kind, references, literal );
|
||||
return new ASTLiteralExpression( kind, references, literal.toCharArray() );
|
||||
|
||||
if( idExpression != null && lhs == null )
|
||||
return new ASTIdExpression( kind, references, idExpression );
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ASTGCCSimpleTypeSpecifier extends ASTSimpleTypeSpecifier implements
|
|||
* @param string
|
||||
* @param references
|
||||
*/
|
||||
public ASTGCCSimpleTypeSpecifier(ISymbol s, boolean b, String string, List references, IASTExpression typeOfExpression ) {
|
||||
public ASTGCCSimpleTypeSpecifier(ISymbol s, boolean b, char[] string, List references, IASTExpression typeOfExpression ) {
|
||||
super(s, b, string, references);
|
||||
expression = typeOfExpression;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class GCCASTExpressionExtension extends GCCASTExtension {
|
|||
* @return
|
||||
*/
|
||||
private static IASTExpression createExpression(IASTExpression.Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
|
||||
if( !idExpression.equals( EMPTY_STRING ) && literal.equals( EMPTY_STRING ))
|
||||
if( !idExpression.equals( String.valueOf(EMPTY_STRING) ) && literal.equals( String.valueOf(EMPTY_STRING) ))
|
||||
return new ASTIdExpression( kind, idExpression )
|
||||
{
|
||||
public long evaluateExpression() throws ASTExpressionEvaluationException {
|
||||
|
@ -132,6 +132,6 @@ public class GCCASTExpressionExtension extends GCCASTExtension {
|
|||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#createExpression(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTExpression.Kind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTTypeId, org.eclipse.cdt.core.parser.ITokenDuple, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor, java.util.List)
|
||||
*/
|
||||
public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor, List references) {
|
||||
return createExpression( kind, lhs, rhs, thirdExpression, typeId, (idExpression == null ) ? EMPTY_STRING : idExpression.toString(), literal, newDescriptor );
|
||||
return createExpression( kind, lhs, rhs, thirdExpression, typeId, (idExpression == null ) ? String.valueOf(EMPTY_STRING) : idExpression.toString(), literal, newDescriptor );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ASTGCCDesignator extends ASTDesignator
|
|||
* @param fieldName
|
||||
* @param fieldOffset
|
||||
*/
|
||||
public ASTGCCDesignator(IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, String fieldName, int fieldOffset, IASTExpression secondSubscriptExpression) {
|
||||
public ASTGCCDesignator(IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, char[] fieldName, int fieldOffset, IASTExpression secondSubscriptExpression) {
|
||||
super(kind, constantExpression, fieldName, fieldOffset);
|
||||
secondExpression = secondSubscriptExpression;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ASTElaboratedTypeSpecifier extends ASTNode implements IASTElaborate
|
|||
setNameOffset( nameOffset );
|
||||
setNameEndOffsetAndLineNumber( nameEndOffset, nameLine );
|
||||
setEndingOffsetAndLineNumber( endOffset, endingLine );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, typeName );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, typeName.toCharArray() );
|
||||
fn = filename;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
ownerTemplate.setOwnedDeclaration( this );
|
||||
setStartingOffsetAndLineNumber( startOffset, startLine );
|
||||
setNameOffset( nameOffset );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name.toCharArray() );
|
||||
setNameEndOffsetAndLineNumber(nameEndOffset, nameLine);
|
||||
this.hasFunctionTryBlock = hasFunctionTryBlock;
|
||||
this.varArgs = hasVarArgs;
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
this.isVolatile = isVolatile;
|
||||
this.visibility = visibility;
|
||||
this.constructorChainElements = constructorChainElements;
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name.toCharArray() );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVirtual()
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ASTNamespaceDefinition extends ASTDeclaration implements IASTNamesp
|
|||
public ASTNamespaceDefinition( IASTScope scope, String name, int startOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, char[] filename )
|
||||
{
|
||||
super( scope );
|
||||
qualifiedNameElement = new ASTQualifiedNamedElement( scope, name );
|
||||
qualifiedNameElement = new ASTQualifiedNamedElement( scope, name.toCharArray() );
|
||||
this.name = name;
|
||||
setStartingOffsetAndLineNumber(startOffset, startingLine);
|
||||
setNameOffset(nameOffset);
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ASTScopedTypeSpecifier extends ASTQualifiedNamedElement implements
|
|||
|
||||
public ASTScopedTypeSpecifier( IASTScope scope, String name )
|
||||
{
|
||||
super( scope, name );
|
||||
super( scope, name.toCharArray() );
|
||||
this.scope = scope;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedef
|
|||
setStartingOffsetAndLineNumber(startingOffset, startingLine);
|
||||
setNameOffset(nameOffset);
|
||||
setNameEndOffsetAndLineNumber(nameEndOffset, nameLine);
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name.toCharArray() );
|
||||
fn = filename;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
|||
this.isStatic = isStatic;
|
||||
this.name = name;
|
||||
this.constructorExpression = constructorExpression;
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name );
|
||||
qualifiedName = new ASTQualifiedNamedElement( scope, name.toCharArray() );
|
||||
setStartingOffsetAndLineNumber(startingOffset, startLine);
|
||||
setNameOffset(nameOffset);
|
||||
setNameEndOffsetAndLineNumber( nameEndOffset, nameLine );
|
||||
|
|
|
@ -19,12 +19,12 @@ import java.util.Map;
|
|||
public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||
{
|
||||
|
||||
public BasicSymbol( ParserSymbolTable table, String name ){
|
||||
public BasicSymbol( ParserSymbolTable table, char[] name ){
|
||||
super( table );
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public BasicSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo )
|
||||
public BasicSymbol( ParserSymbolTable table, char[] name, ITypeInfo.eType typeInfo )
|
||||
{
|
||||
super( table );
|
||||
_name = name;
|
||||
|
@ -42,8 +42,8 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
|||
return newSymbol;
|
||||
}
|
||||
|
||||
public String getName() { return _name; }
|
||||
public void setName(String name) { _name = name; }
|
||||
public char[] getName() { return _name; }
|
||||
public void setName(char[] name) { _name = name; }
|
||||
|
||||
|
||||
public void setContainingSymbol( IContainerSymbol scope ){
|
||||
|
@ -167,7 +167,7 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
|||
_isInvisible = invisible ;
|
||||
}
|
||||
|
||||
private String _name; //our name
|
||||
private char[] _name; //our name
|
||||
private ITypeInfo _typeInfo; //our type info
|
||||
private int _depth; //how far down the scope stack we are
|
||||
|
||||
|
|
|
@ -237,33 +237,33 @@ public class BasicTypeInfo implements ITypeInfo {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static final String _image[] = { "", //$NON-NLS-1$ t_undef
|
||||
"", //$NON-NLS-1$ t_type
|
||||
"namespace", //$NON-NLS-1$ t_namespace
|
||||
"class", //$NON-NLS-1$ t_class
|
||||
"struct", //$NON-NLS-1$ t_struct
|
||||
"union", //$NON-NLS-1$ t_union
|
||||
"enum", //$NON-NLS-1$ t_enumeration
|
||||
"", //$NON-NLS-1$ t_constructor
|
||||
"", //$NON-NLS-1$ t_function
|
||||
"_Bool", //$NON-NLS-1$ t__Bool
|
||||
"bool", //$NON-NLS-1$ t_bool
|
||||
"char", //$NON-NLS-1$ t_char
|
||||
"wchar_t", //$NON-NLS-1$ t_wchar_t
|
||||
"int", //$NON-NLS-1$ t_int
|
||||
"float", //$NON-NLS-1$ t_float
|
||||
"double", //$NON-NLS-1$ t_double
|
||||
"void", //$NON-NLS-1$ t_void
|
||||
"", //$NON-NLS-1$ t_enumerator
|
||||
"", //$NON-NLS-1$ t_block
|
||||
"template", //$NON-NLS-1$ t_template
|
||||
"", //$NON-NLS-1$ t_asm
|
||||
"", //$NON-NLS-1$ t_linkage
|
||||
"", //$NON-NLS-1$ t_templateParameter
|
||||
"typename" //$NON-NLS-1$ t_typeName
|
||||
private static final char _image[][] = { "".toCharArray(), //$NON-NLS-1$ t_undef
|
||||
"".toCharArray(), //$NON-NLS-1$ t_type
|
||||
"namespace".toCharArray(), //$NON-NLS-1$ t_namespace
|
||||
"class".toCharArray(), //$NON-NLS-1$ t_class
|
||||
"struct".toCharArray(), //$NON-NLS-1$ t_struct
|
||||
"union".toCharArray(), //$NON-NLS-1$ t_union
|
||||
"enum".toCharArray(), //$NON-NLS-1$ t_enumeration
|
||||
"".toCharArray(), //$NON-NLS-1$ t_constructor
|
||||
"".toCharArray(), //$NON-NLS-1$ t_function
|
||||
"_Bool".toCharArray(), //$NON-NLS-1$ t__Bool
|
||||
"bool".toCharArray(), //$NON-NLS-1$ t_bool
|
||||
"char".toCharArray(), //$NON-NLS-1$ t_char
|
||||
"wchar_t".toCharArray(), //$NON-NLS-1$ t_wchar_t
|
||||
"int".toCharArray(), //$NON-NLS-1$ t_int
|
||||
"float".toCharArray(), //$NON-NLS-1$ t_float
|
||||
"double".toCharArray(), //$NON-NLS-1$ t_double
|
||||
"void".toCharArray(), //$NON-NLS-1$ t_void
|
||||
"".toCharArray(), //$NON-NLS-1$ t_enumerator
|
||||
"".toCharArray(), //$NON-NLS-1$ t_block
|
||||
"template".toCharArray(), //$NON-NLS-1$ t_template
|
||||
"".toCharArray(), //$NON-NLS-1$ t_asm
|
||||
"".toCharArray(), //$NON-NLS-1$ t_linkage
|
||||
"".toCharArray(), //$NON-NLS-1$ t_templateParameter
|
||||
"typename".toCharArray() //$NON-NLS-1$ t_typeName
|
||||
};
|
||||
|
||||
public String toString() {
|
||||
public char[] toCharArray() {
|
||||
if( isType( t_type ) && getTypeSymbol() != null ){
|
||||
return getTypeSymbol().getName();
|
||||
}
|
||||
|
|
|
@ -29,8 +29,10 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMember;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.LookupData;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArraySet;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -40,11 +42,11 @@ import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
|
|||
*/
|
||||
public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||
|
||||
protected ContainerSymbol( ParserSymbolTable table, String name ){
|
||||
protected ContainerSymbol( ParserSymbolTable table, char[] name ){
|
||||
super( table, name );
|
||||
}
|
||||
|
||||
protected ContainerSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){
|
||||
protected ContainerSymbol( ParserSymbolTable table, char[] name, ITypeInfo.eType typeInfo ){
|
||||
super( table, name, typeInfo );
|
||||
}
|
||||
|
||||
|
@ -52,7 +54,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
ContainerSymbol copy = (ContainerSymbol)super.clone();
|
||||
|
||||
copy._usingDirectives = (_usingDirectives != Collections.EMPTY_LIST) ? (List) ((ArrayList)_usingDirectives).clone() : _usingDirectives;
|
||||
copy._containedSymbols = (ObjectMap) ( ( _containedSymbols != ObjectMap.EMPTY_MAP )? _containedSymbols.clone() : _containedSymbols );
|
||||
copy._containedSymbols = (CharArrayObjectMap) ( ( _containedSymbols != CharArrayObjectMap.EMPTY_MAP )? _containedSymbols.clone() : _containedSymbols );
|
||||
copy._contents = (_contents != Collections.EMPTY_LIST) ? (List) ((ArrayList)_contents).clone() : _contents;
|
||||
|
||||
return copy;
|
||||
|
@ -188,7 +190,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
}
|
||||
|
||||
boolean unnamed = obj.getName().equals( ParserSymbolTable.EMPTY_NAME );
|
||||
boolean unnamed = CharArrayUtils.equals( obj.getName(), ParserSymbolTable.EMPTY_NAME_ARRAY );
|
||||
|
||||
Object origObj = null;
|
||||
|
||||
|
@ -344,15 +346,15 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
* class being defined, or shall refer to an enumerator for an enumeration
|
||||
* type that is a member of a base class of the class being defined.
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( String name ) throws ParserSymbolTableException {
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( char[] name ) throws ParserSymbolTableException {
|
||||
return addUsingDeclaration( name, null );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name );
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( char[] name, IContainerSymbol declContext ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name );
|
||||
|
||||
if( declContext != null ){
|
||||
data.qualified = true;
|
||||
|
@ -421,20 +423,20 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#getContainedSymbols()
|
||||
*/
|
||||
public ObjectMap getContainedSymbols(){
|
||||
public CharArrayObjectMap getContainedSymbols(){
|
||||
return _containedSymbols;
|
||||
}
|
||||
|
||||
protected void putInContainedSymbols( String key, Object obj ){
|
||||
if( _containedSymbols == ObjectMap.EMPTY_MAP ){
|
||||
_containedSymbols = new ObjectMap( 4 );
|
||||
protected void putInContainedSymbols( char[] key, Object obj ){
|
||||
if( _containedSymbols == CharArrayObjectMap.EMPTY_MAP ){
|
||||
_containedSymbols = new CharArrayObjectMap( 4 );
|
||||
}
|
||||
_containedSymbols.put( key, obj );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String)
|
||||
*/
|
||||
public ISymbol elaboratedLookup( final ITypeInfo.eType type, String name ) throws ParserSymbolTableException{
|
||||
public ISymbol elaboratedLookup( final ITypeInfo.eType type, char[] name ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name ){
|
||||
public TypeFilter getFilter() {
|
||||
if( t == ITypeInfo.t_any ) return ANY_FILTER;
|
||||
|
@ -469,7 +471,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookup(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookup( String name ) throws ParserSymbolTableException {
|
||||
public ISymbol lookup( char[] name ) throws ParserSymbolTableException {
|
||||
LookupData data = new LookupData( name );
|
||||
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
|
@ -514,7 +516,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
* ie, We need a seperate lookup function for looking up the member names
|
||||
* for a definition.
|
||||
*/
|
||||
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException{
|
||||
public ISymbol lookupMemberForDefinition( char[] name ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name );
|
||||
data.qualified = true;
|
||||
|
||||
|
@ -534,7 +536,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
return null;
|
||||
}
|
||||
|
||||
public IParameterizedSymbol lookupMethodForDefinition( String name, final List parameters ) throws ParserSymbolTableException{
|
||||
public IParameterizedSymbol lookupMethodForDefinition( char[] name, final List parameters ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name ){
|
||||
public List getParameters() { return params; }
|
||||
final private List params = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
|
@ -574,10 +576,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
* the ::, object, function and enumerator names are ignored. If the name
|
||||
* is not a class-name or namespace-name, the program is ill-formed
|
||||
*/
|
||||
public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException {
|
||||
public IContainerSymbol lookupNestedNameSpecifier( char[] name ) throws ParserSymbolTableException {
|
||||
return lookupNestedNameSpecifier( name, this );
|
||||
}
|
||||
private IContainerSymbol lookupNestedNameSpecifier(String name, IContainerSymbol inSymbol ) throws ParserSymbolTableException{
|
||||
private IContainerSymbol lookupNestedNameSpecifier(char[] name, IContainerSymbol inSymbol ) throws ParserSymbolTableException{
|
||||
ISymbol foundSymbol = null;
|
||||
|
||||
final TypeFilter filter = new TypeFilter( ITypeInfo.t_namespace );
|
||||
|
@ -609,7 +611,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String)
|
||||
*/
|
||||
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException{
|
||||
public ISymbol qualifiedLookup( char[] name ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name );
|
||||
data.qualified = true;
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
|
@ -620,7 +622,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||
*/
|
||||
public ISymbol qualifiedLookup( String name, final ITypeInfo.eType t ) throws ParserSymbolTableException{
|
||||
public ISymbol qualifiedLookup( char[] name, final ITypeInfo.eType t ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name ){
|
||||
public TypeFilter getFilter() {
|
||||
if( t == ITypeInfo.t_any ) return ANY_FILTER;
|
||||
|
@ -663,7 +665,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
* ordinary unqualified lookup and the set of declarations found in the
|
||||
* namespaces and classes associated with the argument types.
|
||||
*/
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup( String name, final List parameters ) throws ParserSymbolTableException{
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup( char[] name, final List parameters ) throws ParserSymbolTableException{
|
||||
//figure out the set of associated scopes first, so we can remove those that are searched
|
||||
//during the normal lookup to avoid doing them twice
|
||||
final ObjectSet associated = new ObjectSet(0);
|
||||
|
@ -756,7 +758,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
* Member lookup really proceeds as an unqualified lookup, but doesn't
|
||||
* include argument dependant scopes
|
||||
*/
|
||||
public IParameterizedSymbol memberFunctionLookup( String name, final List parameters ) throws ParserSymbolTableException{
|
||||
public IParameterizedSymbol memberFunctionLookup( char[] name, final List parameters ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name ){
|
||||
public List getParameters() { return params; }
|
||||
final private List params = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
|
@ -769,7 +771,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol qualifiedFunctionLookup( String name, final List parameters ) throws ParserSymbolTableException{
|
||||
public IParameterizedSymbol qualifiedFunctionLookup( char[] name, final List parameters ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name ){
|
||||
public List getParameters() { return params; }
|
||||
final private List params = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
|
@ -785,7 +787,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#templateLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public ISymbol lookupTemplateId( String name, List arguments ) throws ParserSymbolTableException
|
||||
public ISymbol lookupTemplateId( char[] name, List arguments ) throws ParserSymbolTableException
|
||||
{
|
||||
LookupData data = new LookupData( name );
|
||||
|
||||
|
@ -807,7 +809,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupFunctionTemplateId(java.lang.String, java.util.List, java.util.List)
|
||||
*/
|
||||
public ISymbol lookupFunctionTemplateId(String name, final List parameters, final List arguments, boolean forDefinition) throws ParserSymbolTableException {
|
||||
public ISymbol lookupFunctionTemplateId(char[] name, final List parameters, final List arguments, boolean forDefinition) throws ParserSymbolTableException {
|
||||
LookupData data = new LookupData( name ){
|
||||
public List getParameters() { return params; }
|
||||
public List getTemplateParameters() { return templateParams; }
|
||||
|
@ -827,27 +829,27 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupTemplateIdForDefinition(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(String name, List arguments){
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(char[] name, List arguments){
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List prefixLookup( final TypeFilter filter, String prefix, boolean qualified, final List paramList ) throws ParserSymbolTableException{
|
||||
public List prefixLookup( final TypeFilter filter, char[] prefix, boolean qualified, final List paramList ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( prefix ){
|
||||
public List getParameters() { return params; }
|
||||
public boolean isPrefixLookup(){ return true; }
|
||||
public ObjectSet getAmbiguities(){ return ambiguities; }
|
||||
public CharArraySet getAmbiguities(){ return ambiguities; }
|
||||
public TypeFilter getFilter() { return typeFilter; }
|
||||
|
||||
public void addAmbiguity( String n ){
|
||||
if( ambiguities == ObjectSet.EMPTY_SET ){
|
||||
ambiguities = new ObjectSet(2);
|
||||
public void addAmbiguity( char[] n ){
|
||||
if( ambiguities == CharArraySet.EMPTY_SET ){
|
||||
ambiguities = new CharArraySet(2);
|
||||
}
|
||||
ambiguities.put( n );
|
||||
}
|
||||
|
||||
final private List params = paramList;
|
||||
private ObjectSet ambiguities = ObjectSet.EMPTY_SET;
|
||||
private CharArraySet ambiguities = CharArraySet.EMPTY_SET;
|
||||
final private TypeFilter typeFilter = filter;
|
||||
};
|
||||
|
||||
|
@ -857,7 +859,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
List constructors = null;
|
||||
if( filter != null && filter.willAccept( ITypeInfo.t_constructor ) && (this instanceof IDerivableContainerSymbol) ){
|
||||
if( getName().startsWith( prefix ) ){
|
||||
if( CharArrayUtils.equals( getName(), 0, prefix.length, prefix, true ) ){
|
||||
List temp = ((IDerivableContainerSymbol)this).getConstructors();
|
||||
int size = temp.size();
|
||||
constructors = new ArrayList( size );
|
||||
|
@ -880,7 +882,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
List list = new ArrayList();
|
||||
|
||||
Object obj = null;
|
||||
Object key = null;
|
||||
char[] key = null;
|
||||
List tempList = null;
|
||||
int size = data.foundItems.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
|
@ -1175,10 +1177,12 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
static final private Collator collator = Collator.getInstance();
|
||||
static { collator.setStrength( Collator.PRIMARY ); }
|
||||
public int compare( Object o1, Object o2 ){
|
||||
int result = collator.compare( o1, o2 );
|
||||
String s1 = String.valueOf( (char[])o1 );
|
||||
String s2 = String.valueOf( (char[])o2 );
|
||||
int result = collator.compare( s1, s2 );
|
||||
if( result == 0 ){
|
||||
collator.setStrength( Collator.IDENTICAL );
|
||||
result = collator.compare( o1, o2 );
|
||||
result = collator.compare( s1, s2 );
|
||||
collator.setStrength( Collator.PRIMARY );
|
||||
}
|
||||
return result;
|
||||
|
@ -1191,7 +1195,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
private List _contents = Collections.EMPTY_LIST; //ordered list of all contents of this symbol
|
||||
private List _usingDirectives = Collections.EMPTY_LIST; //collection of nominated namespaces
|
||||
private ObjectMap _containedSymbols = ObjectMap.EMPTY_MAP; //declarations contained by us.
|
||||
private CharArrayObjectMap _containedSymbols = CharArrayObjectMap.EMPTY_MAP; //declarations contained by us.
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addTemplateId(org.eclipse.cdt.internal.core.parser.pst.ISymbol, java.util.List)
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTemplateInstance {
|
||||
|
||||
public DeferredTemplateInstance( ParserSymbolTable table, ITemplateSymbol template, List args ){
|
||||
super(table, ParserSymbolTable.EMPTY_NAME );
|
||||
super(table, ParserSymbolTable.EMPTY_NAME_ARRAY );
|
||||
_template = template;
|
||||
_arguments = new ArrayList( args );
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.LookupData;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -32,11 +32,11 @@ import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
|||
*/
|
||||
public class DerivableContainerSymbol extends ContainerSymbol implements IDerivableContainerSymbol {
|
||||
|
||||
protected DerivableContainerSymbol( ParserSymbolTable table, String name ){
|
||||
protected DerivableContainerSymbol( ParserSymbolTable table, char[] name ){
|
||||
super( table, name );
|
||||
}
|
||||
|
||||
protected DerivableContainerSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){
|
||||
protected DerivableContainerSymbol( ParserSymbolTable table, char[] name, ITypeInfo.eType typeInfo ){
|
||||
super( table, name, typeInfo );
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
*/
|
||||
public IParameterizedSymbol lookupConstructor( final List parameters ) throws ParserSymbolTableException
|
||||
{
|
||||
LookupData data = new LookupData( ParserSymbolTable.EMPTY_NAME ){
|
||||
LookupData data = new LookupData( ParserSymbolTable.EMPTY_NAME_ARRAY ){
|
||||
public List getParameters() { return params; }
|
||||
public TypeFilter getFilter() { return CONSTRUCTOR_FILTER; }
|
||||
final private List params = parameters;
|
||||
|
@ -285,7 +285,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
|
||||
LookupData data = new LookupData( ParserSymbolTable.THIS );
|
||||
try {
|
||||
ObjectMap map = ParserSymbolTable.lookupInContained( data, obj );
|
||||
CharArrayObjectMap map = ParserSymbolTable.lookupInContained( data, obj );
|
||||
foundThis = ( map != null ) ? map.containsKey( data.name ) : false;
|
||||
} catch (ParserSymbolTableException e) {
|
||||
return false;
|
||||
|
@ -366,7 +366,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
* without considering scopes that are outside the innermost enclosing non-
|
||||
* class scope.
|
||||
*/
|
||||
public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException{
|
||||
public ISymbol lookupForFriendship( char[] name ) throws ParserSymbolTableException{
|
||||
IContainerSymbol enclosing = getContainingSymbol();
|
||||
if( enclosing != null && enclosing.isType( ITypeInfo.t_namespace, ITypeInfo.t_union ) ){
|
||||
while( enclosing != null && ( enclosing.getType() != ITypeInfo.t_namespace) )
|
||||
|
@ -386,7 +386,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
return getSymbolTable().resolveAmbiguities( data );
|
||||
}
|
||||
|
||||
public IParameterizedSymbol lookupFunctionForFriendship( String name, final List parameters ) throws ParserSymbolTableException{
|
||||
public IParameterizedSymbol lookupFunctionForFriendship( char[] name, final List parameters ) throws ParserSymbolTableException{
|
||||
|
||||
|
||||
IContainerSymbol enclosing = getContainingSymbol();
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.eclipse.cdt.internal.core.parser.pst;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -70,10 +70,10 @@ public interface IContainerSymbol extends ISymbol {
|
|||
* IDerivableContainerSymbol
|
||||
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( String name ) throws ParserSymbolTableException;
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException;
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( char[] name ) throws ParserSymbolTableException;
|
||||
public IUsingDeclarationSymbol addUsingDeclaration( char[] name, IContainerSymbol declContext ) throws ParserSymbolTableException;
|
||||
|
||||
public ObjectMap getContainedSymbols();
|
||||
public CharArrayObjectMap getContainedSymbols();
|
||||
|
||||
/**
|
||||
* Lookup symbols matching the given prefix
|
||||
|
@ -87,7 +87,7 @@ public interface IContainerSymbol extends ISymbol {
|
|||
* IDerivableContainerSymbol
|
||||
* r_CircularInheritance if during lookup, we come across a class with a circular inheritance tree
|
||||
*/
|
||||
public List prefixLookup( TypeFilter filter, String prefix, boolean qualified, List paramList ) throws ParserSymbolTableException;
|
||||
public List prefixLookup( TypeFilter filter, char[] prefix, boolean qualified, List paramList ) throws ParserSymbolTableException;
|
||||
|
||||
/**
|
||||
* Lookups
|
||||
|
@ -98,16 +98,16 @@ public interface IContainerSymbol extends ISymbol {
|
|||
* IDerivableContainerSymbol
|
||||
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
|
||||
*/
|
||||
public ISymbol elaboratedLookup( ITypeInfo.eType type, String name ) throws ParserSymbolTableException;
|
||||
public ISymbol lookup( String name ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol lookupMethodForDefinition( String name, List parameters ) throws ParserSymbolTableException;
|
||||
public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException;
|
||||
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException;
|
||||
public ISymbol qualifiedLookup( String name, ITypeInfo.eType t ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol memberFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol qualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
|
||||
public ISymbol elaboratedLookup( ITypeInfo.eType type, char[] name ) throws ParserSymbolTableException;
|
||||
public ISymbol lookup( char[] name ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupMemberForDefinition( char[] name ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol lookupMethodForDefinition( char[] name, List parameters ) throws ParserSymbolTableException;
|
||||
public IContainerSymbol lookupNestedNameSpecifier( char[] name ) throws ParserSymbolTableException;
|
||||
public ISymbol qualifiedLookup( char[] name ) throws ParserSymbolTableException;
|
||||
public ISymbol qualifiedLookup( char[] name, ITypeInfo.eType t ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup( char[] name, List parameters ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol memberFunctionLookup( char[] name, List parameters ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol qualifiedFunctionLookup( char[] name, List parameters ) throws ParserSymbolTableException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -119,10 +119,10 @@ public interface IContainerSymbol extends ISymbol {
|
|||
* r_Ambiguous if (14.5.4.1) more than one specialization can be used and none is more specializaed than all the others
|
||||
* r_BadTemplateArgument if (14.3.1, 14.3.2) a template argument is invalid
|
||||
*/
|
||||
public ISymbol lookupTemplateId( String name, List arguments ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupFunctionTemplateId( String name, List parameters, List arguments, boolean forDefinition ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupTemplateId( char[] name, List arguments ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupFunctionTemplateId( char[] name, List parameters, List arguments, boolean forDefinition ) throws ParserSymbolTableException;
|
||||
|
||||
public IContainerSymbol lookupTemplateIdForDefinition( String name, List arguments ) throws ParserSymbolTableException;
|
||||
public IContainerSymbol lookupTemplateIdForDefinition( char[] name, List arguments ) throws ParserSymbolTableException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -67,8 +67,8 @@ public interface IDerivableContainerSymbol extends IContainerSymbol {
|
|||
* IDerivableContainerSymbol
|
||||
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
|
||||
*/
|
||||
public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol lookupFunctionForFriendship( String name, List parameters ) throws ParserSymbolTableException;
|
||||
public ISymbol lookupForFriendship( char[] name ) throws ParserSymbolTableException;
|
||||
public IParameterizedSymbol lookupFunctionForFriendship( char[] name, List parameters ) throws ParserSymbolTableException;
|
||||
|
||||
public List getFriends();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.eclipse.cdt.internal.core.parser.pst;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -32,7 +32,7 @@ public interface IParameterizedSymbol extends IContainerSymbol {
|
|||
public void addParameter( ITypeInfo.eType type, int info, ITypeInfo.PtrOp ptrOp, boolean hasDefault );
|
||||
public void addParameter( ISymbol typeSymbol, int info, ITypeInfo.PtrOp ptrOp, boolean hasDefault );
|
||||
|
||||
public ObjectMap getParameterMap();
|
||||
public CharArrayObjectMap getParameterMap();
|
||||
public List getParameterList();
|
||||
//public void setParameterList( List list );
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ public interface ISymbol extends Cloneable, IExtensibleSymbol {
|
|||
*/
|
||||
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException;
|
||||
|
||||
public void setName(String name);
|
||||
public String getName();
|
||||
public void setName(char[] name);
|
||||
public char[] getName();
|
||||
|
||||
public IContainerSymbol getContainingSymbol();
|
||||
public void setContainingSymbol( IContainerSymbol containing );
|
||||
|
|
|
@ -246,7 +246,7 @@ public interface ITypeInfo {
|
|||
|
||||
public abstract boolean equals( Object t );
|
||||
|
||||
public abstract String toString();
|
||||
public abstract char[] toCharArray();
|
||||
|
||||
public abstract void clear();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -27,13 +27,13 @@ import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
|||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class ParameterizedSymbol extends ContainerSymbol implements IParameterizedSymbol {
|
||||
public class ParameterizedSymbol extends ContainerSymbol implements IParameterizedSymbol {
|
||||
|
||||
protected ParameterizedSymbol( ParserSymbolTable table, String name ){
|
||||
protected ParameterizedSymbol( ParserSymbolTable table, char[] name ){
|
||||
super( table, name );
|
||||
}
|
||||
|
||||
protected ParameterizedSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){
|
||||
protected ParameterizedSymbol( ParserSymbolTable table, char[] name, ITypeInfo.eType typeInfo ){
|
||||
super( table, name, typeInfo );
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
ParameterizedSymbol copy = (ParameterizedSymbol)super.clone();
|
||||
|
||||
copy._parameterList = ( _parameterList != Collections.EMPTY_LIST ) ? (List) ((ArrayList)_parameterList).clone() : _parameterList;
|
||||
copy._parameterMap = ( _parameterMap != ObjectMap.EMPTY_MAP ) ? (ObjectMap) _parameterMap.clone() : _parameterMap;
|
||||
copy._parameterMap = ( _parameterMap != CharArrayObjectMap.EMPTY_MAP ) ? (CharArrayObjectMap) _parameterMap.clone() : _parameterMap;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
if( _returnType != null ){
|
||||
if( _returnType.isType( ITypeInfo.t_templateParameter ) ){
|
||||
if( argMap.containsKey( _returnType ) ){
|
||||
newParameterized.setReturnType( getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME ) );
|
||||
newParameterized.setReturnType( getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY ) );
|
||||
newParameterized.getReturnType().setTypeInfo( (ITypeInfo) argMap.get( _returnType ) );
|
||||
newParameterized.getReturnType().setInstantiatedSymbol( _returnType );
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
|
||||
_parameterList.add( param );
|
||||
|
||||
String name = param.getName();
|
||||
if( name != null && !name.equals(ParserSymbolTable.EMPTY_NAME) )
|
||||
char[] name = param.getName();
|
||||
if( name != null && !name.equals(ParserSymbolTable.EMPTY_NAME_ARRAY) )
|
||||
{
|
||||
if( _parameterMap == ObjectMap.EMPTY_MAP ){
|
||||
_parameterMap = new ObjectMap( 2 );
|
||||
if( _parameterMap == CharArrayObjectMap.EMPTY_MAP ){
|
||||
_parameterMap = new CharArrayObjectMap( 2 );
|
||||
}
|
||||
|
||||
if( !_parameterMap.containsKey( name ) )
|
||||
|
@ -143,7 +143,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addParameter(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, int, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp, boolean)
|
||||
*/
|
||||
public void addParameter( ITypeInfo.eType type, int info, ITypeInfo.PtrOp ptrOp, boolean hasDefault ){
|
||||
BasicSymbol param = new BasicSymbol(getSymbolTable(), ParserSymbolTable.EMPTY_NAME);
|
||||
BasicSymbol param = new BasicSymbol(getSymbolTable(), ParserSymbolTable.EMPTY_NAME_ARRAY);
|
||||
|
||||
ITypeInfo t = TypeInfoProvider.newTypeInfo( type, info, ptrOp, hasDefault );
|
||||
param.setTypeInfo( t );
|
||||
|
@ -155,7 +155,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addParameter(org.eclipse.cdt.internal.core.parser.pst.ISymbol, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp, boolean)
|
||||
*/
|
||||
public void addParameter( ISymbol typeSymbol, int info, ITypeInfo.PtrOp ptrOp, boolean hasDefault ){
|
||||
BasicSymbol param = new BasicSymbol(getSymbolTable(), ParserSymbolTable.EMPTY_NAME);
|
||||
BasicSymbol param = new BasicSymbol(getSymbolTable(), ParserSymbolTable.EMPTY_NAME_ARRAY);
|
||||
|
||||
ITypeInfo nfo = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, info, typeSymbol, ptrOp, hasDefault );
|
||||
param.setTypeInfo( nfo );
|
||||
|
@ -166,7 +166,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#getParameterMap()
|
||||
*/
|
||||
public ObjectMap getParameterMap(){
|
||||
public CharArrayObjectMap getParameterMap(){
|
||||
return _parameterMap;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
|
||||
|
||||
private List _parameterList = Collections.EMPTY_LIST; //have my cake
|
||||
private ObjectMap _parameterMap = ObjectMap.EMPTY_MAP; //and eat it too
|
||||
private CharArrayObjectMap _parameterMap = CharArrayObjectMap.EMPTY_MAP; //and eat it too
|
||||
private ISymbol _returnType;
|
||||
private boolean _hasVarArgs = false; //whether or not this function has variable arguments
|
||||
}
|
||||
|
|
|
@ -26,8 +26,11 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMember;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArraySet;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -37,15 +40,16 @@ public class ParserSymbolTable {
|
|||
|
||||
public static final int TYPE_LOOP_THRESHOLD = 50;
|
||||
public static final int TEMPLATE_LOOP_THRESHOLD = 10;
|
||||
public static final String EMPTY_NAME = ""; //$NON-NLS-1$
|
||||
public static final String THIS = "this"; //$NON-NLS-1$
|
||||
public static final char[] EMPTY_NAME_ARRAY = new char[0]; //$NON-NLS-1$
|
||||
public static final char[] THIS = new char[] {'t','h','i','s'}; //$NON-NLS-1$
|
||||
public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '}; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constructor for ParserSymbolTable.
|
||||
*/
|
||||
public ParserSymbolTable( ParserLanguage language, ParserMode mode ) {
|
||||
super();
|
||||
_compilationUnit = newContainerSymbol( EMPTY_NAME, ITypeInfo.t_namespace );
|
||||
_compilationUnit = newContainerSymbol( EMPTY_NAME_ARRAY, ITypeInfo.t_namespace );
|
||||
_language = language;
|
||||
_mode = mode;
|
||||
_typeInfoProvider = new TypeInfoProvider();
|
||||
|
@ -55,47 +59,44 @@ public class ParserSymbolTable {
|
|||
return _compilationUnit;
|
||||
}
|
||||
|
||||
public IContainerSymbol newContainerSymbol( String name ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public IContainerSymbol newContainerSymbol( char[] name ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new ContainerSymbol( this, name );
|
||||
}
|
||||
public IContainerSymbol newContainerSymbol( String name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public IContainerSymbol newContainerSymbol( char[] name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new ContainerSymbol( this, name, type );
|
||||
}
|
||||
|
||||
public ISymbol newSymbol( String name ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public ISymbol newSymbol( char[] name ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new BasicSymbol( this, name );
|
||||
}
|
||||
public ISymbol newSymbol( String name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public ISymbol newSymbol( char[] name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new BasicSymbol( this, name, type );
|
||||
}
|
||||
|
||||
public IDerivableContainerSymbol newDerivableContainerSymbol( String name ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
return new DerivableContainerSymbol( this, name );
|
||||
public IDerivableContainerSymbol newDerivableContainerSymbol( char[] name ){
|
||||
return new DerivableContainerSymbol( this, name != null ? name : EMPTY_NAME_ARRAY );
|
||||
}
|
||||
public IDerivableContainerSymbol newDerivableContainerSymbol( String name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
return new DerivableContainerSymbol( this, name, type );
|
||||
public IDerivableContainerSymbol newDerivableContainerSymbol( char[] name, ITypeInfo.eType type ){
|
||||
return new DerivableContainerSymbol( this, name != null ? name : EMPTY_NAME_ARRAY, type );
|
||||
}
|
||||
public IParameterizedSymbol newParameterizedSymbol( String name ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public IParameterizedSymbol newParameterizedSymbol( char[] name ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new ParameterizedSymbol( this, name );
|
||||
}
|
||||
public IParameterizedSymbol newParameterizedSymbol( String name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public IParameterizedSymbol newParameterizedSymbol( char[] name, ITypeInfo.eType type ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new ParameterizedSymbol( this, name, type );
|
||||
}
|
||||
public ITemplateSymbol newTemplateSymbol( String name ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public ITemplateSymbol newTemplateSymbol( char[] name ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new TemplateSymbol( this, name );
|
||||
}
|
||||
|
||||
public ISpecializedSymbol newSpecializedSymbol( String name ){
|
||||
if( name == null ) name = EMPTY_NAME;
|
||||
public ISpecializedSymbol newSpecializedSymbol( char[] name ){
|
||||
if( name == null ) name = EMPTY_NAME_ARRAY;
|
||||
return new SpecializedSymbol( this, name );
|
||||
}
|
||||
|
||||
|
@ -123,7 +124,7 @@ public class ParserSymbolTable {
|
|||
ArrayList transitives = null; //list of transitive using directives
|
||||
|
||||
//if this name define in this scope?
|
||||
ObjectMap map = null;
|
||||
CharArrayObjectMap map = null;
|
||||
if( !data.usingDirectivesOnly ){
|
||||
map = lookupInContained( data, inSymbol );
|
||||
if( data.foundItems == null || data.foundItems.isEmpty() ){
|
||||
|
@ -247,7 +248,7 @@ public class ParserSymbolTable {
|
|||
if( !data.visited.containsKey( temp ) ){
|
||||
data.visited.put( temp );
|
||||
|
||||
ObjectMap map = lookupInContained( data, temp );
|
||||
CharArrayObjectMap map = lookupInContained( data, temp );
|
||||
foundSomething = ( map != null && !map.isEmpty() );
|
||||
if( foundSomething ){
|
||||
if( data.foundItems == null )
|
||||
|
@ -274,12 +275,12 @@ public class ParserSymbolTable {
|
|||
* @param map
|
||||
* @param map2
|
||||
*/
|
||||
private static void mergeResults( LookupData data, ObjectMap resultMap, ObjectMap map ) throws ParserSymbolTableException {
|
||||
private static void mergeResults( LookupData data, CharArrayObjectMap resultMap, CharArrayObjectMap map ) throws ParserSymbolTableException {
|
||||
if( resultMap == null || map == null || map.isEmpty() ){
|
||||
return;
|
||||
}
|
||||
|
||||
Object key = null;
|
||||
char[] key = null;
|
||||
int size = map.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
key = map.keyAt( i );
|
||||
|
@ -309,8 +310,8 @@ public class ParserSymbolTable {
|
|||
*
|
||||
* Look for data.name in our collection _containedDeclarations
|
||||
*/
|
||||
protected static ObjectMap lookupInContained( LookupData data, IContainerSymbol lookIn ) throws ParserSymbolTableException{
|
||||
ObjectMap found = null;
|
||||
protected static CharArrayObjectMap lookupInContained( LookupData data, IContainerSymbol lookIn ) throws ParserSymbolTableException{
|
||||
CharArrayObjectMap found = null;
|
||||
|
||||
Object obj = null;
|
||||
|
||||
|
@ -319,15 +320,15 @@ public class ParserSymbolTable {
|
|||
data.getAssociated().remove( lookIn );
|
||||
}
|
||||
|
||||
ObjectMap declarations = lookIn.getContainedSymbols();
|
||||
CharArrayObjectMap declarations = lookIn.getContainedSymbols();
|
||||
|
||||
int numKeys = -1;
|
||||
int idx = 0;
|
||||
if( data.isPrefixLookup() && declarations != ObjectMap.EMPTY_MAP ){
|
||||
if( data.isPrefixLookup() && declarations != CharArrayObjectMap.EMPTY_MAP ){
|
||||
numKeys = declarations.size();
|
||||
}
|
||||
|
||||
String name = ( numKeys > 0 ) ? (String) declarations.keyAt( idx++ ) : data.name;
|
||||
char[] name = ( numKeys > 0 ) ? (char[]) declarations.keyAt( idx++ ) : data.name;
|
||||
|
||||
while( name != null ) {
|
||||
if( nameMatches( data, name ) ){
|
||||
|
@ -337,14 +338,14 @@ public class ParserSymbolTable {
|
|||
|
||||
if( obj != null ){
|
||||
if( found == null ){
|
||||
found = new ObjectMap( 2 );
|
||||
found = new CharArrayObjectMap( 2 );
|
||||
}
|
||||
found.put( name, obj );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( idx < numKeys )
|
||||
name = (String) declarations.keyAt( idx++ );
|
||||
name = declarations.keyAt( idx++ );
|
||||
else
|
||||
name = null;
|
||||
}
|
||||
|
@ -379,10 +380,10 @@ public class ParserSymbolTable {
|
|||
* @param found
|
||||
* @throws ParserSymbolTableException
|
||||
*/
|
||||
private static ObjectMap lookupInParameters(LookupData data, IContainerSymbol lookIn, ObjectMap found) throws ParserSymbolTableException {
|
||||
private static CharArrayObjectMap lookupInParameters(LookupData data, IContainerSymbol lookIn, CharArrayObjectMap found) throws ParserSymbolTableException {
|
||||
Object obj;
|
||||
Iterator iterator;
|
||||
String name;
|
||||
char[] name;
|
||||
|
||||
if( lookIn instanceof ITemplateSymbol && !((ITemplateSymbol)lookIn).getDefinitionParameterMap().isEmpty() ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) lookIn;
|
||||
|
@ -395,7 +396,7 @@ public class ParserSymbolTable {
|
|||
obj = collectSymbol( data, symbol );
|
||||
if( obj != null ){
|
||||
if( found == null ){
|
||||
found = new ObjectMap(2);
|
||||
found = new CharArrayObjectMap(2);
|
||||
}
|
||||
found.put( symbol.getName(), obj );
|
||||
}
|
||||
|
@ -408,29 +409,29 @@ public class ParserSymbolTable {
|
|||
}
|
||||
|
||||
}
|
||||
ObjectMap parameters = ((IParameterizedSymbol)lookIn).getParameterMap();
|
||||
if( parameters != ObjectMap.EMPTY_MAP ){
|
||||
CharArrayObjectMap parameters = ((IParameterizedSymbol)lookIn).getParameterMap();
|
||||
if( parameters != CharArrayObjectMap.EMPTY_MAP ){
|
||||
int numKeys = -1;
|
||||
int idx = 0;
|
||||
|
||||
if( data.isPrefixLookup() && parameters != ObjectMap.EMPTY_MAP ){
|
||||
if( data.isPrefixLookup() && parameters != CharArrayObjectMap.EMPTY_MAP ){
|
||||
numKeys = parameters.size();
|
||||
}
|
||||
name = ( numKeys > 0 ) ? (String) parameters.keyAt( idx++ ) : data.name;
|
||||
name = ( numKeys > 0 ) ? (char[]) parameters.keyAt( idx++ ) : data.name;
|
||||
while( name != null ){
|
||||
if( nameMatches( data, name ) ){
|
||||
obj = parameters.get( name );
|
||||
obj = collectSymbol( data, obj );
|
||||
if( obj != null ){
|
||||
if( found == null ){
|
||||
found = new ObjectMap( 2 );
|
||||
found = new CharArrayObjectMap( 2 );
|
||||
}
|
||||
found.put( name, obj );
|
||||
}
|
||||
}
|
||||
|
||||
if( idx < numKeys )
|
||||
name = (String) parameters.keyAt( idx++ );
|
||||
name = parameters.keyAt( idx++ );
|
||||
else
|
||||
name = null;
|
||||
}
|
||||
|
@ -441,11 +442,11 @@ public class ParserSymbolTable {
|
|||
return found;
|
||||
}
|
||||
|
||||
private static boolean nameMatches( LookupData data, String name ){
|
||||
private static boolean nameMatches( LookupData data, char[] name ){
|
||||
if( data.isPrefixLookup() ){
|
||||
return name.regionMatches( true, 0, data.name, 0, data.name.length() );
|
||||
return CharArrayUtils.equals( name, 0, data.name.length, data.name, true);
|
||||
}
|
||||
return name.equals( data.name );
|
||||
return CharArrayUtils.equals( name, data.name );
|
||||
}
|
||||
private static boolean checkType( LookupData data, ISymbol symbol ) {
|
||||
if( data.getFilter() == null ){
|
||||
|
@ -623,7 +624,7 @@ public class ParserSymbolTable {
|
|||
* @return Declaration
|
||||
* @throws ParserSymbolTableException
|
||||
*/
|
||||
private static ObjectMap lookupInParents( LookupData data, ISymbol lookIn ) throws ParserSymbolTableException{
|
||||
private static CharArrayObjectMap lookupInParents( LookupData data, ISymbol lookIn ) throws ParserSymbolTableException{
|
||||
IDerivableContainerSymbol container = null;
|
||||
|
||||
if( lookIn instanceof IDerivableContainerSymbol ){
|
||||
|
@ -634,9 +635,9 @@ public class ParserSymbolTable {
|
|||
|
||||
List scopes = container.getParents();
|
||||
|
||||
ObjectMap temp = null;
|
||||
ObjectMap symbol = null;
|
||||
ObjectMap inherited = null;
|
||||
CharArrayObjectMap temp = null;
|
||||
CharArrayObjectMap symbol = null;
|
||||
CharArrayObjectMap inherited = null;
|
||||
|
||||
IDerivableContainerSymbol.IParentSymbol wrapper = null;
|
||||
|
||||
|
@ -694,7 +695,7 @@ public class ParserSymbolTable {
|
|||
if( symbol == null || symbol.isEmpty() ){
|
||||
symbol = temp;
|
||||
} else if ( temp != null && !temp.isEmpty() ) {
|
||||
Object key = null;
|
||||
char[] key = null;
|
||||
int tempSize = temp.size();
|
||||
for( int ii = 0; ii < tempSize; ii++ ){
|
||||
key = temp.keyAt( ii );
|
||||
|
@ -764,12 +765,12 @@ public class ParserSymbolTable {
|
|||
* @param map
|
||||
* @throws ParserSymbolTableException
|
||||
*/
|
||||
private static void mergeInheritedResults( ObjectMap resultMap, ObjectMap map ){
|
||||
private static void mergeInheritedResults( CharArrayObjectMap resultMap, CharArrayObjectMap map ){
|
||||
if( resultMap == null || map == null || map.isEmpty() ){
|
||||
return;
|
||||
}
|
||||
|
||||
Object key = null;
|
||||
char[] key = null;
|
||||
int size = map.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
key = map.keyAt( i );
|
||||
|
@ -1073,7 +1074,7 @@ public class ParserSymbolTable {
|
|||
//the only way we get here and have no parameters, is if we are looking
|
||||
//for a function that takes void parameters ie f( void )
|
||||
targetParameters = new ArrayList(1);
|
||||
targetParameters.add( currFn.getSymbolTable().newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$
|
||||
targetParameters.add( currFn.getSymbolTable().newSymbol( EMPTY_NAME_ARRAY, ITypeInfo.t_void ) ); //$NON-NLS-1$
|
||||
} else {
|
||||
targetParameters = currFn.getParameterList();
|
||||
}
|
||||
|
@ -1262,11 +1263,11 @@ public class ParserSymbolTable {
|
|||
return function.getParameterList().isEmpty();
|
||||
}
|
||||
//create a new function that has params as its parameters, then use IParameterizedSymbol.hasSameParameters
|
||||
IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME, ITypeInfo.t_function );
|
||||
IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME_ARRAY, ITypeInfo.t_function );
|
||||
|
||||
int size = params.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol param = function.getSymbolTable().newSymbol( EMPTY_NAME );
|
||||
ISymbol param = function.getSymbolTable().newSymbol( EMPTY_NAME_ARRAY );
|
||||
param.setTypeInfo( (ITypeInfo) params.get(i) );
|
||||
tempFn.addParameter( param );
|
||||
}
|
||||
|
@ -1925,7 +1926,7 @@ public class ParserSymbolTable {
|
|||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
||||
}
|
||||
if( targetDecl.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||
LookupData data = new LookupData( EMPTY_NAME){
|
||||
LookupData data = new LookupData( EMPTY_NAME_ARRAY ){
|
||||
public List getParameters() { return parameters; }
|
||||
public TypeFilter getFilter() { return CONSTRUCTOR_FILTER; }
|
||||
private List parameters = new ArrayList( 1 );
|
||||
|
@ -1957,10 +1958,11 @@ public class ParserSymbolTable {
|
|||
provider.returnTypeInfo( source );
|
||||
|
||||
if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){
|
||||
String name = target.toString();
|
||||
char[] name = target.toCharArray();
|
||||
|
||||
if( !name.equals(EMPTY_NAME) ){
|
||||
LookupData data = new LookupData( "operator " + name ){ //$NON-NLS-1$
|
||||
if( !CharArrayUtils.equals( name, EMPTY_NAME_ARRAY) ){
|
||||
|
||||
LookupData data = new LookupData( CharArrayUtils.concat( OPERATOR_, name )){ //$NON-NLS-1$
|
||||
public List getParameters() { return Collections.EMPTY_LIST; }
|
||||
public TypeFilter getFilter() { return FUNCTION_FILTER; }
|
||||
};
|
||||
|
@ -2217,7 +2219,7 @@ public class ParserSymbolTable {
|
|||
protected static final TypeFilter CONSTRUCTOR_FILTER = new TypeFilter( ITypeInfo.t_constructor );
|
||||
protected static final TypeFilter FUNCTION_FILTER = new TypeFilter( ITypeInfo.t_function );
|
||||
|
||||
public String name;
|
||||
public char[] name;
|
||||
public ObjectMap usingDirectives;
|
||||
public ObjectSet visited = new ObjectSet(0); //used to ensure we don't visit things more than once
|
||||
public ObjectSet inheritanceChain; //used to detect circular inheritance
|
||||
|
@ -2230,17 +2232,17 @@ public class ParserSymbolTable {
|
|||
public boolean exactFunctionsOnly = false;
|
||||
public boolean returnInvisibleSymbols = false;
|
||||
|
||||
public ObjectMap foundItems = null;
|
||||
public CharArrayObjectMap foundItems = null;
|
||||
|
||||
public LookupData( String n ){
|
||||
public LookupData( char[] n ){
|
||||
name = n;
|
||||
}
|
||||
|
||||
//the following function are optionally overloaded by anonymous classes deriving from
|
||||
//this LookupData
|
||||
public boolean isPrefixLookup(){ return false;} //prefix lookup
|
||||
public ObjectSet getAmbiguities() { return null; }
|
||||
public void addAmbiguity(String n ) { /*nothing*/ }
|
||||
public CharArraySet getAmbiguities() { return null; }
|
||||
public void addAmbiguity(char[] n ) { /*nothing*/ }
|
||||
public List getParameters() { return null; } //parameter info for resolving functions
|
||||
public ObjectSet getAssociated() { return null; } //associated namespaces for argument dependant lookup
|
||||
public ISymbol getStopAt() { return null; } //stop looking along the stack once we hit this declaration
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
*/
|
||||
|
||||
public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSymbol {
|
||||
protected SpecializedSymbol( ParserSymbolTable table, String name ){
|
||||
protected SpecializedSymbol( ParserSymbolTable table, char[] name ){
|
||||
super( table, name );
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Cost;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
|
||||
|
||||
/**
|
||||
|
@ -112,7 +113,7 @@ public final class TemplateEngine {
|
|||
info1 = (ITypeInfo) specArgs.get(j);
|
||||
info2 = (ITypeInfo) args.get(j);
|
||||
|
||||
ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY );
|
||||
sym1.setTypeInfo( info1 );
|
||||
|
||||
if( !deduceTemplateArgument( map, sym1, info2 ) ){
|
||||
|
@ -208,7 +209,7 @@ public final class TemplateEngine {
|
|||
//14.3.1, local type, type with no name
|
||||
if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol() != null ){
|
||||
ISymbol symbol = arg.getTypeSymbol();
|
||||
if( symbol.getName().equals( ParserSymbolTable.EMPTY_NAME ) ){
|
||||
if( CharArrayUtils.equals( symbol.getName(), ParserSymbolTable.EMPTY_NAME_ARRAY ) ){
|
||||
return false;
|
||||
} else if( hasNoLinkage( arg ) ){
|
||||
return false;
|
||||
|
@ -223,7 +224,7 @@ public final class TemplateEngine {
|
|||
//if the parameter has reference type
|
||||
if( op != null && op.getType() == ITypeInfo.PtrOp.t_reference ){
|
||||
if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol() != null ){
|
||||
if( arg.getTypeSymbol().getName().equals( ParserSymbolTable.EMPTY_NAME ) ){
|
||||
if( CharArrayUtils.equals( arg.getTypeSymbol().getName(), ParserSymbolTable.EMPTY_NAME_ARRAY )){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +572,9 @@ public final class TemplateEngine {
|
|||
}
|
||||
if( p.getType() == a.getType() ){
|
||||
if( p.getDefault() != null ){
|
||||
return ( p.getDefault().equals( a.getDefault() ) );
|
||||
if( p.getDefault() instanceof char[] && a.getDefault() instanceof char[] )
|
||||
return CharArrayUtils.equals( (char[])p.getDefault(), (char[])a.getDefault() );
|
||||
return ( p.getDefault().equals( a.getDefault() ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -628,7 +631,7 @@ public final class TemplateEngine {
|
|||
if( obj instanceof ISymbol ){
|
||||
sym = (ISymbol) obj;
|
||||
} else {
|
||||
sym = pSymbol.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
sym = pSymbol.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY );
|
||||
sym.setTypeInfo( (ITypeInfo) obj );
|
||||
}
|
||||
|
||||
|
@ -820,7 +823,7 @@ public final class TemplateEngine {
|
|||
ISymbol param = (ISymbol) paramList.get( i );
|
||||
//template type parameter
|
||||
if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){
|
||||
val = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, template.getSymbolTable().newSymbol( "", ITypeInfo.t_class ) ); //$NON-NLS-1$
|
||||
val = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY, ITypeInfo.t_class ) ); //$NON-NLS-1$
|
||||
}
|
||||
//template parameter
|
||||
else if ( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ) {
|
||||
|
@ -858,7 +861,7 @@ public final class TemplateEngine {
|
|||
} catch ( ParserSymbolTableException e ){
|
||||
//we shouldn't get this because there aren't any other symbols in the template
|
||||
}
|
||||
ISymbol param = specialization.getSymbolTable().newSymbol( "", ITypeInfo.t_type ); //$NON-NLS-1$
|
||||
ISymbol param = specialization.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME_ARRAY, ITypeInfo.t_type ); //$NON-NLS-1$
|
||||
|
||||
param.setTypeSymbol( specialization.instantiate( specialization.getArgumentList() ) );
|
||||
|
||||
|
@ -1148,7 +1151,7 @@ public final class TemplateEngine {
|
|||
return ( instance != null ) ? instance : (ISymbol) symbol;
|
||||
}
|
||||
|
||||
static protected boolean alreadyHasTemplateParameter( IContainerSymbol container, String name ){
|
||||
static protected boolean alreadyHasTemplateParameter( IContainerSymbol container, char[] name ){
|
||||
while( container != null ){
|
||||
if( container instanceof ITemplateSymbol ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) container;
|
||||
|
@ -1197,7 +1200,7 @@ public final class TemplateEngine {
|
|||
//14.7.3-11 a trailing template-argument can be left unspecified in the template-id naming an explicit
|
||||
//function template specialization provided it can be deduced from the function argument type
|
||||
if( template.getTemplatedSymbol() instanceof IParameterizedSymbol &&
|
||||
symbol instanceof IParameterizedSymbol && template.getTemplatedSymbol().getName().equals( symbol.getName() ) )
|
||||
symbol instanceof IParameterizedSymbol && CharArrayUtils.equals( template.getTemplatedSymbol().getName(), symbol.getName() ) )
|
||||
{
|
||||
Map map = deduceTemplateArgumentsUsingParameterList( template, (IParameterizedSymbol) symbol );
|
||||
if( map != null && map.containsKey( param ) ){
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateInstantiation;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -345,7 +345,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory#lookupMemberForDefinition(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookupMemberForDefinition(String name) throws ParserSymbolTableException {
|
||||
public ISymbol lookupMemberForDefinition(char[] name) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
|
@ -362,7 +362,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String)
|
||||
*/
|
||||
public ISymbol elaboratedLookup(ITypeInfo.eType type, String name) throws ParserSymbolTableException {
|
||||
public ISymbol elaboratedLookup(ITypeInfo.eType type, char[] name) throws ParserSymbolTableException {
|
||||
ListIterator iter = templates.listIterator( templates.size() );
|
||||
while( iter.hasPrevious() ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) iter.previous();
|
||||
|
@ -379,7 +379,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookup(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookup(String name) throws ParserSymbolTableException {
|
||||
public ISymbol lookup(char[] name) throws ParserSymbolTableException {
|
||||
ListIterator iter = templates.listIterator( templates.size() );
|
||||
while( iter.hasPrevious() ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) iter.previous();
|
||||
|
@ -396,7 +396,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupMethodForDefinition(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupMethodForDefinition(String name, List parameters) throws ParserSymbolTableException {
|
||||
public IParameterizedSymbol lookupMethodForDefinition(char[] name, List parameters) throws ParserSymbolTableException {
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
IParameterizedSymbol found = last.lookupMethodForDefinition( name, parameters );
|
||||
|
@ -410,49 +410,49 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupNestedNameSpecifier(java.lang.String)
|
||||
*/
|
||||
public IContainerSymbol lookupNestedNameSpecifier(String name) throws ParserSymbolTableException {
|
||||
public IContainerSymbol lookupNestedNameSpecifier(char[] name) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().lookupNestedNameSpecifier( name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String)
|
||||
*/
|
||||
public ISymbol qualifiedLookup(String name) throws ParserSymbolTableException {
|
||||
public ISymbol qualifiedLookup(char[] name) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().qualifiedLookup( name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||
*/
|
||||
public ISymbol qualifiedLookup(String name, ITypeInfo.eType t) throws ParserSymbolTableException {
|
||||
public ISymbol qualifiedLookup(char[] name, ITypeInfo.eType t) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().qualifiedLookup( name, t );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#unqualifiedFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup(String name, List parameters) throws ParserSymbolTableException {
|
||||
public IParameterizedSymbol unqualifiedFunctionLookup(char[] name, List parameters) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().unqualifiedFunctionLookup( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#memberFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol memberFunctionLookup(String name, List parameters) throws ParserSymbolTableException {
|
||||
public IParameterizedSymbol memberFunctionLookup(char[] name, List parameters) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().memberFunctionLookup( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedFunctionLookup(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol qualifiedFunctionLookup(String name, List parameters) throws ParserSymbolTableException {
|
||||
public IParameterizedSymbol qualifiedFunctionLookup(char[] name, List parameters) throws ParserSymbolTableException {
|
||||
return getContainingSymbol().qualifiedFunctionLookup( name, parameters );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupTemplate(java.lang.String, java.util.List)
|
||||
*/
|
||||
public ISymbol lookupTemplateId(String name, List arguments) throws ParserSymbolTableException {
|
||||
public ISymbol lookupTemplateId(char[] name, List arguments) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
|
@ -463,7 +463,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
return look;
|
||||
}
|
||||
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(String name, List arguments) throws ParserSymbolTableException {
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(char[] name, List arguments) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
|
@ -482,7 +482,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupFunctionTemplateId(java.lang.String, java.util.List, java.util.List)
|
||||
*/
|
||||
public ISymbol lookupFunctionTemplateId(String name, List parameters, List arguments, boolean forDefinition) throws ParserSymbolTableException {
|
||||
public ISymbol lookupFunctionTemplateId(char[] name, List parameters, List arguments, boolean forDefinition) throws ParserSymbolTableException {
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
IParameterizedSymbol found = (IParameterizedSymbol) last.lookupFunctionTemplateId( name, parameters, arguments, forDefinition );
|
||||
|
@ -562,28 +562,28 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String)
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration(String name) {
|
||||
public IUsingDeclarationSymbol addUsingDeclaration(char[] name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||
*/
|
||||
public IUsingDeclarationSymbol addUsingDeclaration(String name, IContainerSymbol declContext) {
|
||||
public IUsingDeclarationSymbol addUsingDeclaration(char[] name, IContainerSymbol declContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#getContainedSymbols()
|
||||
*/
|
||||
public ObjectMap getContainedSymbols() {
|
||||
public CharArrayObjectMap getContainedSymbols() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#prefixLookup(org.eclipse.cdt.internal.core.parser.pst.TypeFilter, java.lang.String, boolean)
|
||||
*/
|
||||
public List prefixLookup(TypeFilter filter, String prefix, boolean qualified, List paramList) {
|
||||
public List prefixLookup(TypeFilter filter, char[] prefix, boolean qualified, List paramList) {
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
@ -617,14 +617,14 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
public void setName(char[] name) {
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
public char[] getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -834,14 +834,14 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupForFriendship(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookupForFriendship(String name) {
|
||||
public ISymbol lookupForFriendship(char[] name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupFunctionForFriendship(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupFunctionForFriendship(String name, List parameters) {
|
||||
public IParameterizedSymbol lookupFunctionForFriendship(char[] name, List parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
|
@ -25,7 +27,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymbol {
|
||||
|
||||
protected TemplateSymbol ( ParserSymbolTable table, String name ){
|
||||
protected TemplateSymbol ( ParserSymbolTable table, char[] name ){
|
||||
super( table, name, ITypeInfo.t_template );
|
||||
}
|
||||
|
||||
|
@ -198,7 +200,9 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
if( !param.isType( ITypeInfo.t_templateParameter ) )
|
||||
return false;
|
||||
|
||||
if( !getName().equals( ParserSymbolTable.EMPTY_NAME ) && param.getName().equals( getName() ) ){
|
||||
if( !CharArrayUtils.equals( getName(), ParserSymbolTable.EMPTY_NAME_ARRAY ) &&
|
||||
CharArrayUtils.equals( param.getName(), getName() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -294,7 +298,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
} catch (ParserSymbolTableException e) {
|
||||
/* nothing */
|
||||
}
|
||||
if( found == null && getTemplatedSymbol().getName().equals( symbol.getName() ) ){
|
||||
if( found == null && CharArrayUtils.equals( getTemplatedSymbol().getName(), symbol.getName() ) ){
|
||||
found = getTemplatedSymbol();
|
||||
|
||||
IContainerSymbol instance = findInstantiation( actualArgs );
|
||||
|
|
|
@ -10,23 +10,34 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class CharArrayObjectMap extends CharArrayMap {
|
||||
public class CharArrayObjectMap {//extends CharArrayMap {
|
||||
public static final CharArrayObjectMap EMPTY_MAP = new CharArrayObjectMap( 0 ){
|
||||
public Object clone() { return this; }
|
||||
public Object put( char[] key, int start, int length, Object value )
|
||||
{ throw new UnsupportedOperationException(); }
|
||||
};
|
||||
|
||||
private char[][] keyTable;
|
||||
private int[] hashTable;
|
||||
private int[] nextTable;
|
||||
private Object[] valueTable;
|
||||
|
||||
private int currEntry = -1;
|
||||
|
||||
public CharArrayObjectMap(int initialSize) {
|
||||
super(initialSize);
|
||||
valueTable = new Object[capacity()];
|
||||
}
|
||||
|
||||
protected void resize(int size) {
|
||||
super.resize(size);
|
||||
Object[] oldValueTable = valueTable;
|
||||
int size = 1;
|
||||
while (size < initialSize)
|
||||
size <<= 1;
|
||||
|
||||
keyTable = new char[size][];
|
||||
hashTable = new int[size * 2];
|
||||
nextTable = new int[size];
|
||||
valueTable = new Object[size];
|
||||
System.arraycopy(oldValueTable, 0, valueTable, 0, oldValueTable.length);
|
||||
}
|
||||
|
||||
public Object put(char[] key, int start, int length, Object value) {
|
||||
|
@ -36,22 +47,39 @@ public class CharArrayObjectMap extends CharArrayMap {
|
|||
return oldvalue;
|
||||
}
|
||||
|
||||
public Object put(char[] key, Object value) {
|
||||
final public Object put(char[] key, Object value) {
|
||||
return put(key, 0, key.length, value);
|
||||
}
|
||||
|
||||
public Object get(char[] key, int start, int length) {
|
||||
final public Object get(char[] key, int start, int length) {
|
||||
int i = lookup(key, start, length);
|
||||
if (i >= 0)
|
||||
return valueTable[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object get(char[] key) {
|
||||
final public Object get(char[] key) {
|
||||
return get(key, 0, key.length);
|
||||
}
|
||||
|
||||
public Object remove(char[] key, int start, int length) {
|
||||
final public Object getAt( int i ){
|
||||
if( i < 0 || i > currEntry )
|
||||
return null;
|
||||
|
||||
char [] key = keyAt( i );
|
||||
if( key == null ) return null;
|
||||
|
||||
return get( key, 0, key.length );
|
||||
}
|
||||
|
||||
final public char[] keyAt( int i ){
|
||||
if( i < 0 || i > currEntry )
|
||||
return null;
|
||||
|
||||
return keyTable[ i ];
|
||||
}
|
||||
|
||||
final public Object remove(char[] key, int start, int length) {
|
||||
int i = lookup(key, start, length);
|
||||
if (i < 0)
|
||||
return null;
|
||||
|
@ -63,17 +91,249 @@ public class CharArrayObjectMap extends CharArrayMap {
|
|||
return value;
|
||||
}
|
||||
|
||||
public Object remove(char[] key) {
|
||||
final public Object remove(char[] key) {
|
||||
return remove(key, 0, key.length);
|
||||
}
|
||||
|
||||
protected void removeEntry(int i) {
|
||||
// Remove the entry from the valueTable, shifting everything over if necessary
|
||||
if (i < currEntry)
|
||||
public Object clone(){
|
||||
int size = capacity();
|
||||
|
||||
CharArrayObjectMap newTable = new CharArrayObjectMap( size );
|
||||
newTable.keyTable = new char[ size ][];
|
||||
newTable.hashTable = new int[ size*2 ];
|
||||
newTable.nextTable = new int[ size ];
|
||||
newTable.valueTable = new Object[ capacity() ];
|
||||
|
||||
System.arraycopy(valueTable, 0, newTable.valueTable, 0, valueTable.length);
|
||||
System.arraycopy(keyTable, 0, newTable.keyTable, 0, keyTable.length);
|
||||
System.arraycopy(hashTable, 0, newTable.hashTable, 0, hashTable.length);
|
||||
System.arraycopy(nextTable, 0, newTable.nextTable, 0, nextTable.length);
|
||||
|
||||
newTable.currEntry = currEntry;
|
||||
return newTable;
|
||||
}
|
||||
|
||||
final public int size(){
|
||||
return currEntry + 1;
|
||||
}
|
||||
|
||||
final public void clear(){
|
||||
for( int i = 0; i < keyTable.length; i++ ){
|
||||
keyTable[i] = null;
|
||||
hashTable[ 2*i ] = 0;
|
||||
hashTable[ 2*i + 1 ] = 0;
|
||||
nextTable[i] = 0;
|
||||
valueTable[i] = null;
|
||||
}
|
||||
currEntry = -1;
|
||||
}
|
||||
|
||||
final public int capacity() {
|
||||
return keyTable.length;
|
||||
}
|
||||
|
||||
final public boolean containsKey( char[] key ){
|
||||
return lookup( key, 0, key.length ) != -1;
|
||||
}
|
||||
|
||||
final public char [][] keyArray(){
|
||||
char [][] keys = new char[ size() ][];
|
||||
System.arraycopy( keyTable, 0, keys, 0, keys.length );
|
||||
return keys;
|
||||
}
|
||||
|
||||
final public boolean isEmpty(){
|
||||
return currEntry == -1;
|
||||
}
|
||||
|
||||
final public void sort( Comparator c ) {
|
||||
if( size() > 1 ){
|
||||
quickSort( c, 0, size() - 1 );
|
||||
|
||||
rehash( size(), false );
|
||||
}
|
||||
}
|
||||
|
||||
private void resize() {
|
||||
resize(keyTable.length << 1);
|
||||
}
|
||||
|
||||
private void resize(int size) {
|
||||
Object[] oldValueTable = valueTable;
|
||||
valueTable = new Object[size];
|
||||
System.arraycopy(oldValueTable, 0, valueTable, 0, oldValueTable.length);
|
||||
|
||||
Object[] oldKeyTable = keyTable;
|
||||
keyTable = new char[size][];
|
||||
System.arraycopy(oldKeyTable, 0, keyTable, 0, oldKeyTable.length);
|
||||
|
||||
// Need to rehash everything
|
||||
rehash( oldKeyTable.length, true );
|
||||
}
|
||||
|
||||
private int hash(char[] buffer, int start, int len) {
|
||||
return CharArrayUtils.hash(buffer, start, len) & (hashTable.length - 1);
|
||||
}
|
||||
|
||||
private void insert(int i) {
|
||||
insert(i, hash(keyTable[i], 0, keyTable[i].length));
|
||||
}
|
||||
private void insert(int i, int hash) {
|
||||
|
||||
if (hashTable[hash] == 0) {
|
||||
hashTable[hash] = i + 1;
|
||||
} else {
|
||||
// need to link
|
||||
int j = hashTable[hash] - 1;
|
||||
while (nextTable[j] != 0)
|
||||
j = nextTable[j] - 1;
|
||||
nextTable[j] = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void rehash( int n, boolean reallocate ){
|
||||
if( reallocate ){
|
||||
hashTable = new int[ keyTable.length * 2 ];
|
||||
nextTable = new int[ keyTable.length ];
|
||||
} else {
|
||||
for( int i = 0; i < keyTable.length; i++ ){
|
||||
hashTable[2*i] = 0;
|
||||
hashTable[2*i+1] = 0;
|
||||
nextTable[i] = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; ++i) {
|
||||
insert(i);
|
||||
}
|
||||
}
|
||||
|
||||
private int add(char[] buffer, int start, int len) {
|
||||
int hash = hash(buffer, start, len);
|
||||
|
||||
if (hashTable[hash] == 0) {
|
||||
if( (currEntry + 1) >= keyTable.length){
|
||||
//need to recompute hash for this add, recurse.
|
||||
resize();
|
||||
return add( buffer, start, len );
|
||||
}
|
||||
currEntry++;
|
||||
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
|
||||
insert(currEntry, hash);
|
||||
return currEntry;
|
||||
}
|
||||
// is the key already registered?
|
||||
int i = hashTable[hash] - 1;
|
||||
if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
|
||||
// yup
|
||||
return i;
|
||||
|
||||
// follow the next chain
|
||||
int last = i;
|
||||
for (i = nextTable[i] - 1; i >= 0; i = nextTable[i] - 1) {
|
||||
if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
|
||||
// yup this time
|
||||
return i;
|
||||
last = i;
|
||||
}
|
||||
|
||||
// nope, add it in
|
||||
if (currEntry + 1 >= keyTable.length){
|
||||
//need to recompute hash for this add, recurse
|
||||
resize();
|
||||
return add( buffer, start, len );
|
||||
}
|
||||
currEntry++;
|
||||
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
|
||||
nextTable[last] = currEntry + 1;
|
||||
return currEntry;
|
||||
}
|
||||
|
||||
private void removeEntry(int i) {
|
||||
if (i < currEntry)
|
||||
System.arraycopy(valueTable, i + 1, valueTable, i, currEntry - i);
|
||||
valueTable[currEntry] = null;
|
||||
|
||||
// Remove the hash entry
|
||||
int hash = hash(keyTable[i], 0, keyTable[i].length);
|
||||
if (hashTable[hash] == i + 1)
|
||||
hashTable[hash] = nextTable[i];
|
||||
else {
|
||||
// find entry pointing to me
|
||||
int j = hashTable[hash] - 1;
|
||||
while (nextTable[j] != 0 && nextTable[j] != i + 1)
|
||||
j = nextTable[j] - 1;
|
||||
nextTable[j] = nextTable[i];
|
||||
}
|
||||
|
||||
if (i < currEntry) {
|
||||
// shift everything over
|
||||
System.arraycopy(keyTable, i + 1, keyTable, i, currEntry - i);
|
||||
System.arraycopy(nextTable, i + 1, nextTable, i, currEntry - i);
|
||||
|
||||
// adjust hash and next entries for things that moved
|
||||
for (int j = 0; j < hashTable.length; ++j)
|
||||
if (hashTable[j] > i + 1)
|
||||
--hashTable[j];
|
||||
|
||||
// Make sure you remove the value before calling super where currEntry will change
|
||||
super.removeEntry(i);
|
||||
for (int j = 0; j < nextTable.length; ++j)
|
||||
if (nextTable[j] > i + 1)
|
||||
--nextTable[j];
|
||||
}
|
||||
|
||||
// last entry is now free
|
||||
keyTable[currEntry] = null;
|
||||
nextTable[currEntry] = 0;
|
||||
--currEntry;
|
||||
}
|
||||
|
||||
private int lookup(char[] buffer, int start, int len) {
|
||||
int hash = hash(buffer, start, len);
|
||||
|
||||
if (hashTable[hash] == 0)
|
||||
return -1;
|
||||
|
||||
int i = hashTable[hash] - 1;
|
||||
if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
|
||||
return i;
|
||||
|
||||
// Follow the next chain
|
||||
for (i = nextTable[i] - 1; i >= 0; i = nextTable[i] - 1)
|
||||
if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void quickSort( Comparator c, int p, int r ){
|
||||
if( p < r ){
|
||||
int q = partition( c, p, r );
|
||||
if( p < q ) quickSort( c, p, q );
|
||||
if( ++q < r ) quickSort( c, q, r );
|
||||
}
|
||||
}
|
||||
private int partition( Comparator c, int p, int r ){
|
||||
char[] x = keyTable[ p ];
|
||||
Object temp = null;
|
||||
int i = p;
|
||||
int j = r;
|
||||
|
||||
while( true ){
|
||||
while( c.compare( keyTable[ j ], x ) > 0 ){ j--; }
|
||||
if( i < j )
|
||||
while( c.compare( keyTable[ i ], x ) < 0 ){ i++; }
|
||||
|
||||
if( i < j ){
|
||||
temp = keyTable[j];
|
||||
keyTable[j] = keyTable[i];
|
||||
keyTable[i] = (char[]) temp;
|
||||
|
||||
temp = valueTable[j];
|
||||
valueTable[j] = valueTable[i];
|
||||
valueTable[i] = temp;
|
||||
} else {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,295 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Jul 21, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CharArraySet {
|
||||
private char[][] keyTable;
|
||||
private int[] hashTable;
|
||||
private int[] nextTable;
|
||||
|
||||
private int currEntry = -1;
|
||||
|
||||
public static final CharArraySet EMPTY_SET = new CharArraySet( 0 ){
|
||||
public Object clone() { return this; }
|
||||
public List toList() { return Collections.EMPTY_LIST; }
|
||||
public void put( char[] key ) { throw new UnsupportedOperationException(); }
|
||||
public void addAll( List list ) { throw new UnsupportedOperationException(); }
|
||||
public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); }
|
||||
};
|
||||
|
||||
public CharArraySet(int initialSize) {
|
||||
int size = 1;
|
||||
while (size < initialSize)
|
||||
size <<= 1;
|
||||
|
||||
keyTable = new char[size][];
|
||||
hashTable = new int[size * 2];
|
||||
nextTable = new int[size];
|
||||
}
|
||||
|
||||
public void put(char[] key ){
|
||||
add(key);
|
||||
}
|
||||
|
||||
public void addAll( List list ){
|
||||
if( list == null )
|
||||
return;
|
||||
|
||||
int size = list.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
add( (char[]) list.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void addAll( CharArraySet set ){
|
||||
if( set == null )
|
||||
return;
|
||||
int size = set.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
add( set.keyAt( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
public List toList(){
|
||||
List list = new ArrayList( size() );
|
||||
int size = size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
list.add( keyAt( i ) );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
final public boolean remove( char[] key ) {
|
||||
int i = lookup(key);
|
||||
if (i < 0)
|
||||
return false;
|
||||
|
||||
removeEntry(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
final public boolean isEmpty() {
|
||||
return currEntry == -1;
|
||||
}
|
||||
|
||||
// public Object clone(){
|
||||
// HashTable newTable = null;
|
||||
// try {
|
||||
// newTable = (HashTable) super.clone();
|
||||
// } catch ( CloneNotSupportedException e ) {
|
||||
// //shouldn't happen because object supports clone.
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// int size = capacity();
|
||||
// newTable.keyTable = new Object[ size ];
|
||||
// newTable.hashTable = new int[ size*2 ];
|
||||
// newTable.nextTable = new int[ size ];
|
||||
//
|
||||
// System.arraycopy(keyTable, 0, newTable.keyTable, 0, keyTable.length);
|
||||
// System.arraycopy(hashTable, 0, newTable.hashTable, 0, hashTable.length);
|
||||
// System.arraycopy(nextTable, 0, newTable.nextTable, 0, nextTable.length);
|
||||
//
|
||||
// newTable.currEntry = currEntry;
|
||||
// return newTable;
|
||||
// }
|
||||
|
||||
final public int size(){
|
||||
return currEntry + 1;
|
||||
}
|
||||
|
||||
final public char[] keyAt( int i ){
|
||||
if( i < 0 || i > currEntry )
|
||||
return null;
|
||||
|
||||
return keyTable[ i ];
|
||||
}
|
||||
|
||||
final public boolean containsKey( char[] key ){
|
||||
return lookup( key ) != -1;
|
||||
}
|
||||
|
||||
// public Object [] keyArray(){
|
||||
// Object [] keys = new Object[ size() ];
|
||||
// System.arraycopy( keyTable, 0, keys, 0, keys.length );
|
||||
// return keys;
|
||||
// }
|
||||
final public void clear(){
|
||||
for( int i = 0; i < keyTable.length; i++ ){
|
||||
keyTable[i] = null;
|
||||
hashTable[ 2*i ] = 0;
|
||||
hashTable[ 2*i + 1 ] = 0;
|
||||
nextTable[i] = 0;
|
||||
}
|
||||
currEntry = -1;
|
||||
}
|
||||
|
||||
final public int capacity() {
|
||||
return keyTable.length;
|
||||
}
|
||||
|
||||
private int hash( char[] obj ){
|
||||
return CharArrayUtils.hash( obj ) & (hashTable.length - 1);
|
||||
}
|
||||
|
||||
private void insert(int i) {
|
||||
insert(i, hash(keyTable[i]));
|
||||
}
|
||||
|
||||
private void insert(int i, int hash) {
|
||||
|
||||
if (hashTable[hash] == 0) {
|
||||
hashTable[hash] = i + 1;
|
||||
} else {
|
||||
// need to link
|
||||
int j = hashTable[hash] - 1;
|
||||
while (nextTable[j] != 0)
|
||||
j = nextTable[j] - 1;
|
||||
nextTable[j] = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void resize(int size) {
|
||||
Object[] oldKeyTable = keyTable;
|
||||
keyTable = new char[size][];
|
||||
System.arraycopy(oldKeyTable, 0, keyTable, 0, oldKeyTable.length);
|
||||
|
||||
// Need to rehash everything
|
||||
rehash( oldKeyTable.length, true );
|
||||
}
|
||||
|
||||
private void rehash( int n, boolean reallocate ){
|
||||
if( reallocate ){
|
||||
hashTable = new int[ keyTable.length * 2 ];
|
||||
nextTable = new int[ keyTable.length ];
|
||||
} else {
|
||||
for( int i = 0; i < keyTable.length; i++ ){
|
||||
hashTable[2*i] = 0;
|
||||
hashTable[2*i+1] = 0;
|
||||
nextTable[i] = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; ++i) {
|
||||
insert(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void resize() {
|
||||
resize(keyTable.length << 1);
|
||||
}
|
||||
|
||||
private int add(char[] obj) {
|
||||
int hash = hash(obj);
|
||||
|
||||
if (hashTable[hash] == 0) {
|
||||
if ( (currEntry + 1) >= keyTable.length){
|
||||
resize();
|
||||
//hash code needs to be recomputed, just recurse.
|
||||
return add( obj );
|
||||
}
|
||||
currEntry++;
|
||||
keyTable[currEntry] = obj;
|
||||
insert(currEntry, hash);
|
||||
return currEntry;
|
||||
}
|
||||
// is the key already registered?
|
||||
int i = hashTable[hash] - 1;
|
||||
if ( CharArrayUtils.equals( obj, keyTable[i] ) )
|
||||
// yup
|
||||
return i;
|
||||
|
||||
// follow the next chain
|
||||
int last = i;
|
||||
for (i = nextTable[i] - 1; i >= 0; i = nextTable[i] - 1) {
|
||||
if ( CharArrayUtils.equals( obj, keyTable[i] ) )
|
||||
// yup this time
|
||||
return i;
|
||||
last = i;
|
||||
}
|
||||
|
||||
// nope, add it in
|
||||
if ( (currEntry + 1) >= keyTable.length){
|
||||
resize();
|
||||
//hash code needs to be recomputed, just recurse.
|
||||
return add( obj );
|
||||
}
|
||||
currEntry++;
|
||||
keyTable[currEntry] = obj;
|
||||
nextTable[last] = currEntry + 1;
|
||||
return currEntry;
|
||||
}
|
||||
|
||||
private void removeEntry(int i) {
|
||||
// Remove the hash entry
|
||||
int hash = hash(keyTable[i]);
|
||||
if (hashTable[hash] == i + 1)
|
||||
hashTable[hash] = nextTable[i];
|
||||
else {
|
||||
// find entry pointing to me
|
||||
int j = hashTable[hash] - 1;
|
||||
while (nextTable[j] != 0 && nextTable[j] != i + 1)
|
||||
j = nextTable[j] - 1;
|
||||
nextTable[j] = nextTable[i];
|
||||
}
|
||||
|
||||
if (i < currEntry) {
|
||||
// shift everything over
|
||||
System.arraycopy(keyTable, i + 1, keyTable, i, currEntry - i);
|
||||
System.arraycopy(nextTable, i + 1, nextTable, i, currEntry - i);
|
||||
|
||||
// adjust hash and next entries for things that moved
|
||||
for (int j = 0; j < hashTable.length; ++j)
|
||||
if (hashTable[j] > i + 1)
|
||||
--hashTable[j];
|
||||
|
||||
for (int j = 0; j < nextTable.length; ++j)
|
||||
if (nextTable[j] > i + 1)
|
||||
--nextTable[j];
|
||||
}
|
||||
|
||||
// last entry is now free
|
||||
keyTable[currEntry] = null;
|
||||
nextTable[currEntry] = 0;
|
||||
--currEntry;
|
||||
}
|
||||
|
||||
private int lookup(char[] buffer ){
|
||||
int hash = hash(buffer);
|
||||
|
||||
if (hashTable[hash] == 0)
|
||||
return -1;
|
||||
|
||||
int i = hashTable[hash] - 1;
|
||||
if ( CharArrayUtils.equals( buffer, keyTable[i] ) )
|
||||
return i;
|
||||
|
||||
// Follow the next chain
|
||||
for (i = nextTable[i] - 1; i >= 0; i = nextTable[i] - 1)
|
||||
if ( CharArrayUtils.equals( buffer, keyTable[i] ) )
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@ public class CharArrayUtils {
|
|||
}
|
||||
|
||||
public static final boolean equals(char[] str1, int start1, int length1, char[] str2) {
|
||||
if (length1 != str2.length)
|
||||
if (length1 != str2.length || str1.length < length1 )
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < length1; ++i)
|
||||
|
@ -63,6 +63,20 @@ public class CharArrayUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static final boolean equals(char[] str1, int start1, int length1, char[] str2, boolean ignoreCase ) {
|
||||
if( !ignoreCase )
|
||||
return equals( str1, start1, length1, str2 );
|
||||
|
||||
if (length1 != str2.length || str1.length < length1 )
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < length1; ++i)
|
||||
if( Character.toLowerCase(str1[start1++]) != Character.toLowerCase( str2[i] ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final char[] extract(char[] str, int start, int length) {
|
||||
if (start == 0 && length == str.length)
|
||||
return str;
|
||||
|
@ -179,6 +193,32 @@ public class CharArrayUtils {
|
|||
return i;
|
||||
return -1;
|
||||
}
|
||||
public static final int indexOf( char[] toBeFound, char[] array ){
|
||||
if( toBeFound.length > array.length )
|
||||
return -1;
|
||||
|
||||
int j = 0;
|
||||
for( int i = 0; i < array.length; i++ ){
|
||||
if( toBeFound[j] == array[i] ){
|
||||
if( ++j == toBeFound.length )
|
||||
return i - j;
|
||||
}
|
||||
else j = 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static final int lastIndexOf(char[] toBeFound, char[] array) {
|
||||
int j = toBeFound.length - 1;
|
||||
for (int i = array.length; --i >= 0;){
|
||||
if (toBeFound[j] == array[i]){
|
||||
if( --j == -1 )
|
||||
return i;
|
||||
} else j = toBeFound.length - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
final static public char[] trim(char[] chars) {
|
||||
|
||||
if (chars == null)
|
||||
|
@ -196,4 +236,12 @@ public class CharArrayUtils {
|
|||
}
|
||||
return chars;
|
||||
}
|
||||
|
||||
|
||||
final static public char[] lastSegment(char[] array, char[] separator) {
|
||||
int pos = lastIndexOf(separator, array);
|
||||
if (pos < 0)
|
||||
return array;
|
||||
return subarray(array, pos + separator.length, array.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ObjectMap extends HashTable{
|
|||
return newMap;
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
final public void clear(){
|
||||
super.clear();
|
||||
for( int i = 0; i < valueTable.length; i++ ){
|
||||
valueTable[i] = null;
|
||||
|
@ -65,25 +65,25 @@ public class ObjectMap extends HashTable{
|
|||
return oldvalue;
|
||||
}
|
||||
|
||||
public Object get(Object key) {
|
||||
final public Object get(Object key) {
|
||||
int i = lookup(key);
|
||||
if (i >= 0)
|
||||
return valueTable[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getAt( int i ){
|
||||
final public Object getAt( int i ){
|
||||
if( i < 0 || i > currEntry )
|
||||
return null;
|
||||
|
||||
return get( keyAt( i ) );
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
final public boolean isEmpty(){
|
||||
return currEntry == -1;
|
||||
}
|
||||
|
||||
public Object remove( Object key ) {
|
||||
final public Object remove( Object key ) {
|
||||
int i = lookup(key);
|
||||
if (i < 0)
|
||||
return null;
|
||||
|
@ -94,7 +94,7 @@ public class ObjectMap extends HashTable{
|
|||
return value;
|
||||
}
|
||||
|
||||
protected void removeEntry(int i) {
|
||||
final protected void removeEntry(int i) {
|
||||
// Remove the entry from the valueTable, shifting everything over if necessary
|
||||
if (i < currEntry)
|
||||
System.arraycopy(valueTable, i + 1, valueTable, i, currEntry - i);
|
||||
|
@ -104,7 +104,7 @@ public class ObjectMap extends HashTable{
|
|||
super.removeEntry(i);
|
||||
}
|
||||
|
||||
public void sort( Comparator c ) {
|
||||
final public void sort( Comparator c ) {
|
||||
if( size() > 1 ){
|
||||
quickSort( c, 0, size() - 1 );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue