mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Refactoring pst.TypeInfo for memory performance. see parser.changelog
this is a small step toward a faster parser (see bugs 59468, 54040, 60902, et al)
This commit is contained in:
parent
04c74b6af0
commit
c9c666335f
38 changed files with 2952 additions and 2520 deletions
|
@ -1887,8 +1887,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( "typedef int DWORD;\n" ); //$NON-NLS-1$
|
writer.write( "typedef int DWORD;\n" ); //$NON-NLS-1$
|
||||||
writer.write( "typedef char BYTE;\n"); //$NON-NLS-1$
|
writer.write( "typedef char BYTE;\n"); //$NON-NLS-1$
|
||||||
writer.write( "#define MAKEFOURCC(ch0, ch1, ch2, ch3) \\n"); //$NON-NLS-1$
|
writer.write( "#define MAKEFOURCC(ch0, ch1, ch2, ch3) \\\n"); //$NON-NLS-1$
|
||||||
writer.write( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\n"); //$NON-NLS-1$
|
writer.write( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\\n"); //$NON-NLS-1$
|
||||||
writer.write( "((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$
|
writer.write( "((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$
|
||||||
writer.write( "enum e {\n"); //$NON-NLS-1$
|
writer.write( "enum e {\n"); //$NON-NLS-1$
|
||||||
writer.write( "blah1 = 5,\n"); //$NON-NLS-1$
|
writer.write( "blah1 = 5,\n"); //$NON-NLS-1$
|
||||||
|
|
|
@ -1125,8 +1125,8 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write( "typedef int DWORD;\n" ); //$NON-NLS-1$
|
writer.write( "typedef int DWORD;\n" ); //$NON-NLS-1$
|
||||||
writer.write( "typedef char BYTE;\n"); //$NON-NLS-1$
|
writer.write( "typedef char BYTE;\n"); //$NON-NLS-1$
|
||||||
writer.write( "#define MAKEFOURCC(ch0, ch1, ch2, ch3) \\n"); //$NON-NLS-1$
|
writer.write( "#define MAKEFOURCC(ch0, ch1, ch2, ch3) \\\n"); //$NON-NLS-1$
|
||||||
writer.write( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\n"); //$NON-NLS-1$
|
writer.write( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\\n"); //$NON-NLS-1$
|
||||||
writer.write( "((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$
|
writer.write( "((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$
|
||||||
writer.write( "enum e {\n"); //$NON-NLS-1$
|
writer.write( "enum e {\n"); //$NON-NLS-1$
|
||||||
writer.write( "blah1 = 5,\n"); //$NON-NLS-1$
|
writer.write( "blah1 = 5,\n"); //$NON-NLS-1$
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,17 @@
|
||||||
|
2004-07-07 Andrew Niefer
|
||||||
|
Symbol Table Refactoring:
|
||||||
|
- TypeInfo._typeDeclaration is no longer used for forward declarations, instead BasicSymbol._instantiatedSymbol
|
||||||
|
has been renamed to _symbolDef and is used for forwarding and also for its original template purpose.
|
||||||
|
- TypeInfo._operatorExpressions has been removed. You now apply operator expressions directly to the TypeInfo
|
||||||
|
with TypeInfo.applyOperatorExpression.
|
||||||
|
- a new interface ITypeInfo has been created. This interface should now be used instead of TypeInfo.
|
||||||
|
- the old TypeInfo has been separated into BasicTypeInfo, TypeInfo, and TemplateParameterTypeInfo, as well as dynamic
|
||||||
|
overrides of these classes.
|
||||||
|
- all construction of TypeInfo objects should now be done through TypeInfoProvider.newTypeInfo( ... ) functions
|
||||||
|
to ensure the object obtain has the needed fields.
|
||||||
|
The sum total of these changes is a reduction of memory used while parsing the combination of stdio.h,
|
||||||
|
iostream, and windows.h by about 4 Megs.
|
||||||
|
|
||||||
2004-06-22 Alain Magloire
|
2004-06-22 Alain Magloire
|
||||||
|
|
||||||
Part of PR 68246.
|
Part of PR 68246.
|
||||||
|
|
|
@ -257,7 +257,54 @@ public interface IASTExpression extends ISourceElementCallbackDelegate, IASTNode
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBasicType(){
|
||||||
|
if(this == PRIMARY_EMPTY
|
||||||
|
|| this == THROWEXPRESSION
|
||||||
|
|| this == POSTFIX_DOT_DESTRUCTOR
|
||||||
|
|| this == POSTFIX_ARROW_DESTRUCTOR
|
||||||
|
|| this == DELETE_CASTEXPRESSION
|
||||||
|
|| this == DELETE_VECTORCASTEXPRESSION
|
||||||
|
|| this == PRIMARY_INTEGER_LITERAL
|
||||||
|
|| this == POSTFIX_SIMPLETYPE_INT
|
||||||
|
|| this == UNARY_SIZEOF_TYPEID
|
||||||
|
|| this == UNARY_SIZEOF_UNARYEXPRESSION
|
||||||
|
|| this == PRIMARY_CHAR_LITERAL
|
||||||
|
|| this == POSTFIX_SIMPLETYPE_CHAR
|
||||||
|
|| this == PRIMARY_STRING_LITERAL
|
||||||
|
|| this == PRIMARY_FLOAT_LITERAL
|
||||||
|
|| this == POSTFIX_SIMPLETYPE_FLOAT
|
||||||
|
|| this == POSTFIX_SIMPLETYPE_DOUBLE
|
||||||
|
|| this == POSTFIX_SIMPLETYPE_WCHART
|
||||||
|
|| this == PRIMARY_BOOLEAN_LITERAL
|
||||||
|
|| this == POSTFIX_SIMPLETYPE_BOOL
|
||||||
|
|| this == RELATIONAL_GREATERTHAN
|
||||||
|
|| this == RELATIONAL_GREATERTHANEQUALTO
|
||||||
|
|| this == RELATIONAL_LESSTHAN
|
||||||
|
|| this == RELATIONAL_LESSTHANEQUALTO
|
||||||
|
|| this == EQUALITY_EQUALS
|
||||||
|
|| this == EQUALITY_NOTEQUALS
|
||||||
|
|| this == LOGICALANDEXPRESSION
|
||||||
|
|| this == LOGICALOREXPRESSION
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public boolean isPostfixSimpleType(){
|
||||||
|
if((this == POSTFIX_SIMPLETYPE_INT)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_SHORT)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_DOUBLE)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_FLOAT)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_CHAR)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_WCHART)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_SIGNED)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_UNSIGNED)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_BOOL)
|
||||||
|
|| (this == POSTFIX_SIMPLETYPE_LONG) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IASTNewExpressionDescriptor extends ISourceElementCallbackDelegate
|
public interface IASTNewExpressionDescriptor extends ISourceElementCallbackDelegate
|
||||||
|
|
|
@ -23,8 +23,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -53,7 +53,7 @@ public interface IASTFactoryExtension {
|
||||||
* @param typeId
|
* @param typeId
|
||||||
* @return TODO
|
* @return TODO
|
||||||
*/
|
*/
|
||||||
public TypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId);
|
public ITypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId);
|
||||||
|
|
||||||
public boolean overrideCreateSimpleTypeSpecifierMethod(Type type);
|
public boolean overrideCreateSimpleTypeSpecifierMethod(Type type);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,9 @@ import org.eclipse.cdt.internal.core.parser.ast.complete.gcc.GCCASTCompleteExten
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.expression.GCCASTExpressionExtension;
|
import org.eclipse.cdt.internal.core.parser.ast.expression.GCCASTExpressionExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.gcc.ASTGCCDesignator;
|
import org.eclipse.cdt.internal.core.parser.ast.gcc.ASTGCCDesignator;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -68,35 +69,34 @@ public abstract class GCCASTExtension implements IASTFactoryExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#getExpressionResultType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo, 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.internal.core.parser.pst.ISymbol)
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#getExpressionResultType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo, 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.internal.core.parser.pst.ISymbol)
|
||||||
*/
|
*/
|
||||||
public TypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId) {
|
public ITypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId) {
|
||||||
TypeInfo info = null;
|
ITypeInfo info = null;
|
||||||
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID ||
|
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID ||
|
||||||
kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||||
{
|
{
|
||||||
info = new TypeInfo();
|
info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int );
|
||||||
info.setType(TypeInfo.t_int);
|
info.setBit(true, ITypeInfo.isUnsigned);
|
||||||
info.setBit(true, TypeInfo.isUnsigned);
|
|
||||||
}
|
}
|
||||||
else if( kind == IASTGCCExpression.Kind.RELATIONAL_MAX ||
|
else if( kind == IASTGCCExpression.Kind.RELATIONAL_MAX ||
|
||||||
kind == IASTGCCExpression.Kind.RELATIONAL_MIN )
|
kind == IASTGCCExpression.Kind.RELATIONAL_MIN )
|
||||||
{
|
{
|
||||||
if( lhs instanceof ASTExpression )
|
if( lhs instanceof ASTExpression )
|
||||||
info = new TypeInfo( ((ASTExpression)lhs).getResultType().getResult() );
|
info = TypeInfoProvider.newTypeInfo( ((ASTExpression)lhs).getResultType().getResult() );
|
||||||
}
|
}
|
||||||
else if( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_TYPEID )
|
else if( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_TYPEID )
|
||||||
{
|
{
|
||||||
if( typeId instanceof ASTTypeId )
|
if( typeId instanceof ASTTypeId )
|
||||||
info = new TypeInfo( ((ASTTypeId)typeId).getTypeSymbol().getTypeInfo() );
|
info = TypeInfoProvider.newTypeInfo( ((ASTTypeId)typeId).getTypeSymbol().getTypeInfo() );
|
||||||
}
|
}
|
||||||
else if ( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_UNARYEXPRESSION )
|
else if ( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_UNARYEXPRESSION )
|
||||||
{
|
{
|
||||||
if( lhs instanceof ASTExpression )
|
if( lhs instanceof ASTExpression )
|
||||||
info = new TypeInfo( ((ASTExpression)lhs).getResultType().getResult() );
|
info = TypeInfoProvider.newTypeInfo( ((ASTExpression)lhs).getResultType().getResult() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( info != null )
|
if( info != null )
|
||||||
return info;
|
return info;
|
||||||
return new TypeInfo();
|
return TypeInfoProvider.newTypeInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -23,8 +23,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider;
|
import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -177,13 +177,13 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression
|
||||||
|
|
||||||
public IContainerSymbol getLookupQualificationSymbol() throws LookupError {
|
public IContainerSymbol getLookupQualificationSymbol() throws LookupError {
|
||||||
ExpressionResult result = getResultType();
|
ExpressionResult result = getResultType();
|
||||||
TypeInfo type = (result != null ) ? result.getResult() : null;
|
ITypeInfo type = (result != null ) ? result.getResult() : null;
|
||||||
IContainerSymbol containerSymbol = null;
|
IContainerSymbol containerSymbol = null;
|
||||||
|
|
||||||
if( type != null && type.getTypeSymbol() != null ){
|
if( type != null && type.getTypeSymbol() != null ){
|
||||||
TypeInfoProvider provider = type.getTypeSymbol().getSymbolTable().getTypeInfoProvider();
|
TypeInfoProvider provider = type.getTypeSymbol().getSymbolTable().getTypeInfoProvider();
|
||||||
type = type.getFinalType( provider );
|
type = type.getFinalType( provider );
|
||||||
if( type.isType( TypeInfo.t_type ) &&
|
if( type.isType( ITypeInfo.t_type ) &&
|
||||||
type.getTypeSymbol() != null && type.getTypeSymbol() instanceof IContainerSymbol )
|
type.getTypeSymbol() != null && type.getTypeSymbol() instanceof IContainerSymbol )
|
||||||
{
|
{
|
||||||
containerSymbol = (IContainerSymbol) type.getTypeSymbol();
|
containerSymbol = (IContainerSymbol) type.getTypeSymbol();
|
||||||
|
@ -196,15 +196,15 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression
|
||||||
|
|
||||||
public boolean shouldFilterLookupResult( ISymbol symbol ){
|
public boolean shouldFilterLookupResult( ISymbol symbol ){
|
||||||
ExpressionResult result = getResultType();
|
ExpressionResult result = getResultType();
|
||||||
TypeInfo type = ( result != null ) ? result.getResult() : null;
|
ITypeInfo type = ( result != null ) ? result.getResult() : null;
|
||||||
if( type != null ){
|
if( type != null ){
|
||||||
boolean answer = false;
|
boolean answer = false;
|
||||||
TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider();
|
TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider();
|
||||||
type = type.getFinalType( provider );
|
type = type.getFinalType( provider );
|
||||||
if( type.checkBit( TypeInfo.isConst ) && !symbol.getTypeInfo().checkBit( TypeInfo.isConst ) )
|
if( type.checkBit( ITypeInfo.isConst ) && !symbol.getTypeInfo().checkBit( ITypeInfo.isConst ) )
|
||||||
answer = true;
|
answer = true;
|
||||||
|
|
||||||
if( type.checkBit( TypeInfo.isVolatile ) && !symbol.getTypeInfo().checkBit( TypeInfo.isVolatile ) )
|
if( type.checkBit( ITypeInfo.isVolatile ) && !symbol.getTypeInfo().checkBit( ITypeInfo.isVolatile ) )
|
||||||
answer = true;
|
answer = true;
|
||||||
|
|
||||||
provider.returnTypeInfo( type );
|
provider.returnTypeInfo( type );
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -79,7 +79,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
||||||
*/
|
*/
|
||||||
public boolean isInline()
|
public boolean isInline()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isInline );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isInline );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#isFriend()
|
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#isFriend()
|
||||||
|
@ -93,7 +93,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
||||||
*/
|
*/
|
||||||
public boolean isStatic()
|
public boolean isStatic()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isStatic );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isStatic );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
|
||||||
|
|
|
@ -27,11 +27,11 @@ import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableError;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableError;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeFilter;
|
import org.eclipse.cdt.internal.core.parser.pst.TypeFilter;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -78,14 +78,14 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
||||||
*/
|
*/
|
||||||
public boolean isVirtual()
|
public boolean isVirtual()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isVirtual );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isVirtual );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isExplicit()
|
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isExplicit()
|
||||||
*/
|
*/
|
||||||
public boolean isExplicit()
|
public boolean isExplicit()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isExplicit);
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isExplicit);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConstructor()
|
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConstructor()
|
||||||
|
@ -106,14 +106,14 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
||||||
*/
|
*/
|
||||||
public boolean isConst()
|
public boolean isConst()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isConst);
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isConst);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVolatile()
|
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVolatile()
|
||||||
*/
|
*/
|
||||||
public boolean isVolatile()
|
public boolean isVolatile()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isVolatile );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isVolatile );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isPureVirtual()
|
* @see org.eclipse.cdt.core.parser.ast.IASTMethod#isPureVirtual()
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ReferenceCache.ASTReference;
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ReferenceCache.ASTReference;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -49,23 +49,23 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
||||||
*/
|
*/
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
if( symbol.getType() == TypeInfo.t_int )
|
if( symbol.getType() == ITypeInfo.t_int )
|
||||||
return IASTSimpleTypeSpecifier.Type.INT;
|
return IASTSimpleTypeSpecifier.Type.INT;
|
||||||
if( symbol.getType() == TypeInfo.t_double )
|
if( symbol.getType() == ITypeInfo.t_double )
|
||||||
return IASTSimpleTypeSpecifier.Type.DOUBLE;
|
return IASTSimpleTypeSpecifier.Type.DOUBLE;
|
||||||
if( symbol.getType() == TypeInfo.t_float )
|
if( symbol.getType() == ITypeInfo.t_float )
|
||||||
return IASTSimpleTypeSpecifier.Type.FLOAT;
|
return IASTSimpleTypeSpecifier.Type.FLOAT;
|
||||||
if( symbol.getType() == TypeInfo.t_bool )
|
if( symbol.getType() == ITypeInfo.t_bool )
|
||||||
return IASTSimpleTypeSpecifier.Type.BOOL;
|
return IASTSimpleTypeSpecifier.Type.BOOL;
|
||||||
if( symbol.getType() == TypeInfo.t_type )
|
if( symbol.getType() == ITypeInfo.t_type )
|
||||||
return IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
return IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||||
if( symbol.getType() == TypeInfo.t_char )
|
if( symbol.getType() == ITypeInfo.t_char )
|
||||||
return IASTSimpleTypeSpecifier.Type.CHAR;
|
return IASTSimpleTypeSpecifier.Type.CHAR;
|
||||||
if( symbol.getType() == TypeInfo.t_void )
|
if( symbol.getType() == ITypeInfo.t_void )
|
||||||
return IASTSimpleTypeSpecifier.Type.VOID;
|
return IASTSimpleTypeSpecifier.Type.VOID;
|
||||||
if( symbol.getType() == TypeInfo.t_wchar_t)
|
if( symbol.getType() == ITypeInfo.t_wchar_t)
|
||||||
return IASTSimpleTypeSpecifier.Type.WCHAR_T;
|
return IASTSimpleTypeSpecifier.Type.WCHAR_T;
|
||||||
if( symbol.getType() == TypeInfo.t__Bool )
|
if( symbol.getType() == ITypeInfo.t__Bool )
|
||||||
return IASTSimpleTypeSpecifier.Type._BOOL;
|
return IASTSimpleTypeSpecifier.Type._BOOL;
|
||||||
|
|
||||||
return IASTSimpleTypeSpecifier.Type.UNSPECIFIED;
|
return IASTSimpleTypeSpecifier.Type.UNSPECIFIED;
|
||||||
|
@ -83,28 +83,28 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
||||||
*/
|
*/
|
||||||
public boolean isLong()
|
public boolean isLong()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isLong );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isLong );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isShort()
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isShort()
|
||||||
*/
|
*/
|
||||||
public boolean isShort()
|
public boolean isShort()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isShort );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isShort );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isSigned()
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isSigned()
|
||||||
*/
|
*/
|
||||||
public boolean isSigned()
|
public boolean isSigned()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isSigned);
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isSigned);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isUnsigned()
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isUnsigned()
|
||||||
*/
|
*/
|
||||||
public boolean isUnsigned()
|
public boolean isUnsigned()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isUnsigned );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isUnsigned );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isTypename()
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isTypename()
|
||||||
|
@ -139,7 +139,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
||||||
*/
|
*/
|
||||||
public boolean isComplex()
|
public boolean isComplex()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isComplex );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isComplex );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -147,7 +147,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
||||||
*/
|
*/
|
||||||
public boolean isImaginary()
|
public boolean isImaginary()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isImaginary );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isImaginary );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -15,9 +15,9 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableError;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableError;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -44,8 +44,8 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
|
||||||
public IContainerSymbol getLookupQualificationSymbol() throws LookupError {
|
public IContainerSymbol getLookupQualificationSymbol() throws LookupError {
|
||||||
ISymbol sym = getSymbol();
|
ISymbol sym = getSymbol();
|
||||||
IContainerSymbol result = null;
|
IContainerSymbol result = null;
|
||||||
ParserSymbolTable.TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider();
|
TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider();
|
||||||
TypeInfo info = null;
|
ITypeInfo info = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
info = sym.getTypeInfo().getFinalType( provider );
|
info = sym.getTypeInfo().getFinalType( provider );
|
||||||
|
@ -53,7 +53,7 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
|
||||||
throw new LookupError();
|
throw new LookupError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() != null && info.getTypeSymbol() instanceof IContainerSymbol )
|
if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol() != null && info.getTypeSymbol() instanceof IContainerSymbol )
|
||||||
result = (IContainerSymbol) info.getTypeSymbol();
|
result = (IContainerSymbol) info.getTypeSymbol();
|
||||||
else if( sym instanceof IContainerSymbol )
|
else if( sym instanceof IContainerSymbol )
|
||||||
result = (IContainerSymbol) sym;
|
result = (IContainerSymbol) sym;
|
||||||
|
@ -64,18 +64,18 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
|
||||||
|
|
||||||
public boolean shouldFilterLookupResult( ISymbol sym ){
|
public boolean shouldFilterLookupResult( ISymbol sym ){
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
ParserSymbolTable.TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider();
|
TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider();
|
||||||
TypeInfo info = null;
|
ITypeInfo info = null;
|
||||||
try{
|
try{
|
||||||
info = getSymbol().getTypeInfo().getFinalType( provider );
|
info = getSymbol().getTypeInfo().getFinalType( provider );
|
||||||
} catch( ParserSymbolTableError e ){
|
} catch( ParserSymbolTableError e ){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( info.checkBit( TypeInfo.isConst ) && !sym.getTypeInfo().checkBit( TypeInfo.isConst ) )
|
if( info.checkBit( ITypeInfo.isConst ) && !sym.getTypeInfo().checkBit( ITypeInfo.isConst ) )
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
if( info.checkBit( TypeInfo.isVolatile ) && !sym.getTypeInfo().checkBit( TypeInfo.isVolatile ) )
|
if( info.checkBit( ITypeInfo.isVolatile ) && !sym.getTypeInfo().checkBit( ITypeInfo.isVolatile ) )
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
provider.returnTypeInfo( info );
|
provider.returnTypeInfo( info );
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -67,11 +67,11 @@ public class ASTTemplateParameter extends ASTSymbol implements IASTTemplateParam
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getTemplateParameterKind()
|
* @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getTemplateParameterKind()
|
||||||
*/
|
*/
|
||||||
public ParamKind getTemplateParameterKind() {
|
public ParamKind getTemplateParameterKind() {
|
||||||
TypeInfo.eType type = symbol.getTypeInfo().getTemplateParameterType();
|
ITypeInfo.eType type = symbol.getTypeInfo().getTemplateParameterType();
|
||||||
if( type == TypeInfo.t_typeName )
|
if( type == ITypeInfo.t_typeName )
|
||||||
//TODO: difference between class & typename?
|
//TODO: difference between class & typename?
|
||||||
return ParamKind.TYPENAME;
|
return ParamKind.TYPENAME;
|
||||||
else if( type == TypeInfo.t_template )
|
else if( type == ITypeInfo.t_template )
|
||||||
return ParamKind.TEMPLATE_LIST;
|
return ParamKind.TEMPLATE_LIST;
|
||||||
else
|
else
|
||||||
return ParamKind.PARAMETER;
|
return ParamKind.PARAMETER;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.parser.ast.IReferenceManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -64,35 +64,35 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
|
||||||
*/
|
*/
|
||||||
public boolean isAuto()
|
public boolean isAuto()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isAuto );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isAuto );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isRegister()
|
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isRegister()
|
||||||
*/
|
*/
|
||||||
public boolean isRegister()
|
public boolean isRegister()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isRegister);
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isRegister);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isStatic()
|
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isStatic()
|
||||||
*/
|
*/
|
||||||
public boolean isStatic()
|
public boolean isStatic()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isStatic);
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isStatic);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isExtern()
|
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isExtern()
|
||||||
*/
|
*/
|
||||||
public boolean isExtern()
|
public boolean isExtern()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isExtern );
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isExtern );
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isMutable()
|
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isMutable()
|
||||||
*/
|
*/
|
||||||
public boolean isMutable()
|
public boolean isMutable()
|
||||||
{
|
{
|
||||||
return symbol.getTypeInfo().checkBit( TypeInfo.isMutable);
|
return symbol.getTypeInfo().checkBit( ITypeInfo.isMutable);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#getAbstractDeclaration()
|
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#getAbstractDeclaration()
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,8 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hamer
|
* @author hamer
|
||||||
|
@ -19,26 +20,26 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||||
public class ExpressionResult {
|
public class ExpressionResult {
|
||||||
|
|
||||||
|
|
||||||
private TypeInfo result;
|
private ITypeInfo result;
|
||||||
private boolean failedToDereference = false;
|
private boolean failedToDereference = false;
|
||||||
|
|
||||||
ExpressionResult(){
|
ExpressionResult(){
|
||||||
result = new TypeInfo();
|
result = TypeInfoProvider.newTypeInfo();
|
||||||
}
|
}
|
||||||
ExpressionResult(TypeInfo result){
|
ExpressionResult(ITypeInfo result){
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TypeInfo getResult() {
|
public ITypeInfo getResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
public void setResult(TypeInfo info) {
|
public void setResult(ITypeInfo info) {
|
||||||
result = info;
|
result = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hamer
|
* @author hamer
|
||||||
|
@ -27,15 +27,15 @@ public class ExpressionResultList extends ExpressionResult {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionResult#getResult()
|
* @see org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionResult#getResult()
|
||||||
*/
|
*/
|
||||||
public TypeInfo getResult() {
|
public ITypeInfo getResult() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return (TypeInfo)resultList.get(0);
|
return (ITypeInfo)resultList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionResult#setResult(org.eclipse.cdt.internal.core.parser.pst.TypeInfo)
|
* @see org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionResult#setResult(org.eclipse.cdt.internal.core.parser.pst.TypeInfo)
|
||||||
*/
|
*/
|
||||||
public void setResult(TypeInfo info) {
|
public void setResult(ITypeInfo info) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
resultList.add(info);
|
resultList.add(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,28 +16,19 @@ package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
{
|
{
|
||||||
|
|
||||||
public BasicSymbol( ParserSymbolTable table, String name ){
|
public BasicSymbol( ParserSymbolTable table, String name ){
|
||||||
super( table );
|
super( table );
|
||||||
_name = name;
|
_name = name;
|
||||||
_typeInfo = new TypeInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){
|
public BasicSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo )
|
||||||
super( table, obj );
|
|
||||||
_name = name;
|
|
||||||
_typeInfo = new TypeInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BasicSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo )
|
|
||||||
{
|
{
|
||||||
super( table );
|
super( table );
|
||||||
_name = name;
|
_name = name;
|
||||||
_typeInfo = new TypeInfo( typeInfo, 0, null );
|
_typeInfo = TypeInfoProvider.newTypeInfo( typeInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||||
|
@ -60,27 +51,27 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
_depth = scope.getDepth() + 1;
|
_depth = scope.getDepth() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(TypeInfo.eType t){
|
public void setType(ITypeInfo.eType t){
|
||||||
getTypeInfo().setType( t );
|
getTypeInfo().setType( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInfo.eType getType(){
|
public ITypeInfo.eType getType(){
|
||||||
return getTypeInfo().getType();
|
return getTypeInfo().getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type ){
|
public boolean isType( ITypeInfo.eType type ){
|
||||||
return getTypeInfo().isType( type, TypeInfo.t_undef );
|
return getTypeInfo().isType( type, ITypeInfo.t_undef );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ){
|
public boolean isType( ITypeInfo.eType type, ITypeInfo.eType upperType ){
|
||||||
return getTypeInfo().isType( type, upperType );
|
return getTypeInfo().isType( type, upperType );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISymbol getTypeSymbol(){
|
public ISymbol getTypeSymbol(){
|
||||||
ISymbol symbol = getTypeInfo().getTypeSymbol();
|
ISymbol symbol = getTypeInfo().getTypeSymbol();
|
||||||
|
|
||||||
if( symbol != null && symbol.getTypeInfo().isForwardDeclaration() && symbol.getTypeSymbol() != null ){
|
if( symbol != null && symbol.isForwardDeclaration() && symbol.getForwardSymbol() != null ){
|
||||||
return symbol.getTypeSymbol();
|
return symbol.getForwardSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
return symbol;
|
return symbol;
|
||||||
|
@ -90,22 +81,27 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
getTypeInfo().setTypeSymbol( type );
|
getTypeInfo().setTypeSymbol( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInfo getTypeInfo(){
|
public ITypeInfo getTypeInfo(){
|
||||||
return _typeInfo;
|
return ( _typeInfo != null ) ? _typeInfo : (_typeInfo = new TypeInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeInfo( TypeInfo info ) {
|
public void setTypeInfo( ITypeInfo info ) {
|
||||||
_typeInfo = info;
|
_typeInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isForwardDeclaration(){
|
public boolean isForwardDeclaration(){
|
||||||
return getTypeInfo().isForwardDeclaration();
|
return _isForwardDeclaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsForwardDeclaration( boolean forward ){
|
public void setIsForwardDeclaration( boolean forward ){
|
||||||
getTypeInfo().setIsForwardDeclaration( forward );
|
_isForwardDeclaration = forward;
|
||||||
|
}
|
||||||
|
public void setForwardSymbol( ISymbol forward ){
|
||||||
|
_symbolDef = forward;
|
||||||
|
}
|
||||||
|
public ISymbol getForwardSymbol(){
|
||||||
|
return (_isForwardDeclaration || isType( ITypeInfo.t_namespace) ) ? _symbolDef : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns 0 if same, non zero otherwise
|
* returns 0 if same, non zero otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -118,10 +114,10 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
} else if( size == 0 )
|
} else if( size == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
ITypeInfo.PtrOp op1 = null, op2 = null;
|
||||||
for( int i = 0; i > size; i++ ){
|
for( int i = 0; i > size; i++ ){
|
||||||
op1 = (TypeInfo.PtrOp)symbol.getTypeInfo().getPtrOperators().get(i);
|
op1 = (ITypeInfo.PtrOp)symbol.getTypeInfo().getPtrOperators().get(i);
|
||||||
op2 = (TypeInfo.PtrOp)getTypeInfo().getPtrOperators().get(i);
|
op2 = (ITypeInfo.PtrOp)getTypeInfo().getPtrOperators().get(i);
|
||||||
|
|
||||||
if( op1.compareCVTo( op2 ) != 0 ){
|
if( op1.compareCVTo( op2 ) != 0 ){
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -135,7 +131,7 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
public List getPtrOperators(){
|
public List getPtrOperators(){
|
||||||
return getTypeInfo().getPtrOperators();
|
return getTypeInfo().getPtrOperators();
|
||||||
}
|
}
|
||||||
public void addPtrOperator( TypeInfo.PtrOp ptrOp ){
|
public void addPtrOperator( ITypeInfo.PtrOp ptrOp ){
|
||||||
getTypeInfo().addPtrOperator( ptrOp );
|
getTypeInfo().addPtrOperator( ptrOp );
|
||||||
}
|
}
|
||||||
public void preparePtrOperatros(int numPtrOps) {
|
public void preparePtrOperatros(int numPtrOps) {
|
||||||
|
@ -154,13 +150,13 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
_isTemplateMember = isMember;
|
_isTemplateMember = isMember;
|
||||||
}
|
}
|
||||||
public boolean isTemplateInstance(){
|
public boolean isTemplateInstance(){
|
||||||
return ( _instantiatedSymbol != null );
|
return ( _symbolDef != null );
|
||||||
}
|
}
|
||||||
public ISymbol getInstantiatedSymbol(){
|
public ISymbol getInstantiatedSymbol(){
|
||||||
return _instantiatedSymbol;
|
return _symbolDef;
|
||||||
}
|
}
|
||||||
public void setInstantiatedSymbol( ISymbol symbol ){
|
public void setInstantiatedSymbol( ISymbol symbol ){
|
||||||
_instantiatedSymbol = symbol;
|
_symbolDef = symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsInvisible(){
|
public boolean getIsInvisible(){
|
||||||
|
@ -171,13 +167,14 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
private String _name; //our name
|
private String _name; //our name
|
||||||
private TypeInfo _typeInfo; //our type info
|
private ITypeInfo _typeInfo; //our type info
|
||||||
private int _depth; //how far down the scope stack we are
|
private int _depth; //how far down the scope stack we are
|
||||||
|
|
||||||
private boolean _isInvisible = false; //used by friend declarations (11.4-9)
|
private boolean _isInvisible = false; //used by friend declarations (11.4-9)
|
||||||
|
|
||||||
private boolean _isTemplateMember = false;
|
private boolean _isTemplateMember = false;
|
||||||
private ISymbol _instantiatedSymbol = null;
|
private boolean _isForwardDeclaration = false;
|
||||||
|
private ISymbol _symbolDef = null; //used for forward declarations and template instantiations
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -186,7 +183,7 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
|
|
||||||
BasicSymbol s = (BasicSymbol) super.clone();
|
BasicSymbol s = (BasicSymbol) super.clone();
|
||||||
s._typeInfo = new TypeInfo( s._typeInfo );
|
s._typeInfo = TypeInfoProvider.newTypeInfo( s._typeInfo );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,309 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 5, 2004
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public class BasicTypeInfo implements ITypeInfo {
|
||||||
|
|
||||||
|
public void setBit( boolean b, int mask ) {
|
||||||
|
if( b ){
|
||||||
|
_typeBits = _typeBits | mask;
|
||||||
|
} else {
|
||||||
|
_typeBits = _typeBits & ~mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkBit( int mask ) {
|
||||||
|
return (_typeBits & mask) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType( ITypeInfo.eType t ) {
|
||||||
|
_type = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITypeInfo.eType getType() {
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isType( ITypeInfo.eType type ) {
|
||||||
|
return isType( type, t_undef );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTypeBits() {
|
||||||
|
return _typeBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeBits( int typeInfo ) {
|
||||||
|
_typeBits = typeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param infoProvider - TypeInfoProvider to use if pooling the TypeInfo created, if null,
|
||||||
|
* pooling is not used. If pooling is used, TypeInfoProvider.returnTypeInfo
|
||||||
|
* must be called when the TypeInfo is no longer needed
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ITypeInfo getFinalType( TypeInfoProvider infoProvider ) {
|
||||||
|
return ParserSymbolTable.getFlatTypeInfo( this, infoProvider );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param upperType
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
* type checking, check that this declaration's type is between type and
|
||||||
|
* upperType (inclusive). upperType of 0 means no range and our type must
|
||||||
|
* be type.
|
||||||
|
*/
|
||||||
|
public boolean isType( ITypeInfo.eType type, ITypeInfo.eType upperType ) {
|
||||||
|
//type of -1 means we don't care
|
||||||
|
if( type == t_any )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//upperType of 0 means no range
|
||||||
|
if( upperType == t_undef ){
|
||||||
|
return ( getType() == type );
|
||||||
|
}
|
||||||
|
return ( getType().compareTo( type ) >= 0 && getType().compareTo( upperType ) <= 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasPtrOperators() {
|
||||||
|
return _ptrOperators.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getPtrOperators() {
|
||||||
|
return _ptrOperators;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSamePtrs( ITypeInfo type ) {
|
||||||
|
int size = getPtrOperators().size();
|
||||||
|
int size2 = type.getPtrOperators().size();
|
||||||
|
ITypeInfo.PtrOp ptr1 = null, ptr2 = null;
|
||||||
|
|
||||||
|
if( size == size2 ){
|
||||||
|
if( size > 0 ){
|
||||||
|
for( int i = 0; i < size; i++ ){
|
||||||
|
ptr1 = (ITypeInfo.PtrOp)getPtrOperators().get(i);
|
||||||
|
ptr2 = (ITypeInfo.PtrOp)type.getPtrOperators().get(i);
|
||||||
|
if( ptr1.getType() != ptr2.getType() ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyOperatorExpression( ITypeInfo.OperatorExpression op ) {
|
||||||
|
if( op == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( op == ITypeInfo.OperatorExpression.indirection ||
|
||||||
|
op == ITypeInfo.OperatorExpression.subscript )
|
||||||
|
{
|
||||||
|
//indirection operator, can only be applied to a pointer
|
||||||
|
//subscript should be applied to something that is "pointer to T", the result is a lvalue of type "T"
|
||||||
|
if( hasPtrOperators() ){
|
||||||
|
ListIterator iterator = getPtrOperators().listIterator( getPtrOperators().size() );
|
||||||
|
ITypeInfo.PtrOp last = (ITypeInfo.PtrOp)iterator.previous();
|
||||||
|
if( last.getType() == ITypeInfo.PtrOp.t_pointer ||
|
||||||
|
last.getType() == ITypeInfo.PtrOp.t_array )
|
||||||
|
{
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if( op == ITypeInfo.OperatorExpression.addressof ){
|
||||||
|
//Address-of unary operator, results in pointer to T
|
||||||
|
//TODO or pointer to member
|
||||||
|
ITypeInfo.PtrOp newOp = new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer );
|
||||||
|
addPtrOperator( newOp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPtrOperator( ITypeInfo.PtrOp ptr ) {
|
||||||
|
if( ptr != null ){
|
||||||
|
if( _ptrOperators == Collections.EMPTY_LIST ){
|
||||||
|
_ptrOperators = new ArrayList(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ptrOperators.add( ptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPtrOperator( List ptrs ) {
|
||||||
|
if( ptrs == null || ptrs.size() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( _ptrOperators == Collections.EMPTY_LIST ){
|
||||||
|
_ptrOperators = new ArrayList( ptrs.size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = ptrs.size();
|
||||||
|
for( int i = 0; i < size; i++ ){
|
||||||
|
_ptrOperators.add( ptrs.get( i ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void preparePtrOperators( int numPtrOps ) {
|
||||||
|
if( _ptrOperators == Collections.EMPTY_LIST )
|
||||||
|
_ptrOperators = new ArrayList( numPtrOps );
|
||||||
|
else
|
||||||
|
((ArrayList) _ptrOperators).ensureCapacity( numPtrOps );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* canHold
|
||||||
|
* @param type
|
||||||
|
* @return boolean
|
||||||
|
* return true if our type can hold all the values of the passed in
|
||||||
|
* type.
|
||||||
|
* TODO, for now return true if our type is "larger" (based on ordering of
|
||||||
|
* the type values)
|
||||||
|
*/
|
||||||
|
public boolean canHold( ITypeInfo type ) {
|
||||||
|
if( getType().compareTo( type.getType()) > 0 ){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
int mask = isShort | isLong | isLongLong;
|
||||||
|
return ( getTypeBits() & mask ) >= ( type.getTypeBits() & mask );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals( Object t ) {
|
||||||
|
if( t == null || !(t instanceof ITypeInfo) ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ITypeInfo type = (ITypeInfo)t;
|
||||||
|
|
||||||
|
boolean result = ( _typeBits == type.getTypeBits() );
|
||||||
|
result &= ( _type == type.getType() );
|
||||||
|
|
||||||
|
// Object def1 = getDefault();
|
||||||
|
// Object def2 = type.getDefault();
|
||||||
|
// result &= ( (def1 == null && def2 == null) ||
|
||||||
|
// (def1 != null && def2 != null && def1.equals( def2 )) );
|
||||||
|
//
|
||||||
|
if( !result )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int size1 = _ptrOperators.size();
|
||||||
|
int size2 = type.getPtrOperators().size();
|
||||||
|
if( size1 == size2 ){
|
||||||
|
if( size1 != 0 ){
|
||||||
|
ITypeInfo.PtrOp op1 = null, op2 = null;
|
||||||
|
for( int i = 0; i < size1; i++ ){
|
||||||
|
op1 = (ITypeInfo.PtrOp)_ptrOperators.get(i);
|
||||||
|
op2 = (ITypeInfo.PtrOp)type.getPtrOperators().get(i);
|
||||||
|
|
||||||
|
if( !op1.equals(op2) ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
if( isType( t_type ) && getTypeSymbol() != null ){
|
||||||
|
return getTypeSymbol().getName();
|
||||||
|
}
|
||||||
|
return _image[ getType().toInt() ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
_typeBits = 0;
|
||||||
|
_type = t_undef;
|
||||||
|
_ptrOperators = Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copy( ITypeInfo t ) {
|
||||||
|
if( t == null )
|
||||||
|
return;
|
||||||
|
_typeBits = t.getTypeBits();
|
||||||
|
_type = t.getType();
|
||||||
|
|
||||||
|
if( t.getPtrOperators() != Collections.EMPTY_LIST )
|
||||||
|
_ptrOperators = (ArrayList)((ArrayList)t.getPtrOperators()).clone();
|
||||||
|
else
|
||||||
|
_ptrOperators = Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasDefault(){
|
||||||
|
return _hasDefault;
|
||||||
|
}
|
||||||
|
public void setHasDefault( boolean def ){
|
||||||
|
_hasDefault = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The following functions are implemented in derived classes
|
||||||
|
*/
|
||||||
|
public ITypeInfo.eType getTemplateParameterType() { return ITypeInfo.t_undef; }
|
||||||
|
public void setTemplateParameterType( ITypeInfo.eType type ) { throw new UnsupportedOperationException(); }
|
||||||
|
public ISymbol getTypeSymbol() { return null; }
|
||||||
|
public void setTypeSymbol( ISymbol type ) { if( type != null ) throw new UnsupportedOperationException(); }
|
||||||
|
public void setDefault( Object t ) { if( t != null ) throw new UnsupportedOperationException(); }
|
||||||
|
public Object getDefault() { return null; }
|
||||||
|
|
||||||
|
protected int _typeBits = 0;
|
||||||
|
protected ITypeInfo.eType _type = t_undef;
|
||||||
|
protected List _ptrOperators = Collections.EMPTY_LIST;
|
||||||
|
protected boolean _hasDefault = false;
|
||||||
|
}
|
|
@ -47,11 +47,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
super( table, name );
|
super( table, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ContainerSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){
|
protected ContainerSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){
|
||||||
super( table, name, obj );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ContainerSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ){
|
|
||||||
super( table, name, typeInfo );
|
super( table, name, typeInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +89,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
newContainer._contents.add( containedSymbol );
|
newContainer._contents.add( containedSymbol );
|
||||||
} else {
|
} else {
|
||||||
ISymbol symbol = (ISymbol) containedSymbol;
|
ISymbol symbol = (ISymbol) containedSymbol;
|
||||||
if( symbol.isForwardDeclaration() && symbol.getTypeSymbol() != null ){
|
if( symbol.isForwardDeclaration() && symbol.getForwardSymbol() != null ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +130,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
newSymbol.setContainingSymbol( newContainer );
|
newSymbol.setContainingSymbol( newContainer );
|
||||||
newContainer._contents.add( newSymbol );
|
newContainer._contents.add( newSymbol );
|
||||||
|
|
||||||
if( newSymbol instanceof IParameterizedSymbol && newSymbol.isType( TypeInfo.t_constructor ) ){
|
if( newSymbol instanceof IParameterizedSymbol && newSymbol.isType( ITypeInfo.t_constructor ) ){
|
||||||
collectInstantiatedConstructor( (IParameterizedSymbol) containedSymbol );
|
collectInstantiatedConstructor( (IParameterizedSymbol) containedSymbol );
|
||||||
} else {
|
} else {
|
||||||
if( newContainer.getContainedSymbols().containsKey( newSymbol.getName() ) ){
|
if( newContainer.getContainedSymbols().containsKey( newSymbol.getName() ) ){
|
||||||
|
@ -168,10 +164,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
IContainerSymbol containing = this;
|
IContainerSymbol containing = this;
|
||||||
|
|
||||||
//handle enumerators
|
//handle enumerators
|
||||||
if( obj.getType() == TypeInfo.t_enumerator ){
|
if( obj.getType() == ITypeInfo.t_enumerator ){
|
||||||
//a using declaration of an enumerator will not be contained in a
|
//a using declaration of an enumerator will not be contained in a
|
||||||
//enumeration.
|
//enumeration.
|
||||||
if( containing.getType() == TypeInfo.t_enumeration ){
|
if( containing.getType() == ITypeInfo.t_enumeration ){
|
||||||
//Following the closing brace of an enum-specifier, each enumerator has the type of its
|
//Following the closing brace of an enum-specifier, each enumerator has the type of its
|
||||||
//enumeration
|
//enumeration
|
||||||
obj.setTypeSymbol( containing );
|
obj.setTypeSymbol( containing );
|
||||||
|
@ -180,7 +176,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( obj.isType( TypeInfo.t_template ) ){
|
if( obj.isType( ITypeInfo.t_template ) ){
|
||||||
if( ! TemplateEngine.canAddTemplate( containing, (ITemplateSymbol) obj ) ) {
|
if( ! TemplateEngine.canAddTemplate( containing, (ITemplateSymbol) obj ) ) {
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||||
}
|
}
|
||||||
|
@ -188,13 +184,13 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
|
|
||||||
//in C, structs, unions, enums don't nest
|
//in C, structs, unions, enums don't nest
|
||||||
if( getSymbolTable().getLanguage() == ParserLanguage.C ){
|
if( getSymbolTable().getLanguage() == ParserLanguage.C ){
|
||||||
if( obj.isType( TypeInfo.t_struct, TypeInfo.t_enumeration ) ){
|
if( obj.isType( ITypeInfo.t_struct, ITypeInfo.t_enumeration ) ){
|
||||||
containing = getScopeForCTag( containing );
|
containing = getScopeForCTag( containing );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//14.6.1-4 A Template parameter shall not be redeclared within its scope.
|
//14.6.1-4 A Template parameter shall not be redeclared within its scope.
|
||||||
if( isTemplateMember() || isType( TypeInfo.t_template ) ){
|
if( isTemplateMember() || isType( ITypeInfo.t_template ) ){
|
||||||
if( TemplateEngine.alreadyHasTemplateParameter( this, obj.getName() ) ){
|
if( TemplateEngine.alreadyHasTemplateParameter( this, obj.getName() ) ){
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_RedeclaredTemplateParam );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_RedeclaredTemplateParam );
|
||||||
}
|
}
|
||||||
|
@ -245,7 +241,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
((ContainerSymbol)containing).putInContainedSymbols( obj.getName(), obj );
|
((ContainerSymbol)containing).putInContainedSymbols( obj.getName(), obj );
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
obj.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template );
|
||||||
|
|
||||||
addToContents( obj );
|
addToContents( obj );
|
||||||
|
|
||||||
|
@ -312,17 +308,17 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDirective(org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDirective(org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||||
*/
|
*/
|
||||||
public IUsingDirectiveSymbol addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException{
|
public IUsingDirectiveSymbol addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException{
|
||||||
if( namespace.getType() != TypeInfo.t_namespace ){
|
if( namespace.getType() != ITypeInfo.t_namespace ){
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );
|
||||||
}
|
}
|
||||||
//7.3.4 A using-directive shall not appear in class scope
|
//7.3.4 A using-directive shall not appear in class scope
|
||||||
if( isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if( isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle namespace aliasing
|
//handle namespace aliasing
|
||||||
ISymbol alias = namespace.getTypeSymbol();
|
ISymbol alias = namespace.getForwardSymbol();
|
||||||
if( alias != null && alias.isType( TypeInfo.t_namespace ) ){
|
if( alias != null && alias.isType( ITypeInfo.t_namespace ) ){
|
||||||
namespace = (IContainerSymbol) alias;
|
namespace = (IContainerSymbol) alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,15 +446,15 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String)
|
* @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 TypeInfo.eType type, String name ) throws ParserSymbolTableException{
|
public ISymbol elaboratedLookup( final ITypeInfo.eType type, String name ) throws ParserSymbolTableException{
|
||||||
LookupData data = new LookupData( name ){
|
LookupData data = new LookupData( name ){
|
||||||
public TypeFilter getFilter() {
|
public TypeFilter getFilter() {
|
||||||
if( t == TypeInfo.t_any ) return ANY_FILTER;
|
if( t == ITypeInfo.t_any ) return ANY_FILTER;
|
||||||
if( filter == null ) filter = new TypeFilter( t );
|
if( filter == null ) filter = new TypeFilter( t );
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
private TypeFilter filter = null;
|
private TypeFilter filter = null;
|
||||||
private final TypeInfo.eType t = type;
|
private final ITypeInfo.eType t = type;
|
||||||
};
|
};
|
||||||
|
|
||||||
ParserSymbolTable.lookup( data, this );
|
ParserSymbolTable.lookup( data, this );
|
||||||
|
@ -537,9 +533,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
IContainerSymbol container = this;
|
IContainerSymbol container = this;
|
||||||
|
|
||||||
//handle namespace aliases
|
//handle namespace aliases
|
||||||
if( container.isType( TypeInfo.t_namespace ) ){
|
if( container.isType( ITypeInfo.t_namespace ) ){
|
||||||
ISymbol symbol = container.getTypeSymbol();
|
ISymbol symbol = container.getForwardSymbol();
|
||||||
if( symbol != null && symbol.isType( TypeInfo.t_namespace ) ){
|
if( symbol != null && symbol.isType( ITypeInfo.t_namespace ) ){
|
||||||
container = (IContainerSymbol) symbol;
|
container = (IContainerSymbol) symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,9 +557,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
IContainerSymbol container = this;
|
IContainerSymbol container = this;
|
||||||
|
|
||||||
//handle namespace aliases
|
//handle namespace aliases
|
||||||
if( container.isType( TypeInfo.t_namespace ) ){
|
if( container.isType( ITypeInfo.t_namespace ) ){
|
||||||
ISymbol symbol = container.getTypeSymbol();
|
ISymbol symbol = container.getForwardSymbol();
|
||||||
if( symbol != null && symbol.isType( TypeInfo.t_namespace ) ){
|
if( symbol != null && symbol.isType( ITypeInfo.t_namespace ) ){
|
||||||
container = (IContainerSymbol) symbol;
|
container = (IContainerSymbol) symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,10 +592,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
private IContainerSymbol lookupNestedNameSpecifier(String name, IContainerSymbol inSymbol ) throws ParserSymbolTableException{
|
private IContainerSymbol lookupNestedNameSpecifier(String name, IContainerSymbol inSymbol ) throws ParserSymbolTableException{
|
||||||
ISymbol foundSymbol = null;
|
ISymbol foundSymbol = null;
|
||||||
|
|
||||||
final TypeFilter filter = new TypeFilter( TypeInfo.t_namespace );
|
final TypeFilter filter = new TypeFilter( ITypeInfo.t_namespace );
|
||||||
filter.addAcceptedType( TypeInfo.t_class );
|
filter.addAcceptedType( ITypeInfo.t_class );
|
||||||
filter.addAcceptedType( TypeInfo.t_struct );
|
filter.addAcceptedType( ITypeInfo.t_struct );
|
||||||
filter.addAcceptedType( TypeInfo.t_union );
|
filter.addAcceptedType( ITypeInfo.t_union );
|
||||||
|
|
||||||
LookupData data = new LookupData( name ){
|
LookupData data = new LookupData( name ){
|
||||||
public TypeFilter getFilter() { return typeFilter; }
|
public TypeFilter getFilter() { return typeFilter; }
|
||||||
|
@ -636,10 +632,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
* @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 TypeInfo.eType t ) throws ParserSymbolTableException{
|
public ISymbol qualifiedLookup( String name, final ITypeInfo.eType t ) throws ParserSymbolTableException{
|
||||||
LookupData data = new LookupData( name ){
|
LookupData data = new LookupData( name ){
|
||||||
public TypeFilter getFilter() {
|
public TypeFilter getFilter() {
|
||||||
if( t == TypeInfo.t_any ) return ANY_FILTER;
|
if( t == ITypeInfo.t_any ) return ANY_FILTER;
|
||||||
|
|
||||||
if( filter == null )
|
if( filter == null )
|
||||||
filter = new TypeFilter( t );
|
filter = new TypeFilter( t );
|
||||||
|
@ -687,11 +683,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
//collect associated namespaces & classes.
|
//collect associated namespaces & classes.
|
||||||
int size = ( parameters == null ) ? 0 : parameters.size();
|
int size = ( parameters == null ) ? 0 : parameters.size();
|
||||||
|
|
||||||
TypeInfo param = null;
|
ITypeInfo param = null;
|
||||||
ISymbol paramType = null;
|
ISymbol paramType = null;
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
param = (TypeInfo) parameters.get(i);
|
param = (ITypeInfo) parameters.get(i);
|
||||||
TypeInfo info = ParserSymbolTable.getFlatTypeInfo( param, getSymbolTable().getTypeInfoProvider() );
|
ITypeInfo info = ParserSymbolTable.getFlatTypeInfo( param, getSymbolTable().getTypeInfoProvider() );
|
||||||
paramType = info.getTypeSymbol();
|
paramType = info.getTypeSymbol();
|
||||||
getSymbolTable().getTypeInfoProvider().returnTypeInfo( info );
|
getSymbolTable().getTypeInfoProvider().returnTypeInfo( info );
|
||||||
|
|
||||||
|
@ -704,9 +700,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
//if T is a pointer to a data member of class X, its associated namespaces and classes
|
//if T is a pointer to a data member of class X, its associated namespaces and classes
|
||||||
//are those associated with the member type together with those associated with X
|
//are those associated with the member type together with those associated with X
|
||||||
if( param.hasPtrOperators() && param.getPtrOperators().size() == 1 ){
|
if( param.hasPtrOperators() && param.getPtrOperators().size() == 1 ){
|
||||||
TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().get(0);
|
ITypeInfo.PtrOp op = (ITypeInfo.PtrOp)param.getPtrOperators().get(0);
|
||||||
if( op.getType() == TypeInfo.PtrOp.t_pointer &&
|
if( op.getType() == ITypeInfo.PtrOp.t_pointer &&
|
||||||
paramType.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) )
|
paramType.getContainingSymbol().isType( ITypeInfo.t_class, ITypeInfo.t_union ) )
|
||||||
{
|
{
|
||||||
ParserSymbolTable.getAssociatedScopes( paramType.getContainingSymbol(), associated );
|
ParserSymbolTable.getAssociatedScopes( paramType.getContainingSymbol(), associated );
|
||||||
}
|
}
|
||||||
|
@ -728,7 +724,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
|
|
||||||
//if we haven't found anything, or what we found is not a class member, consider the
|
//if we haven't found anything, or what we found is not a class member, consider the
|
||||||
//associated scopes
|
//associated scopes
|
||||||
if( found == null || found.getContainingSymbol().getType() != TypeInfo.t_class ){
|
if( found == null || found.getContainingSymbol().getType() != ITypeInfo.t_class ){
|
||||||
// if( found != null ){
|
// if( found != null ){
|
||||||
// data.foundItems.add( found );
|
// data.foundItems.add( found );
|
||||||
// }
|
// }
|
||||||
|
@ -808,11 +804,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
ParserSymbolTable.lookup( data, this );
|
ParserSymbolTable.lookup( data, this );
|
||||||
ISymbol found = getSymbolTable().resolveAmbiguities( data );
|
ISymbol found = getSymbolTable().resolveAmbiguities( data );
|
||||||
if( found != null ){
|
if( found != null ){
|
||||||
if( (found.isType( TypeInfo.t_templateParameter ) && found.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template) ||
|
if( (found.isType( ITypeInfo.t_templateParameter ) && found.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template) ||
|
||||||
found.isType( TypeInfo.t_template ) )
|
found.isType( ITypeInfo.t_template ) )
|
||||||
{
|
{
|
||||||
found = ((ITemplateSymbol) found).instantiate( arguments );
|
found = ((ITemplateSymbol) found).instantiate( arguments );
|
||||||
} else if( found.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
} else if( found.getContainingSymbol().isType( ITypeInfo.t_template ) ){
|
||||||
found = ((ITemplateSymbol) found.getContainingSymbol()).instantiate( arguments );
|
found = ((ITemplateSymbol) found.getContainingSymbol()).instantiate( arguments );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,7 +868,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
ParserSymbolTable.lookup( data, this );
|
ParserSymbolTable.lookup( data, this );
|
||||||
|
|
||||||
List constructors = null;
|
List constructors = null;
|
||||||
if( filter != null && filter.willAccept( TypeInfo.t_constructor ) && (this instanceof IDerivableContainerSymbol) ){
|
if( filter != null && filter.willAccept( ITypeInfo.t_constructor ) && (this instanceof IDerivableContainerSymbol) ){
|
||||||
if( getName().startsWith( prefix ) ){
|
if( getName().startsWith( prefix ) ){
|
||||||
List temp = ((IDerivableContainerSymbol)this).getConstructors();
|
List temp = ((IDerivableContainerSymbol)this).getConstructors();
|
||||||
int size = temp.size();
|
int size = temp.size();
|
||||||
|
@ -914,7 +910,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
getSymbolTable().resolveFunction( data, (List) obj );
|
getSymbolTable().resolveFunction( data, (List) obj );
|
||||||
list.addAll( (List) obj );
|
list.addAll( (List) obj );
|
||||||
} else{
|
} else{
|
||||||
if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) )
|
if( paramList != null && ((ISymbol)obj).isType( ITypeInfo.t_function ) )
|
||||||
{
|
{
|
||||||
if( tempList == null )
|
if( tempList == null )
|
||||||
tempList = new ArrayList(1);
|
tempList = new ArrayList(1);
|
||||||
|
@ -958,7 +954,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
IContainerSymbol container = getContainingSymbol();
|
IContainerSymbol container = getContainingSymbol();
|
||||||
IContainerSymbol symbolContainer = symbol.getContainingSymbol();
|
IContainerSymbol symbolContainer = symbol.getContainingSymbol();
|
||||||
|
|
||||||
if( !symbolContainer.isType( TypeInfo.t_class, TypeInfo.t_union ) ||
|
if( !symbolContainer.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ||
|
||||||
symbolContainer.equals( container ) )
|
symbolContainer.equals( container ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -986,10 +982,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
if( symbol instanceof IDerivableContainerSymbol ){
|
if( symbol instanceof IDerivableContainerSymbol ){
|
||||||
IContainerSymbol container = this.getContainingSymbol();
|
IContainerSymbol container = this.getContainingSymbol();
|
||||||
|
|
||||||
while( container != null && container.isType( TypeInfo.t_block ) ){
|
while( container != null && container.isType( ITypeInfo.t_block ) ){
|
||||||
container = container.getContainingSymbol();
|
container = container.getContainingSymbol();
|
||||||
}
|
}
|
||||||
if( container != null && !container.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if( container != null && !container.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
container = null;
|
container = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,9 +995,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
int size = friends.size();
|
int size = friends.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
ISymbol friend = (ISymbol) friends.get(i);
|
ISymbol friend = (ISymbol) friends.get(i);
|
||||||
ISymbol typeSymbol = friend.getTypeSymbol();
|
ISymbol forwardSymbol = friend.getForwardSymbol();
|
||||||
if( friend == this || typeSymbol == this ||
|
if( friend == this || forwardSymbol == this ||
|
||||||
friend == container || ( container != null && typeSymbol == container ) )
|
friend == container || ( container != null && forwardSymbol == container ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1011,9 +1007,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IContainerSymbol getScopeForCTag( IContainerSymbol container ){
|
private IContainerSymbol getScopeForCTag( IContainerSymbol container ){
|
||||||
while( !container.isType( TypeInfo.t_namespace ) &&
|
while( !container.isType( ITypeInfo.t_namespace ) &&
|
||||||
!container.isType( TypeInfo.t_function ) &&
|
!container.isType( ITypeInfo.t_function ) &&
|
||||||
!container.isType( TypeInfo.t_block ) )
|
!container.isType( ITypeInfo.t_block ) )
|
||||||
{
|
{
|
||||||
container = container.getContainingSymbol();
|
container = container.getContainingSymbol();
|
||||||
}
|
}
|
||||||
|
@ -1022,11 +1018,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
|
|
||||||
protected void addToContents( IExtensibleSymbol symbol ){
|
protected void addToContents( IExtensibleSymbol symbol ){
|
||||||
if( _contents == Collections.EMPTY_LIST ){
|
if( _contents == Collections.EMPTY_LIST ){
|
||||||
if( isType( TypeInfo.t_namespace ) )
|
if( isType( ITypeInfo.t_namespace ) )
|
||||||
_contents = new ArrayList( 64 );
|
_contents = new ArrayList( 64 );
|
||||||
else if( isType( TypeInfo.t_class ) || isType( TypeInfo.t_struct ) )
|
else if( isType( ITypeInfo.t_class ) || isType( ITypeInfo.t_struct ) )
|
||||||
_contents = new ArrayList( 32 );
|
_contents = new ArrayList( 32 );
|
||||||
else if( isType( TypeInfo.t_function ) )
|
else if( isType( ITypeInfo.t_function ) )
|
||||||
_contents = new ArrayList( 16 );
|
_contents = new ArrayList( 16 );
|
||||||
else
|
else
|
||||||
_contents = new ArrayList( 8 );
|
_contents = new ArrayList( 8 );
|
||||||
|
@ -1063,11 +1059,12 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
if( !alreadyReturned.contains( extensible ) ){
|
if( !alreadyReturned.contains( extensible ) ){
|
||||||
if( extensible instanceof ISymbol ){
|
if( extensible instanceof ISymbol ){
|
||||||
ISymbol symbol = (ISymbol) extensible;
|
ISymbol symbol = (ISymbol) extensible;
|
||||||
if( symbol.isForwardDeclaration() && symbol.getTypeSymbol() != null &&
|
ISymbol forward = symbol.getForwardSymbol();
|
||||||
symbol.getTypeSymbol().getContainingSymbol() == ContainerSymbol.this )
|
if( symbol.isForwardDeclaration() && forward != null &&
|
||||||
|
forward.getContainingSymbol() == ContainerSymbol.this )
|
||||||
{
|
{
|
||||||
alreadyReturned.add( symbol.getTypeSymbol() );
|
alreadyReturned.add( forward );
|
||||||
next = symbol.getTypeSymbol();
|
next = forward;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if( extensible instanceof IUsingDeclarationSymbol ){
|
} else if( extensible instanceof IUsingDeclarationSymbol ){
|
||||||
|
|
|
@ -52,13 +52,13 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
||||||
List newArgs = new ArrayList( args.size() );
|
List newArgs = new ArrayList( args.size() );
|
||||||
int size = args.size();
|
int size = args.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
TypeInfo arg = (TypeInfo) args.get(i);
|
ITypeInfo arg = (ITypeInfo) args.get(i);
|
||||||
newArgs.add( TemplateEngine.instantiateTypeInfo( arg, template, argMap ) );
|
newArgs.add( TemplateEngine.instantiateTypeInfo( arg, template, argMap ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ITemplateSymbol deferredTemplate = getTemplate();
|
ITemplateSymbol deferredTemplate = getTemplate();
|
||||||
if( deferredTemplate.isType( TypeInfo.t_templateParameter ) && argMap.containsKey( deferredTemplate ) ){
|
if( deferredTemplate.isType( ITypeInfo.t_templateParameter ) && argMap.containsKey( deferredTemplate ) ){
|
||||||
TypeInfo i = (TypeInfo) argMap.get( deferredTemplate );
|
ITypeInfo i = (ITypeInfo) argMap.get( deferredTemplate );
|
||||||
deferredTemplate = (ITemplateSymbol) i.getTypeSymbol();
|
deferredTemplate = (ITemplateSymbol) i.getTypeSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ){
|
public boolean isType( ITypeInfo.eType type, ITypeInfo.eType upperType ){
|
||||||
ISymbol symbol = _template.getTemplatedSymbol();
|
ISymbol symbol = _template.getTemplatedSymbol();
|
||||||
if( symbol != null )
|
if( symbol != null )
|
||||||
return symbol.isType( type, upperType );
|
return symbol.isType( type, upperType );
|
||||||
|
@ -77,21 +77,21 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInfo.eType getType(){
|
public ITypeInfo.eType getType(){
|
||||||
ISymbol symbol = _template.getTemplatedSymbol();
|
ISymbol symbol = _template.getTemplatedSymbol();
|
||||||
if( symbol != null )
|
if( symbol != null )
|
||||||
return symbol.getType();
|
return symbol.getType();
|
||||||
return super.getType();
|
return super.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInfo getTypeInfo(){
|
public ITypeInfo getTypeInfo(){
|
||||||
ISymbol symbol = _template.getTemplatedSymbol();
|
ISymbol symbol = _template.getTemplatedSymbol();
|
||||||
if( symbol != null )
|
if( symbol != null )
|
||||||
return symbol.getTypeInfo();
|
return symbol.getTypeInfo();
|
||||||
return super.getTypeInfo();
|
return super.getTypeInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type ){
|
public boolean isType( ITypeInfo.eType type ){
|
||||||
return _template.getTemplatedSymbol().isType( type );
|
return _template.getTemplatedSymbol().isType( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
super( table, name );
|
super( table, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DerivableContainerSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){
|
protected DerivableContainerSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){
|
||||||
super( table, name, obj );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DerivableContainerSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ){
|
|
||||||
super( table, name, typeInfo );
|
super( table, name, typeInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +69,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
|
|
||||||
if( parent instanceof IDeferredTemplateInstance ){
|
if( parent instanceof IDeferredTemplateInstance ){
|
||||||
template.registerDeferredInstatiation( newSymbol, parent, ITemplateSymbol.DeferredKind.PARENT, argMap );
|
template.registerDeferredInstatiation( newSymbol, parent, ITemplateSymbol.DeferredKind.PARENT, argMap );
|
||||||
} else if( parent.isType( TypeInfo.t_templateParameter ) && argMap.containsKey( parent ) ){
|
} else if( parent.isType( ITypeInfo.t_templateParameter ) && argMap.containsKey( parent ) ){
|
||||||
TypeInfo info = (TypeInfo) argMap.get( parent );
|
ITypeInfo info = (ITypeInfo) argMap.get( parent );
|
||||||
parent = info.getTypeSymbol();
|
parent = info.getTypeSymbol();
|
||||||
}
|
}
|
||||||
newSymbol.addParent( parent, wrapper.isVirtual(), wrapper.getAccess(), wrapper.getOffset(), wrapper.getReferences() );
|
newSymbol.addParent( parent, wrapper.isVirtual(), wrapper.getAccess(), wrapper.getOffset(), wrapper.getReferences() );
|
||||||
|
@ -119,7 +115,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void collectInstantiatedConstructor( IParameterizedSymbol constructor ){
|
protected void collectInstantiatedConstructor( IParameterizedSymbol constructor ){
|
||||||
if( constructor.isType( TypeInfo.t_constructor ) )
|
if( constructor.isType( ITypeInfo.t_constructor ) )
|
||||||
addToConstructors( constructor );
|
addToConstructors( constructor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +168,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addConstructor(org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addConstructor(org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol)
|
||||||
*/
|
*/
|
||||||
public void addConstructor(IParameterizedSymbol constructor) throws ParserSymbolTableException {
|
public void addConstructor(IParameterizedSymbol constructor) throws ParserSymbolTableException {
|
||||||
if( !constructor.isType( TypeInfo.t_constructor ) )
|
if( !constructor.isType( ITypeInfo.t_constructor ) )
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
||||||
|
|
||||||
List constructors = getConstructors();
|
List constructors = getConstructors();
|
||||||
|
@ -184,7 +180,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor.setContainingSymbol( this );
|
constructor.setContainingSymbol( this );
|
||||||
constructor.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
constructor.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template );
|
||||||
|
|
||||||
addThis( constructor );
|
addThis( constructor );
|
||||||
|
|
||||||
|
@ -205,24 +201,25 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
paramType = TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) getContainingSymbol() );
|
paramType = TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) getContainingSymbol() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo param = getSymbolTable().getTypeInfoProvider().getTypeInfo();
|
ITypeInfo param = TypeInfoProvider.getProvider(getSymbolTable()).getTypeInfo( ITypeInfo.t_type );
|
||||||
param.setType( TypeInfo.t_type );
|
param.setType( ITypeInfo.t_type );
|
||||||
param.setBit( true, TypeInfo.isConst );
|
param.setBit( true, ITypeInfo.isConst );
|
||||||
param.setTypeSymbol( paramType );
|
param.setTypeSymbol( paramType );
|
||||||
param.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference, false, false ) );
|
param.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, false, false ) );
|
||||||
parameters.add( param );
|
parameters.add( param );
|
||||||
|
|
||||||
IParameterizedSymbol constructor = null;
|
IParameterizedSymbol constructor = null;
|
||||||
try{
|
try{
|
||||||
constructor = lookupConstructor( parameters );
|
constructor = lookupConstructor( parameters );
|
||||||
} catch ( ParserSymbolTableException e ){
|
} catch ( ParserSymbolTableException e ){
|
||||||
|
/* nothing */
|
||||||
} finally {
|
} finally {
|
||||||
getSymbolTable().getTypeInfoProvider().returnTypeInfo( param );
|
getSymbolTable().getTypeInfoProvider().returnTypeInfo( param );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( constructor == null ){
|
if( constructor == null ){
|
||||||
constructor = getSymbolTable().newParameterizedSymbol( getName(), TypeInfo.t_constructor );
|
constructor = getSymbolTable().newParameterizedSymbol( getName(), ITypeInfo.t_constructor );
|
||||||
constructor.addParameter( this, TypeInfo.isConst, new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference, false, false ), false );
|
constructor.addParameter( this, ITypeInfo.isConst, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, false, false ), false );
|
||||||
|
|
||||||
addConstructor( constructor );
|
addConstructor( constructor );
|
||||||
}
|
}
|
||||||
|
@ -274,13 +271,13 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo type = obj.getTypeInfo();
|
ITypeInfo type = obj.getTypeInfo();
|
||||||
if( ( !type.isType( TypeInfo.t_function ) && !type.isType( TypeInfo.t_constructor) ) ||
|
if( ( !type.isType( ITypeInfo.t_function ) && !type.isType( ITypeInfo.t_constructor) ) ||
|
||||||
type.checkBit( TypeInfo.isStatic ) ){
|
type.checkBit( ITypeInfo.isStatic ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( obj.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if( obj.getContainingSymbol().isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
//check to see if there is already a this object, since using declarations
|
//check to see if there is already a this object, since using declarations
|
||||||
//of function will have them from the original declaration
|
//of function will have them from the original declaration
|
||||||
boolean foundThis = false;
|
boolean foundThis = false;
|
||||||
|
@ -296,13 +293,13 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
//if we didn't find "this" then foundItems will still be null, no need to actually
|
//if we didn't find "this" then foundItems will still be null, no need to actually
|
||||||
//check its contents
|
//check its contents
|
||||||
if( !foundThis ){
|
if( !foundThis ){
|
||||||
ISymbol thisObj = getSymbolTable().newSymbol( ParserSymbolTable.THIS, TypeInfo.t_type );
|
ISymbol thisObj = getSymbolTable().newSymbol( ParserSymbolTable.THIS, ITypeInfo.t_type );
|
||||||
thisObj.setTypeSymbol( obj.getContainingSymbol() );
|
thisObj.setTypeSymbol( obj.getContainingSymbol() );
|
||||||
//thisObj.setCVQualifier( obj.getCVQualifier() );
|
//thisObj.setCVQualifier( obj.getCVQualifier() );
|
||||||
TypeInfo.PtrOp ptr = new TypeInfo.PtrOp();
|
ITypeInfo.PtrOp ptr = new ITypeInfo.PtrOp();
|
||||||
ptr.setType( TypeInfo.PtrOp.t_pointer );
|
ptr.setType( ITypeInfo.PtrOp.t_pointer );
|
||||||
thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( TypeInfo.isConst ), TypeInfo.isConst );
|
thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( ITypeInfo.isConst ), ITypeInfo.isConst );
|
||||||
thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( TypeInfo.isVolatile ), TypeInfo.isVolatile );
|
thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( ITypeInfo.isVolatile ), ITypeInfo.isVolatile );
|
||||||
|
|
||||||
thisObj.addPtrOperator(ptr);
|
thisObj.addPtrOperator(ptr);
|
||||||
|
|
||||||
|
@ -336,11 +333,11 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
//its not, it goes in the innermost enclosing namespace
|
//its not, it goes in the innermost enclosing namespace
|
||||||
IContainerSymbol enclosing = getContainingSymbol();
|
IContainerSymbol enclosing = getContainingSymbol();
|
||||||
|
|
||||||
boolean local = enclosing.isType( TypeInfo.t_constructor ) ||
|
boolean local = enclosing.isType( ITypeInfo.t_constructor ) ||
|
||||||
enclosing.isType( TypeInfo.t_function ) ||
|
enclosing.isType( ITypeInfo.t_function ) ||
|
||||||
enclosing.isType( TypeInfo.t_block );
|
enclosing.isType( ITypeInfo.t_block );
|
||||||
|
|
||||||
while( enclosing != null && !enclosing.isType( TypeInfo.t_namespace ) ){
|
while( enclosing != null && !enclosing.isType( ITypeInfo.t_namespace ) ){
|
||||||
enclosing = enclosing.getContainingSymbol();
|
enclosing = enclosing.getContainingSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +346,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
try {
|
try {
|
||||||
enclosing.addSymbol( friend );
|
enclosing.addSymbol( friend );
|
||||||
} catch (ParserSymbolTableException e) {
|
} catch (ParserSymbolTableException e) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,8 +367,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
*/
|
*/
|
||||||
public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException{
|
public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException{
|
||||||
IContainerSymbol enclosing = getContainingSymbol();
|
IContainerSymbol enclosing = getContainingSymbol();
|
||||||
if( enclosing != null && enclosing.isType( TypeInfo.t_namespace, TypeInfo.t_union ) ){
|
if( enclosing != null && enclosing.isType( ITypeInfo.t_namespace, ITypeInfo.t_union ) ){
|
||||||
while( enclosing != null && ( enclosing.getType() != TypeInfo.t_namespace) )
|
while( enclosing != null && ( enclosing.getType() != ITypeInfo.t_namespace) )
|
||||||
{
|
{
|
||||||
enclosing = enclosing.getContainingSymbol();
|
enclosing = enclosing.getContainingSymbol();
|
||||||
}
|
}
|
||||||
|
@ -391,8 +389,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
||||||
|
|
||||||
|
|
||||||
IContainerSymbol enclosing = getContainingSymbol();
|
IContainerSymbol enclosing = getContainingSymbol();
|
||||||
if( enclosing != null && enclosing.isType( TypeInfo.t_namespace, TypeInfo.t_union ) ){
|
if( enclosing != null && enclosing.isType( ITypeInfo.t_namespace, ITypeInfo.t_union ) ){
|
||||||
while( enclosing != null && ( enclosing.getType() != TypeInfo.t_namespace) )
|
while( enclosing != null && ( enclosing.getType() != ITypeInfo.t_namespace) )
|
||||||
{
|
{
|
||||||
enclosing = enclosing.getContainingSymbol();
|
enclosing = enclosing.getContainingSymbol();
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,13 +98,13 @@ public interface IContainerSymbol extends ISymbol {
|
||||||
* IDerivableContainerSymbol
|
* IDerivableContainerSymbol
|
||||||
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
|
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
|
||||||
*/
|
*/
|
||||||
public ISymbol elaboratedLookup( TypeInfo.eType type, String name ) throws ParserSymbolTableException;
|
public ISymbol elaboratedLookup( ITypeInfo.eType type, String name ) throws ParserSymbolTableException;
|
||||||
public ISymbol lookup( String name ) throws ParserSymbolTableException;
|
public ISymbol lookup( String name ) throws ParserSymbolTableException;
|
||||||
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
|
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
|
||||||
public IParameterizedSymbol lookupMethodForDefinition( String name, List parameters ) throws ParserSymbolTableException;
|
public IParameterizedSymbol lookupMethodForDefinition( String name, List parameters ) throws ParserSymbolTableException;
|
||||||
public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException;
|
public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException;
|
||||||
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException;
|
public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException;
|
||||||
public ISymbol qualifiedLookup( String name, TypeInfo.eType t ) throws ParserSymbolTableException;
|
public ISymbol qualifiedLookup( String name, ITypeInfo.eType t ) throws ParserSymbolTableException;
|
||||||
public IParameterizedSymbol unqualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
|
public IParameterizedSymbol unqualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
|
||||||
public IParameterizedSymbol memberFunctionLookup( 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 IParameterizedSymbol qualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
|
||||||
|
|
|
@ -29,8 +29,8 @@ import java.util.Map;
|
||||||
public interface IParameterizedSymbol extends IContainerSymbol {
|
public interface IParameterizedSymbol extends IContainerSymbol {
|
||||||
|
|
||||||
public void addParameter( ISymbol param );
|
public void addParameter( ISymbol param );
|
||||||
public void addParameter( TypeInfo.eType type, int info, TypeInfo.PtrOp ptrOp, boolean hasDefault );
|
public void addParameter( ITypeInfo.eType type, int info, ITypeInfo.PtrOp ptrOp, boolean hasDefault );
|
||||||
public void addParameter( ISymbol typeSymbol, int info, TypeInfo.PtrOp ptrOp, boolean hasDefault );
|
public void addParameter( ISymbol typeSymbol, int info, ITypeInfo.PtrOp ptrOp, boolean hasDefault );
|
||||||
|
|
||||||
public Map getParameterMap();
|
public Map getParameterMap();
|
||||||
public List getParameterList();
|
public List getParameterList();
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ISpecializedSymbol extends ITemplateSymbol {
|
public interface ISpecializedSymbol extends ITemplateSymbol {
|
||||||
|
|
||||||
public void addArgument( TypeInfo arg );
|
public void addArgument( ITypeInfo arg );
|
||||||
|
|
||||||
public List getArgumentList();
|
public List getArgumentList();
|
||||||
|
|
||||||
|
|
|
@ -39,21 +39,23 @@ public interface ISymbol extends Cloneable, IExtensibleSymbol {
|
||||||
public IContainerSymbol getContainingSymbol();
|
public IContainerSymbol getContainingSymbol();
|
||||||
public void setContainingSymbol( IContainerSymbol containing );
|
public void setContainingSymbol( IContainerSymbol containing );
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type );
|
public boolean isType( ITypeInfo.eType type );
|
||||||
public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType );
|
public boolean isType( ITypeInfo.eType type, ITypeInfo.eType upperType );
|
||||||
public TypeInfo.eType getType();
|
public ITypeInfo.eType getType();
|
||||||
public void setType(TypeInfo.eType t);
|
public void setType(ITypeInfo.eType t);
|
||||||
public TypeInfo getTypeInfo();
|
public ITypeInfo getTypeInfo();
|
||||||
public void setTypeInfo( TypeInfo info );
|
public void setTypeInfo( ITypeInfo info );
|
||||||
public ISymbol getTypeSymbol();
|
public ISymbol getTypeSymbol();
|
||||||
public void setTypeSymbol( ISymbol type );
|
public void setTypeSymbol( ISymbol type );
|
||||||
|
|
||||||
public boolean isForwardDeclaration();
|
public boolean isForwardDeclaration();
|
||||||
public void setIsForwardDeclaration( boolean forward );
|
public void setIsForwardDeclaration( boolean forward );
|
||||||
|
public void setForwardSymbol( ISymbol forward );
|
||||||
|
public ISymbol getForwardSymbol();
|
||||||
|
|
||||||
public int compareCVQualifiersTo( ISymbol symbol );
|
public int compareCVQualifiersTo( ISymbol symbol );
|
||||||
public List getPtrOperators();
|
public List getPtrOperators();
|
||||||
public void addPtrOperator( TypeInfo.PtrOp ptrOp );
|
public void addPtrOperator( ITypeInfo.PtrOp ptrOp );
|
||||||
|
|
||||||
public boolean isTemplateInstance();
|
public boolean isTemplateInstance();
|
||||||
public ISymbol getInstantiatedSymbol();
|
public ISymbol getInstantiatedSymbol();
|
||||||
|
|
|
@ -0,0 +1,254 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 5, 2004
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.Enum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public interface ITypeInfo {
|
||||||
|
public static class OperatorExpression extends Enum{
|
||||||
|
|
||||||
|
//5.3.1-1 : The unary * operator, the expression to which it is applied shall be
|
||||||
|
//a pointer to an object type or a pointer to a function type and the result
|
||||||
|
//is an lvalue refering to the object or function to which the expression points
|
||||||
|
public static final OperatorExpression indirection = new OperatorExpression( 1 );
|
||||||
|
|
||||||
|
//5.3.1-2 : The result of the unary & operator is a pointer to its operand
|
||||||
|
public static final OperatorExpression addressof = new OperatorExpression( 0 );
|
||||||
|
|
||||||
|
//5.2.1 A postfix expression followed by an expression in square brackets is a postfix
|
||||||
|
//expression. one of the expressions shall have the type "pointer to T" and the other
|
||||||
|
//shall have a enumeration or integral type. The result is an lvalue of type "T"
|
||||||
|
public static final OperatorExpression subscript = new OperatorExpression( 2 );
|
||||||
|
|
||||||
|
protected OperatorExpression(int enumValue) {
|
||||||
|
super(enumValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PtrOp {
|
||||||
|
public PtrOp( eType type ){
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
public PtrOp( eType type, boolean isConst, boolean isVolatile ){
|
||||||
|
this.type = type;
|
||||||
|
this.isConstPtr = isConst;
|
||||||
|
this.isVolatilePtr = isVolatile;
|
||||||
|
}
|
||||||
|
public PtrOp( ISymbol memberOf, boolean isConst, boolean isVolatile ){
|
||||||
|
this.type = PtrOp.t_memberPointer;
|
||||||
|
this.isConstPtr = isConst;
|
||||||
|
this.isVolatilePtr = isVolatile;
|
||||||
|
this.memberOf = memberOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PtrOp(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final eType t_undef_ptr = new eType( 0 );
|
||||||
|
public static final eType t_pointer = new eType( 1 );
|
||||||
|
public static final eType t_reference = new eType( 2 );
|
||||||
|
public static final eType t_array = new eType( 3 );
|
||||||
|
public static final eType t_memberPointer = new eType( 4 );
|
||||||
|
|
||||||
|
public eType getType() { return type; }
|
||||||
|
public void setType( eType type ) { this.type = type; }
|
||||||
|
|
||||||
|
public boolean isConst() { return isConstPtr; }
|
||||||
|
public boolean isVolatile() { return isVolatilePtr; }
|
||||||
|
public void setConst( boolean isConst ) { this.isConstPtr = isConst; }
|
||||||
|
public void setVolatile(boolean isVolatile) { this.isVolatilePtr = isVolatile; }
|
||||||
|
|
||||||
|
public ISymbol getMemberOf() { return memberOf; }
|
||||||
|
public void setMemberOf( ISymbol member ) { this.memberOf = member; }
|
||||||
|
|
||||||
|
public int compareCVTo( ITypeInfo.PtrOp ptr ){
|
||||||
|
int cv1 = ( isConst() ? 1 : 0 ) + ( isVolatile() ? 1 : 0 );
|
||||||
|
int cv2 = ( ptr.isConst() ? 1 : 0 ) + ( ptr.isVolatile() ? 1 : 0 );
|
||||||
|
|
||||||
|
return cv1 - cv2;
|
||||||
|
}
|
||||||
|
public boolean equals( Object o ){
|
||||||
|
if( o == null || !(o instanceof ITypeInfo.PtrOp) ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ITypeInfo.PtrOp op = (ITypeInfo.PtrOp)o;
|
||||||
|
|
||||||
|
return ( isConst() == op.isConst() &&
|
||||||
|
isVolatile() == op.isVolatile() &&
|
||||||
|
getType() == op.getType() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private eType type = PtrOp.t_undef_ptr;
|
||||||
|
private boolean isConstPtr = false;
|
||||||
|
private boolean isVolatilePtr = false;
|
||||||
|
private ISymbol memberOf = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class eType extends Enum implements Comparable{
|
||||||
|
protected eType( int v ){
|
||||||
|
super( v );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo( Object o ){
|
||||||
|
ITypeInfo.eType t = (ITypeInfo.eType) o;
|
||||||
|
return getEnumValue() - t.getEnumValue();
|
||||||
|
}
|
||||||
|
public int toInt() {
|
||||||
|
return getEnumValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int isAuto = 1 << 0;
|
||||||
|
public static final int isRegister = 1 << 1;
|
||||||
|
public static final int isStatic = 1 << 2;
|
||||||
|
public static final int isExtern = 1 << 3;
|
||||||
|
public static final int isMutable = 1 << 4;
|
||||||
|
public static final int isInline = 1 << 5;
|
||||||
|
public static final int isVirtual = 1 << 6;
|
||||||
|
public static final int isExplicit = 1 << 7;
|
||||||
|
public static final int isTypedef = 1 << 8;
|
||||||
|
public static final int isFriend = 1 << 9;
|
||||||
|
public static final int isConst = 1 << 10;
|
||||||
|
public static final int isVolatile = 1 << 11;
|
||||||
|
public static final int isUnsigned = 1 << 12;
|
||||||
|
public static final int isShort = 1 << 13;
|
||||||
|
public static final int isLong = 1 << 14;
|
||||||
|
public static final int isForward = 1 << 15;
|
||||||
|
public static final int isComplex = 1 << 16;
|
||||||
|
public static final int isImaginary = 1 << 17;
|
||||||
|
public static final int isLongLong = 1 << 18;
|
||||||
|
public static final int isSigned = 1 << 19;
|
||||||
|
|
||||||
|
// Types
|
||||||
|
// Note that these should be considered ordered and if you change
|
||||||
|
// the order, you should consider the ParserSymbolTable uses
|
||||||
|
public static final ITypeInfo.eType t_any = new ITypeInfo.eType( -1 ); //don't care
|
||||||
|
public static final ITypeInfo.eType t_undef = new ITypeInfo.eType( 0 ); //not specified
|
||||||
|
public static final ITypeInfo.eType t_type = new ITypeInfo.eType( 1 ); //Type Specifier
|
||||||
|
public static final ITypeInfo.eType t_namespace = new ITypeInfo.eType( 2 );
|
||||||
|
public static final ITypeInfo.eType t_class = new ITypeInfo.eType( 3 );
|
||||||
|
public static final ITypeInfo.eType t_struct = new ITypeInfo.eType( 4 );
|
||||||
|
public static final ITypeInfo.eType t_union = new ITypeInfo.eType( 5 );
|
||||||
|
public static final ITypeInfo.eType t_enumeration = new ITypeInfo.eType( 6 );
|
||||||
|
public static final ITypeInfo.eType t_constructor = new ITypeInfo.eType( 7 );
|
||||||
|
public static final ITypeInfo.eType t_function = new ITypeInfo.eType( 8 );
|
||||||
|
public static final ITypeInfo.eType t__Bool = new ITypeInfo.eType( 9 );
|
||||||
|
public static final ITypeInfo.eType t_bool = new ITypeInfo.eType( 10 );
|
||||||
|
public static final ITypeInfo.eType t_char = new ITypeInfo.eType( 11 );
|
||||||
|
public static final ITypeInfo.eType t_wchar_t = new ITypeInfo.eType( 12 );
|
||||||
|
public static final ITypeInfo.eType t_int = new ITypeInfo.eType( 13 );
|
||||||
|
public static final ITypeInfo.eType t_float = new ITypeInfo.eType( 14 );
|
||||||
|
public static final ITypeInfo.eType t_double = new ITypeInfo.eType( 15 );
|
||||||
|
public static final ITypeInfo.eType t_void = new ITypeInfo.eType( 16 );
|
||||||
|
public static final ITypeInfo.eType t_enumerator = new ITypeInfo.eType( 17 );
|
||||||
|
public static final ITypeInfo.eType t_block = new ITypeInfo.eType( 18 );
|
||||||
|
public static final ITypeInfo.eType t_template = new ITypeInfo.eType( 19 );
|
||||||
|
public static final ITypeInfo.eType t_asm = new ITypeInfo.eType( 20 );
|
||||||
|
public static final ITypeInfo.eType t_linkage = new ITypeInfo.eType( 21 );
|
||||||
|
public static final ITypeInfo.eType t_templateParameter = new ITypeInfo.eType( 22 );
|
||||||
|
|
||||||
|
public static final ITypeInfo.eType t_typeName = new ITypeInfo.eType( 23 );
|
||||||
|
|
||||||
|
public abstract void setBit( boolean b, int mask );
|
||||||
|
|
||||||
|
public abstract boolean checkBit( int mask );
|
||||||
|
|
||||||
|
public abstract void setType( ITypeInfo.eType t );
|
||||||
|
|
||||||
|
public abstract ITypeInfo.eType getType();
|
||||||
|
|
||||||
|
public abstract boolean isType( ITypeInfo.eType type );
|
||||||
|
|
||||||
|
public abstract int getTypeBits();
|
||||||
|
|
||||||
|
public abstract void setTypeBits( int typeInfo );
|
||||||
|
|
||||||
|
public abstract ITypeInfo.eType getTemplateParameterType();
|
||||||
|
|
||||||
|
public abstract void setTemplateParameterType( ITypeInfo.eType type );
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param infoProvider - TypeInfoProvider to use if pooling the TypeInfo created, if null,
|
||||||
|
* pooling is not used. If pooling is used, TypeInfoProvider.returnTypeInfo
|
||||||
|
* must be called when the TypeInfo is no longer needed
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract ITypeInfo getFinalType( TypeInfoProvider infoProvider );
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param upperType
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
* type checking, check that this declaration's type is between type and
|
||||||
|
* upperType (inclusive). upperType of 0 means no range and our type must
|
||||||
|
* be type.
|
||||||
|
*/
|
||||||
|
public abstract boolean isType( ITypeInfo.eType type,
|
||||||
|
ITypeInfo.eType upperType );
|
||||||
|
|
||||||
|
public abstract ISymbol getTypeSymbol();
|
||||||
|
|
||||||
|
public abstract void setTypeSymbol( ISymbol type );
|
||||||
|
|
||||||
|
public abstract boolean hasPtrOperators();
|
||||||
|
|
||||||
|
public abstract List getPtrOperators();
|
||||||
|
|
||||||
|
public abstract boolean hasSamePtrs( ITypeInfo type );
|
||||||
|
|
||||||
|
public abstract void applyOperatorExpression( ITypeInfo.OperatorExpression op );
|
||||||
|
|
||||||
|
public abstract void addPtrOperator( ITypeInfo.PtrOp ptr );
|
||||||
|
|
||||||
|
public abstract void addPtrOperator( List ptrs );
|
||||||
|
|
||||||
|
public abstract void preparePtrOperators( int numPtrOps );
|
||||||
|
|
||||||
|
public abstract boolean getHasDefault();
|
||||||
|
|
||||||
|
public abstract void setHasDefault( boolean def );
|
||||||
|
|
||||||
|
public abstract void setDefault( Object t );
|
||||||
|
|
||||||
|
public abstract Object getDefault();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* canHold
|
||||||
|
* @param type
|
||||||
|
* @return boolean
|
||||||
|
* return true if our type can hold all the values of the passed in
|
||||||
|
* type.
|
||||||
|
* TODO, for now return true if our type is "larger" (based on ordering of
|
||||||
|
* the type values)
|
||||||
|
*/
|
||||||
|
public abstract boolean canHold( ITypeInfo type );
|
||||||
|
|
||||||
|
public abstract boolean equals( Object t );
|
||||||
|
|
||||||
|
public abstract String toString();
|
||||||
|
|
||||||
|
public abstract void clear();
|
||||||
|
|
||||||
|
public abstract void copy( ITypeInfo t );
|
||||||
|
}
|
|
@ -22,8 +22,6 @@ import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -37,11 +35,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
super( table, name );
|
super( table, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ParameterizedSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){
|
protected ParameterizedSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){
|
||||||
super( table, name, obj );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ParameterizedSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ){
|
|
||||||
super( table, name, typeInfo );
|
super( table, name, typeInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,10 +60,10 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
ParameterizedSymbol newParameterized = (ParameterizedSymbol) super.instantiate( template, argMap );
|
ParameterizedSymbol newParameterized = (ParameterizedSymbol) super.instantiate( template, argMap );
|
||||||
|
|
||||||
if( _returnType != null ){
|
if( _returnType != null ){
|
||||||
if( _returnType.isType( TypeInfo.t_templateParameter ) ){
|
if( _returnType.isType( ITypeInfo.t_templateParameter ) ){
|
||||||
if( argMap.containsKey( _returnType ) ){
|
if( argMap.containsKey( _returnType ) ){
|
||||||
newParameterized.setReturnType( getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME ) );
|
newParameterized.setReturnType( getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME ) );
|
||||||
newParameterized.getReturnType().setTypeInfo( (TypeInfo) argMap.get( _returnType ) );
|
newParameterized.getReturnType().setTypeInfo( (ITypeInfo) argMap.get( _returnType ) );
|
||||||
newParameterized.getReturnType().setInstantiatedSymbol( _returnType );
|
newParameterized.getReturnType().setInstantiatedSymbol( _returnType );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,7 +75,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle template parameter lists in TemplateSymbol, only do function parameter lists here.
|
//handle template parameter lists in TemplateSymbol, only do function parameter lists here.
|
||||||
if( !isType( TypeInfo.t_template ) ){
|
if( !isType( ITypeInfo.t_template ) ){
|
||||||
List params = getParameterList();
|
List params = getParameterList();
|
||||||
int size = params.size();
|
int size = params.size();
|
||||||
|
|
||||||
|
@ -148,7 +142,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
}
|
}
|
||||||
|
|
||||||
param.setContainingSymbol( this );
|
param.setContainingSymbol( this );
|
||||||
param.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
param.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template );
|
||||||
|
|
||||||
// Command command = new AddParameterCommand( this, param );
|
// Command command = new AddParameterCommand( this, param );
|
||||||
// getSymbolTable().pushCommand( command );
|
// getSymbolTable().pushCommand( command );
|
||||||
|
@ -157,14 +151,11 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @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)
|
* @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( TypeInfo.eType type, int info, TypeInfo.PtrOp ptrOp, boolean hasDefault ){
|
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);
|
||||||
|
|
||||||
TypeInfo t = param.getTypeInfo();
|
ITypeInfo t = TypeInfoProvider.newTypeInfo( type, info, ptrOp, hasDefault );
|
||||||
t.setTypeInfo( info );
|
param.setTypeInfo( t );
|
||||||
t.setType( type );
|
|
||||||
t.addPtrOperator( ptrOp );
|
|
||||||
t.setHasDefault( hasDefault );
|
|
||||||
|
|
||||||
addParameter( param );
|
addParameter( param );
|
||||||
}
|
}
|
||||||
|
@ -172,15 +163,11 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @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)
|
* @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, TypeInfo.PtrOp ptrOp, boolean hasDefault ){
|
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);
|
||||||
|
|
||||||
TypeInfo nfo = param.getTypeInfo();
|
ITypeInfo nfo = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, info, typeSymbol, ptrOp, hasDefault );
|
||||||
nfo.setTypeInfo( info );
|
param.setTypeInfo( nfo );
|
||||||
nfo.setType( TypeInfo.t_type );
|
|
||||||
nfo.setTypeSymbol( typeSymbol );
|
|
||||||
nfo.addPtrOperator( ptrOp );
|
|
||||||
nfo.setHasDefault( hasDefault );
|
|
||||||
|
|
||||||
addParameter( param );
|
addParameter( param );
|
||||||
}
|
}
|
||||||
|
@ -225,8 +212,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
List params = getParameterList();
|
List params = getParameterList();
|
||||||
List functionParams = function.getParameterList();
|
List functionParams = function.getParameterList();
|
||||||
|
|
||||||
TypeInfo info = null;
|
ITypeInfo info = null;
|
||||||
TypeInfo fInfo = null;
|
ITypeInfo fInfo = null;
|
||||||
|
|
||||||
TypeInfoProvider provider = getSymbolTable().getTypeInfoProvider();
|
TypeInfoProvider provider = getSymbolTable().getTypeInfoProvider();
|
||||||
|
|
||||||
|
@ -241,33 +228,33 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
info = ParserSymbolTable.getFlatTypeInfo( info, provider );
|
info = ParserSymbolTable.getFlatTypeInfo( info, provider );
|
||||||
fInfo = ParserSymbolTable.getFlatTypeInfo( fInfo, provider );
|
fInfo = ParserSymbolTable.getFlatTypeInfo( fInfo, provider );
|
||||||
|
|
||||||
for( TypeInfo nfo = info; nfo != null; nfo = fInfo ){
|
for( ITypeInfo nfo = info; nfo != null; nfo = fInfo ){
|
||||||
//an array declaration is adjusted to become a pointer declaration
|
//an array declaration is adjusted to become a pointer declaration
|
||||||
//only the second and subsequent array dimensions are significant in parameter types
|
//only the second and subsequent array dimensions are significant in parameter types
|
||||||
ListIterator ptrs = nfo.getPtrOperators().listIterator();
|
ListIterator ptrs = nfo.getPtrOperators().listIterator();
|
||||||
if( ptrs.hasNext() ){
|
if( ptrs.hasNext() ){
|
||||||
PtrOp op = (PtrOp) ptrs.next();
|
ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) ptrs.next();
|
||||||
if( op.getType() == PtrOp.t_array ){
|
if( op.getType() == ITypeInfo.PtrOp.t_array ){
|
||||||
ptrs.remove();
|
ptrs.remove();
|
||||||
ptrs.add( new PtrOp( PtrOp.t_pointer, op.isConst(), op.isVolatile() ) );
|
ptrs.add( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, op.isConst(), op.isVolatile() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//a function type is adjusted to become a pointer to function type
|
//a function type is adjusted to become a pointer to function type
|
||||||
if( nfo.isType( TypeInfo.t_type ) && nfo.getTypeSymbol() != null &&
|
if( nfo.isType( ITypeInfo.t_type ) && nfo.getTypeSymbol() != null &&
|
||||||
nfo.getTypeSymbol().isType( TypeInfo.t_function ) )
|
nfo.getTypeSymbol().isType( ITypeInfo.t_function ) )
|
||||||
{
|
{
|
||||||
if( nfo.getPtrOperators().size() == 0 ){
|
if( nfo.getPtrOperators().size() == 0 ){
|
||||||
nfo.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
nfo.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//const and volatile type-specifiers are ignored (only the outermost level)
|
//const and volatile type-specifiers are ignored (only the outermost level)
|
||||||
if( nfo.getPtrOperators().size() == 0 ){
|
if( nfo.getPtrOperators().size() == 0 ){
|
||||||
nfo.setBit( false, TypeInfo.isConst );
|
nfo.setBit( false, ITypeInfo.isConst );
|
||||||
nfo.setBit( false, TypeInfo.isVolatile );
|
nfo.setBit( false, ITypeInfo.isVolatile );
|
||||||
} else {
|
} else {
|
||||||
PtrOp op = (PtrOp) nfo.getPtrOperators().get( nfo.getPtrOperators().size() - 1 );
|
ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) nfo.getPtrOperators().get( nfo.getPtrOperators().size() - 1 );
|
||||||
op.setConst( false );
|
op.setConst( false );
|
||||||
op.setVolatile( false );
|
op.setVolatile( false );
|
||||||
}
|
}
|
||||||
|
@ -295,7 +282,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
||||||
public void setReturnType( ISymbol type ){
|
public void setReturnType( ISymbol type ){
|
||||||
_returnType = type;
|
_returnType = type;
|
||||||
_returnType.setContainingSymbol( this );
|
_returnType.setContainingSymbol( this );
|
||||||
_returnType.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
_returnType.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMember;
|
import org.eclipse.cdt.core.parser.ast.IASTMember;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
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.pst.IDerivableContainerSymbol.IParentSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -49,7 +48,7 @@ public class ParserSymbolTable {
|
||||||
*/
|
*/
|
||||||
public ParserSymbolTable( ParserLanguage language, ParserMode mode ) {
|
public ParserSymbolTable( ParserLanguage language, ParserMode mode ) {
|
||||||
super();
|
super();
|
||||||
_compilationUnit = newContainerSymbol( EMPTY_NAME, TypeInfo.t_namespace );
|
_compilationUnit = newContainerSymbol( EMPTY_NAME, ITypeInfo.t_namespace );
|
||||||
_language = language;
|
_language = language;
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +61,7 @@ public class ParserSymbolTable {
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new ContainerSymbol( this, name );
|
return new ContainerSymbol( this, name );
|
||||||
}
|
}
|
||||||
public IContainerSymbol newContainerSymbol( String name, TypeInfo.eType type ){
|
public IContainerSymbol newContainerSymbol( String name, ITypeInfo.eType type ){
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new ContainerSymbol( this, name, type );
|
return new ContainerSymbol( this, name, type );
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@ public class ParserSymbolTable {
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new BasicSymbol( this, name );
|
return new BasicSymbol( this, name );
|
||||||
}
|
}
|
||||||
public ISymbol newSymbol( String name, TypeInfo.eType type ){
|
public ISymbol newSymbol( String name, ITypeInfo.eType type ){
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new BasicSymbol( this, name, type );
|
return new BasicSymbol( this, name, type );
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,7 @@ public class ParserSymbolTable {
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new DerivableContainerSymbol( this, name );
|
return new DerivableContainerSymbol( this, name );
|
||||||
}
|
}
|
||||||
public IDerivableContainerSymbol newDerivableContainerSymbol( String name, TypeInfo.eType type ){
|
public IDerivableContainerSymbol newDerivableContainerSymbol( String name, ITypeInfo.eType type ){
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new DerivableContainerSymbol( this, name, type );
|
return new DerivableContainerSymbol( this, name, type );
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,7 @@ public class ParserSymbolTable {
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new ParameterizedSymbol( this, name );
|
return new ParameterizedSymbol( this, name );
|
||||||
}
|
}
|
||||||
public IParameterizedSymbol newParameterizedSymbol( String name, TypeInfo.eType type ){
|
public IParameterizedSymbol newParameterizedSymbol( String name, ITypeInfo.eType type ){
|
||||||
if( name == null ) name = EMPTY_NAME;
|
if( name == null ) name = EMPTY_NAME;
|
||||||
return new ParameterizedSymbol( this, name, type );
|
return new ParameterizedSymbol( this, name, type );
|
||||||
}
|
}
|
||||||
|
@ -116,9 +115,9 @@ public class ParserSymbolTable {
|
||||||
static protected void lookup( LookupData data, IContainerSymbol inSymbol ) throws ParserSymbolTableException
|
static protected void lookup( LookupData data, IContainerSymbol inSymbol ) throws ParserSymbolTableException
|
||||||
{
|
{
|
||||||
//handle namespace aliases
|
//handle namespace aliases
|
||||||
if( inSymbol.isType( TypeInfo.t_namespace ) ){
|
if( inSymbol.isType( ITypeInfo.t_namespace ) ){
|
||||||
ISymbol symbol = inSymbol.getTypeSymbol();
|
ISymbol symbol = inSymbol.getForwardSymbol();
|
||||||
if( symbol != null && symbol.isType( TypeInfo.t_namespace ) ){
|
if( symbol != null && symbol.isType( ITypeInfo.t_namespace ) ){
|
||||||
inSymbol = (IContainerSymbol) symbol;
|
inSymbol = (IContainerSymbol) symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,8 +456,8 @@ public class ParserSymbolTable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider();
|
TypeInfoProvider provider = TypeInfoProvider.getProvider( symbol.getSymbolTable() );
|
||||||
TypeInfo typeInfo = ParserSymbolTable.getFlatTypeInfo( symbol.getTypeInfo(), provider );
|
ITypeInfo typeInfo = ParserSymbolTable.getFlatTypeInfo( symbol.getTypeInfo(), provider );
|
||||||
boolean accept = data.getFilter().shouldAccept( symbol, typeInfo ) || data.getFilter().shouldAccept( symbol );
|
boolean accept = data.getFilter().shouldAccept( symbol, typeInfo ) || data.getFilter().shouldAccept( symbol );
|
||||||
provider.returnTypeInfo( typeInfo );
|
provider.returnTypeInfo( typeInfo );
|
||||||
|
|
||||||
|
@ -491,13 +490,13 @@ public class ParserSymbolTable {
|
||||||
if( ( data.returnInvisibleSymbols || !symbol.getIsInvisible() ) && checkType( data, symbol ) ){
|
if( ( data.returnInvisibleSymbols || !symbol.getIsInvisible() ) && checkType( data, symbol ) ){
|
||||||
foundSymbol = symbol;
|
foundSymbol = symbol;
|
||||||
|
|
||||||
if( foundSymbol.isType( TypeInfo.t_function ) ){
|
if( foundSymbol.isType( ITypeInfo.t_function ) ){
|
||||||
if( foundSymbol.isForwardDeclaration() && foundSymbol.getTypeSymbol() != null &&
|
if( foundSymbol.isForwardDeclaration() && foundSymbol.getForwardSymbol() != null &&
|
||||||
foundSymbol.getTypeSymbol().getContainingSymbol() == foundSymbol.getContainingSymbol() )
|
foundSymbol.getForwardSymbol().getContainingSymbol() == foundSymbol.getContainingSymbol() )
|
||||||
{
|
{
|
||||||
foundSymbol = foundSymbol.getTypeSymbol();
|
foundSymbol = foundSymbol.getForwardSymbol();
|
||||||
}
|
}
|
||||||
if( foundSymbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
if( foundSymbol.getContainingSymbol().isType( ITypeInfo.t_template ) ){
|
||||||
templateFunctionSet.add( foundSymbol );
|
templateFunctionSet.add( foundSymbol );
|
||||||
} else {
|
} else {
|
||||||
functionSet.add( foundSymbol );
|
functionSet.add( foundSymbol );
|
||||||
|
@ -505,14 +504,14 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//if this is a class-name, other stuff hides it
|
//if this is a class-name, other stuff hides it
|
||||||
if( foundSymbol.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) ){
|
if( foundSymbol.isType( ITypeInfo.t_class, ITypeInfo.t_enumeration ) ){
|
||||||
if( cls == null ){
|
if( cls == null ){
|
||||||
cls = (IContainerSymbol) foundSymbol;
|
cls = (IContainerSymbol) foundSymbol;
|
||||||
} else {
|
} else {
|
||||||
if( cls.getTypeInfo().isForwardDeclaration() && cls.getTypeSymbol() == foundSymbol ){
|
if( cls.isForwardDeclaration() && cls.getForwardSymbol() == foundSymbol ){
|
||||||
//cls is a forward declaration of decl, we want decl.
|
//cls is a forward declaration of decl, we want decl.
|
||||||
cls = (IContainerSymbol) foundSymbol;
|
cls = (IContainerSymbol) foundSymbol;
|
||||||
} else if( foundSymbol.getTypeInfo().isForwardDeclaration() && foundSymbol.getTypeSymbol() == cls ){
|
} else if( foundSymbol.isForwardDeclaration() && foundSymbol.getForwardSymbol() == cls ){
|
||||||
//decl is a forward declaration of cls, we already have what we want (cls)
|
//decl is a forward declaration of cls, we already have what we want (cls)
|
||||||
} else {
|
} else {
|
||||||
if( data.isPrefixLookup() ){
|
if( data.isPrefixLookup() ){
|
||||||
|
@ -738,8 +737,8 @@ public class ParserSymbolTable {
|
||||||
ISymbol symbol = ( objList != null ) ? (ISymbol) objList.get(0) : ( ISymbol )obj1;
|
ISymbol symbol = ( objList != null ) ? (ISymbol) objList.get(0) : ( ISymbol )obj1;
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
while( symbol != null ) {
|
while( symbol != null ) {
|
||||||
TypeInfo type = ((ISymbol)obj1).getTypeInfo();
|
ITypeInfo type = ((ISymbol)obj1).getTypeInfo();
|
||||||
if( !type.checkBit( TypeInfo.isStatic ) && !type.isType( TypeInfo.t_enumerator ) ){
|
if( !type.checkBit( ITypeInfo.isStatic ) && !type.isType( ITypeInfo.t_enumerator ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,10 +787,10 @@ public class ParserSymbolTable {
|
||||||
* it finds the name to be a function name"
|
* it finds the name to be a function name"
|
||||||
*/
|
*/
|
||||||
protected static boolean isValidOverload( ISymbol origSymbol, ISymbol newSymbol ){
|
protected static boolean isValidOverload( ISymbol origSymbol, ISymbol newSymbol ){
|
||||||
TypeInfo.eType origType = origSymbol.getType();
|
ITypeInfo.eType origType = origSymbol.getType();
|
||||||
TypeInfo.eType newType = newSymbol.getType();
|
ITypeInfo.eType newType = newSymbol.getType();
|
||||||
|
|
||||||
if( origType == TypeInfo.t_template ){
|
if( origType == ITypeInfo.t_template ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) origSymbol;
|
ITemplateSymbol template = (ITemplateSymbol) origSymbol;
|
||||||
origSymbol = template.getTemplatedSymbol();
|
origSymbol = template.getTemplatedSymbol();
|
||||||
if( origSymbol == null )
|
if( origSymbol == null )
|
||||||
|
@ -799,7 +798,7 @@ public class ParserSymbolTable {
|
||||||
origType = origSymbol.getType();
|
origType = origSymbol.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( newType == TypeInfo.t_template ){
|
if( newType == ITypeInfo.t_template ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
||||||
newSymbol = template.getTemplatedSymbol();
|
newSymbol = template.getTemplatedSymbol();
|
||||||
if( newSymbol == null )
|
if( newSymbol == null )
|
||||||
|
@ -808,8 +807,8 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle forward decls
|
//handle forward decls
|
||||||
if( origSymbol.getTypeInfo().isForwardDeclaration() ){
|
if( origSymbol.isForwardDeclaration() ){
|
||||||
if( origSymbol.getTypeSymbol() == newSymbol )
|
if( origSymbol.getForwardSymbol() == newSymbol )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//friend class declarations
|
//friend class declarations
|
||||||
|
@ -819,8 +818,8 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (origType.compareTo(TypeInfo.t_class) >= 0 && origType.compareTo(TypeInfo.t_enumeration) <= 0) && //class name or enumeration ...
|
if( (origType.compareTo(ITypeInfo.t_class) >= 0 && origType.compareTo(ITypeInfo.t_enumeration) <= 0) && //class name or enumeration ...
|
||||||
( newType == TypeInfo.t_type || (newType.compareTo( TypeInfo.t_function ) >= 0 /*&& newType <= TypeInfo.typeMask*/) ) ){
|
( newType == ITypeInfo.t_type || (newType.compareTo( ITypeInfo.t_function ) >= 0 /*&& newType <= TypeInfo.typeMask*/) ) ){
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -835,7 +834,7 @@ public class ParserSymbolTable {
|
||||||
if( origList.size() == 1 ){
|
if( origList.size() == 1 ){
|
||||||
return isValidOverload( (ISymbol)origList.get(0), newSymbol );
|
return isValidOverload( (ISymbol)origList.get(0), newSymbol );
|
||||||
} else if ( origList.size() > 1 ){
|
} else if ( origList.size() > 1 ){
|
||||||
if( newSymbol.isType( TypeInfo.t_template ) ){
|
if( newSymbol.isType( ITypeInfo.t_template ) ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
||||||
newSymbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
newSymbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
||||||
}
|
}
|
||||||
|
@ -843,14 +842,14 @@ public class ParserSymbolTable {
|
||||||
//the first thing can be a class-name or enumeration name, but the rest
|
//the first thing can be a class-name or enumeration name, but the rest
|
||||||
//must be functions. So make sure the newDecl is a function before even
|
//must be functions. So make sure the newDecl is a function before even
|
||||||
//considering the list
|
//considering the list
|
||||||
if( newSymbol.getType() != TypeInfo.t_function && newSymbol.getType() != TypeInfo.t_constructor ){
|
if( newSymbol.getType() != ITypeInfo.t_function && newSymbol.getType() != ITypeInfo.t_constructor ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Iterator iter = origList.iterator();
|
//Iterator iter = origList.iterator();
|
||||||
ISymbol symbol = (ISymbol) origList.get(0);
|
ISymbol symbol = (ISymbol) origList.get(0);
|
||||||
int numSymbols = origList.size();
|
int numSymbols = origList.size();
|
||||||
if( symbol.isType( TypeInfo.t_template ) ){
|
if( symbol.isType( ITypeInfo.t_template ) ){
|
||||||
IParameterizedSymbol template = (IParameterizedSymbol) symbol;
|
IParameterizedSymbol template = (IParameterizedSymbol) symbol;
|
||||||
symbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
symbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
||||||
}
|
}
|
||||||
|
@ -859,7 +858,7 @@ public class ParserSymbolTable {
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
while( valid && idx < numSymbols ){
|
while( valid && idx < numSymbols ){
|
||||||
symbol = (ISymbol) origList.get(idx++);
|
symbol = (ISymbol) origList.get(idx++);
|
||||||
if( symbol.isType( TypeInfo.t_template ) ){
|
if( symbol.isType( ITypeInfo.t_template ) ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) symbol;
|
ITemplateSymbol template = (ITemplateSymbol) symbol;
|
||||||
symbol = template.getTemplatedSymbol();
|
symbol = template.getTemplatedSymbol();
|
||||||
}
|
}
|
||||||
|
@ -874,21 +873,21 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidFunctionOverload( IParameterizedSymbol origSymbol, IParameterizedSymbol newSymbol ){
|
private static boolean isValidFunctionOverload( IParameterizedSymbol origSymbol, IParameterizedSymbol newSymbol ){
|
||||||
if( ( !origSymbol.isType( TypeInfo.t_function ) && !origSymbol.isType( TypeInfo.t_constructor ) ) ||
|
if( ( !origSymbol.isType( ITypeInfo.t_function ) && !origSymbol.isType( ITypeInfo.t_constructor ) ) ||
|
||||||
( ! newSymbol.isType( TypeInfo.t_function ) && ! newSymbol.isType( TypeInfo.t_constructor ) ) ){
|
( ! newSymbol.isType( ITypeInfo.t_function ) && ! newSymbol.isType( ITypeInfo.t_constructor ) ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle forward decls
|
//handle forward decls
|
||||||
if( origSymbol.getTypeInfo().isForwardDeclaration() &&
|
if( origSymbol.isForwardDeclaration() &&
|
||||||
origSymbol.getTypeSymbol() == newSymbol )
|
origSymbol.getForwardSymbol() == newSymbol )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if( origSymbol.hasSameParameters( newSymbol ) ){
|
if( origSymbol.hasSameParameters( newSymbol ) ){
|
||||||
//functions with the same name and same parameter types cannot be overloaded if any of them
|
//functions with the same name and same parameter types cannot be overloaded if any of them
|
||||||
//is static
|
//is static
|
||||||
if( origSymbol.getTypeInfo().checkBit( TypeInfo.isStatic ) || newSymbol.getTypeInfo().checkBit( TypeInfo.isStatic ) ){
|
if( origSymbol.getTypeInfo().checkBit( ITypeInfo.isStatic ) || newSymbol.getTypeInfo().checkBit( ITypeInfo.isStatic ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,12 +939,12 @@ public class ParserSymbolTable {
|
||||||
functionList.addAll( (List) object );
|
functionList.addAll( (List) object );
|
||||||
} else {
|
} else {
|
||||||
ISymbol symbol = (ISymbol) object;
|
ISymbol symbol = (ISymbol) object;
|
||||||
if( symbol.isType( TypeInfo.t_function ) ){
|
if( symbol.isType( ITypeInfo.t_function ) ){
|
||||||
functionList = new ArrayList(1);
|
functionList = new ArrayList(1);
|
||||||
functionList.add( symbol );
|
functionList.add( symbol );
|
||||||
} else {
|
} else {
|
||||||
if( symbol.isTemplateMember() && !symbol.isTemplateInstance() &&
|
if( symbol.isTemplateMember() && !symbol.isTemplateInstance() &&
|
||||||
!symbol.isType( TypeInfo.t_templateParameter ) && symbol.getContainingSymbol().isType( TypeInfo.t_template ))
|
!symbol.isType( ITypeInfo.t_templateParameter ) && symbol.getContainingSymbol().isType( ITypeInfo.t_template ))
|
||||||
{
|
{
|
||||||
resolvedSymbol = symbol.getContainingSymbol();
|
resolvedSymbol = symbol.getContainingSymbol();
|
||||||
if( resolvedSymbol instanceof ISpecializedSymbol ){
|
if( resolvedSymbol instanceof ISpecializedSymbol ){
|
||||||
|
@ -1004,7 +1003,7 @@ public class ParserSymbolTable {
|
||||||
} else if ( numFns == 2 ){
|
} else if ( numFns == 2 ){
|
||||||
for (int i = 0; i < numFns; i++) {
|
for (int i = 0; i < numFns; i++) {
|
||||||
IParameterizedSymbol fn = (IParameterizedSymbol) functions.get(i);
|
IParameterizedSymbol fn = (IParameterizedSymbol) functions.get(i);
|
||||||
if( fn.getTypeInfo().isForwardDeclaration() && fn.getTypeSymbol() != null ){
|
if( fn.isForwardDeclaration() && fn.getForwardSymbol() != null ){
|
||||||
if( functions.contains( fn.getTypeSymbol() ) ){
|
if( functions.contains( fn.getTypeSymbol() ) ){
|
||||||
return (IParameterizedSymbol) fn.getTypeSymbol();
|
return (IParameterizedSymbol) fn.getTypeSymbol();
|
||||||
}
|
}
|
||||||
|
@ -1021,9 +1020,9 @@ public class ParserSymbolTable {
|
||||||
Cost [] bestFnCost = null; //the cost of the best function
|
Cost [] bestFnCost = null; //the cost of the best function
|
||||||
Cost [] currFnCost = null; //the cost for the current function
|
Cost [] currFnCost = null; //the cost for the current function
|
||||||
|
|
||||||
TypeInfo source = null; //parameter we are called with
|
ITypeInfo source = null; //parameter we are called with
|
||||||
TypeInfo target = null; //function's parameter
|
ITypeInfo target = null; //function's parameter
|
||||||
TypeInfo voidInfo = null; //used to compare f() and f(void)
|
ITypeInfo voidInfo = null; //used to compare f() and f(void)
|
||||||
|
|
||||||
int comparison;
|
int comparison;
|
||||||
Cost cost = null; //the cost of converting source to target
|
Cost cost = null; //the cost of converting source to target
|
||||||
|
@ -1038,13 +1037,13 @@ public class ParserSymbolTable {
|
||||||
List sourceParameters = null; //the parameters the function is being called with
|
List sourceParameters = null; //the parameters the function is being called with
|
||||||
List targetParameters = null; //the current function's parameters
|
List targetParameters = null; //the current function's parameters
|
||||||
|
|
||||||
TypeInfoProvider infoProvider = getTypeInfoProvider();
|
TypeInfoProvider infoProvider = TypeInfoProvider.getProvider( this );
|
||||||
|
|
||||||
if( numSourceParams == 0 ){
|
if( numSourceParams == 0 ){
|
||||||
//f() is the same as f( void )
|
//f() is the same as f( void )
|
||||||
sourceParameters = new ArrayList(1);
|
sourceParameters = new ArrayList(1);
|
||||||
voidInfo = infoProvider.getTypeInfo();
|
voidInfo = infoProvider.getTypeInfo( ITypeInfo.t_void );
|
||||||
voidInfo.setType( TypeInfo.t_void );
|
voidInfo.setType( ITypeInfo.t_void );
|
||||||
sourceParameters.add( voidInfo );
|
sourceParameters.add( voidInfo );
|
||||||
numSourceParams = 1;
|
numSourceParams = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1056,10 +1055,10 @@ public class ParserSymbolTable {
|
||||||
currFn = (IParameterizedSymbol) functions.get( fnIdx );
|
currFn = (IParameterizedSymbol) functions.get( fnIdx );
|
||||||
|
|
||||||
if( bestFn != null ){
|
if( bestFn != null ){
|
||||||
if( bestFn.isForwardDeclaration() && bestFn.getTypeSymbol() == currFn ){
|
if( bestFn.isForwardDeclaration() && bestFn.getForwardSymbol() == currFn ){
|
||||||
bestFn = currFn;
|
bestFn = currFn;
|
||||||
continue;
|
continue;
|
||||||
} else if( currFn.isForwardDeclaration() && currFn.getTypeSymbol() == bestFn ){
|
} else if( currFn.isForwardDeclaration() && currFn.getForwardSymbol() == bestFn ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1068,7 @@ public class ParserSymbolTable {
|
||||||
//the only way we get here and have no parameters, is if we are looking
|
//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 )
|
//for a function that takes void parameters ie f( void )
|
||||||
targetParameters = new ArrayList(1);
|
targetParameters = new ArrayList(1);
|
||||||
targetParameters.add( currFn.getSymbolTable().newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$
|
targetParameters.add( currFn.getSymbolTable().newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
targetParameters = currFn.getParameterList();
|
targetParameters = currFn.getParameterList();
|
||||||
}
|
}
|
||||||
|
@ -1083,7 +1082,7 @@ public class ParserSymbolTable {
|
||||||
boolean varArgs = false;
|
boolean varArgs = false;
|
||||||
|
|
||||||
for( int j = 0; j < numSourceParams; j++ ){
|
for( int j = 0; j < numSourceParams; j++ ){
|
||||||
source = (TypeInfo) sourceParameters.get(j);
|
source = (ITypeInfo) sourceParameters.get(j);
|
||||||
|
|
||||||
if( j < numTargetParams )
|
if( j < numTargetParams )
|
||||||
target = ((ISymbol)targetParameters.get(j)).getTypeInfo();
|
target = ((ISymbol)targetParameters.get(j)).getTypeInfo();
|
||||||
|
@ -1093,7 +1092,7 @@ public class ParserSymbolTable {
|
||||||
if( varArgs ){
|
if( varArgs ){
|
||||||
cost = new Cost( infoProvider, source, null );
|
cost = new Cost( infoProvider, source, null );
|
||||||
cost.rank = Cost.ELLIPSIS_CONVERSION;
|
cost.rank = Cost.ELLIPSIS_CONVERSION;
|
||||||
} else if ( target.getHasDefault() && source.isType( TypeInfo.t_void ) && !source.hasPtrOperators() ){
|
} else if ( target.getHasDefault() && source.isType( ITypeInfo.t_void ) && !source.hasPtrOperators() ){
|
||||||
//source is just void, ie no parameter, if target had a default, then use that
|
//source is just void, ie no parameter, if target had a default, then use that
|
||||||
cost = new Cost( infoProvider, source, target );
|
cost = new Cost( infoProvider, source, target );
|
||||||
cost.rank = Cost.IDENTITY_RANK;
|
cost.rank = Cost.IDENTITY_RANK;
|
||||||
|
@ -1258,12 +1257,12 @@ public class ParserSymbolTable {
|
||||||
return function.getParameterList().isEmpty();
|
return function.getParameterList().isEmpty();
|
||||||
}
|
}
|
||||||
//create a new function that has params as its parameters, then use IParameterizedSymbol.hasSameParameters
|
//create a new function that has params as its parameters, then use IParameterizedSymbol.hasSameParameters
|
||||||
IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME, TypeInfo.t_function );
|
IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME, ITypeInfo.t_function );
|
||||||
|
|
||||||
int size = params.size();
|
int size = params.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
ISymbol param = function.getSymbolTable().newSymbol( EMPTY_NAME );
|
ISymbol param = function.getSymbolTable().newSymbol( EMPTY_NAME );
|
||||||
param.setTypeInfo( (TypeInfo) params.get(i) );
|
param.setTypeInfo( (ITypeInfo) params.get(i) );
|
||||||
tempFn.addParameter( param );
|
tempFn.addParameter( param );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1289,7 +1288,7 @@ public class ParserSymbolTable {
|
||||||
//sanity check
|
//sanity check
|
||||||
if( obj instanceof IParameterizedSymbol ){
|
if( obj instanceof IParameterizedSymbol ){
|
||||||
function = (IParameterizedSymbol) obj;
|
function = (IParameterizedSymbol) obj;
|
||||||
if( !function.isType( TypeInfo.t_function) && !function.isType( TypeInfo.t_constructor ) ){
|
if( !function.isType( ITypeInfo.t_function) && !function.isType( ITypeInfo.t_constructor ) ){
|
||||||
functions.remove( i-- );
|
functions.remove( i-- );
|
||||||
size--;
|
size--;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1314,12 +1313,12 @@ public class ParserSymbolTable {
|
||||||
//check for void
|
//check for void
|
||||||
else if( numParameters == 0 && num == 1 ){
|
else if( numParameters == 0 && num == 1 ){
|
||||||
ISymbol param = (ISymbol)function.getParameterList().get(0);
|
ISymbol param = (ISymbol)function.getParameterList().get(0);
|
||||||
if( param.isType( TypeInfo.t_void ) )
|
if( param.isType( ITypeInfo.t_void ) )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if( numParameters == 1 && num == 0 ){
|
else if( numParameters == 1 && num == 0 ){
|
||||||
TypeInfo paramType = (TypeInfo) data.getParameters().get(0);
|
ITypeInfo paramType = (ITypeInfo) data.getParameters().get(0);
|
||||||
if( paramType.isType( TypeInfo.t_void ) )
|
if( paramType.isType( ITypeInfo.t_void ) )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1341,7 +1340,7 @@ public class ParserSymbolTable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List params = function.getParameterList();
|
List params = function.getParameterList();
|
||||||
TypeInfo param;
|
ITypeInfo param;
|
||||||
for( int j = num - 1; j > ( numParameters - num); j-- ){
|
for( int j = num - 1; j > ( numParameters - num); j-- ){
|
||||||
param = ((ISymbol)params.get(j)).getTypeInfo();
|
param = ((ISymbol)params.get(j)).getTypeInfo();
|
||||||
if( !param.getHasDefault() ){
|
if( !param.getHasDefault() ){
|
||||||
|
@ -1504,7 +1503,7 @@ public class ParserSymbolTable {
|
||||||
//if T is a union or enumeration type, its associated namespace is the namespace in
|
//if T is a union or enumeration type, its associated namespace is the namespace in
|
||||||
//which it is defined. if it is a class member, its associated class is the member's
|
//which it is defined. if it is a class member, its associated class is the member's
|
||||||
//class
|
//class
|
||||||
else if( symbol.getType() == TypeInfo.t_union || symbol.getType() == TypeInfo.t_enumeration ){
|
else if( symbol.getType() == ITypeInfo.t_union || symbol.getType() == ITypeInfo.t_enumeration ){
|
||||||
associated.add( symbol.getContainingSymbol() );
|
associated.add( symbol.getContainingSymbol() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1526,7 +1525,7 @@ public class ParserSymbolTable {
|
||||||
//TODO: what about IDeferredTemplateInstance parents?
|
//TODO: what about IDeferredTemplateInstance parents?
|
||||||
if( base instanceof IDerivableContainerSymbol ){
|
if( base instanceof IDerivableContainerSymbol ){
|
||||||
classes.add( base );
|
classes.add( base );
|
||||||
if( base.getContainingSymbol().getType() == TypeInfo.t_namespace ){
|
if( base.getContainingSymbol().getType() == ITypeInfo.t_namespace ){
|
||||||
classes.add( base.getContainingSymbol());
|
classes.add( base.getContainingSymbol());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1541,11 +1540,11 @@ public class ParserSymbolTable {
|
||||||
boolean okToAdd = false;
|
boolean okToAdd = false;
|
||||||
|
|
||||||
//7.3.3-5 A using-declaration shall not name a template-id
|
//7.3.3-5 A using-declaration shall not name a template-id
|
||||||
if( obj.isTemplateMember() && obj.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
if( obj.isTemplateMember() && obj.getContainingSymbol().isType( ITypeInfo.t_template ) ){
|
||||||
okToAdd = false;
|
okToAdd = false;
|
||||||
}
|
}
|
||||||
//7.3.3-4
|
//7.3.3-4
|
||||||
else if( context.isType( TypeInfo.t_class, TypeInfo.t_struct ) ){
|
else if( context.isType( ITypeInfo.t_class, ITypeInfo.t_struct ) ){
|
||||||
IContainerSymbol container = obj.getContainingSymbol();
|
IContainerSymbol container = obj.getContainingSymbol();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -1553,7 +1552,7 @@ public class ParserSymbolTable {
|
||||||
if( obj.getContainingSymbol().getType() == context.getType() ){
|
if( obj.getContainingSymbol().getType() == context.getType() ){
|
||||||
okToAdd = ( hasBaseClass( context, container ) > 0 );
|
okToAdd = ( hasBaseClass( context, container ) > 0 );
|
||||||
}
|
}
|
||||||
else if ( obj.getContainingSymbol().getType() == TypeInfo.t_union ) {
|
else if ( obj.getContainingSymbol().getType() == ITypeInfo.t_union ) {
|
||||||
// TODO : must be an _anonymous_ union
|
// TODO : must be an _anonymous_ union
|
||||||
container = container.getContainingSymbol();
|
container = container.getContainingSymbol();
|
||||||
okToAdd = ( container instanceof IDerivableContainerSymbol )
|
okToAdd = ( container instanceof IDerivableContainerSymbol )
|
||||||
|
@ -1561,7 +1560,7 @@ public class ParserSymbolTable {
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
//an enumerator for an enumeration
|
//an enumerator for an enumeration
|
||||||
else if ( obj.getType() == TypeInfo.t_enumerator ){
|
else if ( obj.getType() == ITypeInfo.t_enumerator ){
|
||||||
container = container.getContainingSymbol();
|
container = container.getContainingSymbol();
|
||||||
okToAdd = ( container instanceof IDerivableContainerSymbol )
|
okToAdd = ( container instanceof IDerivableContainerSymbol )
|
||||||
? ( hasBaseClass( context, container ) > 0 )
|
? ( hasBaseClass( context, container ) > 0 )
|
||||||
|
@ -1577,14 +1576,14 @@ public class ParserSymbolTable {
|
||||||
return okToAdd;
|
return okToAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private Cost lvalue_to_rvalue( TypeInfoProvider provider, TypeInfo source, TypeInfo target ){
|
static private Cost lvalue_to_rvalue( TypeInfoProvider provider, ITypeInfo source, ITypeInfo target ){
|
||||||
|
|
||||||
//lvalues will have type t_type
|
//lvalues will have type t_type
|
||||||
if( source.isType( TypeInfo.t_type ) ){
|
if( source.isType( ITypeInfo.t_type ) ){
|
||||||
source = getFlatTypeInfo( source, null );
|
source = getFlatTypeInfo( source, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( target.isType( TypeInfo.t_type ) ){
|
if( target.isType( ITypeInfo.t_type ) ){
|
||||||
target = getFlatTypeInfo( target, null );
|
target = getFlatTypeInfo( target, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1596,19 +1595,19 @@ public class ParserSymbolTable {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo.PtrOp op = null;
|
ITypeInfo.PtrOp op = null;
|
||||||
|
|
||||||
if( cost.getSource().hasPtrOperators() ){
|
if( cost.getSource().hasPtrOperators() ){
|
||||||
List sourcePtrs = cost.getSource().getPtrOperators();
|
List sourcePtrs = cost.getSource().getPtrOperators();
|
||||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)sourcePtrs.get( 0 );
|
ITypeInfo.PtrOp ptr = (ITypeInfo.PtrOp)sourcePtrs.get( 0 );
|
||||||
if( ptr.getType() == TypeInfo.PtrOp.t_reference ){
|
if( ptr.getType() == ITypeInfo.PtrOp.t_reference ){
|
||||||
sourcePtrs.remove( 0 );
|
sourcePtrs.remove( 0 );
|
||||||
}
|
}
|
||||||
int size = sourcePtrs.size();
|
int size = sourcePtrs.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
op = (TypeInfo.PtrOp) sourcePtrs.get( 0 );
|
op = (ITypeInfo.PtrOp) sourcePtrs.get( 0 );
|
||||||
if( op.getType() == TypeInfo.PtrOp.t_array ){
|
if( op.getType() == ITypeInfo.PtrOp.t_array ){
|
||||||
op.setType( TypeInfo.PtrOp.t_pointer );
|
op.setType( ITypeInfo.PtrOp.t_pointer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1616,17 +1615,17 @@ public class ParserSymbolTable {
|
||||||
if( cost.getTarget().hasPtrOperators() ){
|
if( cost.getTarget().hasPtrOperators() ){
|
||||||
List targetPtrs = cost.getTarget().getPtrOperators();
|
List targetPtrs = cost.getTarget().getPtrOperators();
|
||||||
//ListIterator iterator = targetPtrs.listIterator();
|
//ListIterator iterator = targetPtrs.listIterator();
|
||||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)targetPtrs.get(0);
|
ITypeInfo.PtrOp ptr = (ITypeInfo.PtrOp)targetPtrs.get(0);
|
||||||
|
|
||||||
if( ptr.getType() == TypeInfo.PtrOp.t_reference ){
|
if( ptr.getType() == ITypeInfo.PtrOp.t_reference ){
|
||||||
targetPtrs.remove(0);
|
targetPtrs.remove(0);
|
||||||
cost.targetHadReference = true;
|
cost.targetHadReference = true;
|
||||||
}
|
}
|
||||||
int size = targetPtrs.size();
|
int size = targetPtrs.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
op = (TypeInfo.PtrOp) targetPtrs.get(0);
|
op = (ITypeInfo.PtrOp) targetPtrs.get(0);
|
||||||
if( op.getType() == TypeInfo.PtrOp.t_array ){
|
if( op.getType() == ITypeInfo.PtrOp.t_array ){
|
||||||
op.setType( TypeInfo.PtrOp.t_pointer );
|
op.setType( ITypeInfo.PtrOp.t_pointer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1646,20 +1645,20 @@ public class ParserSymbolTable {
|
||||||
int size = sourcePtrs.size();
|
int size = sourcePtrs.size();
|
||||||
int size2 = targetPtrs.size();
|
int size2 = targetPtrs.size();
|
||||||
|
|
||||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
ITypeInfo.PtrOp op1 = null, op2 = null;
|
||||||
boolean canConvert = true;
|
boolean canConvert = true;
|
||||||
|
|
||||||
if( size != size2 ){
|
if( size != size2 ){
|
||||||
canConvert = false;
|
canConvert = false;
|
||||||
} else if( size > 0 ){
|
} else if( size > 0 ){
|
||||||
op1 = (TypeInfo.PtrOp) sourcePtrs.get(0);
|
op1 = (ITypeInfo.PtrOp) sourcePtrs.get(0);
|
||||||
op2 = (TypeInfo.PtrOp) targetPtrs.get(0);
|
op2 = (ITypeInfo.PtrOp) targetPtrs.get(0);
|
||||||
|
|
||||||
boolean constInEveryCV2k = true;
|
boolean constInEveryCV2k = true;
|
||||||
|
|
||||||
for( int j= 1; j < size; j++ ){
|
for( int j= 1; j < size; j++ ){
|
||||||
op1 = (TypeInfo.PtrOp) sourcePtrs.get(j);
|
op1 = (ITypeInfo.PtrOp) sourcePtrs.get(j);
|
||||||
op2 = (TypeInfo.PtrOp) targetPtrs.get(j);
|
op2 = (ITypeInfo.PtrOp) targetPtrs.get(j);
|
||||||
|
|
||||||
//pointer types must be similar
|
//pointer types must be similar
|
||||||
if( op1.getType() != op2.getType() ){
|
if( op1.getType() != op2.getType() ){
|
||||||
|
@ -1684,8 +1683,8 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( cost.getSource().checkBit( TypeInfo.isConst ) && !cost.getTarget().checkBit( TypeInfo.isConst ) ) ||
|
if( ( cost.getSource().checkBit( ITypeInfo.isConst ) && !cost.getTarget().checkBit( ITypeInfo.isConst ) ) ||
|
||||||
( cost.getSource().checkBit( TypeInfo.isVolatile ) && !cost.getTarget().checkBit( TypeInfo.isVolatile ) ) )
|
( cost.getSource().checkBit( ITypeInfo.isVolatile ) && !cost.getTarget().checkBit( ITypeInfo.isVolatile ) ) )
|
||||||
{
|
{
|
||||||
canConvert = false;
|
canConvert = false;
|
||||||
}
|
}
|
||||||
|
@ -1713,23 +1712,23 @@ public class ParserSymbolTable {
|
||||||
* 4.6 float can be promoted to double
|
* 4.6 float can be promoted to double
|
||||||
*/
|
*/
|
||||||
static private void promotion( Cost cost ){
|
static private void promotion( Cost cost ){
|
||||||
TypeInfo src = cost.getSource();
|
ITypeInfo src = cost.getSource();
|
||||||
TypeInfo trg = cost.getTarget();
|
ITypeInfo trg = cost.getTarget();
|
||||||
|
|
||||||
int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isUnsigned | TypeInfo.isLongLong | TypeInfo.isSigned;
|
int mask = ITypeInfo.isShort | ITypeInfo.isLong | ITypeInfo.isUnsigned | ITypeInfo.isLongLong | ITypeInfo.isSigned;
|
||||||
|
|
||||||
if( (src.isType( TypeInfo.t__Bool, TypeInfo.t_float ) || src.isType( TypeInfo.t_enumeration )) &&
|
if( (src.isType( ITypeInfo.t__Bool, ITypeInfo.t_float ) || src.isType( ITypeInfo.t_enumeration )) &&
|
||||||
(trg.isType( TypeInfo.t_int ) || trg.isType( TypeInfo.t_double )) )
|
(trg.isType( ITypeInfo.t_int ) || trg.isType( ITypeInfo.t_double )) )
|
||||||
{
|
{
|
||||||
if( src.getType() == trg.getType() && (( src.getTypeInfo() & mask) == (trg.getTypeInfo() & mask)) ){
|
if( src.getType() == trg.getType() && (( src.getTypeBits() & mask) == (trg.getTypeBits() & mask)) ){
|
||||||
//same, no promotion needed
|
//same, no promotion needed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( src.isType( TypeInfo.t_float ) ){
|
if( src.isType( ITypeInfo.t_float ) ){
|
||||||
cost.promotion = trg.isType( TypeInfo.t_double ) ? 1 : 0;
|
cost.promotion = trg.isType( ITypeInfo.t_double ) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
cost.promotion = ( trg.isType( TypeInfo.t_int ) && trg.canHold( src ) ) ? 1 : 0;
|
cost.promotion = ( trg.isType( ITypeInfo.t_int ) && trg.canHold( src ) ) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1747,8 +1746,8 @@ public class ParserSymbolTable {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static private void conversion( Cost cost ){
|
static private void conversion( Cost cost ){
|
||||||
TypeInfo src = cost.getSource();
|
ITypeInfo src = cost.getSource();
|
||||||
TypeInfo trg = cost.getTarget();
|
ITypeInfo trg = cost.getTarget();
|
||||||
|
|
||||||
int temp = -1;
|
int temp = -1;
|
||||||
|
|
||||||
|
@ -1759,17 +1758,17 @@ public class ParserSymbolTable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( src.hasPtrOperators() && src.getPtrOperators().size() == 1 ){
|
if( src.hasPtrOperators() && src.getPtrOperators().size() == 1 ){
|
||||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)src.getPtrOperators().get(0);
|
ITypeInfo.PtrOp ptr = (ITypeInfo.PtrOp)src.getPtrOperators().get(0);
|
||||||
ISymbol srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeSymbol() : null;
|
ISymbol srcDecl = src.isType( ITypeInfo.t_type ) ? src.getTypeSymbol() : null;
|
||||||
ISymbol trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeSymbol() : null;
|
ISymbol trgDecl = trg.isType( ITypeInfo.t_type ) ? trg.getTypeSymbol() : null;
|
||||||
if( ptr.getType() == TypeInfo.PtrOp.t_pointer ){
|
if( ptr.getType() == ITypeInfo.PtrOp.t_pointer ){
|
||||||
if( srcDecl == null || (trgDecl == null && !trg.isType( TypeInfo.t_void )) ){
|
if( srcDecl == null || (trgDecl == null && !trg.isType( ITypeInfo.t_void )) ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
|
//4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
|
||||||
//converted to an rvalue of type "pointer to cv void"
|
//converted to an rvalue of type "pointer to cv void"
|
||||||
if( trg.isType( TypeInfo.t_void ) ){
|
if( trg.isType( ITypeInfo.t_void ) ){
|
||||||
cost.rank = Cost.CONVERSION_RANK;
|
cost.rank = Cost.CONVERSION_RANK;
|
||||||
cost.conversion = 1;
|
cost.conversion = 1;
|
||||||
cost.detail = 2;
|
cost.detail = 2;
|
||||||
|
@ -1791,7 +1790,7 @@ public class ParserSymbolTable {
|
||||||
cost.detail = 1;
|
cost.detail = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if( ptr.getType() == TypeInfo.PtrOp.t_memberPointer ){
|
} else if( ptr.getType() == ITypeInfo.PtrOp.t_memberPointer ){
|
||||||
//4.11-2 An rvalue of type "pointer to member of B of type cv T", where B is a class type,
|
//4.11-2 An rvalue of type "pointer to member of B of type cv T", where B is a class type,
|
||||||
//can be converted to an rvalue of type "pointer to member of D of type cv T" where D is a
|
//can be converted to an rvalue of type "pointer to member of D of type cv T" where D is a
|
||||||
//derived class of B
|
//derived class of B
|
||||||
|
@ -1799,8 +1798,8 @@ public class ParserSymbolTable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (TypeInfo.PtrOp)trg.getPtrOperators().get(0) : null;
|
ITypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (ITypeInfo.PtrOp)trg.getPtrOperators().get(0) : null;
|
||||||
if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == TypeInfo.PtrOp.t_memberPointer ){
|
if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == ITypeInfo.PtrOp.t_memberPointer ){
|
||||||
try {
|
try {
|
||||||
temp = hasBaseClass( ptr.getMemberOf(), srcPtr.getMemberOf() );
|
temp = hasBaseClass( ptr.getMemberOf(), srcPtr.getMemberOf() );
|
||||||
} catch (ParserSymbolTableException e) {
|
} catch (ParserSymbolTableException e) {
|
||||||
|
@ -1815,12 +1814,12 @@ public class ParserSymbolTable {
|
||||||
} else if( !src.hasPtrOperators() ) {
|
} else if( !src.hasPtrOperators() ) {
|
||||||
//4.7 An rvalue of an integer type can be converted to an rvalue of another integer type.
|
//4.7 An rvalue of an integer type can be converted to an rvalue of another integer type.
|
||||||
//An rvalue of an enumeration type can be converted to an rvalue of an integer type.
|
//An rvalue of an enumeration type can be converted to an rvalue of an integer type.
|
||||||
if( src.isType( TypeInfo.t__Bool, TypeInfo.t_int ) ||
|
if( src.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) ||
|
||||||
src.isType( TypeInfo.t_float, TypeInfo.t_double ) ||
|
src.isType( ITypeInfo.t_float, ITypeInfo.t_double ) ||
|
||||||
src.isType( TypeInfo.t_enumeration ) )
|
src.isType( ITypeInfo.t_enumeration ) )
|
||||||
{
|
{
|
||||||
if( trg.isType( TypeInfo.t__Bool, TypeInfo.t_int ) ||
|
if( trg.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) ||
|
||||||
trg.isType( TypeInfo.t_float, TypeInfo.t_double ) )
|
trg.isType( ITypeInfo.t_float, ITypeInfo.t_double ) )
|
||||||
{
|
{
|
||||||
cost.rank = Cost.CONVERSION_RANK;
|
cost.rank = Cost.CONVERSION_RANK;
|
||||||
cost.conversion = 1;
|
cost.conversion = 1;
|
||||||
|
@ -1830,11 +1829,11 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
static private void derivedToBaseConversion( Cost cost ) throws ParserSymbolTableException{
|
static private void derivedToBaseConversion( Cost cost ) throws ParserSymbolTableException{
|
||||||
TypeInfo src = cost.getSource();
|
ITypeInfo src = cost.getSource();
|
||||||
TypeInfo trg = cost.getTarget();
|
ITypeInfo trg = cost.getTarget();
|
||||||
|
|
||||||
ISymbol srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeSymbol() : null;
|
ISymbol srcDecl = src.isType( ITypeInfo.t_type ) ? src.getTypeSymbol() : null;
|
||||||
ISymbol trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeSymbol() : null;
|
ISymbol trgDecl = trg.isType( ITypeInfo.t_type ) ? trg.getTypeSymbol() : null;
|
||||||
|
|
||||||
if( !src.hasSamePtrs( trg ) || srcDecl == null || trgDecl == null || !cost.targetHadReference ){
|
if( !src.hasSamePtrs( trg ) || srcDecl == null || trgDecl == null || !cost.targetHadReference ){
|
||||||
return;
|
return;
|
||||||
|
@ -1848,8 +1847,8 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Cost checkStandardConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException{
|
protected Cost checkStandardConversionSequence( ITypeInfo source, ITypeInfo target ) throws ParserSymbolTableException{
|
||||||
Cost cost = lvalue_to_rvalue( getTypeInfoProvider(), source, target );
|
Cost cost = lvalue_to_rvalue( TypeInfoProvider.getProvider( this ), source, target );
|
||||||
|
|
||||||
if( cost.getSource() == null || cost.getTarget() == null ){
|
if( cost.getSource() == null || cost.getTarget() == null ){
|
||||||
return cost;
|
return cost;
|
||||||
|
@ -1868,7 +1867,7 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
//was the qualification conversion enough?
|
//was the qualification conversion enough?
|
||||||
if( cost.getSource().isType( TypeInfo.t_type ) && cost.getTarget().isType( TypeInfo.t_type ) ){
|
if( cost.getSource().isType( ITypeInfo.t_type ) && cost.getTarget().isType( ITypeInfo.t_type ) ){
|
||||||
if( cost.getTarget().hasSamePtrs( cost.getSource() ) ){
|
if( cost.getTarget().hasSamePtrs( cost.getSource() ) ){
|
||||||
ISymbol srcSymbol = cost.getSource().getTypeSymbol();
|
ISymbol srcSymbol = cost.getSource().getTypeSymbol();
|
||||||
ISymbol trgSymbol = cost.getTarget().getTypeSymbol();
|
ISymbol trgSymbol = cost.getTarget().getTypeSymbol();
|
||||||
|
@ -1880,7 +1879,7 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if( cost.getSource().getType() == cost.getTarget().getType() &&
|
} else if( cost.getSource().getType() == cost.getTarget().getType() &&
|
||||||
(cost.getSource().getTypeInfo() & ~TypeInfo.isConst & ~TypeInfo.isVolatile) == (cost.getTarget().getTypeInfo() & ~TypeInfo.isConst & ~TypeInfo.isVolatile) )
|
(cost.getSource().getTypeBits() & ~ITypeInfo.isConst & ~ITypeInfo.isVolatile) == (cost.getTarget().getTypeBits() & ~ITypeInfo.isConst & ~ITypeInfo.isVolatile) )
|
||||||
{
|
{
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
@ -1897,14 +1896,14 @@ public class ParserSymbolTable {
|
||||||
try{
|
try{
|
||||||
derivedToBaseConversion( cost );
|
derivedToBaseConversion( cost );
|
||||||
} catch ( ParserSymbolTableException e ){
|
} catch ( ParserSymbolTableException e ){
|
||||||
cost.release( getTypeInfoProvider() );
|
cost.release( TypeInfoProvider.getProvider( this ) );
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cost checkUserDefinedConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException {
|
private Cost checkUserDefinedConversionSequence( ITypeInfo source, ITypeInfo target ) throws ParserSymbolTableException {
|
||||||
Cost cost = null;
|
Cost cost = null;
|
||||||
Cost constructorCost = null;
|
Cost constructorCost = null;
|
||||||
Cost conversionCost = null;
|
Cost conversionCost = null;
|
||||||
|
@ -1915,12 +1914,12 @@ public class ParserSymbolTable {
|
||||||
IParameterizedSymbol conversion = null;
|
IParameterizedSymbol conversion = null;
|
||||||
|
|
||||||
//constructors
|
//constructors
|
||||||
if( target.getType() == TypeInfo.t_type ){
|
if( target.getType() == ITypeInfo.t_type ){
|
||||||
targetDecl = target.getTypeSymbol();
|
targetDecl = target.getTypeSymbol();
|
||||||
if( targetDecl == null ){
|
if( targetDecl == null ){
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
||||||
}
|
}
|
||||||
if( targetDecl.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if( targetDecl.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
LookupData data = new LookupData( EMPTY_NAME){
|
LookupData data = new LookupData( EMPTY_NAME){
|
||||||
public List getParameters() { return parameters; }
|
public List getParameters() { return parameters; }
|
||||||
public TypeFilter getFilter() { return CONSTRUCTOR_FILTER; }
|
public TypeFilter getFilter() { return CONSTRUCTOR_FILTER; }
|
||||||
|
@ -1938,18 +1937,19 @@ public class ParserSymbolTable {
|
||||||
ArrayList constructors = new ArrayList( container.getConstructors() );
|
ArrayList constructors = new ArrayList( container.getConstructors() );
|
||||||
constructor = resolveFunction( data, constructors );
|
constructor = resolveFunction( data, constructors );
|
||||||
}
|
}
|
||||||
if( constructor != null && constructor.getTypeInfo().checkBit( TypeInfo.isExplicit ) ){
|
if( constructor != null && constructor.getTypeInfo().checkBit( ITypeInfo.isExplicit ) ){
|
||||||
constructor = null;
|
constructor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TypeInfoProvider provider = TypeInfoProvider.getProvider( this );
|
||||||
//conversion operators
|
//conversion operators
|
||||||
if( source.getType() == TypeInfo.t_type ){
|
if( source.getType() == ITypeInfo.t_type ){
|
||||||
source = getFlatTypeInfo( source, getTypeInfoProvider() );
|
source = getFlatTypeInfo( source, provider );
|
||||||
sourceDecl = ( source != null ) ? source.getTypeSymbol() : null;
|
sourceDecl = ( source != null ) ? source.getTypeSymbol() : null;
|
||||||
getTypeInfoProvider().returnTypeInfo( source );
|
provider.returnTypeInfo( source );
|
||||||
|
|
||||||
if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){
|
if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){
|
||||||
String name = target.toString();
|
String name = target.toString();
|
||||||
|
@ -1968,18 +1968,16 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if( constructor != null ){
|
if( constructor != null ){
|
||||||
TypeInfo info = getTypeInfoProvider().getTypeInfo();
|
ITypeInfo info = provider.getTypeInfo( ITypeInfo.t_type );
|
||||||
info.setType( TypeInfo.t_type );
|
|
||||||
info.setTypeSymbol( constructor.getContainingSymbol() );
|
info.setTypeSymbol( constructor.getContainingSymbol() );
|
||||||
constructorCost = checkStandardConversionSequence( info, target );
|
constructorCost = checkStandardConversionSequence( info, target );
|
||||||
getTypeInfoProvider().returnTypeInfo( info );
|
provider.returnTypeInfo( info );
|
||||||
}
|
}
|
||||||
if( conversion != null ){
|
if( conversion != null ){
|
||||||
TypeInfo info = getTypeInfoProvider().getTypeInfo();
|
ITypeInfo info = provider.getTypeInfo( target.getType() );
|
||||||
info.setType( target.getType() );
|
|
||||||
info.setTypeSymbol( target.getTypeSymbol() );
|
info.setTypeSymbol( target.getTypeSymbol() );
|
||||||
conversionCost = checkStandardConversionSequence( info, target );
|
conversionCost = checkStandardConversionSequence( info, target );
|
||||||
getTypeInfoProvider().returnTypeInfo( info );
|
provider.returnTypeInfo( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
//if both are valid, then the conversion is ambiguous
|
//if both are valid, then the conversion is ambiguous
|
||||||
|
@ -2002,9 +2000,9 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if( constructorCost != null && constructorCost != cost )
|
if( constructorCost != null && constructorCost != cost )
|
||||||
constructorCost.release( getTypeInfoProvider() );
|
constructorCost.release( provider );
|
||||||
if( conversionCost != null && conversionCost != cost )
|
if( conversionCost != null && conversionCost != cost )
|
||||||
conversionCost.release( getTypeInfoProvider() );
|
conversionCost.release( provider );
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
@ -2021,9 +2019,9 @@ public class ParserSymbolTable {
|
||||||
* - If neither can be converted, further checking must be done (return null)
|
* - If neither can be converted, further checking must be done (return null)
|
||||||
* - If exactly one conversion is possible, that conversion is applied ( return the other TypeInfo )
|
* - If exactly one conversion is possible, that conversion is applied ( return the other TypeInfo )
|
||||||
*/
|
*/
|
||||||
public TypeInfo getConditionalOperand( TypeInfo secondOp, TypeInfo thirdOp ) throws ParserSymbolTableException{
|
public ITypeInfo getConditionalOperand( ITypeInfo secondOp, ITypeInfo thirdOp ) throws ParserSymbolTableException{
|
||||||
Cost thirdCost = null, secondCost = null;
|
Cost thirdCost = null, secondCost = null;
|
||||||
TypeInfo temp = null;
|
ITypeInfo temp = null;
|
||||||
TypeInfoProvider provider = getTypeInfoProvider();
|
TypeInfoProvider provider = getTypeInfoProvider();
|
||||||
try{
|
try{
|
||||||
//can secondOp convert to thirdOp ?
|
//can secondOp convert to thirdOp ?
|
||||||
|
@ -2081,24 +2079,25 @@ public class ParserSymbolTable {
|
||||||
* The top level TypeInfo represents modifications to the object and the
|
* The top level TypeInfo represents modifications to the object and the
|
||||||
* remaining TypeInfo's represent the object.
|
* remaining TypeInfo's represent the object.
|
||||||
*/
|
*/
|
||||||
static protected TypeInfo getFlatTypeInfo( TypeInfo topInfo, TypeInfoProvider infoProvider ){
|
static protected ITypeInfo getFlatTypeInfo( ITypeInfo topInfo, TypeInfoProvider infoProvider ){
|
||||||
TypeInfo returnInfo = null;
|
ITypeInfo returnInfo = null;
|
||||||
TypeInfo info = null;
|
ITypeInfo info = null;
|
||||||
|
|
||||||
if( topInfo.getType() == TypeInfo.t_type && topInfo.getTypeSymbol() != null ){
|
if( topInfo.getType() == ITypeInfo.t_type && topInfo.getTypeSymbol() != null ){
|
||||||
if( infoProvider != null ) returnInfo = infoProvider.getTypeInfo();
|
if( infoProvider != null ) returnInfo = infoProvider.getTypeInfo( ITypeInfo.t_type );
|
||||||
else returnInfo = new TypeInfo();
|
else returnInfo = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type );
|
||||||
|
|
||||||
returnInfo.setTypeInfo( topInfo.getTypeInfo() );
|
returnInfo.setTypeBits( topInfo.getTypeBits() );
|
||||||
ISymbol typeSymbol = topInfo.getTypeSymbol();
|
ISymbol typeSymbol = topInfo.getTypeSymbol();
|
||||||
|
|
||||||
info = typeSymbol.getTypeInfo();
|
info = typeSymbol.getTypeInfo();
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while( info.getTypeSymbol() != null && ( info.getType() == TypeInfo.t_type || info.isForwardDeclaration() ) ){
|
while( (info.getTypeSymbol() != null && info.getType() == ITypeInfo.t_type) ||
|
||||||
typeSymbol = info.getTypeSymbol();
|
(typeSymbol != null && typeSymbol.isForwardDeclaration() && typeSymbol.getForwardSymbol() != null ) ){
|
||||||
|
typeSymbol = info.isType( ITypeInfo.t_type) ? info.getTypeSymbol() : typeSymbol.getForwardSymbol();
|
||||||
|
|
||||||
returnInfo.addPtrOperator( info.getPtrOperators() );
|
returnInfo.addPtrOperator( info.getPtrOperators() );
|
||||||
returnInfo.setTypeInfo( ( returnInfo.getTypeInfo() | info.getTypeInfo() ) & ~TypeInfo.isTypedef & ~TypeInfo.isForward );
|
returnInfo.setTypeBits( ( returnInfo.getTypeBits() | info.getTypeBits() ) & ~ITypeInfo.isTypedef & ~ITypeInfo.isForward );
|
||||||
info = typeSymbol.getTypeInfo();
|
info = typeSymbol.getTypeInfo();
|
||||||
if( ++j > TYPE_LOOP_THRESHOLD ){
|
if( ++j > TYPE_LOOP_THRESHOLD ){
|
||||||
if( infoProvider != null )
|
if( infoProvider != null )
|
||||||
|
@ -2107,46 +2106,33 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( info.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) || info.isType( TypeInfo.t_function ) ){
|
if( info.isType( ITypeInfo.t_class, ITypeInfo.t_enumeration ) || info.isType( ITypeInfo.t_function ) ){
|
||||||
returnInfo.setType( TypeInfo.t_type );
|
returnInfo.setType( ITypeInfo.t_type );
|
||||||
returnInfo.setTypeSymbol( typeSymbol );
|
returnInfo.setTypeSymbol( typeSymbol );
|
||||||
} else {
|
} else {
|
||||||
returnInfo.setTypeInfo( ( returnInfo.getTypeInfo() | info.getTypeInfo() ) & ~TypeInfo.isTypedef & ~TypeInfo.isForward );
|
returnInfo.setTypeBits( ( returnInfo.getTypeBits() | info.getTypeBits() ) & ~ITypeInfo.isTypedef & ~ITypeInfo.isForward );
|
||||||
returnInfo.setType( info.getType() );
|
returnInfo.setType( info.getType() );
|
||||||
returnInfo.setTypeSymbol( null );
|
returnInfo.setTypeSymbol( null );
|
||||||
returnInfo.addPtrOperator( info.getPtrOperators() );
|
returnInfo.addPtrOperator( info.getPtrOperators() );
|
||||||
}
|
}
|
||||||
if( returnInfo.isType( TypeInfo.t_templateParameter ) ){
|
if( returnInfo.isType( ITypeInfo.t_templateParameter ) ){
|
||||||
returnInfo.setTypeSymbol( typeSymbol );
|
returnInfo.setTypeSymbol( typeSymbol );
|
||||||
}
|
}
|
||||||
returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() );
|
|
||||||
|
|
||||||
if( topInfo.hasPtrOperators() ){
|
if( topInfo.hasPtrOperators() ){
|
||||||
TypeInfo.PtrOp topPtr = (PtrOp) topInfo.getPtrOperators().get(0);
|
returnInfo.addPtrOperator( topInfo.getPtrOperators() );
|
||||||
TypeInfo.PtrOp ptr = new PtrOp( topPtr.getType(), topPtr.isConst(), topPtr.isVolatile() );
|
|
||||||
returnInfo.addPtrOperator( ptr );
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if( infoProvider != null ){
|
if( infoProvider != null ){
|
||||||
returnInfo = infoProvider.getTypeInfo();
|
returnInfo = infoProvider.getTypeInfo( topInfo.getType() );
|
||||||
returnInfo.copy( topInfo );
|
returnInfo.copy( topInfo );
|
||||||
} else
|
} else
|
||||||
returnInfo = new TypeInfo( topInfo );
|
returnInfo = TypeInfoProvider.newTypeInfo( topInfo );
|
||||||
returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() );
|
|
||||||
returnInfo.getOperatorExpressions().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnInfo;
|
return returnInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public TypeInfoProvider getTypeInfoProvider() {
|
|
||||||
return _provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TypeInfoProvider _provider = new TypeInfoProvider();
|
|
||||||
private IContainerSymbol _compilationUnit;
|
private IContainerSymbol _compilationUnit;
|
||||||
private ParserLanguage _language;
|
private ParserLanguage _language;
|
||||||
private ParserMode _mode;
|
private ParserMode _mode;
|
||||||
|
@ -2163,6 +2149,10 @@ public class ParserSymbolTable {
|
||||||
return _mode;
|
return _mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TypeInfoProvider getTypeInfoProvider(){
|
||||||
|
return TypeInfoProvider.getProvider( this );
|
||||||
|
}
|
||||||
|
|
||||||
// protected void pushCommand( Command command ){
|
// protected void pushCommand( Command command ){
|
||||||
// undoList.addFirst( command );
|
// undoList.addFirst( command );
|
||||||
// }
|
// }
|
||||||
|
@ -2214,9 +2204,9 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
static protected class LookupData
|
static protected class LookupData
|
||||||
{
|
{
|
||||||
protected static final TypeFilter ANY_FILTER = new TypeFilter( TypeInfo.t_any );
|
protected static final TypeFilter ANY_FILTER = new TypeFilter( ITypeInfo.t_any );
|
||||||
protected static final TypeFilter CONSTRUCTOR_FILTER = new TypeFilter( TypeInfo.t_constructor );
|
protected static final TypeFilter CONSTRUCTOR_FILTER = new TypeFilter( ITypeInfo.t_constructor );
|
||||||
protected static final TypeFilter FUNCTION_FILTER = new TypeFilter( TypeInfo.t_function );
|
protected static final TypeFilter FUNCTION_FILTER = new TypeFilter( ITypeInfo.t_function );
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Map usingDirectives;
|
public Map usingDirectives;
|
||||||
|
@ -2241,7 +2231,7 @@ public class ParserSymbolTable {
|
||||||
//this LookupData
|
//this LookupData
|
||||||
public boolean isPrefixLookup(){ return false;} //prefix lookup
|
public boolean isPrefixLookup(){ return false;} //prefix lookup
|
||||||
public Set getAmbiguities() { return null; }
|
public Set getAmbiguities() { return null; }
|
||||||
public void addAmbiguity(String n ) { }
|
public void addAmbiguity(String n ) { /*nothing*/ }
|
||||||
public List getParameters() { return null; } //parameter info for resolving functions
|
public List getParameters() { return null; } //parameter info for resolving functions
|
||||||
public HashSet getAssociated() { return null; } //associated namespaces for argument dependant lookup
|
public HashSet getAssociated() { return null; } //associated namespaces for argument dependant lookup
|
||||||
public ISymbol getStopAt() { return null; } //stop looking along the stack once we hit this declaration
|
public ISymbol getStopAt() { return null; } //stop looking along the stack once we hit this declaration
|
||||||
|
@ -2253,18 +2243,19 @@ public class ParserSymbolTable {
|
||||||
static protected class Cost
|
static protected class Cost
|
||||||
{
|
{
|
||||||
|
|
||||||
public Cost( TypeInfoProvider provider, TypeInfo s, TypeInfo t ){
|
public Cost( TypeInfoProvider provider, ITypeInfo s, ITypeInfo t ){
|
||||||
source = provider.getTypeInfo();
|
if( s != null ){
|
||||||
if( s != null )
|
source = provider.getTypeInfo( s.getType() );
|
||||||
source.copy( s );
|
source.copy( s );
|
||||||
|
}
|
||||||
target = provider.getTypeInfo();
|
if( t != null ){
|
||||||
if( t != null )
|
target = provider.getTypeInfo( t.getType() );
|
||||||
target.copy( t );
|
target.copy( t );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeInfo source;
|
private ITypeInfo source;
|
||||||
private TypeInfo target;
|
private ITypeInfo target;
|
||||||
|
|
||||||
public boolean targetHadReference = false;
|
public boolean targetHadReference = false;
|
||||||
|
|
||||||
|
@ -2336,12 +2327,12 @@ public class ParserSymbolTable {
|
||||||
ListIterator iter1 = cost.getTarget().getPtrOperators().listIterator( size );
|
ListIterator iter1 = cost.getTarget().getPtrOperators().listIterator( size );
|
||||||
ListIterator iter2 = getTarget().getPtrOperators().listIterator( size2 );
|
ListIterator iter2 = getTarget().getPtrOperators().listIterator( size2 );
|
||||||
|
|
||||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
ITypeInfo.PtrOp op1 = null, op2 = null;
|
||||||
|
|
||||||
int subOrSuper = 0;
|
int subOrSuper = 0;
|
||||||
for( int i = ( size < size2 ) ? size : size2; i > 0; i-- ){
|
for( int i = ( size < size2 ) ? size : size2; i > 0; i-- ){
|
||||||
op1 = (TypeInfo.PtrOp)iter1.previous();
|
op1 = (ITypeInfo.PtrOp)iter1.previous();
|
||||||
op2 = (TypeInfo.PtrOp)iter2.previous();
|
op2 = (ITypeInfo.PtrOp)iter2.previous();
|
||||||
|
|
||||||
if( subOrSuper == 0)
|
if( subOrSuper == 0)
|
||||||
subOrSuper = op1.compareCVTo( op2 );
|
subOrSuper = op1.compareCVTo( op2 );
|
||||||
|
@ -2370,14 +2361,14 @@ public class ParserSymbolTable {
|
||||||
/**
|
/**
|
||||||
* @return Returns the source.
|
* @return Returns the source.
|
||||||
*/
|
*/
|
||||||
public TypeInfo getSource() {
|
public ITypeInfo getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the target.
|
* @return Returns the target.
|
||||||
*/
|
*/
|
||||||
public TypeInfo getTarget() {
|
public ITypeInfo getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2423,7 +2414,7 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
//if static or an enumerator, the symbol could be visible through more than one path through the heirarchy,
|
//if static or an enumerator, the symbol could be visible through more than one path through the heirarchy,
|
||||||
//so we need to check all paths
|
//so we need to check all paths
|
||||||
boolean checkAllPaths = ( symbol.isType( TypeInfo.t_enumerator ) || symbol.getTypeInfo().checkBit( TypeInfo.isStatic ) );
|
boolean checkAllPaths = ( symbol.isType( ITypeInfo.t_enumerator ) || symbol.getTypeInfo().checkBit( ITypeInfo.isStatic ) );
|
||||||
ASTAccessVisibility resultingAccess = null;
|
ASTAccessVisibility resultingAccess = null;
|
||||||
for( int i = 0; i < numParents; i++ ){
|
for( int i = 0; i < numParents; i++ ){
|
||||||
parent = (IParentSymbol) parents.get(i);
|
parent = (IParentSymbol) parents.get(i);
|
||||||
|
@ -2455,62 +2446,4 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
return resultingAccess;
|
return resultingAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TypeInfoProvider
|
|
||||||
{
|
|
||||||
private final int POOL_SIZE = 16;
|
|
||||||
private final TypeInfo [] pool;
|
|
||||||
private final boolean [] free;
|
|
||||||
private int firstFreeHint = 0;
|
|
||||||
|
|
||||||
public TypeInfoProvider()
|
|
||||||
{
|
|
||||||
pool = new TypeInfo[ POOL_SIZE ];
|
|
||||||
free = new boolean[POOL_SIZE];
|
|
||||||
for( int i = 0; i < POOL_SIZE; i++ )
|
|
||||||
{
|
|
||||||
pool[i] = new TypeInfo();
|
|
||||||
free[i] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TypeInfo getTypeInfo()
|
|
||||||
{
|
|
||||||
for( int i = firstFreeHint; i < POOL_SIZE; ++i )
|
|
||||||
{
|
|
||||||
if( free[i] )
|
|
||||||
{
|
|
||||||
free[i] = false;
|
|
||||||
firstFreeHint = i + 1;
|
|
||||||
return pool[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if there is nothing free, just give them a new one
|
|
||||||
return new TypeInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void returnTypeInfo( TypeInfo t )
|
|
||||||
{
|
|
||||||
for( int i = 0; i < POOL_SIZE; i++ ){
|
|
||||||
if( pool[i] == t ){
|
|
||||||
t.clear();
|
|
||||||
free[i] = true;
|
|
||||||
if( i < firstFreeHint ){
|
|
||||||
firstFreeHint = i;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//else it was one allocated outside the pool
|
|
||||||
}
|
|
||||||
|
|
||||||
public int numAllocated(){
|
|
||||||
int num = 0;
|
|
||||||
for( int i = 0; i < POOL_SIZE; i++ ){
|
|
||||||
if( !free[i] )
|
|
||||||
num++;
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,6 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
||||||
super( table, name );
|
super( table, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SpecializedSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){
|
|
||||||
super( table, name, obj );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object clone(){
|
public Object clone(){
|
||||||
SpecializedSymbol copy = (SpecializedSymbol)super.clone();
|
SpecializedSymbol copy = (SpecializedSymbol)super.clone();
|
||||||
|
|
||||||
|
@ -67,16 +63,16 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
||||||
|
|
||||||
int numSpecArgs = specArgs.size();
|
int numSpecArgs = specArgs.size();
|
||||||
for( int i = 0; i < numSpecArgs; i++ ){
|
for( int i = 0; i < numSpecArgs; i++ ){
|
||||||
TypeInfo info = (TypeInfo) specArgs.get(i);
|
ITypeInfo info = (ITypeInfo) specArgs.get(i);
|
||||||
TypeInfo mappedInfo = (TypeInfo) arguments.get(i);
|
ITypeInfo mappedInfo = (ITypeInfo) arguments.get(i);
|
||||||
|
|
||||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||||
if( mappedInfo.isType( TypeInfo.t_type ) && mappedInfo.getTypeSymbol().isType( TypeInfo.t_templateParameter ) ){
|
if( mappedInfo.isType( ITypeInfo.t_type ) && mappedInfo.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) ){
|
||||||
return deferredInstance( arguments );
|
return deferredInstance( arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
actualArgs.add( mappedInfo );
|
actualArgs.add( mappedInfo );
|
||||||
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol().isType( TypeInfo.t_templateParameter )){
|
if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol().isType( ITypeInfo.t_templateParameter )){
|
||||||
ISymbol param = info.getTypeSymbol();
|
ISymbol param = info.getTypeSymbol();
|
||||||
|
|
||||||
param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() );
|
param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() );
|
||||||
|
@ -141,7 +137,7 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addArgument(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addArgument(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
*/
|
*/
|
||||||
public void addArgument(TypeInfo arg) {
|
public void addArgument(ITypeInfo arg) {
|
||||||
if( _argumentList == Collections.EMPTY_LIST )
|
if( _argumentList == Collections.EMPTY_LIST )
|
||||||
_argumentList = new ArrayList(4);
|
_argumentList = new ArrayList(4);
|
||||||
|
|
||||||
|
|
|
@ -20,44 +20,43 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol;
|
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.pst.ParserSymbolTable.Cost;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public final class TemplateEngine {
|
public final class TemplateEngine {
|
||||||
|
|
||||||
static protected TypeInfo instantiateTypeInfo( TypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
static protected ITypeInfo instantiateTypeInfo( ITypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||||
if( argMap == null )
|
if( argMap == null )
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() == null )
|
if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol() == null )
|
||||||
return info;
|
return info;
|
||||||
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() instanceof IDeferredTemplateInstance ){
|
if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol() instanceof IDeferredTemplateInstance ){
|
||||||
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) info.getTypeSymbol();
|
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) info.getTypeSymbol();
|
||||||
TypeInfo newInfo = new TypeInfo( info );
|
ITypeInfo newInfo = TypeInfoProvider.newTypeInfo( info );
|
||||||
//newInfo.setTypeSymbol( deferred.instantiate( template, argMap ) );
|
//newInfo.setTypeSymbol( deferred.instantiate( template, argMap ) );
|
||||||
template.registerDeferredInstatiation( newInfo, deferred, ITemplateSymbol.DeferredKind.TYPE_SYMBOL, argMap );
|
template.registerDeferredInstatiation( newInfo, deferred, ITemplateSymbol.DeferredKind.TYPE_SYMBOL, argMap );
|
||||||
newInfo.setTypeSymbol( deferred );
|
newInfo.setTypeSymbol( deferred );
|
||||||
return newInfo;
|
return newInfo;
|
||||||
} else if( info.isType( TypeInfo.t_type ) &&
|
} else if( info.isType( ITypeInfo.t_type ) &&
|
||||||
info.getTypeSymbol().isType( TypeInfo.t_templateParameter ) &&
|
info.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) &&
|
||||||
argMap.containsKey( info.getTypeSymbol() ) )
|
argMap.containsKey( info.getTypeSymbol() ) )
|
||||||
{
|
{
|
||||||
TypeInfo targetInfo = new TypeInfo( (TypeInfo) argMap.get( info.getTypeSymbol() ) );
|
ITypeInfo targetInfo = TypeInfoProvider.newTypeInfo( (ITypeInfo) argMap.get( info.getTypeSymbol() ) );
|
||||||
if( info.hasPtrOperators() ){
|
if( info.hasPtrOperators() ){
|
||||||
targetInfo.addPtrOperator( info.getPtrOperators() );
|
targetInfo.addPtrOperator( info.getPtrOperators() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( info.checkBit( TypeInfo.isConst ) )
|
if( info.checkBit( ITypeInfo.isConst ) )
|
||||||
targetInfo.setBit( true, TypeInfo.isConst );
|
targetInfo.setBit( true, ITypeInfo.isConst );
|
||||||
|
|
||||||
if( info.checkBit( TypeInfo.isVolatile ) )
|
if( info.checkBit( ITypeInfo.isVolatile ) )
|
||||||
targetInfo.setBit( true, TypeInfo.isVolatile );
|
targetInfo.setBit( true, ITypeInfo.isVolatile );
|
||||||
|
|
||||||
return targetInfo;
|
return targetInfo;
|
||||||
} else if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol().isType( TypeInfo.t_function ) ){
|
} else if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol().isType( ITypeInfo.t_function ) ){
|
||||||
TypeInfo newInfo = new TypeInfo( info );
|
ITypeInfo newInfo = TypeInfoProvider.newTypeInfo( info );
|
||||||
newInfo.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
|
newInfo.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
|
||||||
return newInfo;
|
return newInfo;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +64,7 @@ public final class TemplateEngine {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void instantiateDeferredTypeInfo( TypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException {
|
static protected void instantiateDeferredTypeInfo( ITypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException {
|
||||||
info.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
|
info.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ public final class TemplateEngine {
|
||||||
* @param symbol
|
* @param symbol
|
||||||
* @param map
|
* @param map
|
||||||
*/
|
*/
|
||||||
public static void discardDeferredTypeInfo(TypeInfo info, TemplateSymbol template, Map map) {
|
public static void discardDeferredTypeInfo(ITypeInfo info, TemplateSymbol template, Map map) {
|
||||||
ISymbol instance = info.getTypeSymbol();
|
ISymbol instance = info.getTypeSymbol();
|
||||||
if( !(instance instanceof IDeferredTemplateInstance ) )
|
if( !(instance instanceof IDeferredTemplateInstance ) )
|
||||||
template.removeInstantiation( (IContainerSymbol) instance );
|
template.removeInstantiation( (IContainerSymbol) instance );
|
||||||
|
@ -105,12 +104,12 @@ public final class TemplateEngine {
|
||||||
|
|
||||||
int specArgsSize = specArgs.size();
|
int specArgsSize = specArgs.size();
|
||||||
HashMap map = new HashMap();
|
HashMap map = new HashMap();
|
||||||
TypeInfo info1 = null, info2 = null;
|
ITypeInfo info1 = null, info2 = null;
|
||||||
|
|
||||||
boolean match = true;
|
boolean match = true;
|
||||||
for( int j = 0; j < specArgsSize; j++ ){
|
for( int j = 0; j < specArgsSize; j++ ){
|
||||||
info1 = (TypeInfo) specArgs.get(j);
|
info1 = (ITypeInfo) specArgs.get(j);
|
||||||
info2 = (TypeInfo) args.get(j);
|
info2 = (ITypeInfo) args.get(j);
|
||||||
|
|
||||||
ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||||
sym1.setTypeInfo( info1 );
|
sym1.setTypeInfo( info1 );
|
||||||
|
@ -140,17 +139,17 @@ public final class TemplateEngine {
|
||||||
return bestMatch;
|
return bestMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected boolean matchTemplateParameterAndArgument( ISymbol param, TypeInfo arg ){
|
static protected boolean matchTemplateParameterAndArgument( ISymbol param, ITypeInfo arg ){
|
||||||
if( !isValidArgument(param, arg) ){
|
if( !isValidArgument(param, arg) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){
|
||||||
return true;
|
return true;
|
||||||
} else if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
} else if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){
|
||||||
|
|
||||||
ISymbol symbol = arg.getTypeSymbol();
|
ISymbol symbol = arg.getTypeSymbol();
|
||||||
if( !arg.isType( TypeInfo.t_type ) || symbol == null || !symbol.isType( TypeInfo.t_template ) ){
|
if( !arg.isType( ITypeInfo.t_type ) || symbol == null || !symbol.isType( ITypeInfo.t_template ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,12 +177,18 @@ public final class TemplateEngine {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Cost cost = null;
|
Cost cost = null;
|
||||||
|
TypeInfoProvider provider = TypeInfoProvider.getProvider( param.getSymbolTable() );
|
||||||
try{
|
try{
|
||||||
|
ITypeInfo info = provider.getTypeInfo( param.getTypeInfo().getTemplateParameterType() );
|
||||||
try {
|
try {
|
||||||
TypeInfo info = new TypeInfo( param.getTypeInfo() );
|
info.copy( param.getTypeInfo() );
|
||||||
info.setType( info.getTemplateParameterType() );
|
info.setType( info.getTemplateParameterType() );
|
||||||
cost = param.getSymbolTable().checkStandardConversionSequence( arg, info );
|
cost = param.getSymbolTable().checkStandardConversionSequence( arg, info );
|
||||||
|
provider.returnTypeInfo( info );
|
||||||
} catch (ParserSymbolTableException e) {
|
} catch (ParserSymbolTableException e) {
|
||||||
|
//nothing
|
||||||
|
} finally {
|
||||||
|
provider.returnTypeInfo( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cost == null || cost.rank != Cost.NO_MATCH_RANK ){
|
if( cost == null || cost.rank != Cost.NO_MATCH_RANK ){
|
||||||
|
@ -191,16 +196,16 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
} finally{
|
} finally{
|
||||||
if( cost != null )
|
if( cost != null )
|
||||||
cost.release( param.getSymbolTable().getTypeInfoProvider() );
|
cost.release( provider );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private boolean isValidArgument(ISymbol param, TypeInfo arg) {
|
static private boolean isValidArgument(ISymbol param, ITypeInfo arg) {
|
||||||
if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){
|
||||||
//14.3.1, local type, type with no name
|
//14.3.1, local type, type with no name
|
||||||
if( arg.isType( TypeInfo.t_type ) && arg.getTypeSymbol() != null ){
|
if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol() != null ){
|
||||||
ISymbol symbol = arg.getTypeSymbol();
|
ISymbol symbol = arg.getTypeSymbol();
|
||||||
if( symbol.getName().equals( ParserSymbolTable.EMPTY_NAME ) ){
|
if( symbol.getName().equals( ParserSymbolTable.EMPTY_NAME ) ){
|
||||||
return false;
|
return false;
|
||||||
|
@ -208,15 +213,15 @@ public final class TemplateEngine {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
} else if ( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){
|
||||||
|
//TODO
|
||||||
} else {
|
} else {
|
||||||
List ptrs = param.getPtrOperators();
|
List ptrs = param.getPtrOperators();
|
||||||
PtrOp op = ( ptrs.size() > 0 ) ? (PtrOp) ptrs.get(0) : null;
|
ITypeInfo.PtrOp op = ( ptrs.size() > 0 ) ? (ITypeInfo.PtrOp) ptrs.get(0) : null;
|
||||||
|
|
||||||
//if the parameter has reference type
|
//if the parameter has reference type
|
||||||
if( op != null && op.getType() == PtrOp.t_reference ){
|
if( op != null && op.getType() == ITypeInfo.PtrOp.t_reference ){
|
||||||
if( arg.isType( TypeInfo.t_type ) && arg.getTypeSymbol() != null ){
|
if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol() != null ){
|
||||||
if( arg.getTypeSymbol().getName().equals( ParserSymbolTable.EMPTY_NAME ) ){
|
if( arg.getTypeSymbol().getName().equals( ParserSymbolTable.EMPTY_NAME ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -225,17 +230,17 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
List argPtrs = arg.getPtrOperators();
|
List argPtrs = arg.getPtrOperators();
|
||||||
PtrOp argOp = (argPtrs.size() > 0 ) ? (PtrOp)argPtrs.get(0) : null;
|
ITypeInfo.PtrOp argOp = (argPtrs.size() > 0 ) ? (ITypeInfo.PtrOp)argPtrs.get(0) : null;
|
||||||
|
|
||||||
//address of an object with external linkage exluding nonstatic class members
|
//address of an object with external linkage exluding nonstatic class members
|
||||||
//name of an object with external linkage excluding nonstatic class members
|
//name of an object with external linkage excluding nonstatic class members
|
||||||
if( (argOp != null && argOp.getType() == PtrOp.t_pointer ) ||
|
if( (argOp != null && argOp.getType() == ITypeInfo.PtrOp.t_pointer ) ||
|
||||||
( arg.isType( TypeInfo.t_type ) ) )
|
( arg.isType( ITypeInfo.t_type ) ) )
|
||||||
{
|
{
|
||||||
ISymbol symbol = arg.getTypeSymbol();
|
ISymbol symbol = arg.getTypeSymbol();
|
||||||
if ( symbol != null && symbol.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if ( symbol != null && symbol.getContainingSymbol().isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
if( !symbol.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if( !symbol.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
if( !symbol.getTypeInfo().checkBit( TypeInfo.isStatic ) ){
|
if( !symbol.getTypeInfo().checkBit( ITypeInfo.isStatic ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,16 +250,16 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
//integral or enumeration type
|
//integral or enumeration type
|
||||||
if( op == null && ( arg.isType( TypeInfo.t_bool, TypeInfo.t_int ) ||
|
if( op == null && ( arg.isType( ITypeInfo.t_bool, ITypeInfo.t_int ) ||
|
||||||
arg.isType( TypeInfo.t_enumerator ) ) )
|
arg.isType( ITypeInfo.t_enumerator ) ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//name of a non-type template parameter
|
//name of a non-type template parameter
|
||||||
if( arg.isType( TypeInfo.t_templateParameter ) &&
|
if( arg.isType( ITypeInfo.t_templateParameter ) &&
|
||||||
arg.getTemplateParameterType() != TypeInfo.t_typeName &&
|
arg.getTemplateParameterType() != ITypeInfo.t_typeName &&
|
||||||
arg.getTemplateParameterType() != TypeInfo.t_template )
|
arg.getTemplateParameterType() != ITypeInfo.t_template )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -263,25 +268,25 @@ public final class TemplateEngine {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected boolean hasExternalLinkage( TypeInfo type ){
|
static protected boolean hasExternalLinkage( ITypeInfo type ){
|
||||||
if( ! type.isType( TypeInfo.t_type ) )
|
if( ! type.isType( ITypeInfo.t_type ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !hasNoLinkage( type );
|
return !hasNoLinkage( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected boolean hasInternalLinkage( TypeInfo type ){
|
static protected boolean hasInternalLinkage( ITypeInfo type ){
|
||||||
return !hasNoLinkage( type );
|
return !hasNoLinkage( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected boolean hasNoLinkage( TypeInfo type ){
|
static protected boolean hasNoLinkage( ITypeInfo type ){
|
||||||
if( type.isType( TypeInfo.t_type ) ){
|
if( type.isType( ITypeInfo.t_type ) ){
|
||||||
ISymbol symbol = type.getTypeSymbol();
|
ISymbol symbol = type.getTypeSymbol();
|
||||||
if( symbol.getContainingSymbol() == null ){
|
if( symbol.getContainingSymbol() == null ){
|
||||||
return true; //a temporary
|
return true; //a temporary
|
||||||
}
|
}
|
||||||
|
|
||||||
return symbol.getContainingSymbol().isType( TypeInfo.t_function );
|
return symbol.getContainingSymbol().isType( ITypeInfo.t_function );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -293,20 +298,20 @@ public final class TemplateEngine {
|
||||||
* @param pSymbol
|
* @param pSymbol
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static private TypeInfo getParameterTypeForDeduction( ISymbol pSymbol ){
|
static private ITypeInfo getParameterTypeForDeduction( ISymbol pSymbol ){
|
||||||
TypeInfo p = new TypeInfo( pSymbol.getTypeInfo () );
|
ITypeInfo p = TypeInfoProvider.newTypeInfo( pSymbol.getTypeInfo () );
|
||||||
List pPtrs = p.getPtrOperators();
|
List pPtrs = p.getPtrOperators();
|
||||||
if( pPtrs.size() > 0 ){
|
if( pPtrs.size() > 0 ){
|
||||||
PtrOp pOp = (PtrOp) pPtrs.get( 0 );
|
ITypeInfo.PtrOp pOp = (ITypeInfo.PtrOp) pPtrs.get( 0 );
|
||||||
if( pOp.getType() == PtrOp.t_reference || pOp.getType() == PtrOp.t_undef_ptr ){
|
if( pOp.getType() == ITypeInfo.PtrOp.t_reference || pOp.getType() == ITypeInfo.PtrOp.t_undef_ptr ){
|
||||||
pPtrs.remove( 0 );
|
pPtrs.remove( 0 );
|
||||||
} else {
|
} else {
|
||||||
PtrOp newOp = new PtrOp( pOp.getType(), false, false );
|
ITypeInfo.PtrOp newOp = new ITypeInfo.PtrOp( pOp.getType(), false, false );
|
||||||
pPtrs.set( 0, newOp );
|
pPtrs.set( 0, newOp );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.setBit( false, TypeInfo.isConst );
|
p.setBit( false, ITypeInfo.isConst );
|
||||||
p.setBit( false, TypeInfo.isVolatile );
|
p.setBit( false, ITypeInfo.isVolatile );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -322,32 +327,32 @@ public final class TemplateEngine {
|
||||||
* @param aInfo
|
* @param aInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static private TypeInfo getArgumentTypeForDeduction( TypeInfo aInfo, boolean pIsAReferenceType ) throws ParserSymbolTableException{
|
static private ITypeInfo getArgumentTypeForDeduction( ITypeInfo aInfo, boolean pIsAReferenceType ) throws ParserSymbolTableException{
|
||||||
|
|
||||||
TypeInfo a = ParserSymbolTable.getFlatTypeInfo( aInfo, null );
|
ITypeInfo a = ParserSymbolTable.getFlatTypeInfo( aInfo, null );
|
||||||
|
|
||||||
if( !pIsAReferenceType ){
|
if( !pIsAReferenceType ){
|
||||||
ISymbol aSymbol = a.getTypeSymbol();
|
ISymbol aSymbol = a.getTypeSymbol();
|
||||||
|
|
||||||
if( a.getType() == TypeInfo.t_type ){
|
if( a.getType() == ITypeInfo.t_type ){
|
||||||
if( aSymbol == null ){
|
if( aSymbol == null ){
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
||||||
} else if( aSymbol.isType( TypeInfo.t_function ) && a.getPtrOperators().size() == 0 ){
|
} else if( aSymbol.isType( ITypeInfo.t_function ) && a.getPtrOperators().size() == 0 ){
|
||||||
a.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
a.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List aPtrs = a.getPtrOperators();
|
List aPtrs = a.getPtrOperators();
|
||||||
if( aPtrs.size() > 0 ){
|
if( aPtrs.size() > 0 ){
|
||||||
PtrOp pOp = (PtrOp) aPtrs.get( 0 );
|
ITypeInfo.PtrOp pOp = (ITypeInfo.PtrOp) aPtrs.get( 0 );
|
||||||
|
|
||||||
if( pOp.getType() == PtrOp.t_array ){
|
if( pOp.getType() == ITypeInfo.PtrOp.t_array ){
|
||||||
aPtrs.set( 0, new PtrOp( PtrOp.t_pointer, false, false ) );
|
aPtrs.set( 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) );
|
||||||
} else {
|
} else {
|
||||||
aPtrs.set( 0, new PtrOp( pOp.getType(), false, false ) );
|
aPtrs.set( 0, new ITypeInfo.PtrOp( pOp.getType(), false, false ) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a.setBit( false, TypeInfo.isConst );
|
a.setBit( false, ITypeInfo.isConst );
|
||||||
a.setBit( false, TypeInfo.isVolatile );
|
a.setBit( false, ITypeInfo.isVolatile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,30 +442,30 @@ public final class TemplateEngine {
|
||||||
return aSymbol;
|
return aSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private boolean deduceTemplateArgument( Map map, ISymbol pSymbol, TypeInfo a ) throws ParserSymbolTableException{//, Map argumentMap ){
|
static private boolean deduceTemplateArgument( Map map, ISymbol pSymbol, ITypeInfo a ) throws ParserSymbolTableException{
|
||||||
ISymbol symbol;
|
ISymbol symbol;
|
||||||
|
|
||||||
boolean pIsAReferenceType = false;
|
boolean pIsAReferenceType = false;
|
||||||
|
|
||||||
List ptrOps = pSymbol.getPtrOperators();
|
List ptrOps = pSymbol.getPtrOperators();
|
||||||
if( ptrOps.size() > 0 && ((PtrOp)ptrOps.get(0)).getType() == TypeInfo.PtrOp.t_reference ){
|
if( ptrOps.size() > 0 && ((ITypeInfo.PtrOp)ptrOps.get(0)).getType() == ITypeInfo.PtrOp.t_reference ){
|
||||||
pIsAReferenceType = true;
|
pIsAReferenceType = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo p = getParameterTypeForDeduction( pSymbol );
|
ITypeInfo p = getParameterTypeForDeduction( pSymbol );
|
||||||
|
|
||||||
a = getArgumentTypeForDeduction( a, pIsAReferenceType );
|
a = getArgumentTypeForDeduction( a, pIsAReferenceType );
|
||||||
|
|
||||||
if( p.isType( TypeInfo.t_type ) ){
|
if( p.isType( ITypeInfo.t_type ) ){
|
||||||
symbol = p.getTypeSymbol();
|
symbol = p.getTypeSymbol();
|
||||||
ISymbol aSymbol = a.getTypeSymbol();
|
ISymbol aSymbol = a.getTypeSymbol();
|
||||||
if( symbol == null || ( a.isType( TypeInfo.t_type) && aSymbol == null ) || a.isType( TypeInfo.t_undef ))
|
if( symbol == null || ( a.isType( ITypeInfo.t_type) && aSymbol == null ) || a.isType( ITypeInfo.t_undef ))
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
||||||
if( symbol instanceof IDeferredTemplateInstance || symbol.isTemplateInstance() ){
|
if( symbol instanceof IDeferredTemplateInstance || symbol.isTemplateInstance() ){
|
||||||
return deduceFromTemplateTemplateArguments(map, symbol, aSymbol);
|
return deduceFromTemplateTemplateArguments(map, symbol, aSymbol);
|
||||||
}
|
}
|
||||||
if( symbol.isType( TypeInfo.t_templateParameter ) ){
|
if( symbol.isType( ITypeInfo.t_templateParameter ) ){
|
||||||
if( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
if( symbol.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){
|
||||||
//a = getFlatTypeInfo( a );
|
//a = getFlatTypeInfo( a );
|
||||||
List aPtrs = a.getPtrOperators();
|
List aPtrs = a.getPtrOperators();
|
||||||
List pPtrs = p.getPtrOperators();
|
List pPtrs = p.getPtrOperators();
|
||||||
|
@ -475,13 +480,13 @@ public final class TemplateEngine {
|
||||||
if( pSize != aSize )
|
if( pSize != aSize )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PtrOp pOp = null;
|
ITypeInfo.PtrOp pOp = null;
|
||||||
PtrOp aOp = null;
|
ITypeInfo.PtrOp aOp = null;
|
||||||
|
|
||||||
int aIdx = 0;
|
int aIdx = 0;
|
||||||
for( int i = 0; i < pSize; i++ ){
|
for( int i = 0; i < pSize; i++ ){
|
||||||
pOp = (PtrOp) pPtrs.get(i);
|
pOp = (ITypeInfo.PtrOp) pPtrs.get(i);
|
||||||
aOp = (PtrOp) aPtrs.get(aIdx++);
|
aOp = (ITypeInfo.PtrOp) aPtrs.get(aIdx++);
|
||||||
if( pOp.getType() == aOp.getType() ){
|
if( pOp.getType() == aOp.getType() ){
|
||||||
if( !pOp.equals( aOp ) )
|
if( !pOp.equals( aOp ) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -492,22 +497,22 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//cvlist T
|
//cvlist T
|
||||||
if( p.checkBit( TypeInfo.isConst ) ){
|
if( p.checkBit( ITypeInfo.isConst ) ){
|
||||||
if( !a.checkBit( TypeInfo.isConst ) )
|
if( !a.checkBit( ITypeInfo.isConst ) )
|
||||||
return false;
|
return false;
|
||||||
a.setBit( false, TypeInfo.isConst);
|
a.setBit( false, ITypeInfo.isConst);
|
||||||
}
|
}
|
||||||
if( p.checkBit( TypeInfo.isVolatile ) ){
|
if( p.checkBit( ITypeInfo.isVolatile ) ){
|
||||||
if( !a.checkBit( TypeInfo.isVolatile ) )
|
if( !a.checkBit( ITypeInfo.isVolatile ) )
|
||||||
return false;
|
return false;
|
||||||
a.setBit( false, TypeInfo.isVolatile);
|
a.setBit( false, ITypeInfo.isVolatile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//T
|
//T
|
||||||
return deduceArgument( map, symbol, a );
|
return deduceArgument( map, symbol, a );
|
||||||
|
|
||||||
} else if ( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
} else if ( symbol.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){
|
||||||
|
//TODO
|
||||||
} else {
|
} else {
|
||||||
//non-type parameter
|
//non-type parameter
|
||||||
if( symbol.getTypeInfo().getTemplateParameterType() == a.getType() ){
|
if( symbol.getTypeInfo().getTemplateParameterType() == a.getType() ){
|
||||||
|
@ -517,9 +522,9 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//T (*) ( ), T ( T::* ) ( T ), & variations
|
//T (*) ( ), T ( T::* ) ( T ), & variations
|
||||||
else if( symbol.isType( TypeInfo.t_function ) ){
|
else if( symbol.isType( ITypeInfo.t_function ) ){
|
||||||
if( !(aSymbol instanceof IParameterizedSymbol)||
|
if( !(aSymbol instanceof IParameterizedSymbol)||
|
||||||
!aSymbol.isType( TypeInfo.t_function ) )
|
!aSymbol.isType( ITypeInfo.t_function ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -533,9 +538,9 @@ public final class TemplateEngine {
|
||||||
|
|
||||||
List pPtrs = p.getPtrOperators();
|
List pPtrs = p.getPtrOperators();
|
||||||
if( pPtrs.size() != 0 ){
|
if( pPtrs.size() != 0 ){
|
||||||
PtrOp op = (PtrOp) pPtrs.get(0);
|
ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) pPtrs.get(0);
|
||||||
if( op.getType() == PtrOp.t_memberPointer ){
|
if( op.getType() == ITypeInfo.PtrOp.t_memberPointer ){
|
||||||
TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() );
|
ITypeInfo info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, aFunction.getContainingSymbol() );
|
||||||
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
|
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +554,7 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
int size = pParams.size();
|
int size = pParams.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
TypeInfo info = ((ISymbol)aParams.get( i )).getTypeInfo();
|
ITypeInfo info = ((ISymbol)aParams.get( i )).getTypeInfo();
|
||||||
if( !deduceTemplateArgument( map, (ISymbol)pParams.get(i), info ) ){
|
if( !deduceTemplateArgument( map, (ISymbol)pParams.get(i), info ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -558,7 +563,7 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if( p.isType( TypeInfo.t_templateParameter ) ){
|
if( p.isType( ITypeInfo.t_templateParameter ) ){
|
||||||
return deduceArgument( map, pSymbol, a );
|
return deduceArgument( map, pSymbol, a );
|
||||||
}
|
}
|
||||||
if( p.getType() == a.getType() ){
|
if( p.getType() == a.getType() ){
|
||||||
|
@ -621,10 +626,10 @@ public final class TemplateEngine {
|
||||||
sym = (ISymbol) obj;
|
sym = (ISymbol) obj;
|
||||||
} else {
|
} else {
|
||||||
sym = pSymbol.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
sym = pSymbol.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||||
sym.setTypeInfo( (TypeInfo) obj );
|
sym.setTypeInfo( (ITypeInfo) obj );
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo arg = transformTypeInfo( aList.get( i ), null );
|
ITypeInfo arg = transformTypeInfo( aList.get( i ), null );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if( !deduceTemplateArgument( map, sym, arg ) ){
|
if( !deduceTemplateArgument( map, sym, arg ) ){
|
||||||
|
@ -676,7 +681,7 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
ISymbol templateSymbol = template.getTemplatedSymbol();
|
ISymbol templateSymbol = template.getTemplatedSymbol();
|
||||||
if( !templateSymbol.isType( TypeInfo.t_function ) ){
|
if( !templateSymbol.isType( ITypeInfo.t_function ) ){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +698,7 @@ public final class TemplateEngine {
|
||||||
int size = pList.size();
|
int size = pList.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
try {
|
try {
|
||||||
if( !deduceTemplateArgument( map, (ISymbol) pList.get(i), (TypeInfo) arguments.get(i) ) ){
|
if( !deduceTemplateArgument( map, (ISymbol) pList.get(i), (ITypeInfo) arguments.get(i) ) ){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ParserSymbolTableException e) {
|
} catch (ParserSymbolTableException e) {
|
||||||
|
@ -704,12 +709,12 @@ public final class TemplateEngine {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private boolean deduceArgument( Map map, ISymbol p, TypeInfo a ){
|
static private boolean deduceArgument( Map map, ISymbol p, ITypeInfo a ){
|
||||||
|
|
||||||
a = ParserSymbolTable.getFlatTypeInfo( a, null );
|
a = ParserSymbolTable.getFlatTypeInfo( a, null );
|
||||||
|
|
||||||
if( map.containsKey( p ) ){
|
if( map.containsKey( p ) ){
|
||||||
TypeInfo current = (TypeInfo)map.get( p );
|
ITypeInfo current = (ITypeInfo)map.get( p );
|
||||||
return current.equals( a );
|
return current.equals( a );
|
||||||
}
|
}
|
||||||
map.put( p, a );
|
map.put( p, a );
|
||||||
|
@ -733,7 +738,7 @@ public final class TemplateEngine {
|
||||||
ITemplateSymbol template1 = spec1;
|
ITemplateSymbol template1 = spec1;
|
||||||
ITemplateSymbol template2 = spec2;
|
ITemplateSymbol template2 = spec2;
|
||||||
|
|
||||||
if( decl.isType( TypeInfo.t_class, TypeInfo.t_union ) ) {
|
if( decl.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ) {
|
||||||
template1 = classTemplateSpecializationToFunctionTemplate( spec1 );
|
template1 = classTemplateSpecializationToFunctionTemplate( spec1 );
|
||||||
template2 = classTemplateSpecializationToFunctionTemplate( spec2 );
|
template2 = classTemplateSpecializationToFunctionTemplate( spec2 );
|
||||||
}
|
}
|
||||||
|
@ -805,22 +810,22 @@ public final class TemplateEngine {
|
||||||
|
|
||||||
static private Map createMapForFunctionTemplateOrdering( ITemplateSymbol template ){
|
static private Map createMapForFunctionTemplateOrdering( ITemplateSymbol template ){
|
||||||
HashMap map = new HashMap();
|
HashMap map = new HashMap();
|
||||||
TypeInfo val = null;
|
ITypeInfo val = null;
|
||||||
List paramList = template.getParameterList();
|
List paramList = template.getParameterList();
|
||||||
int size = paramList.size();
|
int size = paramList.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
ISymbol param = (ISymbol) paramList.get( i );
|
ISymbol param = (ISymbol) paramList.get( i );
|
||||||
//template type parameter
|
//template type parameter
|
||||||
if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){
|
||||||
val = new TypeInfo( TypeInfo.t_type, 0, template.getSymbolTable().newSymbol( "", TypeInfo.t_class ) ); //$NON-NLS-1$
|
val = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, template.getSymbolTable().newSymbol( "", ITypeInfo.t_class ) ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
//template parameter
|
//template parameter
|
||||||
else if ( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ) {
|
else if ( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ) {
|
||||||
|
//TODO
|
||||||
}
|
}
|
||||||
//non type parameter
|
//non type parameter
|
||||||
else {
|
else {
|
||||||
val = new TypeInfo( param.getTypeInfo().getTemplateParameterType(), 0, null );
|
val = TypeInfoProvider.newTypeInfo( param.getTypeInfo().getTemplateParameterType() );
|
||||||
}
|
}
|
||||||
map.put( param, val );
|
map.put( param, val );
|
||||||
}
|
}
|
||||||
|
@ -844,13 +849,13 @@ public final class TemplateEngine {
|
||||||
//TODO clean up this
|
//TODO clean up this
|
||||||
((ContainerSymbol)transformed).getContents().clear();
|
((ContainerSymbol)transformed).getContents().clear();
|
||||||
|
|
||||||
IParameterizedSymbol function = specialization.getSymbolTable().newParameterizedSymbol( transformed.getName(), TypeInfo.t_function );
|
IParameterizedSymbol function = specialization.getSymbolTable().newParameterizedSymbol( transformed.getName(), ITypeInfo.t_function );
|
||||||
try{
|
try{
|
||||||
transformed.addSymbol( function );
|
transformed.addSymbol( function );
|
||||||
} catch ( ParserSymbolTableException e ){
|
} catch ( ParserSymbolTableException e ){
|
||||||
//we shouldn't get this because there aren't any other symbols in the template
|
//we shouldn't get this because there aren't any other symbols in the template
|
||||||
}
|
}
|
||||||
ISymbol param = specialization.getSymbolTable().newSymbol( "", TypeInfo.t_type ); //$NON-NLS-1$
|
ISymbol param = specialization.getSymbolTable().newSymbol( "", ITypeInfo.t_type ); //$NON-NLS-1$
|
||||||
|
|
||||||
param.setTypeSymbol( specialization.instantiate( specialization.getArgumentList() ) );
|
param.setTypeSymbol( specialization.instantiate( specialization.getArgumentList() ) );
|
||||||
|
|
||||||
|
@ -859,22 +864,22 @@ public final class TemplateEngine {
|
||||||
return transformed;
|
return transformed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private TypeInfo transformTypeInfo( Object obj, Map argumentMap ){
|
static private ITypeInfo transformTypeInfo( Object obj, Map argumentMap ){
|
||||||
TypeInfo info = null;
|
ITypeInfo info = null;
|
||||||
if( obj instanceof ISymbol ){
|
if( obj instanceof ISymbol ){
|
||||||
info = new TypeInfo( TypeInfo.t_type, 0, (ISymbol) obj );
|
info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, (ISymbol) obj );
|
||||||
} else {
|
} else {
|
||||||
info = (TypeInfo) obj;
|
info = (ITypeInfo) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( argumentMap == null )
|
if( argumentMap == null )
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
if( info.isType( TypeInfo.t_type ) &&
|
if( info.isType( ITypeInfo.t_type ) &&
|
||||||
info.getTypeSymbol().isType( TypeInfo.t_templateParameter ) &&
|
info.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) &&
|
||||||
argumentMap.containsKey( info.getTypeSymbol() ) )
|
argumentMap.containsKey( info.getTypeSymbol() ) )
|
||||||
{
|
{
|
||||||
TypeInfo newType = new TypeInfo( (TypeInfo) argumentMap.get( info.getTypeSymbol() ) );
|
ITypeInfo newType = TypeInfoProvider.newTypeInfo( (ITypeInfo) argumentMap.get( info.getTypeSymbol() ) );
|
||||||
if( info.hasPtrOperators() )
|
if( info.hasPtrOperators() )
|
||||||
newType.addPtrOperator( info.getPtrOperators() );
|
newType.addPtrOperator( info.getPtrOperators() );
|
||||||
|
|
||||||
|
@ -907,8 +912,8 @@ public final class TemplateEngine {
|
||||||
List instanceArgs = new ArrayList( templateParams.size() );
|
List instanceArgs = new ArrayList( templateParams.size() );
|
||||||
for( int i = 0; i < numTemplateParams; i++ ){
|
for( int i = 0; i < numTemplateParams; i++ ){
|
||||||
ISymbol param = (ISymbol) templateParams.get(i);
|
ISymbol param = (ISymbol) templateParams.get(i);
|
||||||
TypeInfo arg = (TypeInfo) ( i < numTemplateArgs ? templateArguments.get(i) : null);
|
ITypeInfo arg = (ITypeInfo) ( i < numTemplateArgs ? templateArguments.get(i) : null);
|
||||||
TypeInfo mapped = (TypeInfo) map.get( param );
|
ITypeInfo mapped = (ITypeInfo) map.get( param );
|
||||||
|
|
||||||
if( arg != null && mapped != null )
|
if( arg != null && mapped != null )
|
||||||
if( arg.equals( mapped ) )
|
if( arg.equals( mapped ) )
|
||||||
|
@ -952,7 +957,7 @@ public final class TemplateEngine {
|
||||||
} else if( !parameters.isEmpty() ){
|
} else if( !parameters.isEmpty() ){
|
||||||
int size = parameters.size();
|
int size = parameters.size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
if( parameters.get(i) != ((TypeInfo) arguments.get(i)).getTypeSymbol() ){
|
if( parameters.get(i) != ((ITypeInfo) arguments.get(i)).getTypeSymbol() ){
|
||||||
forPrimary = false;
|
forPrimary = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1025,12 +1030,12 @@ public final class TemplateEngine {
|
||||||
|
|
||||||
int a1Size = a1.size();
|
int a1Size = a1.size();
|
||||||
for( int i = 0; i < a1Size; i++ ){
|
for( int i = 0; i < a1Size; i++ ){
|
||||||
TypeInfo t1 = (TypeInfo) a1.get( i );
|
ITypeInfo t1 = (ITypeInfo) a1.get( i );
|
||||||
TypeInfo t2 = (TypeInfo) a2.get( i );
|
ITypeInfo t2 = (ITypeInfo) a2.get( i );
|
||||||
|
|
||||||
if( t1.equals( t2 ) ){
|
if( t1.equals( t2 ) ){
|
||||||
continue;
|
continue;
|
||||||
} else if( t1.isType( TypeInfo.t_type ) && t2.isType( TypeInfo.t_type ) ) {
|
} else if( t1.isType( ITypeInfo.t_type ) && t2.isType( ITypeInfo.t_type ) ) {
|
||||||
ISymbol s1 = t1.getTypeSymbol(), s2 = t2.getTypeSymbol();
|
ISymbol s1 = t1.getTypeSymbol(), s2 = t2.getTypeSymbol();
|
||||||
if( m[0].containsKey( s1 ) && m[1].containsKey( s2 ) && m[0].get( s1 ).equals( m[1].get( s2 ) ) )
|
if( m[0].containsKey( s1 ) && m[1].containsKey( s2 ) && m[0].get( s1 ).equals( m[1].get( s2 ) ) )
|
||||||
continue;
|
continue;
|
||||||
|
@ -1097,7 +1102,7 @@ public final class TemplateEngine {
|
||||||
*/
|
*/
|
||||||
static protected ISymbol instantiateWithinTemplateScope( IContainerSymbol container, ITemplateSymbol symbol ) throws ParserSymbolTableException
|
static protected ISymbol instantiateWithinTemplateScope( IContainerSymbol container, ITemplateSymbol symbol ) throws ParserSymbolTableException
|
||||||
{
|
{
|
||||||
if( symbol.getTemplatedSymbol().isType( TypeInfo.t_function ) ){
|
if( symbol.getTemplatedSymbol().isType( ITypeInfo.t_function ) ){
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,7 +1120,7 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
containing = containing.getContainingSymbol();
|
containing = containing.getContainingSymbol();
|
||||||
|
|
||||||
if( containing != null && !containing.isTemplateMember() || !containing.isType( TypeInfo.t_template ) ){
|
if( containing != null && !containing.isTemplateMember() || !containing.isType( ITypeInfo.t_template ) ){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1129,7 +1134,7 @@ public final class TemplateEngine {
|
||||||
int size = params.size();
|
int size = params.size();
|
||||||
List args = new ArrayList( size );
|
List args = new ArrayList( size );
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
args.add( new TypeInfo( TypeInfo.t_type, 0, (ISymbol) params.get(i) ) );
|
args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, (ISymbol) params.get(i) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = template.instantiate( args );
|
instance = template.instantiate( args );
|
||||||
|
@ -1154,14 +1159,14 @@ public final class TemplateEngine {
|
||||||
|
|
||||||
static protected boolean canAddTemplate( IContainerSymbol containing, ITemplateSymbol template ){
|
static protected boolean canAddTemplate( IContainerSymbol containing, ITemplateSymbol template ){
|
||||||
//14-2 A template-declaration can appear only as a namespace scope or class scope declaration
|
//14-2 A template-declaration can appear only as a namespace scope or class scope declaration
|
||||||
if( !containing.isType( TypeInfo.t_namespace ) && !containing.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
if( !containing.isType( ITypeInfo.t_namespace ) && !containing.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//14.5.2-3 A member function template shall not be virtual
|
//14.5.2-3 A member function template shall not be virtual
|
||||||
if( containing.isTemplateMember() && containing.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
if( containing.isTemplateMember() && containing.getContainingSymbol().isType( ITypeInfo.t_template ) ){
|
||||||
ISymbol symbol = template.getTemplatedSymbol();
|
ISymbol symbol = template.getTemplatedSymbol();
|
||||||
if( symbol != null && symbol.isType( TypeInfo.t_function ) && symbol.getTypeInfo().checkBit( TypeInfo.isVirtual ) ){
|
if( symbol != null && symbol.isType( ITypeInfo.t_function ) && symbol.getTypeInfo().checkBit( ITypeInfo.isVirtual ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1183,7 @@ public final class TemplateEngine {
|
||||||
for( int i = 0; i < numParams; i++ ){
|
for( int i = 0; i < numParams; i++ ){
|
||||||
ISymbol param = (ISymbol) params.get(i);
|
ISymbol param = (ISymbol) params.get(i);
|
||||||
if( i < numArgs ){
|
if( i < numArgs ){
|
||||||
TypeInfo arg = (TypeInfo) arguments.get(i);
|
ITypeInfo arg = (ITypeInfo) arguments.get(i);
|
||||||
if( matchTemplateParameterAndArgument( param, arg ) ){
|
if( matchTemplateParameterAndArgument( param, arg ) ){
|
||||||
actualArgs.add( arg );
|
actualArgs.add( arg );
|
||||||
} else {
|
} else {
|
||||||
|
@ -1220,7 +1225,7 @@ public final class TemplateEngine {
|
||||||
int numArgs = args.size();
|
int numArgs = args.size();
|
||||||
for( int i = 0; i < numParams && i < numArgs; i++ ){
|
for( int i = 0; i < numParams && i < numArgs; i++ ){
|
||||||
ISymbol param = (ISymbol) params.get(i);
|
ISymbol param = (ISymbol) params.get(i);
|
||||||
TypeInfo arg = (TypeInfo) args.get(i);
|
ITypeInfo arg = (ITypeInfo) args.get(i);
|
||||||
if( map.containsKey( param ) ) {
|
if( map.containsKey( param ) ) {
|
||||||
if( !map.get( param ).equals( arg )){
|
if( !map.get( param ).equals( arg )){
|
||||||
continue outer;
|
continue outer;
|
||||||
|
@ -1250,9 +1255,9 @@ public final class TemplateEngine {
|
||||||
int numArgs = ( args != null ) ? args.size() : 0;
|
int numArgs = ( args != null ) ? args.size() : 0;
|
||||||
for( int i = 0; i < numParams; i++ ){
|
for( int i = 0; i < numParams; i++ ){
|
||||||
ISymbol param = (ISymbol) params.get(i);
|
ISymbol param = (ISymbol) params.get(i);
|
||||||
TypeInfo arg = null;
|
ITypeInfo arg = null;
|
||||||
if( i < numArgs ){
|
if( i < numArgs ){
|
||||||
arg = (TypeInfo) args.get(i);
|
arg = (ITypeInfo) args.get(i);
|
||||||
} else {
|
} else {
|
||||||
if( map == null ){
|
if( map == null ){
|
||||||
map = deduceTemplateArgumentsUsingParameterList( template, fn );
|
map = deduceTemplateArgumentsUsingParameterList( template, fn );
|
||||||
|
@ -1260,7 +1265,7 @@ public final class TemplateEngine {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if( map.containsKey( param ) ){
|
if( map.containsKey( param ) ){
|
||||||
arg = (TypeInfo) map.get( param );
|
arg = (ITypeInfo) map.get( param );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1294,7 +1299,7 @@ public final class TemplateEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected boolean templateParametersAreEquivalent( ISymbol p1, ISymbol p2 ){
|
static protected boolean templateParametersAreEquivalent( ISymbol p1, ISymbol p2 ){
|
||||||
if( !p1.isType( TypeInfo.t_templateParameter ) || !p2.isType( TypeInfo.t_templateParameter ) ||
|
if( !p1.isType( ITypeInfo.t_templateParameter ) || !p2.isType( ITypeInfo.t_templateParameter ) ||
|
||||||
p1.getTypeInfo().getTemplateParameterType() != p2.getTypeInfo().getTemplateParameterType() )
|
p1.getTypeInfo().getTemplateParameterType() != p2.getTypeInfo().getTemplateParameterType() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1303,11 +1308,11 @@ public final class TemplateEngine {
|
||||||
ITemplateSymbol t1 = getContainingTemplate( p1 );
|
ITemplateSymbol t1 = getContainingTemplate( p1 );
|
||||||
ITemplateSymbol t2 = getContainingTemplate( p2 );
|
ITemplateSymbol t2 = getContainingTemplate( p2 );
|
||||||
|
|
||||||
if( p1.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName )
|
if( p1.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName )
|
||||||
{
|
{
|
||||||
List l1 = t1.getParameterList(), l2 = t2.getParameterList();
|
List l1 = t1.getParameterList(), l2 = t2.getParameterList();
|
||||||
return ( l1 != null && l2 != null && l1.indexOf( p1 ) == l2.indexOf( p2 ) );
|
return ( l1 != null && l2 != null && l1.indexOf( p1 ) == l2.indexOf( p2 ) );
|
||||||
} else if( p1.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
} else if( p1.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){
|
||||||
ITemplateSymbol pt1 = (ITemplateSymbol)p1.getTypeSymbol();
|
ITemplateSymbol pt1 = (ITemplateSymbol)p1.getTypeSymbol();
|
||||||
ITemplateSymbol pt2 = (ITemplateSymbol)p2.getTypeSymbol();
|
ITemplateSymbol pt2 = (ITemplateSymbol)p2.getTypeSymbol();
|
||||||
return checkTemplateParameterListsAreEquivalent( pt1.getParameterList(), pt2.getParameterList() );
|
return checkTemplateParameterListsAreEquivalent( pt1.getParameterList(), pt2.getParameterList() );
|
||||||
|
@ -1343,8 +1348,8 @@ public final class TemplateEngine {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
TypeInfo info1 = (TypeInfo) args.get(i);
|
ITypeInfo info1 = (ITypeInfo) args.get(i);
|
||||||
TypeInfo info2 = (TypeInfo) args2.get(i);
|
ITypeInfo info2 = (ITypeInfo) args2.get(i);
|
||||||
|
|
||||||
if( ! info1.equals( info2 ) )
|
if( ! info1.equals( info2 ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,8 +21,6 @@ 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.ASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateInstantiation;
|
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.ast.complete.ASTTemplateSpecialization;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -84,7 +82,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
size = args.size();
|
size = args.size();
|
||||||
spec.prepareArguments( size );
|
spec.prepareArguments( size );
|
||||||
for( int i = 0; i < size; i++){
|
for( int i = 0; i < size; i++){
|
||||||
spec.addArgument( (TypeInfo) args.get(i) );
|
spec.addArgument( (ITypeInfo) args.get(i) );
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.addSymbol( symbol );
|
spec.addSymbol( symbol );
|
||||||
|
@ -114,7 +112,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
int templatesSize = templates.size(), templatesIdx = 0;
|
int templatesSize = templates.size(), templatesIdx = 0;
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
sym = (ISymbol) symbols.get( i );
|
sym = (ISymbol) symbols.get( i );
|
||||||
if( !sym.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
if( !sym.getContainingSymbol().isType( ITypeInfo.t_template ) ){
|
||||||
symbols.remove( i-- );
|
symbols.remove( i-- );
|
||||||
size--;
|
size--;
|
||||||
} else if( templatesIdx < templatesSize ) {
|
} else if( templatesIdx < templatesSize ) {
|
||||||
|
@ -165,12 +163,12 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( symbol.isType( TypeInfo.t_function ) ){
|
if( symbol.isType( ITypeInfo.t_function ) ){
|
||||||
if( args != null )
|
if( args != null )
|
||||||
previous = lookupFunctionTemplateId( symbol.getName(), argList, args, false );
|
previous = lookupFunctionTemplateId( symbol.getName(), argList, args, false );
|
||||||
else
|
else
|
||||||
previous = lookupMethodForDefinition( symbol.getName(), argList );
|
previous = lookupMethodForDefinition( symbol.getName(), argList );
|
||||||
} else if ( symbol.isType( TypeInfo.t_constructor ) ){
|
} else if ( symbol.isType( ITypeInfo.t_constructor ) ){
|
||||||
previous = lookupConstructor( argList );
|
previous = lookupConstructor( argList );
|
||||||
} else {
|
} else {
|
||||||
previous = lookupMemberForDefinition( symbol.getName() );
|
previous = lookupMemberForDefinition( symbol.getName() );
|
||||||
|
@ -318,7 +316,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
ISymbol instantiated = sym.getInstantiatedSymbol();
|
ISymbol instantiated = sym.getInstantiatedSymbol();
|
||||||
if( instantiated != null ){
|
if( instantiated != null ){
|
||||||
IContainerSymbol container = instantiated.getContainingSymbol();
|
IContainerSymbol container = instantiated.getContainingSymbol();
|
||||||
if( container.isType( TypeInfo.t_template ) ){
|
if( container.isType( ITypeInfo.t_template ) ){
|
||||||
((ITemplateSymbol) container ).removeInstantiation( sym );
|
((ITemplateSymbol) container ).removeInstantiation( sym );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,7 +361,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String)
|
* @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(eType type, String name) throws ParserSymbolTableException {
|
public ISymbol elaboratedLookup(ITypeInfo.eType type, String name) throws ParserSymbolTableException {
|
||||||
ListIterator iter = templates.listIterator( templates.size() );
|
ListIterator iter = templates.listIterator( templates.size() );
|
||||||
while( iter.hasPrevious() ){
|
while( iter.hasPrevious() ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) iter.previous();
|
ITemplateSymbol template = (ITemplateSymbol) iter.previous();
|
||||||
|
@ -425,7 +423,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
* @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, eType t) throws ParserSymbolTableException {
|
public ISymbol qualifiedLookup(String name, ITypeInfo.eType t) throws ParserSymbolTableException {
|
||||||
return getContainingSymbol().qualifiedLookup( name, t );
|
return getContainingSymbol().qualifiedLookup( name, t );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,7 +515,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
int templateIdx = 0;
|
int templateIdx = 0;
|
||||||
for( int i = 0; i < numSymbols; i++ ){
|
for( int i = 0; i < numSymbols; i++ ){
|
||||||
ISymbol symbol = (ISymbol) symbols.get(i);
|
ISymbol symbol = (ISymbol) symbols.get(i);
|
||||||
if( symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
if( symbol.getContainingSymbol().isType( ITypeInfo.t_template ) ){
|
||||||
if( templateIdx < numTemplates )
|
if( templateIdx < numTemplates )
|
||||||
templateIdx++;
|
templateIdx++;
|
||||||
else
|
else
|
||||||
|
@ -556,21 +554,21 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDirective(org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDirective(org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||||
*/
|
*/
|
||||||
public IUsingDirectiveSymbol addUsingDirective(IContainerSymbol namespace) throws ParserSymbolTableException {
|
public IUsingDirectiveSymbol addUsingDirective(IContainerSymbol namespace) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public IUsingDeclarationSymbol addUsingDeclaration(String name) throws ParserSymbolTableException {
|
public IUsingDeclarationSymbol addUsingDeclaration(String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
* @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 {
|
public IUsingDeclarationSymbol addUsingDeclaration(String name, IContainerSymbol declContext) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +582,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#prefixLookup(org.eclipse.cdt.internal.core.parser.pst.TypeFilter, java.lang.String, boolean)
|
* @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) throws ParserSymbolTableException {
|
public List prefixLookup(TypeFilter filter, String prefix, boolean qualified, List paramList) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -611,7 +609,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#instantiate(org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol, java.util.Map)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#instantiate(org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol, java.util.Map)
|
||||||
*/
|
*/
|
||||||
public ISymbol instantiate(ITemplateSymbol template, Map argMapParm) throws ParserSymbolTableException {
|
public ISymbol instantiate(ITemplateSymbol template, Map argMapParm) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +617,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setName(java.lang.String)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setName(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -631,41 +630,43 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||||
*/
|
*/
|
||||||
public boolean isType(eType type) {
|
public boolean isType(ITypeInfo.eType type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#isType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||||
*/
|
*/
|
||||||
public boolean isType(eType type, eType upperType) {
|
public boolean isType(ITypeInfo.eType type, ITypeInfo.eType upperType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getType()
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getType()
|
||||||
*/
|
*/
|
||||||
public eType getType() {
|
public ITypeInfo.eType getType() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType)
|
||||||
*/
|
*/
|
||||||
public void setType(eType t) {
|
public void setType(ITypeInfo.eType t) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getTypeInfo()
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getTypeInfo()
|
||||||
*/
|
*/
|
||||||
public TypeInfo getTypeInfo() {
|
public ITypeInfo getTypeInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setTypeInfo(org.eclipse.cdt.internal.core.parser.pst.TypeInfo)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setTypeInfo(org.eclipse.cdt.internal.core.parser.pst.TypeInfo)
|
||||||
*/
|
*/
|
||||||
public void setTypeInfo(TypeInfo info) {
|
public void setTypeInfo(ITypeInfo info) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -679,6 +680,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setTypeSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setTypeSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
*/
|
*/
|
||||||
public void setTypeSymbol(ISymbol type) {
|
public void setTypeSymbol(ISymbol type) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -692,6 +694,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsForwardDeclaration(boolean)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsForwardDeclaration(boolean)
|
||||||
*/
|
*/
|
||||||
public void setIsForwardDeclaration(boolean forward) {
|
public void setIsForwardDeclaration(boolean forward) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -711,7 +714,8 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#addPtrOperator(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#addPtrOperator(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp)
|
||||||
*/
|
*/
|
||||||
public void addPtrOperator(PtrOp ptrOp) {
|
public void addPtrOperator(ITypeInfo.PtrOp ptrOp) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -732,6 +736,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setInstantiatedSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setInstantiatedSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
*/
|
*/
|
||||||
public void setInstantiatedSymbol(ISymbol symbol) {
|
public void setInstantiatedSymbol(ISymbol symbol) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -745,6 +750,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsTemplateMember(boolean)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsTemplateMember(boolean)
|
||||||
*/
|
*/
|
||||||
public void setIsTemplateMember(boolean isMember) {
|
public void setIsTemplateMember(boolean isMember) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -765,18 +771,21 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsInvisible(boolean)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsInvisible(boolean)
|
||||||
*/
|
*/
|
||||||
public void setIsInvisible(boolean invisible) {
|
public void setIsInvisible(boolean invisible) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
*/
|
*/
|
||||||
public void addParent(ISymbol parent) {
|
public void addParent(ISymbol parent) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, java.util.List)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, java.util.List)
|
||||||
*/
|
*/
|
||||||
public void addParent(ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references) {
|
public void addParent(ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -796,13 +805,15 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addConstructor(org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addConstructor(org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol)
|
||||||
*/
|
*/
|
||||||
public void addConstructor(IParameterizedSymbol constructor) throws ParserSymbolTableException {
|
public void addConstructor(IParameterizedSymbol constructor) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addCopyConstructor()
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addCopyConstructor()
|
||||||
*/
|
*/
|
||||||
public void addCopyConstructor() throws ParserSymbolTableException {
|
public void addCopyConstructor() {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -816,19 +827,20 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addFriend(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addFriend(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
*/
|
*/
|
||||||
public void addFriend(ISymbol friend) {
|
public void addFriend(ISymbol friend) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupForFriendship(java.lang.String)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupForFriendship(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public ISymbol lookupForFriendship(String name) throws ParserSymbolTableException {
|
public ISymbol lookupForFriendship(String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupFunctionForFriendship(java.lang.String, java.util.List)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupFunctionForFriendship(java.lang.String, java.util.List)
|
||||||
*/
|
*/
|
||||||
public IParameterizedSymbol lookupFunctionForFriendship(String name, List parameters) throws ParserSymbolTableException {
|
public IParameterizedSymbol lookupFunctionForFriendship(String name, List parameters) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,5 +855,20 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#preparePtrOperatros(int)
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#preparePtrOperatros(int)
|
||||||
*/
|
*/
|
||||||
public void preparePtrOperatros(int numPtrOps) {
|
public void preparePtrOperatros(int numPtrOps) {
|
||||||
|
/* nothing */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setForwardSymbol(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
|
*/
|
||||||
|
public void setForwardSymbol(ISymbol forward) {
|
||||||
|
/* nothing */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getForwardSymbol()
|
||||||
|
*/
|
||||||
|
public ISymbol getForwardSymbol() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 5, 2004
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*/
|
||||||
|
public class TemplateParameterTypeInfo extends TypeInfo {
|
||||||
|
|
||||||
|
public ITypeInfo.eType getTemplateParameterType() {
|
||||||
|
return _templateParameterType;
|
||||||
|
}
|
||||||
|
public void setTemplateParameterType( ITypeInfo.eType type ) {
|
||||||
|
_templateParameterType = type;
|
||||||
|
}
|
||||||
|
public boolean equals( Object t ) {
|
||||||
|
if( !super.equals( t ) ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return _templateParameterType == ((ITypeInfo)t).getTemplateParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ITypeInfo.eType _templateParameterType = t_typeName;
|
||||||
|
}
|
|
@ -17,8 +17,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*
|
*
|
||||||
|
@ -28,11 +26,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||||
public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymbol {
|
public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymbol {
|
||||||
|
|
||||||
protected TemplateSymbol ( ParserSymbolTable table, String name ){
|
protected TemplateSymbol ( ParserSymbolTable table, String name ){
|
||||||
super( table, name, TypeInfo.t_template );
|
super( table, name, ITypeInfo.t_template );
|
||||||
}
|
|
||||||
|
|
||||||
protected TemplateSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){
|
|
||||||
super( table, name, obj );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone(){
|
public Object clone(){
|
||||||
|
@ -57,9 +51,9 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#instantiate(java.util.List)
|
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#instantiate(java.util.List)
|
||||||
*/
|
*/
|
||||||
public ISymbol instantiate( List arguments ) throws ParserSymbolTableException{
|
public ISymbol instantiate( List arguments ) throws ParserSymbolTableException{
|
||||||
if( getType() != TypeInfo.t_template &&
|
if( getType() != ITypeInfo.t_template &&
|
||||||
( getType() != TypeInfo.t_templateParameter ||
|
( getType() != ITypeInfo.t_templateParameter ||
|
||||||
getTypeInfo().getTemplateParameterType() != TypeInfo.t_template ) )
|
getTypeInfo().getTemplateParameterType() != ITypeInfo.t_template ) )
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +78,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
|
|
||||||
HashMap map = new HashMap();
|
HashMap map = new HashMap();
|
||||||
ISymbol param = null;
|
ISymbol param = null;
|
||||||
TypeInfo arg = null;
|
ITypeInfo arg = null;
|
||||||
List actualArgs = new ArrayList( numParams );
|
List actualArgs = new ArrayList( numParams );
|
||||||
|
|
||||||
ISymbol templatedSymbol = template.getTemplatedSymbol();
|
ISymbol templatedSymbol = template.getTemplatedSymbol();
|
||||||
|
@ -98,27 +92,27 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() );
|
param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() );
|
||||||
|
|
||||||
if( i < numArgs ){
|
if( i < numArgs ){
|
||||||
arg = (TypeInfo) arguments.get(i);
|
arg = (ITypeInfo) arguments.get(i);
|
||||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||||
if( arg.isType( TypeInfo.t_type ) ){
|
if( arg.isType( ITypeInfo.t_type ) ){
|
||||||
if( arg.getTypeSymbol() == null )
|
if( arg.getTypeSymbol() == null )
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
||||||
else if( arg.getTypeSymbol().isType( TypeInfo.t_templateParameter ) )
|
else if( arg.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) )
|
||||||
return deferredInstance( arguments );
|
return deferredInstance( arguments );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Object obj = param.getTypeInfo().getDefault();
|
Object obj = param.getTypeInfo().getDefault();
|
||||||
if( obj != null && obj instanceof TypeInfo ){
|
if( obj != null && obj instanceof ITypeInfo ){
|
||||||
arg = (TypeInfo) obj;
|
arg = (ITypeInfo) obj;
|
||||||
if( arg.isType( TypeInfo.t_type ) && arg.getTypeSymbol().isType( TypeInfo.t_templateParameter ) ){
|
if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) ){
|
||||||
if( map.containsKey( arg.getTypeSymbol() ) ){
|
if( map.containsKey( arg.getTypeSymbol() ) ){
|
||||||
arg = (TypeInfo) map.get( arg.getTypeSymbol() );
|
arg = (ITypeInfo) map.get( arg.getTypeSymbol() );
|
||||||
} else {
|
} else {
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
||||||
}
|
}
|
||||||
} else if( arg.isType( TypeInfo.t_type ) && arg.getTypeSymbol() instanceof IDeferredTemplateInstance ){
|
} else if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol() instanceof IDeferredTemplateInstance ){
|
||||||
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) arg.getTypeSymbol();
|
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) arg.getTypeSymbol();
|
||||||
arg = new TypeInfo( arg );
|
arg = TypeInfoProvider.newTypeInfo( arg );
|
||||||
arg.setTypeSymbol( deferred.instantiate( this, map ) );
|
arg.setTypeSymbol( deferred.instantiate( this, map ) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -138,7 +132,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
if( instance != null ){
|
if( instance != null ){
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
if( template.isType( TypeInfo.t_templateParameter ) ){
|
if( template.isType( ITypeInfo.t_templateParameter ) ){
|
||||||
//template template parameter. must defer instantiation
|
//template template parameter. must defer instantiation
|
||||||
return deferredInstance( arguments );
|
return deferredInstance( arguments );
|
||||||
}
|
}
|
||||||
|
@ -177,8 +171,8 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
param = (ISymbol) parameters.get(i);
|
param = (ISymbol) parameters.get(i);
|
||||||
Object obj = param.getTypeInfo().getDefault();
|
Object obj = param.getTypeInfo().getDefault();
|
||||||
if( obj instanceof TypeInfo ){
|
if( obj instanceof ITypeInfo ){
|
||||||
param.getTypeInfo().setDefault( TemplateEngine.instantiateTypeInfo( (TypeInfo) obj, template, argMap ) );
|
param.getTypeInfo().setDefault( TemplateEngine.instantiateTypeInfo( (ITypeInfo) obj, template, argMap ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +184,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTemplateParameter( ISymbol param ) throws ParserSymbolTableException {
|
public void addTemplateParameter( ISymbol param ) throws ParserSymbolTableException {
|
||||||
if( isType( TypeInfo.t_template ) || getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
if( isType( ITypeInfo.t_template ) || getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){
|
||||||
if( !isAllowableTemplateParameter( param ) ){
|
if( !isAllowableTemplateParameter( param ) ){
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateParameter );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateParameter );
|
||||||
}
|
}
|
||||||
|
@ -201,17 +195,17 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAllowableTemplateParameter( ISymbol param ) {
|
private boolean isAllowableTemplateParameter( ISymbol param ) {
|
||||||
if( !param.isType( TypeInfo.t_templateParameter ) )
|
if( !param.isType( ITypeInfo.t_templateParameter ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( !getName().equals( ParserSymbolTable.EMPTY_NAME ) && param.getName().equals( getName() ) ){
|
if( !getName().equals( ParserSymbolTable.EMPTY_NAME ) && param.getName().equals( getName() ) ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( param.getTypeInfo().getTemplateParameterType() != TypeInfo.t_typeName &&
|
if( param.getTypeInfo().getTemplateParameterType() != ITypeInfo.t_typeName &&
|
||||||
param.getTypeInfo().getTemplateParameterType() != TypeInfo.t_template )
|
param.getTypeInfo().getTemplateParameterType() != ITypeInfo.t_template )
|
||||||
{
|
{
|
||||||
TypeInfo info = param.getTypeInfo();
|
ITypeInfo info = param.getTypeInfo();
|
||||||
//a non-type template parameter shall have one of the following:
|
//a non-type template parameter shall have one of the following:
|
||||||
//integral or enumeration type
|
//integral or enumeration type
|
||||||
//pointer to object or pointer to function
|
//pointer to object or pointer to function
|
||||||
|
@ -221,13 +215,13 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
//14.1-7
|
//14.1-7
|
||||||
//A non-type template-parameter shall not be declared to have floating point, class or void type
|
//A non-type template-parameter shall not be declared to have floating point, class or void type
|
||||||
if( info.getPtrOperators().size() == 0 )
|
if( info.getPtrOperators().size() == 0 )
|
||||||
if( info.getTemplateParameterType() == TypeInfo.t_float ||
|
if( info.getTemplateParameterType() == ITypeInfo.t_float ||
|
||||||
info.getTemplateParameterType() == TypeInfo.t_double ||
|
info.getTemplateParameterType() == ITypeInfo.t_double ||
|
||||||
info.getTemplateParameterType() == TypeInfo.t_class ||
|
info.getTemplateParameterType() == ITypeInfo.t_class ||
|
||||||
info.getTemplateParameterType() == TypeInfo.t_struct ||
|
info.getTemplateParameterType() == ITypeInfo.t_struct ||
|
||||||
info.getTemplateParameterType() == TypeInfo.t_union ||
|
info.getTemplateParameterType() == ITypeInfo.t_union ||
|
||||||
info.getTemplateParameterType() == TypeInfo.t_enumeration ||
|
info.getTemplateParameterType() == ITypeInfo.t_enumeration ||
|
||||||
info.getTemplateParameterType() == TypeInfo.t_void )
|
info.getTemplateParameterType() == ITypeInfo.t_void )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -238,12 +232,12 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
private void modifyTemplateParameter( ISymbol param ){
|
private void modifyTemplateParameter( ISymbol param ){
|
||||||
List ptrs = param.getPtrOperators();
|
List ptrs = param.getPtrOperators();
|
||||||
if( ptrs.size() > 0 ){
|
if( ptrs.size() > 0 ){
|
||||||
PtrOp op = (PtrOp) ptrs.get( 0 );
|
ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) ptrs.get( 0 );
|
||||||
if( op.getType() == PtrOp.t_array ){
|
if( op.getType() == ITypeInfo.PtrOp.t_array ){
|
||||||
op.setType( PtrOp.t_pointer );
|
op.setType( ITypeInfo.PtrOp.t_pointer );
|
||||||
}
|
}
|
||||||
} else if ( param.isType( TypeInfo.t_type ) && param.getTypeSymbol().isType( TypeInfo.t_function ) ){
|
} else if ( param.isType( ITypeInfo.t_type ) && param.getTypeSymbol().isType( ITypeInfo.t_function ) ){
|
||||||
param.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
param.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +280,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
|
|
||||||
ISymbol found = null;
|
ISymbol found = null;
|
||||||
try{
|
try{
|
||||||
if( symbol.isType( TypeInfo.t_function ) || symbol.isType( TypeInfo.t_constructor ) ){
|
if( symbol.isType( ITypeInfo.t_function ) || symbol.isType( ITypeInfo.t_constructor ) ){
|
||||||
List params = ((IParameterizedSymbol) symbol).getParameterList();
|
List params = ((IParameterizedSymbol) symbol).getParameterList();
|
||||||
int size = params.size();
|
int size = params.size();
|
||||||
List fnArgs = new ArrayList( size );
|
List fnArgs = new ArrayList( size );
|
||||||
|
@ -298,6 +292,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
found = getTemplatedSymbol().lookupMemberForDefinition( symbol.getName() );
|
found = getTemplatedSymbol().lookupMemberForDefinition( symbol.getName() );
|
||||||
}
|
}
|
||||||
} catch (ParserSymbolTableException e) {
|
} catch (ParserSymbolTableException e) {
|
||||||
|
/* nothing */
|
||||||
}
|
}
|
||||||
if( found == null && getTemplatedSymbol().getName().equals( symbol.getName() ) ){
|
if( found == null && getTemplatedSymbol().getName().equals( symbol.getName() ) ){
|
||||||
found = getTemplatedSymbol();
|
found = getTemplatedSymbol();
|
||||||
|
@ -311,7 +306,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
if( found != null ){
|
if( found != null ){
|
||||||
//in defining the explicit specialization for a member function, the factory would have set
|
//in defining the explicit specialization for a member function, the factory would have set
|
||||||
//the specialization as the definition of the original declaration, which it is not
|
//the specialization as the definition of the original declaration, which it is not
|
||||||
if( found.getTypeInfo().isForwardDeclaration() && found.getTypeSymbol() == symbol )
|
if( found.isForwardDeclaration() && found.getForwardSymbol() == symbol )
|
||||||
found.setTypeSymbol( null );
|
found.setTypeSymbol( null );
|
||||||
|
|
||||||
//TODO, once we can instantiate members as we need them instead of at the same time as the class
|
//TODO, once we can instantiate members as we need them instead of at the same time as the class
|
||||||
|
@ -457,7 +452,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
ParameterizedSymbol p = (ParameterizedSymbol) objs[0];
|
ParameterizedSymbol p = (ParameterizedSymbol) objs[0];
|
||||||
p.instantiateDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] );
|
p.instantiateDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] );
|
||||||
} else if( kind == DeferredKind.TYPE_SYMBOL ){
|
} else if( kind == DeferredKind.TYPE_SYMBOL ){
|
||||||
TemplateEngine.instantiateDeferredTypeInfo( (TypeInfo) objs[0], this, (Map) objs[3] );
|
TemplateEngine.instantiateDeferredTypeInfo( (ITypeInfo) objs[0], this, (Map) objs[3] );
|
||||||
}
|
}
|
||||||
numProcessed++;
|
numProcessed++;
|
||||||
}
|
}
|
||||||
|
@ -485,7 +480,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
ParameterizedSymbol p = (ParameterizedSymbol) objs[0];
|
ParameterizedSymbol p = (ParameterizedSymbol) objs[0];
|
||||||
p.discardDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] );
|
p.discardDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] );
|
||||||
} else if( kind == DeferredKind.TYPE_SYMBOL ){
|
} else if( kind == DeferredKind.TYPE_SYMBOL ){
|
||||||
TemplateEngine.discardDeferredTypeInfo( (TypeInfo) objs[0], this, (Map) objs[3] );
|
TemplateEngine.discardDeferredTypeInfo( (ITypeInfo) objs[0], this, (Map) objs[3] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_deferredInstantiations.clear();
|
_deferredInstantiations.clear();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class TypeFilter {
|
||||||
acceptedTypes.addAll( types );
|
acceptedTypes.addAll( types );
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeFilter( TypeInfo.eType type ){
|
public TypeFilter( ITypeInfo.eType type ){
|
||||||
acceptedTypes.add( type );
|
acceptedTypes.add( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class TypeFilter {
|
||||||
populatedAcceptedTypes( kind );
|
populatedAcceptedTypes( kind );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAcceptedType( TypeInfo.eType type ){
|
public void addAcceptedType( ITypeInfo.eType type ){
|
||||||
acceptedTypes.add( type );
|
acceptedTypes.add( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,16 +46,16 @@ public class TypeFilter {
|
||||||
acceptedKinds.add( kind );
|
acceptedKinds.add( kind );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean willAccept( TypeInfo.eType type ){
|
public boolean willAccept( ITypeInfo.eType type ){
|
||||||
return( acceptedTypes.contains( TypeInfo.t_any ) ||
|
return( acceptedTypes.contains( ITypeInfo.t_any ) ||
|
||||||
acceptedTypes.contains( type ) );
|
acceptedTypes.contains( type ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldAccept( ISymbol symbol ){
|
public boolean shouldAccept( ISymbol symbol ){
|
||||||
return shouldAccept( symbol, symbol.getTypeInfo() );
|
return shouldAccept( symbol, symbol.getTypeInfo() );
|
||||||
}
|
}
|
||||||
public boolean shouldAccept( ISymbol symbol, TypeInfo typeInfo ){
|
public boolean shouldAccept( ISymbol symbol, ITypeInfo typeInfo ){
|
||||||
if( acceptedTypes.contains( TypeInfo.t_any ) ){
|
if( acceptedTypes.contains( ITypeInfo.t_any ) ){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ public class TypeFilter {
|
||||||
|
|
||||||
IContainerSymbol container = symbol.getContainingSymbol();
|
IContainerSymbol container = symbol.getContainingSymbol();
|
||||||
|
|
||||||
boolean symbolIsMember = container.isType( TypeInfo.t_class, TypeInfo.t_union );
|
boolean symbolIsMember = container.isType( ITypeInfo.t_class, ITypeInfo.t_union );
|
||||||
boolean symbolIsLocal = container.isType( TypeInfo.t_constructor, TypeInfo.t_function ) ||
|
boolean symbolIsLocal = container.isType( ITypeInfo.t_constructor, ITypeInfo.t_function ) ||
|
||||||
container.isType( TypeInfo.t_block );
|
container.isType( ITypeInfo.t_block );
|
||||||
|
|
||||||
if( typeInfo.isType( TypeInfo.t_function ) )
|
if( typeInfo.isType( ITypeInfo.t_function ) )
|
||||||
{
|
{
|
||||||
if( ( acceptedKinds.contains( LookupKind.FUNCTIONS ) && !symbolIsMember ) ||
|
if( ( acceptedKinds.contains( LookupKind.FUNCTIONS ) && !symbolIsMember ) ||
|
||||||
( acceptedKinds.contains( LookupKind.METHODS ) && symbolIsMember ) )
|
( acceptedKinds.contains( LookupKind.METHODS ) && symbolIsMember ) )
|
||||||
|
@ -78,7 +78,7 @@ public class TypeFilter {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ( typeInfo.isType( TypeInfo.t_type ) && typeInfo.checkBit( TypeInfo.isTypedef ) ){
|
else if ( typeInfo.isType( ITypeInfo.t_type ) && typeInfo.checkBit( ITypeInfo.isTypedef ) ){
|
||||||
if( acceptedKinds.contains( LookupKind.TYPEDEFS ) ||
|
if( acceptedKinds.contains( LookupKind.TYPEDEFS ) ||
|
||||||
acceptedKinds.contains( LookupKind.TYPES ) )
|
acceptedKinds.contains( LookupKind.TYPES ) )
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@ public class TypeFilter {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
else if ( typeInfo.isType( ITypeInfo.t_type ) || typeInfo.isType( ITypeInfo.t__Bool, ITypeInfo.t_void ) )
|
||||||
{
|
{
|
||||||
if( ( acceptedKinds.contains( LookupKind.VARIABLES ) && !symbolIsMember && !symbolIsLocal ) ||
|
if( ( acceptedKinds.contains( LookupKind.VARIABLES ) && !symbolIsMember && !symbolIsLocal ) ||
|
||||||
( acceptedKinds.contains( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal ) ||
|
( acceptedKinds.contains( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal ) ||
|
||||||
|
@ -106,22 +106,22 @@ public class TypeFilter {
|
||||||
* @param lookupKind
|
* @param lookupKind
|
||||||
*/
|
*/
|
||||||
private void populatedAcceptedTypes(LookupKind kind) {
|
private void populatedAcceptedTypes(LookupKind kind) {
|
||||||
if ( kind == LookupKind.ALL ) { acceptedTypes.add( TypeInfo.t_any ); }
|
if ( kind == LookupKind.ALL ) { acceptedTypes.add( ITypeInfo.t_any ); }
|
||||||
else if ( kind == LookupKind.STRUCTURES ) { acceptedTypes.add( TypeInfo.t_class );
|
else if ( kind == LookupKind.STRUCTURES ) { acceptedTypes.add( ITypeInfo.t_class );
|
||||||
acceptedTypes.add( TypeInfo.t_struct );
|
acceptedTypes.add( ITypeInfo.t_struct );
|
||||||
acceptedTypes.add( TypeInfo.t_union ); }
|
acceptedTypes.add( ITypeInfo.t_union ); }
|
||||||
else if ( kind == LookupKind.STRUCTS ) { acceptedTypes.add( TypeInfo.t_struct ); }
|
else if ( kind == LookupKind.STRUCTS ) { acceptedTypes.add( ITypeInfo.t_struct ); }
|
||||||
else if ( kind == LookupKind.UNIONS ) { acceptedTypes.add( TypeInfo.t_union ); }
|
else if ( kind == LookupKind.UNIONS ) { acceptedTypes.add( ITypeInfo.t_union ); }
|
||||||
else if ( kind == LookupKind.CLASSES ) { acceptedTypes.add( TypeInfo.t_class ); }
|
else if ( kind == LookupKind.CLASSES ) { acceptedTypes.add( ITypeInfo.t_class ); }
|
||||||
else if ( kind == LookupKind.CONSTRUCTORS ){ acceptedTypes.add( TypeInfo.t_constructor ); }
|
else if ( kind == LookupKind.CONSTRUCTORS ){ acceptedTypes.add( ITypeInfo.t_constructor ); }
|
||||||
else if ( kind == LookupKind.NAMESPACES ) { acceptedTypes.add( TypeInfo.t_namespace ); }
|
else if ( kind == LookupKind.NAMESPACES ) { acceptedTypes.add( ITypeInfo.t_namespace ); }
|
||||||
else if ( kind == LookupKind.ENUMERATIONS ){ acceptedTypes.add( TypeInfo.t_enumeration ); }
|
else if ( kind == LookupKind.ENUMERATIONS ){ acceptedTypes.add( ITypeInfo.t_enumeration ); }
|
||||||
else if ( kind == LookupKind.ENUMERATORS ) { acceptedTypes.add( TypeInfo.t_enumerator ); }
|
else if ( kind == LookupKind.ENUMERATORS ) { acceptedTypes.add( ITypeInfo.t_enumerator ); }
|
||||||
// else if ( kind == LookupKind.TYPEDEFS ) { acceptedTypes.add( TypeInfo.t_type ); }
|
// else if ( kind == LookupKind.TYPEDEFS ) { acceptedTypes.add( TypeInfo.t_type ); }
|
||||||
else if ( kind == LookupKind.TYPES ) { acceptedTypes.add( TypeInfo.t_class );
|
else if ( kind == LookupKind.TYPES ) { acceptedTypes.add( ITypeInfo.t_class );
|
||||||
acceptedTypes.add( TypeInfo.t_struct );
|
acceptedTypes.add( ITypeInfo.t_struct );
|
||||||
acceptedTypes.add( TypeInfo.t_union );
|
acceptedTypes.add( ITypeInfo.t_union );
|
||||||
acceptedTypes.add( TypeInfo.t_enumeration ); }
|
acceptedTypes.add( ITypeInfo.t_enumeration ); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,575 +10,86 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.pst;
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Enum;
|
public class TypeInfo extends BasicTypeInfo implements ITypeInfo{
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider;
|
public TypeInfo(){
|
||||||
|
|
||||||
|
|
||||||
public class TypeInfo {
|
|
||||||
public TypeInfo(){
|
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol ){
|
public ISymbol getTypeSymbol() {
|
||||||
super();
|
return _typeDeclaration;
|
||||||
_typeBits = bits;
|
}
|
||||||
_type = type;
|
|
||||||
_typeDeclaration = symbol;
|
public void setTypeSymbol( ISymbol type ) {
|
||||||
}
|
_typeDeclaration = type;
|
||||||
|
}
|
||||||
public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol, TypeInfo.PtrOp op, boolean hasDefault ){
|
|
||||||
super();
|
public boolean getHasDefault() {
|
||||||
_typeBits = bits;
|
return _hasDefaultValue;
|
||||||
_type = type;
|
}
|
||||||
_typeDeclaration = symbol;
|
|
||||||
if( op != null ){
|
public void setHasDefault( boolean def ) {
|
||||||
_ptrOperators = new ArrayList(2);
|
_hasDefaultValue = def;
|
||||||
_ptrOperators.add( op );
|
}
|
||||||
} else {
|
|
||||||
_ptrOperators = Collections.EMPTY_LIST;
|
public void clear() {
|
||||||
}
|
super.clear();
|
||||||
_hasDefaultValue = hasDefault;
|
_typeDeclaration = null;
|
||||||
}
|
_hasDefaultValue = false;
|
||||||
|
}
|
||||||
public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol, TypeInfo.PtrOp op, Object def ){
|
|
||||||
super();
|
public void copy( ITypeInfo t ) {
|
||||||
_typeBits = bits;
|
super.copy( t );
|
||||||
_type = type;
|
_typeDeclaration = t.getTypeSymbol();
|
||||||
_typeDeclaration = symbol;
|
_hasDefaultValue = t.getHasDefault();
|
||||||
if( op != null ){
|
}
|
||||||
_ptrOperators = new ArrayList( 1 );
|
|
||||||
_ptrOperators.add( op );
|
public boolean equals( Object t ) {
|
||||||
} else {
|
if( !super.equals( t ) ){
|
||||||
_ptrOperators = Collections.EMPTY_LIST;
|
return false;
|
||||||
}
|
}
|
||||||
_hasDefaultValue = true;
|
|
||||||
setDefault( def );
|
ITypeInfo type = (ITypeInfo)t;
|
||||||
}
|
|
||||||
|
boolean result = true;
|
||||||
public TypeInfo( TypeInfo info ){
|
ISymbol symbol = type.getTypeSymbol();
|
||||||
super();
|
if( _typeDeclaration != null && symbol != null ){
|
||||||
|
if( _typeDeclaration.isType( t__Bool, t_void ) &&
|
||||||
_typeBits = info._typeBits;
|
symbol.isType( t__Bool, t_void ) )
|
||||||
_type = info._type;
|
{
|
||||||
_typeDeclaration = info._typeDeclaration;
|
//if typeDeclaration is a basic type, then only need the types the same
|
||||||
_ptrOperators = ( info._ptrOperators == Collections.EMPTY_LIST ) ? info._ptrOperators : (ArrayList)((ArrayList)info._ptrOperators).clone();
|
result &= ( _typeDeclaration.getType() == symbol.getType() );
|
||||||
_hasDefaultValue = info._hasDefaultValue;
|
} else if( _typeDeclaration.isType( t_function ) &&
|
||||||
_defaultValue = info._defaultValue;
|
symbol.isType( t_function ) )
|
||||||
}
|
{
|
||||||
|
//function pointers... functions must have same parameter lists and return types
|
||||||
public static final int isAuto = 0x00001;
|
IParameterizedSymbol f1 = (IParameterizedSymbol) _typeDeclaration;
|
||||||
public static final int isRegister = 0x00002;
|
IParameterizedSymbol f2 = (IParameterizedSymbol) symbol;
|
||||||
public static final int isStatic = 0x00004;
|
|
||||||
public static final int isExtern = 0x00008;
|
result &= f1.hasSameParameters( f2 );
|
||||||
public static final int isMutable = 0x00010;
|
if( f1.getReturnType() != null && f2.getReturnType() != null )
|
||||||
public static final int isInline = 0x00020;
|
result &= f1.getReturnType().getTypeInfo().equals( f2.getReturnType().getTypeInfo() );
|
||||||
public static final int isVirtual = 0x00040;
|
else
|
||||||
public static final int isExplicit = 0x00080;
|
result &= (f1.getReturnType() == f2.getReturnType());
|
||||||
public static final int isTypedef = 0x00100;
|
} else if( _typeDeclaration.isType( t_templateParameter ) &&
|
||||||
public static final int isFriend = 0x00200;
|
symbol.isType( t_templateParameter ) )
|
||||||
public static final int isConst = 0x00400;
|
{
|
||||||
public static final int isVolatile = 0x00800;
|
//template parameters
|
||||||
public static final int isUnsigned = 0x01000;
|
result &= TemplateEngine.templateParametersAreEquivalent( _typeDeclaration, symbol );
|
||||||
public static final int isShort = 0x02000;
|
} else if ( _typeDeclaration instanceof IDeferredTemplateInstance &&
|
||||||
public static final int isLong = 0x04000;
|
symbol instanceof IDeferredTemplateInstance )
|
||||||
public static final int isForward = 0x08000;
|
{
|
||||||
public static final int isComplex = 0x10000;
|
result &= TemplateEngine.deferedInstancesAreEquivalent( (IDeferredTemplateInstance) _typeDeclaration, (IDeferredTemplateInstance)symbol );
|
||||||
public static final int isImaginary= 0x20000;
|
}else {
|
||||||
public static final int isLongLong = 0x40000;
|
//otherwise, its a user defined type, need the decls the same
|
||||||
public static final int isSigned = 0x80000;
|
result &= ( _typeDeclaration == symbol );
|
||||||
|
}
|
||||||
// Types (maximum type is typeMask
|
} else {
|
||||||
// Note that these should be considered ordered and if you change
|
result &= ( _typeDeclaration == symbol );
|
||||||
// the order, you should consider the ParserSymbolTable uses
|
}
|
||||||
public static final TypeInfo.eType t_any = new TypeInfo.eType( -1 ); //don't care
|
return result;
|
||||||
public static final TypeInfo.eType t_undef = new TypeInfo.eType( 0 ); //not specified
|
}
|
||||||
public static final TypeInfo.eType t_type = new TypeInfo.eType( 1 ); //Type Specifier
|
|
||||||
public static final TypeInfo.eType t_namespace = new TypeInfo.eType( 2 );
|
private ISymbol _typeDeclaration = null;
|
||||||
public static final TypeInfo.eType t_class = new TypeInfo.eType( 3 );
|
private boolean _hasDefaultValue = false;
|
||||||
public static final TypeInfo.eType t_struct = new TypeInfo.eType( 4 );
|
|
||||||
public static final TypeInfo.eType t_union = new TypeInfo.eType( 5 );
|
|
||||||
public static final TypeInfo.eType t_enumeration = new TypeInfo.eType( 6 );
|
|
||||||
public static final TypeInfo.eType t_constructor = new TypeInfo.eType( 7 );
|
|
||||||
public static final TypeInfo.eType t_function = new TypeInfo.eType( 8 );
|
|
||||||
public static final TypeInfo.eType t__Bool = new TypeInfo.eType( 9 );
|
|
||||||
public static final TypeInfo.eType t_bool = new TypeInfo.eType( 10 );
|
|
||||||
public static final TypeInfo.eType t_char = new TypeInfo.eType( 11 );
|
|
||||||
public static final TypeInfo.eType t_wchar_t = new TypeInfo.eType( 12 );
|
|
||||||
public static final TypeInfo.eType t_int = new TypeInfo.eType( 13 );
|
|
||||||
public static final TypeInfo.eType t_float = new TypeInfo.eType( 14 );
|
|
||||||
public static final TypeInfo.eType t_double = new TypeInfo.eType( 15 );
|
|
||||||
public static final TypeInfo.eType t_void = new TypeInfo.eType( 16 );
|
|
||||||
public static final TypeInfo.eType t_enumerator = new TypeInfo.eType( 17 );
|
|
||||||
public static final TypeInfo.eType t_block = new TypeInfo.eType( 18 );
|
|
||||||
public static final TypeInfo.eType t_template = new TypeInfo.eType( 19 );
|
|
||||||
public static final TypeInfo.eType t_asm = new TypeInfo.eType( 20 );
|
|
||||||
public static final TypeInfo.eType t_linkage = new TypeInfo.eType( 21 );
|
|
||||||
public static final TypeInfo.eType t_templateParameter = new TypeInfo.eType( 22 );
|
|
||||||
public static final TypeInfo.eType t_typeName = new TypeInfo.eType( 23 );
|
|
||||||
|
|
||||||
//public static final eType t_templateParameter = new eType( 18 );
|
|
||||||
|
|
||||||
public static class eType implements Comparable{
|
|
||||||
protected eType( int v ){
|
|
||||||
_val = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo( Object o ){
|
|
||||||
TypeInfo.eType t = (TypeInfo.eType) o;
|
|
||||||
return _val - t._val;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int toInt(){
|
|
||||||
return _val;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int _val;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class OperatorExpression extends Enum{
|
|
||||||
|
|
||||||
//5.3.1-1 : The unary * operator, the expression to which it is applied shall be
|
|
||||||
//a pointer to an object type or a pointer to a function type and the result
|
|
||||||
//is an lvalue refering to the object or function to which the expression points
|
|
||||||
public static final OperatorExpression indirection = new OperatorExpression( 1 );
|
|
||||||
|
|
||||||
//5.3.1-2 : The result of the unary & operator is a pointer to its operand
|
|
||||||
public static final OperatorExpression addressof = new OperatorExpression( 0 );
|
|
||||||
|
|
||||||
//5.2.1 A postfix expression followed by an expression in square brackets is a postfix
|
|
||||||
//expression. one of the expressions shall have the type "pointer to T" and the other
|
|
||||||
//shall have a enumeration or integral type. The result is an lvalue of type "T"
|
|
||||||
public static final OperatorExpression subscript = new OperatorExpression( 2 );
|
|
||||||
|
|
||||||
protected OperatorExpression(int enumValue) {
|
|
||||||
super(enumValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PtrOp {
|
|
||||||
public PtrOp( TypeInfo.eType type ){
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
public PtrOp( TypeInfo.eType type, boolean isConst, boolean isVolatile ){
|
|
||||||
this.type = type;
|
|
||||||
this.isConstPtr = isConst;
|
|
||||||
this.isVolatilePtr = isVolatile;
|
|
||||||
}
|
|
||||||
public PtrOp( ISymbol memberOf, boolean isConst, boolean isVolatile ){
|
|
||||||
this.type = PtrOp.t_memberPointer;
|
|
||||||
this.isConstPtr = isConst;
|
|
||||||
this.isVolatilePtr = isVolatile;
|
|
||||||
this.memberOf = memberOf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PtrOp(){
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final TypeInfo.eType t_undef_ptr = new TypeInfo.eType( 0 );
|
|
||||||
public static final TypeInfo.eType t_pointer = new TypeInfo.eType( 1 );
|
|
||||||
public static final TypeInfo.eType t_reference = new TypeInfo.eType( 2 );
|
|
||||||
public static final TypeInfo.eType t_array = new TypeInfo.eType( 3 );
|
|
||||||
public static final TypeInfo.eType t_memberPointer = new TypeInfo.eType( 4 );
|
|
||||||
|
|
||||||
public TypeInfo.eType getType() { return type; }
|
|
||||||
public void setType( TypeInfo.eType type ) { this.type = type; }
|
|
||||||
|
|
||||||
public boolean isConst() { return isConstPtr; }
|
|
||||||
public boolean isVolatile() { return isVolatilePtr; }
|
|
||||||
public void setConst( boolean isConst ) { this.isConstPtr = isConst; }
|
|
||||||
public void setVolatile(boolean isVolatile) { this.isVolatilePtr = isVolatile; }
|
|
||||||
|
|
||||||
public ISymbol getMemberOf() { return memberOf; }
|
|
||||||
public void setMemberOf( ISymbol member ) { this.memberOf = member; }
|
|
||||||
|
|
||||||
public int compareCVTo( TypeInfo.PtrOp ptr ){
|
|
||||||
int cv1 = ( isConst() ? 1 : 0 ) + ( isVolatile() ? 1 : 0 );
|
|
||||||
int cv2 = ( ptr.isConst() ? 1 : 0 ) + ( ptr.isVolatile() ? 1 : 0 );
|
|
||||||
|
|
||||||
return cv1 - cv2;
|
|
||||||
}
|
|
||||||
public boolean equals( Object o ){
|
|
||||||
if( o == null || !(o instanceof TypeInfo.PtrOp) ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
TypeInfo.PtrOp op = (TypeInfo.PtrOp)o;
|
|
||||||
|
|
||||||
return ( isConst() == op.isConst() &&
|
|
||||||
isVolatile() == op.isVolatile() &&
|
|
||||||
getType() == op.getType() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private TypeInfo.eType type = PtrOp.t_undef_ptr;
|
|
||||||
private boolean isConstPtr = false;
|
|
||||||
private boolean isVolatilePtr = false;
|
|
||||||
private ISymbol memberOf = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
// Convenience methods
|
|
||||||
public void setBit(boolean b, int mask){
|
|
||||||
if( b ){
|
|
||||||
_typeBits = _typeBits | mask;
|
|
||||||
} else {
|
|
||||||
_typeBits = _typeBits & ~mask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkBit(int mask){
|
|
||||||
return (_typeBits & mask) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType( TypeInfo.eType t){
|
|
||||||
_type = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TypeInfo.eType getType(){
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type ){
|
|
||||||
return isType( type, TypeInfo.t_undef );
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTypeInfo(){
|
|
||||||
return _typeBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTypeInfo( int typeInfo ){
|
|
||||||
_typeBits = typeInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public eType getTemplateParameterType(){
|
|
||||||
return _templateParameterType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTemplateParameterType( eType type ){
|
|
||||||
_templateParameterType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param infoProvider - TypeInfoProvider to use if pooling the TypeInfo created, if null,
|
|
||||||
* pooling is not used. If pooling is used, TypeInfoProvider.returnTypeInfo
|
|
||||||
* must be called when the TypeInfo is no longer needed
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public TypeInfo getFinalType(TypeInfoProvider infoProvider){
|
|
||||||
return ParserSymbolTable.getFlatTypeInfo( this, infoProvider );
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param upperType
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* type checking, check that this declaration's type is between type and
|
|
||||||
* upperType (inclusive). upperType of 0 means no range and our type must
|
|
||||||
* be type.
|
|
||||||
*/
|
|
||||||
public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ){
|
|
||||||
//type of -1 means we don't care
|
|
||||||
if( type == TypeInfo.t_any )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//upperType of 0 means no range
|
|
||||||
if( upperType == TypeInfo.t_undef ){
|
|
||||||
return ( getType() == type );
|
|
||||||
}
|
|
||||||
return ( getType().compareTo( type ) >= 0 && getType().compareTo( upperType ) <= 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISymbol getTypeSymbol(){
|
|
||||||
return _typeDeclaration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTypeSymbol( ISymbol type ){
|
|
||||||
_typeDeclaration = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPtrOperators(){
|
|
||||||
return _ptrOperators.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getPtrOperators(){
|
|
||||||
return _ptrOperators;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSamePtrs( TypeInfo type ){
|
|
||||||
int size = getPtrOperators().size();
|
|
||||||
int size2 = type.getPtrOperators().size();
|
|
||||||
TypeInfo.PtrOp ptr1 = null, ptr2 = null;
|
|
||||||
|
|
||||||
if( size == size2 ){
|
|
||||||
if( size > 0 ){
|
|
||||||
for( int i = 0; i < size; i++ ){
|
|
||||||
ptr1 = (TypeInfo.PtrOp)getPtrOperators().get(i);
|
|
||||||
ptr2 = (TypeInfo.PtrOp)type.getPtrOperators().get(i);
|
|
||||||
if( ptr1.getType() != ptr2.getType() ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getOperatorExpressions(){
|
|
||||||
return _operatorExpressions;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void applyOperatorExpressions( List ops ){
|
|
||||||
if( ops == null || ops.isEmpty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
int size = ops.size();
|
|
||||||
OperatorExpression op = null;
|
|
||||||
for( int i = 0; i < size; i++ ){
|
|
||||||
op = (OperatorExpression)ops.get(i);
|
|
||||||
if( op == OperatorExpression.indirection ||
|
|
||||||
op == OperatorExpression.subscript )
|
|
||||||
{
|
|
||||||
//indirection operator, can only be applied to a pointer
|
|
||||||
//subscript should be applied to something that is "pointer to T", the result is a lvalue of type "T"
|
|
||||||
if( hasPtrOperators() ){
|
|
||||||
ListIterator iterator = getPtrOperators().listIterator( getPtrOperators().size() );
|
|
||||||
TypeInfo.PtrOp last = (TypeInfo.PtrOp)iterator.previous();
|
|
||||||
if( last.getType() == TypeInfo.PtrOp.t_pointer ||
|
|
||||||
last.getType() == TypeInfo.PtrOp.t_array )
|
|
||||||
{
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if( op == OperatorExpression.addressof ){
|
|
||||||
//Address-of unary operator, results in pointer to T
|
|
||||||
//TODO or pointer to member
|
|
||||||
TypeInfo.PtrOp newOp = new TypeInfo.PtrOp( PtrOp.t_pointer );
|
|
||||||
addPtrOperator( newOp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPtrOperator( TypeInfo.PtrOp ptr ){
|
|
||||||
if( _ptrOperators == Collections.EMPTY_LIST ){
|
|
||||||
_ptrOperators = new ArrayList(4);
|
|
||||||
}
|
|
||||||
if( ptr != null )
|
|
||||||
_ptrOperators.add( ptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPtrOperator( List ptrs ){
|
|
||||||
if( ptrs == null || ptrs.size() == 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( _ptrOperators == Collections.EMPTY_LIST ){
|
|
||||||
_ptrOperators = new ArrayList( ptrs.size() );
|
|
||||||
}
|
|
||||||
|
|
||||||
int size = ptrs.size();
|
|
||||||
for( int i = 0; i < size; i++ ){
|
|
||||||
_ptrOperators.add( ptrs.get( i ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void preparePtrOperators(int numPtrOps) {
|
|
||||||
if( _ptrOperators == Collections.EMPTY_LIST )
|
|
||||||
_ptrOperators = new ArrayList( numPtrOps );
|
|
||||||
else
|
|
||||||
((ArrayList) _ptrOperators).ensureCapacity( numPtrOps );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOperatorExpression( OperatorExpression exp ){
|
|
||||||
if( _operatorExpressions == Collections.EMPTY_LIST ){
|
|
||||||
_operatorExpressions = new ArrayList(4);
|
|
||||||
}
|
|
||||||
_operatorExpressions.add( exp );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getHasDefault(){
|
|
||||||
return _hasDefaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasDefault( boolean def ){
|
|
||||||
_hasDefaultValue = def;
|
|
||||||
}
|
|
||||||
public void setDefault( Object t ){
|
|
||||||
_defaultValue = t;
|
|
||||||
}
|
|
||||||
public Object getDefault(){
|
|
||||||
return _defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isForwardDeclaration(){
|
|
||||||
return checkBit( isForward );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsForwardDeclaration( boolean forward ){
|
|
||||||
setBit( forward, isForward );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* canHold
|
|
||||||
* @param type
|
|
||||||
* @return boolean
|
|
||||||
* return true if our type can hold all the values of the passed in
|
|
||||||
* type.
|
|
||||||
* TODO, for now return true if our type is "larger" (based on ordering of
|
|
||||||
* the type values)
|
|
||||||
*/
|
|
||||||
public boolean canHold( TypeInfo type ){
|
|
||||||
if( getType().compareTo( type.getType()) > 0 ){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isLongLong;
|
|
||||||
return ( getTypeInfo() & mask ) >= ( type.getTypeInfo() & mask );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals( Object t ){
|
|
||||||
if( t == null || !(t instanceof TypeInfo) ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeInfo type = (TypeInfo)t;
|
|
||||||
|
|
||||||
boolean result = ( _typeBits == type._typeBits );
|
|
||||||
result &= ( _type == type._type );
|
|
||||||
|
|
||||||
if( _typeDeclaration != null && type._typeDeclaration != null ){
|
|
||||||
if( _typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) &&
|
|
||||||
type._typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
|
||||||
{
|
|
||||||
//if typeDeclaration is a basic type, then only need the types the same
|
|
||||||
result &= ( _typeDeclaration.getType() == type._typeDeclaration.getType() );
|
|
||||||
} else if( _typeDeclaration.isType( TypeInfo.t_function ) &&
|
|
||||||
type._typeDeclaration.isType( TypeInfo.t_function ) )
|
|
||||||
{
|
|
||||||
//function pointers... functions must have same parameter lists and return types
|
|
||||||
IParameterizedSymbol f1 = (IParameterizedSymbol) _typeDeclaration;
|
|
||||||
IParameterizedSymbol f2 = (IParameterizedSymbol) type._typeDeclaration;
|
|
||||||
|
|
||||||
result &= f1.hasSameParameters( f2 );
|
|
||||||
if( f1.getReturnType() != null && f2.getReturnType() != null )
|
|
||||||
result &= f1.getReturnType().getTypeInfo().equals( f2.getReturnType().getTypeInfo() );
|
|
||||||
else
|
|
||||||
result &= (f1.getReturnType() == f2.getReturnType());
|
|
||||||
} else if( _typeDeclaration.isType( TypeInfo.t_templateParameter ) &&
|
|
||||||
type._typeDeclaration.isType( TypeInfo.t_templateParameter ) )
|
|
||||||
{
|
|
||||||
//template parameters
|
|
||||||
result &= TemplateEngine.templateParametersAreEquivalent( _typeDeclaration, type._typeDeclaration );
|
|
||||||
} else if ( _typeDeclaration instanceof IDeferredTemplateInstance &&
|
|
||||||
type._typeDeclaration instanceof IDeferredTemplateInstance )
|
|
||||||
{
|
|
||||||
result &= TemplateEngine.deferedInstancesAreEquivalent( (IDeferredTemplateInstance) _typeDeclaration, (IDeferredTemplateInstance)type._typeDeclaration );
|
|
||||||
}else {
|
|
||||||
//otherwise, its a user defined type, need the decls the same
|
|
||||||
result &= ( _typeDeclaration == type._typeDeclaration );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result &= ( _typeDeclaration == type._typeDeclaration );
|
|
||||||
}
|
|
||||||
|
|
||||||
int size1 = _ptrOperators.size();
|
|
||||||
int size2 = type._ptrOperators.size();
|
|
||||||
if( size1 == size2 ){
|
|
||||||
if( size1 != 0 ){
|
|
||||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
|
||||||
for( int i = 0; i < size1; i++ ){
|
|
||||||
op1 = (TypeInfo.PtrOp)_ptrOperators.get(i);
|
|
||||||
op2 = (TypeInfo.PtrOp)type._ptrOperators.get(i);
|
|
||||||
|
|
||||||
if( !op1.equals(op2) ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(){
|
|
||||||
if( isType( TypeInfo.t_type ) ){
|
|
||||||
return _typeDeclaration.getName();
|
|
||||||
}
|
|
||||||
return TypeInfo._image[ getType().toInt() ];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(){
|
|
||||||
_typeBits = 0;
|
|
||||||
_type = TypeInfo.t_undef;
|
|
||||||
_templateParameterType = t_typeName;
|
|
||||||
_typeDeclaration = null;
|
|
||||||
_hasDefaultValue = false;
|
|
||||||
_defaultValue = null;
|
|
||||||
_ptrOperators = Collections.EMPTY_LIST;
|
|
||||||
_operatorExpressions = Collections.EMPTY_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void copy( TypeInfo t ){
|
|
||||||
_typeBits = t._typeBits;
|
|
||||||
_type = t._type;
|
|
||||||
_templateParameterType = t._templateParameterType;
|
|
||||||
_typeDeclaration = t._typeDeclaration;
|
|
||||||
_hasDefaultValue = t._hasDefaultValue;
|
|
||||||
_defaultValue = t._defaultValue;
|
|
||||||
if( t._ptrOperators != Collections.EMPTY_LIST )
|
|
||||||
_ptrOperators = (ArrayList)((ArrayList)t._ptrOperators).clone();
|
|
||||||
else
|
|
||||||
_ptrOperators = Collections.EMPTY_LIST;
|
|
||||||
|
|
||||||
if( t._operatorExpressions != Collections.EMPTY_LIST )
|
|
||||||
_operatorExpressions = (ArrayList)((ArrayList)t._operatorExpressions).clone();
|
|
||||||
else
|
|
||||||
_operatorExpressions = Collections.EMPTY_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void release() {
|
|
||||||
// ParserSymbolTable.TypeInfoProvider.returnTypeInfo( this );
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
private int _typeBits = 0;
|
|
||||||
private eType _type = TypeInfo.t_undef;
|
|
||||||
private eType _templateParameterType = t_typeName;
|
|
||||||
private ISymbol _typeDeclaration;
|
|
||||||
|
|
||||||
private boolean _hasDefaultValue = false;
|
|
||||||
private Object _defaultValue = null;
|
|
||||||
private List _ptrOperators = Collections.EMPTY_LIST;
|
|
||||||
private List _operatorExpressions = Collections.EMPTY_LIST;
|
|
||||||
}
|
}
|
|
@ -0,0 +1,291 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 5, 2004
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo.PtrOp;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo.eType;
|
||||||
|
|
||||||
|
|
||||||
|
public class TypeInfoProvider
|
||||||
|
{
|
||||||
|
private static final int BASIC = 0;
|
||||||
|
private static final int TYPE = 1;
|
||||||
|
private static final int TEMPLATE = 2;
|
||||||
|
private static final int POOL_SIZE = 16;
|
||||||
|
private static final Map providerMap = new HashMap();
|
||||||
|
|
||||||
|
private final ITypeInfo [][] pool;
|
||||||
|
private final boolean [][] free;
|
||||||
|
private final int [] firstFreeHint;
|
||||||
|
|
||||||
|
private TypeInfoProvider()
|
||||||
|
{
|
||||||
|
|
||||||
|
pool = new ITypeInfo[POOL_SIZE][3];
|
||||||
|
free = new boolean [POOL_SIZE][3];
|
||||||
|
firstFreeHint = new int [] { 0, 0, 0 };
|
||||||
|
|
||||||
|
for( int i = 0; i < POOL_SIZE; i++ )
|
||||||
|
{
|
||||||
|
pool[i] = new ITypeInfo[] { new BasicTypeInfo(), new TypeInfo(), new TemplateParameterTypeInfo() };
|
||||||
|
free[i] = new boolean [] { true, true, true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public TypeInfoProvider getProvider( ParserSymbolTable table ){
|
||||||
|
if( providerMap.containsKey( table ) )
|
||||||
|
return (TypeInfoProvider) providerMap.get( table );
|
||||||
|
|
||||||
|
TypeInfoProvider provider = new TypeInfoProvider();
|
||||||
|
providerMap.put( table, provider );
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITypeInfo getTypeInfo( eType type )
|
||||||
|
{
|
||||||
|
int idx = BASIC;
|
||||||
|
if( type == ITypeInfo.t_type )
|
||||||
|
idx = TYPE;
|
||||||
|
else if( type == ITypeInfo.t_templateParameter )
|
||||||
|
idx = TEMPLATE;
|
||||||
|
|
||||||
|
ITypeInfo returnType = null;
|
||||||
|
for( int i = firstFreeHint[idx]; i < POOL_SIZE; ++i )
|
||||||
|
{
|
||||||
|
if( free[i][idx] )
|
||||||
|
{
|
||||||
|
free[i][idx] = false;
|
||||||
|
firstFreeHint[idx] = i + 1;
|
||||||
|
returnType = pool[i][idx];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( returnType == null ){
|
||||||
|
//if there is nothing free, just give them a new one
|
||||||
|
if( type == ITypeInfo.t_type ){
|
||||||
|
returnType = new TypeInfo();
|
||||||
|
} else if( type == ITypeInfo.t_templateParameter ) {
|
||||||
|
returnType = new TemplateParameterTypeInfo();
|
||||||
|
} else {
|
||||||
|
returnType = new BasicTypeInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
returnType.setType( type );
|
||||||
|
return returnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void returnTypeInfo( ITypeInfo t )
|
||||||
|
{
|
||||||
|
int idx = BASIC;
|
||||||
|
if( t instanceof TemplateParameterTypeInfo )
|
||||||
|
idx = TEMPLATE;
|
||||||
|
else if ( t instanceof TypeInfo )
|
||||||
|
idx = TYPE;
|
||||||
|
|
||||||
|
for( int i = 0; i < POOL_SIZE; i++ ){
|
||||||
|
if( pool[i][idx] == t ){
|
||||||
|
t.clear();
|
||||||
|
free[i][idx] = true;
|
||||||
|
if( i < firstFreeHint[idx] ){
|
||||||
|
firstFreeHint[idx] = i;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else it was one allocated outside the pool
|
||||||
|
}
|
||||||
|
|
||||||
|
public int numAllocated(){
|
||||||
|
int num = 0;
|
||||||
|
for( int i = 0; i < POOL_SIZE; i++ ){
|
||||||
|
num += ( free[i][0] ? 0 : 1 ) +
|
||||||
|
( free[i][1] ? 0 : 1 ) +
|
||||||
|
( free[i][2] ? 0 : 1 );
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param topInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static final public ITypeInfo newTypeInfo( ITypeInfo topInfo ) {
|
||||||
|
ITypeInfo newInfo = newInfo( topInfo.getType(), topInfo.getDefault() != null );
|
||||||
|
|
||||||
|
newInfo.copy( topInfo );
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param bits
|
||||||
|
* @param typeSymbol
|
||||||
|
* @param ptrOp
|
||||||
|
* @param hasDefault
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static final public ITypeInfo newTypeInfo( eType type, int bits, ISymbol typeSymbol, PtrOp ptrOp, boolean hasDefault ) {
|
||||||
|
ITypeInfo newInfo = newTypeInfo( type, bits, ptrOp, hasDefault );
|
||||||
|
newInfo.setTypeSymbol( typeSymbol );
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param bits
|
||||||
|
* @param typeSymbol
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static final public ITypeInfo newTypeInfo( eType type, int bits, ISymbol typeSymbol ) {
|
||||||
|
ITypeInfo newInfo = newTypeInfo( type );
|
||||||
|
newInfo.setTypeBits( bits );
|
||||||
|
newInfo.setTypeSymbol( typeSymbol );
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param bits
|
||||||
|
* @param ptrOp
|
||||||
|
* @param hasDefault
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static final public ITypeInfo newTypeInfo( eType type, int bits, PtrOp ptrOp, boolean hasDefault ) {
|
||||||
|
ITypeInfo newInfo = newTypeInfo( type );
|
||||||
|
newInfo.setTypeBits( bits );
|
||||||
|
newInfo.addPtrOperator( ptrOp );
|
||||||
|
newInfo.setHasDefault( hasDefault );
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param typeInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static final public ITypeInfo newTypeInfo( eType type ) {
|
||||||
|
ITypeInfo newInfo = newInfo( type, false );
|
||||||
|
newInfo.setType( type );
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param bits
|
||||||
|
* @param symbol
|
||||||
|
* @param op
|
||||||
|
* @param def
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ITypeInfo newTypeInfo( eType type, int bits, ISymbol symbol, PtrOp op, Object def ) {
|
||||||
|
ITypeInfo newInfo = newInfo( type, def != null );
|
||||||
|
|
||||||
|
newInfo.setType( type );
|
||||||
|
newInfo.setTypeBits( bits );
|
||||||
|
newInfo.setDefault( def );
|
||||||
|
newInfo.setTypeSymbol( symbol );
|
||||||
|
newInfo.addPtrOperator( op );
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ITypeInfo newTypeInfo() {
|
||||||
|
return new BasicTypeInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions for constructing a Type info a piece at a time.
|
||||||
|
*/
|
||||||
|
private eType type;
|
||||||
|
private ISymbol typeSymbol;
|
||||||
|
private int bits;
|
||||||
|
private Object defaultObj;
|
||||||
|
private boolean hasDef;
|
||||||
|
private eType templateParamType;
|
||||||
|
|
||||||
|
public void setType( eType t ) { type = t; }
|
||||||
|
public void setTypeSymbol( ISymbol s ) { typeSymbol = s; }
|
||||||
|
public void setTypeBits( int b ) { bits = b; }
|
||||||
|
public void setHasDef( boolean b ) { hasDef = b; }
|
||||||
|
public void setDefaultObj( Object obj ) { defaultObj = obj; }
|
||||||
|
public void setTemplateParameterType( eType t ) { templateParamType = t; }
|
||||||
|
|
||||||
|
public void setBit( boolean b, int mask ) {
|
||||||
|
if( b ) bits = bits | mask;
|
||||||
|
else bits = bits & ~mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beginTypeConstruction(){
|
||||||
|
type = ITypeInfo.t_undef;
|
||||||
|
typeSymbol = null;
|
||||||
|
bits = 0;
|
||||||
|
defaultObj = null;
|
||||||
|
templateParamType = null;
|
||||||
|
hasDef = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITypeInfo completeConstruction(){
|
||||||
|
ITypeInfo newInfo = newTypeInfo( type, bits, typeSymbol, null, defaultObj );
|
||||||
|
newInfo.setHasDefault( hasDef );
|
||||||
|
if( templateParamType != null )
|
||||||
|
newInfo.setTemplateParameterType( templateParamType );
|
||||||
|
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITypeInfo newInfo( eType type, boolean def ){
|
||||||
|
ITypeInfo newInfo = null;
|
||||||
|
if( type == ITypeInfo.t_type || type == ITypeInfo.t_enumerator ){
|
||||||
|
if( def )
|
||||||
|
newInfo = new TypeInfo(){
|
||||||
|
public void copy( ITypeInfo t ) { super.copy( t ); _defObj = t.getDefault(); }
|
||||||
|
public void setDefault( Object t ) { _defObj = t; }
|
||||||
|
public Object getDefault() { return _defObj;}
|
||||||
|
private Object _defObj;
|
||||||
|
};
|
||||||
|
else
|
||||||
|
newInfo = new TypeInfo();
|
||||||
|
} else if( type == ITypeInfo.t_templateParameter ){
|
||||||
|
if( def )
|
||||||
|
newInfo = new TemplateParameterTypeInfo(){
|
||||||
|
public void copy( ITypeInfo t ) { super.copy( t ); _defObj = t.getDefault(); }
|
||||||
|
public void setDefault( Object t ) { _defObj = t; }
|
||||||
|
public Object getDefault() { return _defObj;}
|
||||||
|
private Object _defObj;
|
||||||
|
};
|
||||||
|
else
|
||||||
|
newInfo = new TemplateParameterTypeInfo();
|
||||||
|
} else {
|
||||||
|
if( def )
|
||||||
|
newInfo = new BasicTypeInfo(){
|
||||||
|
public void copy( ITypeInfo t ) { super.copy( t ); _defObj = t.getDefault(); }
|
||||||
|
public void setDefault( Object t ) { _defObj = t; }
|
||||||
|
public Object getDefault() { return _defObj;}
|
||||||
|
private Object _defObj;
|
||||||
|
};
|
||||||
|
else
|
||||||
|
newInfo = new BasicTypeInfo();
|
||||||
|
}
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue