From c9c666335fcf2e8636c205e8a4c35169627c222b Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Wed, 7 Jul 2004 20:15:06 +0000 Subject: [PATCH] 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) --- .../parser/tests/CompleteParseASTTest.java | 4 +- .../parser/tests/CompletionParseTest.java | 4 +- .../tests/ParserSymbolTableTemplateTests.java | 870 +++++++++--------- .../parser/tests/ParserSymbolTableTest.java | 826 +++++++++-------- .../parser/ChangeLog-parser | 14 + .../cdt/core/parser/ast/IASTExpression.java | 49 +- .../extension/IASTFactoryExtension.java | 4 +- .../core/parser/ast/GCCASTExtension.java | 20 +- .../parser/ast/complete/ASTExpression.java | 14 +- .../core/parser/ast/complete/ASTFunction.java | 6 +- .../core/parser/ast/complete/ASTMethod.java | 10 +- .../ast/complete/ASTSimpleTypeSpecifier.java | 32 +- .../core/parser/ast/complete/ASTSymbol.java | 18 +- .../ast/complete/ASTTemplateParameter.java | 8 +- .../core/parser/ast/complete/ASTVariable.java | 12 +- .../ast/complete/CompleteParseASTFactory.java | 754 +++++++-------- .../parser/ast/complete/ExpressionResult.java | 13 +- .../ast/complete/ExpressionResultList.java | 8 +- .../internal/core/parser/pst/BasicSymbol.java | 67 +- .../core/parser/pst/BasicTypeInfo.java | 309 +++++++ .../core/parser/pst/ContainerSymbol.java | 117 ++- .../parser/pst/DeferredTemplateInstance.java | 14 +- .../parser/pst/DerivableContainerSymbol.java | 66 +- .../core/parser/pst/IContainerSymbol.java | 4 +- .../core/parser/pst/IParameterizedSymbol.java | 4 +- .../core/parser/pst/ISpecializedSymbol.java | 2 +- .../cdt/internal/core/parser/pst/ISymbol.java | 16 +- .../internal/core/parser/pst/ITypeInfo.java | 254 +++++ .../core/parser/pst/ParameterizedSymbol.java | 61 +- .../core/parser/pst/ParserSymbolTable.java | 419 ++++----- .../core/parser/pst/SpecializedSymbol.java | 14 +- .../core/parser/pst/TemplateEngine.java | 283 +++--- .../core/parser/pst/TemplateFactory.java | 79 +- .../parser/pst/TemplateParameterTypeInfo.java | 36 + .../core/parser/pst/TemplateSymbol.java | 83 +- .../internal/core/parser/pst/TypeFilter.java | 54 +- .../internal/core/parser/pst/TypeInfo.java | 633 ++----------- .../core/parser/pst/TypeInfoProvider.java | 291 ++++++ 38 files changed, 2952 insertions(+), 2520 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicTypeInfo.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ITypeInfo.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateParameterTypeInfo.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index 46da8de6552..b6adee8a235 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -1887,8 +1887,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest Writer writer = new StringWriter(); writer.write( "typedef int DWORD;\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( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\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)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$ writer.write( "enum e {\n"); //$NON-NLS-1$ writer.write( "blah1 = 5,\n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java index 351af2ad606..23aafc7c32d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java @@ -1125,8 +1125,8 @@ public class CompletionParseTest extends CompletionParseBaseTest { Writer writer = new StringWriter(); writer.write( "typedef int DWORD;\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( "((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\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)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))\n"); //$NON-NLS-1$ writer.write( "enum e {\n"); //$NON-NLS-1$ writer.write( "blah1 = 5,\n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTemplateTests.java index f9d6613af98..a48a00fe22d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTemplateTests.java @@ -26,10 +26,10 @@ import org.eclipse.cdt.internal.core.parser.pst.ISpecializedSymbol; import org.eclipse.cdt.internal.core.parser.pst.ISymbol; import org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory; import org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol; +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.ParserSymbolTableException; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; +import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider; /** * @author aniefer @@ -38,6 +38,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; public class ParserSymbolTableTemplateTests extends TestCase { public ParserSymbolTable table = null; + public TypeInfoProvider provider = null; public ParserSymbolTableTemplateTests( String arg ) { @@ -50,6 +51,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { public ParserSymbolTable newTable( ParserLanguage language ){ table = new ParserSymbolTable( language, ParserMode.COMPLETE_PARSE ); + provider = TypeInfoProvider.getProvider( table ); return table; } @@ -71,30 +73,30 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol param = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol param = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( param ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( A ); A.addParent( param ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ - ISymbol i = table.newSymbol( "i", TypeInfo.t_int ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ + ISymbol i = table.newSymbol( "i", ITypeInfo.t_int ); //$NON-NLS-1$ B.addSymbol( i ); table.getCompilationUnit().addSymbol( B ); - TypeInfo type = new TypeInfo( TypeInfo.t_type, 0, B ); + ITypeInfo type = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, B ); ArrayList args = new ArrayList(); args.add( type ); IContainerSymbol instance = (IContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertEquals( instance.getInstantiatedSymbol(), A ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( instance ); table.getCompilationUnit().addSymbol( a ); @@ -126,26 +128,26 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol param = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol param = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( param ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( A ); - ISymbol t = table.newSymbol( "t", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol t = table.newSymbol( "t", ITypeInfo.t_type ); //$NON-NLS-1$ ISymbol look = template.lookup( "T" ); //$NON-NLS-1$ assertEquals( look, param ); t.setTypeSymbol( param ); A.addSymbol( t ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( B ); - TypeInfo type = new TypeInfo( TypeInfo.t_int, 0 , null ); + ITypeInfo type = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0 , null ); ArrayList args = new ArrayList(); args.add( type ); @@ -155,7 +157,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { B.addParent( look ); - ISymbol b = table.newSymbol( "b", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol b = table.newSymbol( "b", ITypeInfo.t_type ); //$NON-NLS-1$ b.setTypeSymbol( B ); table.getCompilationUnit().addSymbol( b ); @@ -165,7 +167,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IDerivableContainerSymbol) b.getTypeSymbol()).lookup( "t" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), t ); - assertTrue( look.isType( TypeInfo.t_int ) ); + assertTrue( look.isType( ITypeInfo.t_int ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -190,35 +192,36 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ - ISymbol paramT = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol paramT = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( paramT ); ISymbol look = template.lookup( "T" ); //$NON-NLS-1$ assertEquals( look, paramT ); - ISymbol paramU = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - paramU.getTypeInfo().setDefault( new TypeInfo( TypeInfo.t_type, 0, look ) ); + ISymbol paramU = table.newSymbol( "U" ); //$NON-NLS-1$ + paramU.setTypeInfo( TypeInfoProvider.newTypeInfo( ITypeInfo.t_templateParameter, 0, null, null, + TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, look ) ) ); template.addTemplateParameter( paramU ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( X ); look = X.lookup( "T" ); //$NON-NLS-1$ assertEquals( look, paramT ); - ISymbol t = table.newSymbol( "t", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol t = table.newSymbol( "t", ITypeInfo.t_type ); //$NON-NLS-1$ t.setTypeSymbol( look ); X.addSymbol( t ); look = X.lookup( "U" ); //$NON-NLS-1$ assertEquals( look, paramU ); - ISymbol u = table.newSymbol( "u", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol u = table.newSymbol( "u", ITypeInfo.t_type ); //$NON-NLS-1$ u.setTypeSymbol( look ); X.addSymbol( u ); - TypeInfo type = new TypeInfo( TypeInfo.t_char, 0, null ); + ITypeInfo type = TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ); ArrayList args = new ArrayList(); args.add( type ); IDerivableContainerSymbol lookX = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "X", args ); //$NON-NLS-1$ @@ -230,12 +233,12 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), t ); - assertTrue( look.isType( TypeInfo.t_char ) ); + assertTrue( look.isType( ITypeInfo.t_char ) ); look = lookX.lookup( "u" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), u ); - assertTrue( look.isType( TypeInfo.t_char ) ); + assertTrue( look.isType( ITypeInfo.t_char ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -258,55 +261,55 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol paramT = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol paramT = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( paramT ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( A ); - ISymbol t = table.newSymbol( "t", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol t = table.newSymbol( "t", ITypeInfo.t_type ); //$NON-NLS-1$ t.setTypeSymbol( paramT ); A.addSymbol( t ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( B ); ArrayList args = new ArrayList(); - TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, B ); + ITypeInfo arg = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, B ); args.add( arg ); IDerivableContainerSymbol lookA = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( lookA.isTemplateInstance() ); assertEquals( lookA.getInstantiatedSymbol(), A ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_char, 0, null, false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_char, 0, null, false ); table.getCompilationUnit().addSymbol( f1 ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f2.addParameter( lookA, 0, null, false ); table.getCompilationUnit().addSymbol( f2 ); - IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f3.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f3.addParameter( ITypeInfo.t_int, 0, null, false ); table.getCompilationUnit().addSymbol( f3 ); args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, B ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, B ) ); IDerivableContainerSymbol lookA2 = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertEquals( lookA2, lookA ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( lookA ); table.getCompilationUnit().addSymbol( a ); ArrayList params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_type, 0, a ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ) ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f2 ); @@ -326,23 +329,23 @@ public class ParserSymbolTableTemplateTests extends TestCase { public void test_14_1__3_ParameterLookup() throws Exception{ newTable(); - IDerivableContainerSymbol T = table.newDerivableContainerSymbol( "T", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol T = table.newDerivableContainerSymbol( "T", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( T ); - ISymbol i = table.newSymbol( "i", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol i = table.newSymbol( "i", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( i ); ITemplateSymbol template = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - ISymbol paramT = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol paramT = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( paramT ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - ISymbol parami = table.newSymbol( "i", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - parami.getTypeInfo().setTemplateParameterType( TypeInfo.t_type ); + ISymbol parami = table.newSymbol( "i", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + parami.getTypeInfo().setTemplateParameterType( ITypeInfo.t_type ); ISymbol look = factory.lookup( "T" ); //$NON-NLS-1$ @@ -350,8 +353,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { parami.setTypeSymbol( look ); template.addTemplateParameter( parami ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - ISymbol fParam = table.newSymbol( "t", TypeInfo.t_type ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + ISymbol fParam = table.newSymbol( "t", ITypeInfo.t_type ); //$NON-NLS-1$ fParam.setTypeSymbol( paramT ); f.addParameter( fParam ); @@ -385,30 +388,30 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol templateR = table.newTemplateSymbol( "R" ); //$NON-NLS-1$ - ISymbol paramA = table.newSymbol( "a", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - paramA.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); - paramA.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + ISymbol paramA = table.newSymbol( "a", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + paramA.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); + paramA.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); templateR.addTemplateParameter( paramA ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateR ); - IDerivableContainerSymbol R = table.newDerivableContainerSymbol( "R", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol R = table.newDerivableContainerSymbol( "R", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( R ); ITemplateSymbol templateS = table.newTemplateSymbol( "S" ); //$NON-NLS-1$ - ISymbol paramB = table.newSymbol( "b", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - paramB.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); - paramB.addPtrOperator( new PtrOp( PtrOp.t_array ) ); + ISymbol paramB = table.newSymbol( "b", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + paramB.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); + paramB.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_array ) ); templateS.addTemplateParameter( paramB ); factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateS ); - IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( S ); ISymbol look = table.getCompilationUnit().lookup( "S" ); //$NON-NLS-1$ @@ -418,16 +421,16 @@ public class ParserSymbolTableTemplateTests extends TestCase { ISymbol param = (ISymbol) iter.next(); assertFalse( iter.hasNext() ); iter = param.getTypeInfo().getPtrOperators().iterator(); - PtrOp ptr = (PtrOp) iter.next(); + ITypeInfo.PtrOp ptr = (ITypeInfo.PtrOp) iter.next(); assertFalse( iter.hasNext() ); - assertEquals( ptr.getType(), PtrOp.t_pointer ); + assertEquals( ptr.getType(), ITypeInfo.PtrOp.t_pointer ); - ISymbol p = table.newSymbol( "p", TypeInfo.t_int ); //$NON-NLS-1$ - p.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + ISymbol p = table.newSymbol( "p", ITypeInfo.t_int ); //$NON-NLS-1$ + p.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); table.getCompilationUnit().addSymbol( p ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, p ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, p ) ); look = table.getCompilationUnit().lookupTemplateId( "R", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -437,12 +440,12 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), S ); - ISymbol v = table.newSymbol( "v", TypeInfo.t_int ); //$NON-NLS-1$ - v.addPtrOperator( new PtrOp( PtrOp.t_array ) ); + ISymbol v = table.newSymbol( "v", ITypeInfo.t_int ); //$NON-NLS-1$ + v.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_array ) ); table.getCompilationUnit().addSymbol( v ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, v ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, v ) ); look = table.getCompilationUnit().lookupTemplateId( "R", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -468,15 +471,16 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template = table.newTemplateSymbol( "String" ); //$NON-NLS-1$ - ISymbol param = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - param.getTypeInfo().setDefault( new TypeInfo( TypeInfo.t_char, 0, null ) ); + ISymbol param = table.newSymbol( "T" ); //$NON-NLS-1$ + param.setTypeInfo( TypeInfoProvider.newTypeInfo( ITypeInfo.t_templateParameter, 0, null, null, + TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) )); template.addTemplateParameter( param ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol string = table.newDerivableContainerSymbol( "String", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol string = table.newDerivableContainerSymbol( "String", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( string ); List args = new ArrayList(); @@ -503,22 +507,22 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - factory.addSymbol( table.newDerivableContainerSymbol( "X", TypeInfo.t_class ) ); //$NON-NLS-1$ + factory.addSymbol( table.newDerivableContainerSymbol( "X", ITypeInfo.t_class ) ); //$NON-NLS-1$ - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( f ); - IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", ITypeInfo.t_struct ); //$NON-NLS-1$ f.addSymbol( S ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, S ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, S ) ); try{ f.lookupTemplateId( "X", args ); //$NON-NLS-1$ assertTrue( false ); @@ -527,7 +531,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { } args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, S, new PtrOp( PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, S, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); try{ f.lookupTemplateId( "X", args ); //$NON-NLS-1$ assertTrue( false ); @@ -554,23 +558,28 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ - ISymbol param2 = table.newSymbol( "p", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - param2.getTypeInfo().setTemplateParameterType( TypeInfo.t_char ); - param2.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + ISymbol param2 = table.newSymbol( "p", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + param2.getTypeInfo().setTemplateParameterType( ITypeInfo.t_char ); + param2.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); template.addTemplateParameter( param2 ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( X ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_char, 0, null, new PtrOp( PtrOp.t_pointer ), "Studebaker" ) ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + provider.beginTypeConstruction(); + provider.setType( ITypeInfo.t_char ); + provider.setDefaultObj( "Studebaker" ); //$NON-NLS-1$ + ITypeInfo info = provider.completeConstruction(); + info.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); + args.add( info ); //$NON-NLS-1$ try{ table.getCompilationUnit().lookupTemplateId( "X", args ); //$NON-NLS-1$ @@ -579,13 +588,13 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateArgument ); } - ISymbol p = table.newSymbol( "p", TypeInfo.t_char ); //$NON-NLS-1$ - p.addPtrOperator( new PtrOp( PtrOp.t_array ) ); + ISymbol p = table.newSymbol( "p", ITypeInfo.t_char ); //$NON-NLS-1$ + p.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_array ) ); table.getCompilationUnit().addSymbol( p ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, p ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, p ) ); ISymbol look = table.getCompilationUnit().lookupTemplateId( "X", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -616,33 +625,33 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ - ISymbol param = table.newSymbol( "p", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - param.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); - param.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + ISymbol param = table.newSymbol( "p", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + param.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); + param.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); template.addTemplateParameter( param ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( X ); - IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", ITypeInfo.t_struct ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( S ); - ISymbol m = table.newSymbol( "m", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol m = table.newSymbol( "m", ITypeInfo.t_int ); //$NON-NLS-1$ S.addSymbol( m ); - ISymbol s = table.newSymbol( "s", TypeInfo.t_int ); //$NON-NLS-1$ - s.getTypeInfo().setBit( true, TypeInfo.isStatic ); + ISymbol s = table.newSymbol( "s", ITypeInfo.t_int ); //$NON-NLS-1$ + s.getTypeInfo().setBit( true, ITypeInfo.isStatic ); S.addSymbol( s ); - ISymbol t = table.newSymbol( "t", TypeInfo.t_int ); //$NON-NLS-1$ - t.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + ISymbol t = table.newSymbol( "t", ITypeInfo.t_int ); //$NON-NLS-1$ + t.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); S.addSymbol( t ); List args = new ArrayList(); - TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, m ); - arg.addOperatorExpression( TypeInfo.OperatorExpression.addressof ); + ITypeInfo arg = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, m ); + arg.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); args.add( arg ); try @@ -654,7 +663,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { } args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, t ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, t ) ); try { @@ -665,8 +674,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { } args.clear(); - arg = new TypeInfo( TypeInfo.t_type, 0, s ); - arg.addOperatorExpression( TypeInfo.OperatorExpression.addressof ); + arg = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, s ); + arg.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); args.add( arg ); assertNotNull( table.getCompilationUnit().lookupTemplateId( "X", args ) ); //$NON-NLS-1$ @@ -690,20 +699,20 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template = table.newTemplateSymbol( "B" ); //$NON-NLS-1$ - ISymbol I = table.newSymbol( "I", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - I.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); - I.addPtrOperator( new PtrOp( PtrOp.t_reference, true, false ) ); + ISymbol I = table.newSymbol( "I", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + I.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); + I.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, true, false ) ); template.addTemplateParameter( I ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( B ); List args = new ArrayList( ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ try{ table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$ @@ -712,10 +721,10 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateArgument ); } - ISymbol c = table.newSymbol( "c", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol c = table.newSymbol( "c", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( c ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, c ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, c ) ); ISymbol look = table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -749,62 +758,62 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol templateA = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( templateA ); - templateA.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + templateA.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ - IDerivableContainerSymbol A1 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A1 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ templateA.addSymbol( A1 ); - ISymbol x1 = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol x1 = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ A1.addSymbol( x1 ); ISpecializedSymbol specialization = table.newSpecializedSymbol( "A" ); //$NON-NLS-1$ templateA.addSpecialization( specialization ); - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ specialization.addTemplateParameter( T ); - specialization.addArgument( new TypeInfo( TypeInfo.t_type, 0, T, new PtrOp( PtrOp.t_pointer ), false ) ); + specialization.addArgument( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); - IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ specialization.addSymbol( A2 ); - ISymbol x2 = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ - x2.getTypeInfo().setBit( true, TypeInfo.isLong ); + ISymbol x2 = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ + x2.getTypeInfo().setBit( true, ITypeInfo.isLong ); A2.addSymbol( x2 ); ITemplateSymbol templateC = table.newTemplateSymbol( "C" ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( templateC ); ITemplateSymbol templateV = table.newTemplateSymbol( "V" ); //$NON-NLS-1$ - templateV.setType( TypeInfo.t_templateParameter ); - templateV.getTypeInfo().setTemplateParameterType( TypeInfo.t_template ); - ISymbol U = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + templateV.setTypeInfo( TypeInfoProvider.newTypeInfo( ITypeInfo.t_templateParameter ) ); + templateV.getTypeInfo().setTemplateParameterType( ITypeInfo.t_template ); + ISymbol U = table.newSymbol( "U", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ templateV.addTemplateParameter( U ); templateC.addTemplateParameter( templateV ); - IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C", ITypeInfo.t_class ); //$NON-NLS-1$ templateC.addSymbol( C ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); ISymbol look = templateC.lookupTemplateId( "V", args ); //$NON-NLS-1$ assertTrue( look != null ); assertTrue( look instanceof IDeferredTemplateInstance ); - ISymbol y = table.newSymbol( "y", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol y = table.newSymbol( "y", ITypeInfo.t_type ); //$NON-NLS-1$ y.setTypeSymbol( look ); C.addSymbol( y ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); look = templateC.lookupTemplateId( "V", args ); //$NON-NLS-1$ assertTrue( look != null ); assertTrue( look instanceof IDeferredTemplateInstance ); - ISymbol z = table.newSymbol( "z", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol z = table.newSymbol( "z", ITypeInfo.t_type ); //$NON-NLS-1$ z.setTypeSymbol( look ); C.addSymbol( z ); @@ -812,7 +821,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( look, templateA ); args.clear(); - args.add ( new TypeInfo( TypeInfo.t_type, 0, look ) ); + args.add ( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, look ) ); look = table.getCompilationUnit().lookupTemplateId( "C", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), C ); @@ -820,7 +829,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { IDerivableContainerSymbol lookC = (IDerivableContainerSymbol)look; look = lookC.lookup( "y" ); //$NON-NLS-1$ - assertEquals( look.getType(), TypeInfo.t_type ); + assertEquals( look.getType(), ITypeInfo.t_type ); ISymbol symbol = look.getTypeSymbol(); assertTrue( symbol instanceof IContainerSymbol ); assertTrue( symbol.isTemplateInstance() ); @@ -828,19 +837,19 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IContainerSymbol) symbol).lookup( "x" ); //$NON-NLS-1$ - assertEquals( look.getType(), TypeInfo.t_int ); - assertEquals( look.getTypeInfo().checkBit( TypeInfo.isLong ), false ); + assertEquals( look.getType(), ITypeInfo.t_int ); + assertEquals( look.getTypeInfo().checkBit( ITypeInfo.isLong ), false ); look = lookC.lookup( "z" ); //$NON-NLS-1$ - assertEquals( look.getType(), TypeInfo.t_type ); + assertEquals( look.getType(), ITypeInfo.t_type ); symbol = look.getTypeSymbol(); assertTrue( symbol instanceof IContainerSymbol ); assertTrue( symbol.isTemplateInstance() ); assertEquals( symbol.getInstantiatedSymbol(), A2 ); look = ((IContainerSymbol)symbol).lookup( "x" ); //$NON-NLS-1$ - assertEquals( look.getType(), TypeInfo.t_int ); - assertEquals( look.getTypeInfo().checkBit( TypeInfo.isLong ), true ); + assertEquals( look.getType(), ITypeInfo.t_int ); + assertEquals( look.getTypeInfo().checkBit( ITypeInfo.isLong ), true ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -861,8 +870,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME ); - ISymbol primaryT1 = table.newSymbol( "T1", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol primaryT2 = table.newSymbol( "T2", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol primaryT1 = table.newSymbol( "T1", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol primaryT2 = table.newSymbol( "T2", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( primaryT1 ); template.addTemplateParameter( primaryT2 ); @@ -870,11 +879,11 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( A ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f1", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f1", ITypeInfo.t_function ); //$NON-NLS-1$ ISymbol look = A.lookup( "T1" ); //$NON-NLS-1$ assertEquals( look, primaryT1 ); @@ -882,15 +891,15 @@ public class ParserSymbolTableTemplateTests extends TestCase { f1.setIsForwardDeclaration( true ); f1.setReturnType( look ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f2", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f2", ITypeInfo.t_function ); //$NON-NLS-1$ f2.setIsForwardDeclaration( true ); A.addSymbol( f1 ); A.addSymbol( f2 ); ITemplateSymbol temp = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME ); - ISymbol U = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol V = table.newSymbol( "V", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol U = table.newSymbol( "U", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol V = table.newSymbol( "V", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ temp.addTemplateParameter( U ); temp.addTemplateParameter( V ); @@ -902,8 +911,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( returnType, U ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, U ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, V ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, U ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, V ) ); look = factory.lookupTemplateIdForDefinition( "A", args ); //$NON-NLS-1$ assertEquals( look, A ); @@ -913,15 +922,15 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( lookF, f1 ); assertTrue( lookF.isForwardDeclaration() ); - IParameterizedSymbol defnd = table.newParameterizedSymbol( "f1", TypeInfo.t_function ); //$NON-NLS-1$ - f1.setTypeSymbol( defnd ); + IParameterizedSymbol defnd = table.newParameterizedSymbol( "f1", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.setForwardSymbol( defnd ); defnd.setReturnType( returnType ); factory.addSymbol( defnd ); //Test that the adding was all good by doing a lookup args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); IDerivableContainerSymbol lookA = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( lookA.isTemplateInstance() ); @@ -931,14 +940,14 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = lookA.qualifiedFunctionLookup( "f1", params ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), defnd ); - assertTrue( ((IParameterizedSymbol)look).getReturnType().isType( TypeInfo.t_int ) ); + assertTrue( ((IParameterizedSymbol)look).getReturnType().isType( ITypeInfo.t_int ) ); params.clear(); args.clear(); temp = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME ); - ISymbol X = table.newSymbol( "X", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol Y = table.newSymbol( "Y", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol X = table.newSymbol( "X", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol Y = table.newSymbol( "Y", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ temp.addTemplateParameter( X ); temp.addTemplateParameter( Y ); @@ -946,8 +955,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( temp ); - args.add( new TypeInfo( TypeInfo.t_type, 0, Y ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, X ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, Y ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, X ) ); try{ look = factory.lookupTemplateIdForDefinition( "A", args ); //$NON-NLS-1$ @@ -971,21 +980,21 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol primaryT = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol primaryT = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( primaryT ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( A ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ B.setIsForwardDeclaration( true ); A.addSymbol( B ); - ISymbol U = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol U = table.newSymbol( "U", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ ITemplateSymbol temp = table.newTemplateSymbol( "" ); //$NON-NLS-1$ temp.addTemplateParameter( U ); @@ -994,7 +1003,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( temp ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, U ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, U ) ); IContainerSymbol lookA = factory.lookupTemplateIdForDefinition( "A", args ); //$NON-NLS-1$ assertEquals( lookA, A ); @@ -1003,19 +1012,19 @@ public class ParserSymbolTableTemplateTests extends TestCase { ISymbol look = lookA.lookupMemberForDefinition( "B" ); //$NON-NLS-1$ assertEquals( look, B ); - IDerivableContainerSymbol newB = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ - look.setTypeSymbol( newB ); + IDerivableContainerSymbol newB = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ + look.setForwardSymbol( newB ); factory.addSymbol( newB ); - ISymbol i = table.newSymbol( "i", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol i = table.newSymbol( "i", ITypeInfo.t_type ); //$NON-NLS-1$ look = newB.lookup( "U" ); //$NON-NLS-1$ assertEquals( look, U ); i.setTypeSymbol( U ); newB.addSymbol( i ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -1031,7 +1040,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IDerivableContainerSymbol) look).lookup( "i" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), i ); - assertEquals( look.getType(), TypeInfo.t_int ); + assertEquals( look.getType(), ITypeInfo.t_int ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -1048,27 +1057,27 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( X ); ISymbol look = X.lookup( "T" ); //$NON-NLS-1$ assertEquals( look, T ); - ISymbol s = table.newSymbol( "s", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol s = table.newSymbol( "s", ITypeInfo.t_type ); //$NON-NLS-1$ s.setTypeSymbol( look ); - s.getTypeInfo().setBit( true, TypeInfo.isStatic ); + s.getTypeInfo().setBit( true, ITypeInfo.isStatic ); s.setIsForwardDeclaration( true ); X.addSymbol( s ); ITemplateSymbol temp = table.newTemplateSymbol( "" ); //$NON-NLS-1$ - ISymbol paramU = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol paramU = table.newSymbol( "U", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ temp.addTemplateParameter( paramU ); factory = table.newTemplateFactory(); @@ -1076,7 +1085,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( temp ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, paramU ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, paramU ) ); look = factory.lookupTemplateIdForDefinition( "X", args ); //$NON-NLS-1$ assertEquals( look, X ); @@ -1086,15 +1095,15 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( look, s ); assertTrue( look.isForwardDeclaration() ); - ISymbol newS = table.newSymbol( "s", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol newS = table.newSymbol( "s", ITypeInfo.t_type ); //$NON-NLS-1$ newS.setTypeSymbol( paramU ); - look.setTypeSymbol( newS ); + look.setForwardSymbol( newS ); factory.addSymbol( newS ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_float, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_float, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "X", args ); //$NON-NLS-1$ @@ -1103,7 +1112,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IContainerSymbol)look).qualifiedLookup( "s" ); //$NON-NLS-1$ - assertTrue( look.isType( TypeInfo.t_float ) ); + assertTrue( look.isType( ITypeInfo.t_float ) ); assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), newS ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -1123,33 +1132,33 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template1 = table.newTemplateSymbol( "string" ); //$NON-NLS-1$ - template1.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template1.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template1 ); - IDerivableContainerSymbol string = table.newDerivableContainerSymbol( "string", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol string = table.newDerivableContainerSymbol( "string", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( string ); ITemplateSymbol template2 = table.newTemplateSymbol( "compare" ); //$NON-NLS-1$ - ISymbol T2 = table.newSymbol( "T2", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T2 = table.newSymbol( "T2", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template2.addTemplateParameter( T2 ); factory = table.newTemplateFactory(); factory.setContainingSymbol( string ); factory.pushTemplate( template2 ); - IParameterizedSymbol compare = table.newParameterizedSymbol( "compare", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol compare = table.newParameterizedSymbol( "compare", ITypeInfo.t_function ); //$NON-NLS-1$ compare.setIsForwardDeclaration( true ); - compare.addParameter( T2, 0, new PtrOp( PtrOp.t_reference, true, false ), false ); - ISymbol returnType = table.newSymbol( "", TypeInfo.t_type ); //$NON-NLS-1$ + compare.addParameter( T2, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, true, false ), false ); + ISymbol returnType = table.newSymbol( "", ITypeInfo.t_type ); //$NON-NLS-1$ returnType.setTypeSymbol( T2 ); compare.setReturnType( returnType ); factory.addSymbol( compare ); ITemplateSymbol temp = table.newTemplateSymbol( "" ); //$NON-NLS-1$ - ISymbol U = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol U = table.newSymbol( "U", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ temp.addTemplateParameter( U ); factory = table.newTemplateFactory(); @@ -1157,7 +1166,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( temp ); ITemplateSymbol temp2 = table.newTemplateSymbol( "" ); //$NON-NLS-1$ - ISymbol V = table.newSymbol( "V", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol V = table.newSymbol( "V", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ temp2.addTemplateParameter( V ); factory.pushTemplate( temp2 ); @@ -1166,36 +1175,36 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( lookV, V ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, U ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, U ) ); ISymbol look = factory.lookupTemplateIdForDefinition( "string", args ); //$NON-NLS-1$ assertEquals( look, string ); factory.pushTemplateId( look, args ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, lookV, new PtrOp( PtrOp.t_reference, true, false ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, lookV, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, true, false ), false ) ); look = ((IContainerSymbol)look).lookupMethodForDefinition( "compare", args ); //$NON-NLS-1$ assertEquals( look, compare ); - IParameterizedSymbol compareDef = table.newParameterizedSymbol( "compare", TypeInfo.t_function ); //$NON-NLS-1$ - compareDef.addParameter( lookV, 0, new PtrOp( PtrOp.t_reference, true, false ), false ); - ISymbol defReturn = table.newSymbol( "", TypeInfo.t_type ); //$NON-NLS-1$ + IParameterizedSymbol compareDef = table.newParameterizedSymbol( "compare", ITypeInfo.t_function ); //$NON-NLS-1$ + compareDef.addParameter( lookV, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, true, false ), false ); + ISymbol defReturn = table.newSymbol( "", ITypeInfo.t_type ); //$NON-NLS-1$ defReturn.setTypeSymbol( lookV ); compareDef.setReturnType( defReturn ); - compare.setTypeSymbol( compareDef ); + compare.setForwardSymbol( compareDef ); factory.addSymbol( compareDef ); look = compareDef.lookup( "U" ); //$NON-NLS-1$ assertEquals( look, U ); - ISymbol u = table.newSymbol( "u", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol u = table.newSymbol( "u", ITypeInfo.t_type ); //$NON-NLS-1$ u.setTypeSymbol( look ); compareDef.addSymbol( u ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "string", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -1206,13 +1215,13 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertTrue( look.getInstantiatedSymbol().isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol().getInstantiatedSymbol(), compareDef ); - assertTrue( ((IParameterizedSymbol)look).getReturnType().isType( TypeInfo.t_int ) ); + assertTrue( ((IParameterizedSymbol)look).getReturnType().isType( ITypeInfo.t_int ) ); look = ((IContainerSymbol)look).lookup( "u" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertTrue( look.getInstantiatedSymbol().isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol().getInstantiatedSymbol(), u ); - assertTrue( look.isType( TypeInfo.t_int ) ); + assertTrue( look.isType( ITypeInfo.t_int ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -1229,26 +1238,26 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( A ); ITemplateSymbol memberTemplate = table.newTemplateSymbol( "g" ); //$NON-NLS-1$ - ISymbol C = table.newSymbol( "C", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol C = table.newSymbol( "C", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ memberTemplate.addTemplateParameter( C ); factory = table.newTemplateFactory(); factory.setContainingSymbol( A ); factory.pushTemplate( memberTemplate ); - IParameterizedSymbol g = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol g = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ g.addParameter( C, 0, null, false ); - g.getTypeInfo().setBit( true, TypeInfo.isVirtual ); + g.getTypeInfo().setBit( true, ITypeInfo.isVirtual ); try{ factory.addSymbol( memberTemplate ); @@ -1257,8 +1266,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( e.reason, ParserSymbolTableException.r_BadTemplate ); } - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f.getTypeInfo().setBit( true, TypeInfo.isVirtual ); + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f.getTypeInfo().setBit( true, ITypeInfo.isVirtual ); A.addSymbol( f ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -1289,16 +1298,16 @@ public class ParserSymbolTableTemplateTests extends TestCase { //TODO newTable(); - IContainerSymbol N = table.newContainerSymbol( "N", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol N = table.newContainerSymbol( "N", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( N ); ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T1", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T2", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T1", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T2", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ - IDerivableContainerSymbol A1 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A1 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ template.addSymbol( A1 ); @@ -1307,18 +1316,18 @@ public class ParserSymbolTableTemplateTests extends TestCase { table.getCompilationUnit().addUsingDeclaration( "A", N ); //$NON-NLS-1$ ISpecializedSymbol spec = table.newSpecializedSymbol( "A" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ spec.addTemplateParameter( T ); - spec.addArgument( new TypeInfo( TypeInfo.t_type, 0, T ) ); - spec.addArgument( new TypeInfo( TypeInfo.t_type, 0, T, new PtrOp( PtrOp.t_pointer ), false ) ); + spec.addArgument( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T ) ); + spec.addArgument( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); - IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ spec.addSymbol( A2 ); template.addSpecialization( spec ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); ISymbol look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look != null ); @@ -1347,17 +1356,17 @@ public class ParserSymbolTableTemplateTests extends TestCase { //TODO newTable(); - IDerivableContainerSymbol cls1 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol cls2 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol cls3 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol cls4 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol cls5 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls1 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls2 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls3 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls4 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls5 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ ITemplateSymbol template1 = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol T1p1 = table.newSymbol( "T1", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T1p2 = table.newSymbol( "T2", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T1p3 = table.newSymbol( "I", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - T1p3.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); + ISymbol T1p1 = table.newSymbol( "T1", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T1p2 = table.newSymbol( "T2", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T1p3 = table.newSymbol( "I", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + T1p3.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); template1.addTemplateParameter( T1p1 ); template1.addTemplateParameter( T1p2 ); @@ -1366,16 +1375,16 @@ public class ParserSymbolTableTemplateTests extends TestCase { table.getCompilationUnit().addSymbol( template1 ); ISpecializedSymbol template2 = table.newSpecializedSymbol( "A" ); //$NON-NLS-1$ - ISymbol T2p1 = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T2p2 = table.newSymbol( "I", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - T2p2.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); + ISymbol T2p1 = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T2p2 = table.newSymbol( "I", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + T2p2.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); template2.addTemplateParameter( T2p1 ); template2.addTemplateParameter( T2p2 ); - TypeInfo T2a1 = new TypeInfo( TypeInfo.t_type, 0, T2p1 ); - TypeInfo T2a2 = new TypeInfo( TypeInfo.t_type, 0, T2p1, new PtrOp( PtrOp.t_pointer ), false ); - TypeInfo T2a3 = new TypeInfo( TypeInfo.t_type, 0, T2p2 ); + ITypeInfo T2a1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T2p1 ); + ITypeInfo T2a2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T2p1, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); + ITypeInfo T2a3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T2p2 ); template2.addArgument( T2a1 ); template2.addArgument( T2a2 ); @@ -1384,18 +1393,18 @@ public class ParserSymbolTableTemplateTests extends TestCase { template1.addSpecialization( template2 ); ISpecializedSymbol template3 = table.newSpecializedSymbol( "A" ); //$NON-NLS-1$ - ISymbol T3p1 = table.newSymbol( "T1", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T3p2 = table.newSymbol( "T2", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T3p3 = table.newSymbol( "I", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - T3p3.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); + ISymbol T3p1 = table.newSymbol( "T1", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T3p2 = table.newSymbol( "T2", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T3p3 = table.newSymbol( "I", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + T3p3.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); template3.addTemplateParameter( T3p1 ); template3.addTemplateParameter( T3p2 ); template3.addTemplateParameter( T3p3 ); - TypeInfo T3a1 = new TypeInfo( TypeInfo.t_type, 0, T3p1, new PtrOp( PtrOp.t_pointer ), false ); - TypeInfo T3a2 = new TypeInfo( TypeInfo.t_type, 0, T3p2 ); - TypeInfo T3a3 = new TypeInfo( TypeInfo.t_type, 0, T3p3 ); + ITypeInfo T3a1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T3p1, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); + ITypeInfo T3a2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T3p2 ); + ITypeInfo T3a3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T3p3 ); template3.addArgument( T3a1 ); template3.addArgument( T3a2 ); @@ -1404,13 +1413,12 @@ public class ParserSymbolTableTemplateTests extends TestCase { template1.addSpecialization( template3 ); ISpecializedSymbol template4 = table.newSpecializedSymbol( "A" ); //$NON-NLS-1$ - ISymbol T4p1 = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T4p1 = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template4.addTemplateParameter( T4p1 ); - TypeInfo T4a1 = new TypeInfo( TypeInfo.t_int, 0, null ); - TypeInfo T4a2 = new TypeInfo( TypeInfo.t_type, 0, T4p1, new PtrOp( PtrOp.t_pointer ), false ); - TypeInfo T4a3 = new TypeInfo( TypeInfo.t_int, 0, null, null, "5" ); //$NON-NLS-1$ - //T4a3.setDefault( new Integer(5) ); + ITypeInfo T4a1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ); + ITypeInfo T4a2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T4p1, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); + ITypeInfo T4a3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "5" ); //$NON-NLS-1$ template4.addArgument( T4a1 ); template4.addArgument( T4a2 ); @@ -1419,18 +1427,18 @@ public class ParserSymbolTableTemplateTests extends TestCase { template1.addSpecialization( template4 ); ISpecializedSymbol template5 = table.newSpecializedSymbol( "A" ); //$NON-NLS-1$ - ISymbol T5p1 = table.newSymbol( "T1", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T5p2 = table.newSymbol( "T2", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T5p3 = table.newSymbol( "I", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - T5p3.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); + ISymbol T5p1 = table.newSymbol( "T1", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T5p2 = table.newSymbol( "T2", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T5p3 = table.newSymbol( "I", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + T5p3.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); template5.addTemplateParameter( T5p1 ); template5.addTemplateParameter( T5p2 ); template5.addTemplateParameter( T5p3 ); - TypeInfo T5a1 = new TypeInfo( TypeInfo.t_type, 0, T5p1 ); - TypeInfo T5a2 = new TypeInfo( TypeInfo.t_type, 0, T5p2, new PtrOp( PtrOp.t_pointer ), false ); - TypeInfo T5a3 = new TypeInfo( TypeInfo.t_type, 0, T5p3 ); + ITypeInfo T5a1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T5p1 ); + ITypeInfo T5a2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T5p2, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); + ITypeInfo T5a3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T5p3 ); template5.addArgument( T5a1 ); template5.addArgument( T5a2 ); @@ -1443,43 +1451,43 @@ public class ParserSymbolTableTemplateTests extends TestCase { ArrayList args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(1) ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ IContainerSymbol a1 = (IContainerSymbol) a.instantiate( args ); assertTrue( a1.isTemplateInstance() ); assertEquals( a1.getInstantiatedSymbol(), cls1 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ IContainerSymbol a2 = (IContainerSymbol) a.instantiate( args ); assertTrue( a2.isTemplateInstance() ); assertEquals( a2.getInstantiatedSymbol(), cls2 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_char, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, "5" ) ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "5" ) ); //$NON-NLS-1$ IContainerSymbol a3 = (IContainerSymbol) a.instantiate( args ); assertTrue( a3.isTemplateInstance() ); assertEquals( a3.getInstantiatedSymbol(), cls4 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_char, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "1" ) ); //$NON-NLS-1$ IContainerSymbol a4 = (IContainerSymbol) a.instantiate( args ); assertTrue( a4.isTemplateInstance() ); assertEquals( a4.getInstantiatedSymbol(), cls5 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, "2" ) ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, null, "2" ) ); //$NON-NLS-1$ try{ a.instantiate( args ); @@ -1505,48 +1513,48 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template1 = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - template1.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template1.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template1 ); ISymbol T = template1.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f1.addParameter( T, 0, null, false ); factory.addSymbol( f1 ); ITemplateSymbol template2 = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - template2.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template2.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template2 ); T = template2.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( T, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( T, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); factory.addSymbol( f2 ); ITemplateSymbol template3 = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - template3.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template3.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template3 ); T = template3.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f3.addParameter( T, TypeInfo.isConst, new PtrOp( PtrOp.t_pointer, false, false ), false ); + IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f3.addParameter( T, ITypeInfo.isConst, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ), false ); factory.addSymbol( f3 ); - ISymbol p = table.newSymbol( "p", TypeInfo.t_int ); //$NON-NLS-1$ - p.getTypeInfo().setBit( true, TypeInfo.isConst ); - p.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) ); + ISymbol p = table.newSymbol( "p", ITypeInfo.t_int ); //$NON-NLS-1$ + p.getTypeInfo().setBit( true, ITypeInfo.isConst ); + p.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) ); table.getCompilationUnit().addSymbol( p ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_type, 0, p ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, p ) ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -1567,32 +1575,32 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template1 = table.newTemplateSymbol( "g" ); //$NON-NLS-1$ - template1.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template1.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template1 ); ISymbol T = template1.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol g1 = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol g1 = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ g1.addParameter( T, 0, null, false ); factory.addSymbol( g1 ); ITemplateSymbol template2 = table.newTemplateSymbol( "g" ); //$NON-NLS-1$ - template2.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template2.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template2 ); T = template2.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol g2 = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ - g2.addParameter( T, 0, new PtrOp( PtrOp.t_reference ), false ); + IParameterizedSymbol g2 = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ + g2.addParameter( T, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); factory.addSymbol( g2 ); - ISymbol x = table.newSymbol( "x", TypeInfo.t_float ); //$NON-NLS-1$ + ISymbol x = table.newSymbol( "x", ITypeInfo.t_float ); //$NON-NLS-1$ List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_type, 0, x ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, x ) ); try{ table.getCompilationUnit().unqualifiedFunctionLookup( "g", params ); //$NON-NLS-1$ assertTrue( false ); @@ -1619,29 +1627,29 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol templateA = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - templateA.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + templateA.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateA ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( A ); ITemplateSymbol template1 = table.newTemplateSymbol( "h" ); //$NON-NLS-1$ - template1.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template1.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template1 ); ISymbol T = template1.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol h1 = table.newParameterizedSymbol( "h", TypeInfo.t_function ); //$NON-NLS-1$ - h1.addParameter( T, TypeInfo.isConst, new PtrOp( PtrOp.t_reference, false, false ),false ); + IParameterizedSymbol h1 = table.newParameterizedSymbol( "h", ITypeInfo.t_function ); //$NON-NLS-1$ + h1.addParameter( T, ITypeInfo.isConst, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, false, false ),false ); factory.addSymbol( h1 ); ITemplateSymbol template2 = table.newTemplateSymbol( "h" ); //$NON-NLS-1$ - template2.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template2.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); @@ -1649,35 +1657,35 @@ public class ParserSymbolTableTemplateTests extends TestCase { T = template2.lookup( "T" ); //$NON-NLS-1$ - IParameterizedSymbol h2 = table.newParameterizedSymbol( "h", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol h2 = table.newParameterizedSymbol( "h", ITypeInfo.t_function ); //$NON-NLS-1$ List argList = new ArrayList(); - argList.add( new TypeInfo( TypeInfo.t_type, 0, T ) ); - h2.addParameter( templateA.instantiate( argList ), 0, new PtrOp( PtrOp.t_reference ), false ); + argList.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T ) ); + h2.addParameter( templateA.instantiate( argList ), 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); factory.addSymbol( h2 ); - ISymbol z = table.newSymbol( "z", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol z = table.newSymbol( "z", ITypeInfo.t_type ); //$NON-NLS-1$ List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); ISymbol look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), A ); z.setTypeSymbol( look ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_type, 0, z ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, z ) ); look = table.getCompilationUnit().unqualifiedFunctionLookup( "h", params ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), h2 ); - ISymbol z2 = table.newSymbol( "z2", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol z2 = table.newSymbol( "z2", ITypeInfo.t_type ); //$NON-NLS-1$ look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), A ); z2.setTypeSymbol( look ); - z2.getTypeInfo().setBit( true, TypeInfo.isConst ); + z2.getTypeInfo().setBit( true, ITypeInfo.isConst ); params.clear(); - params.add( new TypeInfo( TypeInfo.t_type, 0, z2 ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, z2 ) ); look = table.getCompilationUnit().unqualifiedFunctionLookup( "h", params ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), h1 ); @@ -1699,14 +1707,14 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( X ); ISymbol look = X.lookup( "X" ); //$NON-NLS-1$ @@ -1717,8 +1725,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( deferred.getTemplate(), template ); Iterator iter = deferred.getArguments().iterator(); - TypeInfo type = (TypeInfo) iter.next(); - assertTrue( type.isType( TypeInfo.t_type ) ); + ITypeInfo type = (ITypeInfo) iter.next(); + assertTrue( type.isType( ITypeInfo.t_type ) ); assertEquals( type.getTypeSymbol(), T ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -1739,19 +1747,19 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "Y" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T ); - IDerivableContainerSymbol Y1 = table.newDerivableContainerSymbol( "Y", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol Y1 = table.newDerivableContainerSymbol( "Y", ITypeInfo.t_class ); //$NON-NLS-1$ template.addSymbol( Y1 ); table.getCompilationUnit().addSymbol( template ); ISpecializedSymbol spec = table.newSpecializedSymbol( "Y" ); //$NON-NLS-1$ - spec.addArgument( new TypeInfo( TypeInfo.t_int, 0, null ) ); + spec.addArgument( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); template.addSpecialization( spec ); - IDerivableContainerSymbol Y2 = table.newDerivableContainerSymbol( "Y", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol Y2 = table.newDerivableContainerSymbol( "Y", ITypeInfo.t_class ); //$NON-NLS-1$ spec.addSymbol( Y2 ); ISymbol look = Y2.lookup( "Y" ); //$NON-NLS-1$ @@ -1781,20 +1789,20 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "Y" ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ - ISymbol i = table.newSymbol( "i", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - i.getTypeInfo().setTemplateParameterType( TypeInfo.t_int ); + ISymbol i = table.newSymbol( "i", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + i.getTypeInfo().setTemplateParameterType( ITypeInfo.t_int ); template.addTemplateParameter( i ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol Y = table.newDerivableContainerSymbol( "Y", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol Y = table.newDerivableContainerSymbol( "Y", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( Y ); - ISymbol T = table.newSymbol( "T", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_int ); //$NON-NLS-1$ try{ Y.addSymbol( T ); assertTrue( false ); @@ -1802,11 +1810,11 @@ public class ParserSymbolTableTemplateTests extends TestCase { assertEquals( e.reason, ParserSymbolTableException.r_RedeclaredTemplateParam ); } - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ Y.addSymbol( f ); try{ - f.addSymbol( table.newSymbol( "T", TypeInfo.t_char ) ); //$NON-NLS-1$ + f.addSymbol( table.newSymbol( "T", ITypeInfo.t_char ) ); //$NON-NLS-1$ assertTrue( false ); } catch ( ParserSymbolTableException e ){ assertEquals( e.reason, ParserSymbolTableException.r_RedeclaredTemplateParam ); @@ -1814,7 +1822,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template2 = table.newTemplateSymbol( "X" ); //$NON-NLS-1$ try{ - template2.addTemplateParameter( table.newSymbol( "X", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template2.addTemplateParameter( table.newSymbol( "X", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ assertTrue( false ); } catch( ParserSymbolTableException e ){ assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateParameter ); @@ -1843,17 +1851,17 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( A ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f.addParameter( T, 0, null, false ); A.addSymbol( f ); @@ -1870,17 +1878,17 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol templateSpec = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME ); factory.pushTemplate( templateSpec ); - IDerivableContainerSymbol ASpec = table.newDerivableContainerSymbol( "A", TypeInfo.t_struct ); //$NON-NLS-1$ - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + IDerivableContainerSymbol ASpec = table.newDerivableContainerSymbol( "A", ITypeInfo.t_struct ); //$NON-NLS-1$ + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); factory.addTemplateId( ASpec, args ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_int, 0, null, false ); f2.setIsForwardDeclaration( true ); ASpec.addSymbol( f2 ); - IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f3.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f3.addParameter( ITypeInfo.t_int, 0, null, false ); IDerivableContainerSymbol look = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -1889,7 +1897,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { ISymbol flook = look.lookupMethodForDefinition( "f", args ); //$NON-NLS-1$ assertTrue( flook.isTemplateInstance() ); assertEquals( flook.getInstantiatedSymbol(), f2 ); - flook.setTypeSymbol( f3 ); + flook.setForwardSymbol( f3 ); look.addSymbol( f3 ); @@ -1912,30 +1920,30 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol templateArray = table.newTemplateSymbol( "Array" ); //$NON-NLS-1$ - templateArray.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + templateArray.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateArray ); - IDerivableContainerSymbol array = table.newDerivableContainerSymbol( "Array", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol array = table.newDerivableContainerSymbol( "Array", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( array ); ITemplateSymbol templateSort = table.newTemplateSymbol( "sort" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ templateSort.addTemplateParameter( T ); factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateSort ); - IParameterizedSymbol sort = table.newParameterizedSymbol( "sort", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol sort = table.newParameterizedSymbol( "sort", ITypeInfo.t_function ); //$NON-NLS-1$ List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, T ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T ) ); ISymbol arrayLook = factory.lookupTemplateId( "Array", args ); //$NON-NLS-1$ - sort.addParameter( arrayLook, 0, new PtrOp( PtrOp.t_reference ), false ); + sort.addParameter( arrayLook, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); factory.addSymbol( sort ); @@ -1945,21 +1953,21 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( temp ); - IParameterizedSymbol newSort = table.newParameterizedSymbol( "sort", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol newSort = table.newParameterizedSymbol( "sort", ITypeInfo.t_function ); //$NON-NLS-1$ args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); arrayLook = table.getCompilationUnit().lookupTemplateId( "Array", args ); //$NON-NLS-1$ assertTrue( arrayLook.isTemplateInstance() ); assertEquals( arrayLook.getInstantiatedSymbol(), array ); - newSort.addParameter( arrayLook, 0, new PtrOp( PtrOp.t_reference ), false ); + newSort.addParameter( arrayLook, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); factory.addSymbol( newSort ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( arrayLook ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, a ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ) ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "sort", args ); //$NON-NLS-1$ @@ -1986,28 +1994,28 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template1 = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - ISymbol T1 = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T1 = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template1.addTemplateParameter( T1 ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template1 ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f1.addParameter( T1, 0, null, false ); factory.addSymbol( f1 ); ITemplateSymbol template2 = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - ISymbol T2 = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T2 = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template2.addTemplateParameter( T2 ); factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template2 ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( T2, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( T2, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); factory.addSymbol( f2 ); @@ -2016,39 +2024,39 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f3.addParameter( TypeInfo.t_int, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f3.addParameter( ITypeInfo.t_int, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ) ); factory.addTemplateId( f3, args ); args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); template = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME ); factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IParameterizedSymbol f4 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f4.addParameter( TypeInfo.t_int, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol f4 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f4.addParameter( ITypeInfo.t_int, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); factory.addTemplateId( f4, args ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); template = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME ); factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IParameterizedSymbol f5 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f5.addParameter( TypeInfo.t_char, 0, null, false ); + IParameterizedSymbol f5 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f5.addParameter( ITypeInfo.t_char, 0, null, false ); factory.addSymbol( f5 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -2075,22 +2083,22 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ ISymbol lookT = template.lookup( "T" ); //$NON-NLS-1$ assertEquals( lookT, T ); - ISymbol paramX = table.newSymbol( "x", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol paramX = table.newSymbol( "x", ITypeInfo.t_type ); //$NON-NLS-1$ paramX.setTypeSymbol( lookT ); - ISymbol paramY = table.newSymbol( "y", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol paramY = table.newSymbol( "y", ITypeInfo.t_type ); //$NON-NLS-1$ paramY.setTypeSymbol( lookT ); f.addParameter( paramX ); @@ -2098,25 +2106,25 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.addSymbol( f ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_struct ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_struct ); //$NON-NLS-1$ B.addParent( A ); table.getCompilationUnit().addSymbol( B ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( A ); - ISymbol b = table.newSymbol( "b", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol b = table.newSymbol( "b", ITypeInfo.t_type ); //$NON-NLS-1$ b.setTypeSymbol( B ); table.getCompilationUnit().addSymbol( a ); table.getCompilationUnit().addSymbol( b ); List argList = new ArrayList(); - TypeInfo aParam = new TypeInfo( TypeInfo.t_type, 0, a ); - TypeInfo bParam = new TypeInfo( TypeInfo.t_type, 0, b ); + ITypeInfo aParam = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ); + ITypeInfo bParam = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, b ); argList.add( aParam ); argList.add( bParam ); @@ -2162,14 +2170,14 @@ public class ParserSymbolTableTemplateTests extends TestCase { ITemplateSymbol template = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ - template.addTemplateParameter( table.newSymbol( "U", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + template.addTemplateParameter( table.newSymbol( "U", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IParameterizedSymbol paramFunction = table.newParameterizedSymbol( "", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol paramFunction = table.newParameterizedSymbol( "", ITypeInfo.t_function ); //$NON-NLS-1$ paramFunction.setIsTemplateMember( true ); ISymbol T = template.lookup( "T" ); //$NON-NLS-1$ @@ -2180,36 +2188,36 @@ public class ParserSymbolTableTemplateTests extends TestCase { paramFunction.addParameter( U, 0, null, false ); paramFunction.addParameter( U, 0, null, false ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f.addParameter( paramFunction, 0, null, false ); factory.addSymbol( f ); - IParameterizedSymbol g1 = table.newParameterizedSymbol( "g1", TypeInfo.t_function ); //$NON-NLS-1$ - g1.setReturnType( table.newSymbol( "", TypeInfo.t_int ) ); //$NON-NLS-1$ - g1.addParameter( TypeInfo.t_int, 0, null, false ); - g1.addParameter( TypeInfo.t_float, 0, null, false ); - g1.addParameter( TypeInfo.t_float, 0, null, false ); + IParameterizedSymbol g1 = table.newParameterizedSymbol( "g1", ITypeInfo.t_function ); //$NON-NLS-1$ + g1.setReturnType( table.newSymbol( "", ITypeInfo.t_int ) ); //$NON-NLS-1$ + g1.addParameter( ITypeInfo.t_int, 0, null, false ); + g1.addParameter( ITypeInfo.t_float, 0, null, false ); + g1.addParameter( ITypeInfo.t_float, 0, null, false ); table.getCompilationUnit().addSymbol( g1 ); - IParameterizedSymbol g2 = table.newParameterizedSymbol( "g2", TypeInfo.t_function ); //$NON-NLS-1$ - g2.setReturnType( table.newSymbol( "", TypeInfo.t_char ) ); //$NON-NLS-1$ - g2.addParameter( TypeInfo.t_int, 0, null, false ); - g2.addParameter( TypeInfo.t_float, 0, null, false ); - g2.addParameter( TypeInfo.t_float, 0, null, false ); + IParameterizedSymbol g2 = table.newParameterizedSymbol( "g2", ITypeInfo.t_function ); //$NON-NLS-1$ + g2.setReturnType( table.newSymbol( "", ITypeInfo.t_char ) ); //$NON-NLS-1$ + g2.addParameter( ITypeInfo.t_int, 0, null, false ); + g2.addParameter( ITypeInfo.t_float, 0, null, false ); + g2.addParameter( ITypeInfo.t_float, 0, null, false ); table.getCompilationUnit().addSymbol( g2); - IParameterizedSymbol g3 = table.newParameterizedSymbol( "g3", TypeInfo.t_function ); //$NON-NLS-1$ - g3.setReturnType( table.newSymbol( "", TypeInfo.t_int ) ); //$NON-NLS-1$ - g3.addParameter( TypeInfo.t_int, 0, null, false ); - g3.addParameter( TypeInfo.t_char, 0, null, false ); - g3.addParameter( TypeInfo.t_float, 0, null, false ); + IParameterizedSymbol g3 = table.newParameterizedSymbol( "g3", ITypeInfo.t_function ); //$NON-NLS-1$ + g3.setReturnType( table.newSymbol( "", ITypeInfo.t_int ) ); //$NON-NLS-1$ + g3.addParameter( ITypeInfo.t_int, 0, null, false ); + g3.addParameter( ITypeInfo.t_char, 0, null, false ); + g3.addParameter( ITypeInfo.t_float, 0, null, false ); table.getCompilationUnit().addSymbol( g3); - TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, g1 ); + ITypeInfo arg = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, g1 ); List argList = new ArrayList(); argList.add( arg ); @@ -2239,22 +2247,22 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol template = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - ISymbol T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T ); ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f.addParameter( T, 0, new PtrOp( PtrOp.t_pointer, true, false ), false ); + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f.addParameter( T, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, true, false ), false ); factory.addSymbol( f ); - ISymbol p = table.newSymbol( "p", TypeInfo.t_int ); //$NON-NLS-1$ - p.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + ISymbol p = table.newSymbol( "p", ITypeInfo.t_int ); //$NON-NLS-1$ + p.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_type, 0, p ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, p ) ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertTrue( look != null ); @@ -2265,14 +2273,14 @@ public class ParserSymbolTableTemplateTests extends TestCase { IParameterizedSymbol fn = (IParameterizedSymbol) look; Iterator iter = fn.getParameterList().iterator(); ISymbol param = (ISymbol) iter.next(); - assertTrue( param.isType( TypeInfo.t_int ) ); + assertTrue( param.isType( ITypeInfo.t_int ) ); assertFalse( iter.hasNext() ); iter = param.getTypeInfo().getPtrOperators().iterator(); - PtrOp op = (PtrOp) iter.next(); + ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) iter.next(); assertTrue( op.isConst() ); - assertEquals( op.getType(), PtrOp.t_pointer ); + assertEquals( op.getType(), ITypeInfo.PtrOp.t_pointer ); assertFalse( iter.hasNext() ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -2297,38 +2305,38 @@ public class ParserSymbolTableTemplateTests extends TestCase { newTable(); ITemplateSymbol templateB = table.newTemplateSymbol( "B" ); //$NON-NLS-1$ - templateB.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + templateB.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ ITemplateFactory factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateB ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( B ); ITemplateSymbol templateD = table.newTemplateSymbol( "D" ); //$NON-NLS-1$ - templateD.addTemplateParameter( table.newSymbol( "T", TypeInfo.t_templateParameter ) ); //$NON-NLS-1$ + templateD.addTemplateParameter( table.newSymbol( "T", ITypeInfo.t_templateParameter ) ); //$NON-NLS-1$ factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templateD ); - IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D", ITypeInfo.t_struct ); //$NON-NLS-1$ factory.addSymbol( D ); ISymbol T = templateD.lookup( "T" ); //$NON-NLS-1$ List args = new ArrayList (); - args.add( new TypeInfo( TypeInfo.t_type, 0, T ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T ) ); ISymbol look = table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$ assertTrue( look instanceof IDeferredTemplateInstance ); assertEquals( ((IDeferredTemplateInstance)look).getTemplate(), templateB ); D.addParent( look ); - IDerivableContainerSymbol D2 = table.newDerivableContainerSymbol( "D2", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol D2 = table.newDerivableContainerSymbol( "D2", ITypeInfo.t_struct ); //$NON-NLS-1$ args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), B ); @@ -2338,33 +2346,33 @@ public class ParserSymbolTableTemplateTests extends TestCase { table.getCompilationUnit().addSymbol( D2 ); ITemplateSymbol templatef = table.newTemplateSymbol( "f" ); //$NON-NLS-1$ - T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ templatef.addTemplateParameter( T ); factory = table.newTemplateFactory(); factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( templatef ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, T ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, T ) ); look = table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$ assertTrue( look instanceof IDeferredTemplateInstance ); assertEquals( ((IDeferredTemplateInstance)look).getTemplate(), templateB ); - ISymbol param = table.newSymbol( "", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol param = table.newSymbol( "", ITypeInfo.t_type ); //$NON-NLS-1$ param.setTypeSymbol( look ); - param.addPtrOperator( new PtrOp( PtrOp.t_reference ) ); + param.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ) ); f.addParameter( param ); factory.addSymbol( f ); - ISymbol d = table.newSymbol( "d", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol d = table.newSymbol( "d", ITypeInfo.t_type ); //$NON-NLS-1$ args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "D", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), D ); @@ -2372,19 +2380,19 @@ public class ParserSymbolTableTemplateTests extends TestCase { d.setTypeSymbol( look ); table.getCompilationUnit().addSymbol( d ); - ISymbol d2 = table.newSymbol( "d2", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol d2 = table.newSymbol( "d2", ITypeInfo.t_type ); //$NON-NLS-1$ d2.setTypeSymbol( D2 ); table.getCompilationUnit().addSymbol( d2 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, d ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, d ) ); look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", args ); //$NON-NLS-1$ assertTrue( look != null ); assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), f ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, d2 ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, d2 ) ); ISymbol look2 = table.getCompilationUnit().unqualifiedFunctionLookup( "f", args ); //$NON-NLS-1$ assertTrue( look2 != null ); assertTrue( look2.isTemplateInstance() ); @@ -2432,8 +2440,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { //template < class T1, class T2 > class A { void f(); }; ITemplateSymbol template = table.newTemplateSymbol( "A" ); //$NON-NLS-1$ - ISymbol T1 = table.newSymbol( "T1", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol T2 = table.newSymbol( "T2", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T1 = table.newSymbol( "T1", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol T2 = table.newSymbol( "T2", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ template.addTemplateParameter( T1 ); template.addTemplateParameter( T2 ); @@ -2441,16 +2449,16 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.setContainingSymbol( table.getCompilationUnit() ); factory.pushTemplate( template ); - IDerivableContainerSymbol A1 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A1 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addSymbol( A1 ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f1.setIsForwardDeclaration( true ); A1.addSymbol( f1 ); //template < class T > class A < T, T > { void f(); }; ITemplateSymbol spec1 = table.newTemplateSymbol(""); //$NON-NLS-1$ - ISymbol spec1_T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol spec1_T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ spec1.addTemplateParameter( spec1_T ); factory = table.newTemplateFactory(); @@ -2458,19 +2466,19 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( spec1 ); List args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, spec1_T ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, spec1_T ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, spec1_T ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, spec1_T ) ); - IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addTemplateId( A2, args ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f2.setIsForwardDeclaration( true ); A2.addSymbol( f2 ); //template < class T > class A < char, T > { void f(); }; ITemplateSymbol spec2 = table.newTemplateSymbol(""); //$NON-NLS-1$ - ISymbol spec2_T = table.newSymbol( "T", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol spec2_T = table.newSymbol( "T", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ spec2.addTemplateParameter( spec2_T ); factory = table.newTemplateFactory(); @@ -2478,20 +2486,20 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( spec2 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, spec2_T ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, spec2_T ) ); - IDerivableContainerSymbol A3 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A3 = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ factory.addTemplateId( A3, args ); - IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f3.setIsForwardDeclaration( true ); A3.addSymbol( f3 ); //template < class U, class V > void A::f(){ int c; } ITemplateSymbol templateDef = table.newTemplateSymbol(""); //$NON-NLS-1$ - ISymbol U = table.newSymbol( "U", TypeInfo.t_templateParameter ); //$NON-NLS-1$ - ISymbol V = table.newSymbol( "V", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol U = table.newSymbol( "U", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol V = table.newSymbol( "V", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ templateDef.addTemplateParameter( U ); templateDef.addTemplateParameter( V ); @@ -2500,8 +2508,8 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( spec2 ); args.clear(); - args.add( new TypeInfo( TypeInfo.t_type, 0, U ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, V ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, U ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, V ) ); ISymbol symbol = factory.lookupTemplateId( "A", args ); //$NON-NLS-1$ assertEquals( ((IDeferredTemplateInstance)symbol).getTemplate(), template ); @@ -2509,16 +2517,16 @@ public class ParserSymbolTableTemplateTests extends TestCase { ISymbol look = factory.lookupMethodForDefinition( "f", new ArrayList() ); //$NON-NLS-1$ assertEquals( look, f1 ); - IParameterizedSymbol f1Def = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.setTypeSymbol( f1Def ); + IParameterizedSymbol f1Def = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.setForwardSymbol( f1Def ); factory.addSymbol( f1Def ); - ISymbol c1 = table.newSymbol( "c", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol c1 = table.newSymbol( "c", ITypeInfo.t_int ); //$NON-NLS-1$ f1Def.addSymbol( c1 ); //template < class W > void A < W, W >::f(){ char c; } ITemplateSymbol specDef1 = table.newTemplateSymbol(""); //$NON-NLS-1$ - ISymbol W = table.newSymbol( "W", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol W = table.newSymbol( "W", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ specDef1.addTemplateParameter( W ); factory = table.newTemplateFactory(); @@ -2526,24 +2534,24 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( specDef1 ); args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_type, 0, W ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, W ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, W ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, W ) ); symbol = factory.lookupTemplateId( "A", args ); //$NON-NLS-1$ factory.pushTemplateId( symbol, args ); look = factory.lookupMethodForDefinition( "f", new ArrayList() ); //$NON-NLS-1$ assertEquals( look, f2 ); - IParameterizedSymbol f2Def = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.setTypeSymbol( f2Def ); + IParameterizedSymbol f2Def = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.setForwardSymbol( f2Def ); factory.addSymbol( f2Def ); - ISymbol c2 = table.newSymbol( "c", TypeInfo.t_char ); //$NON-NLS-1$ + ISymbol c2 = table.newSymbol( "c", ITypeInfo.t_char ); //$NON-NLS-1$ f2Def.addSymbol( c2 ); //template < class X > void < char, X >::f(){ float c; } ITemplateSymbol specDef2 = table.newTemplateSymbol(""); //$NON-NLS-1$ - ISymbol X = table.newSymbol( "X", TypeInfo.t_templateParameter ); //$NON-NLS-1$ + ISymbol X = table.newSymbol( "X", ITypeInfo.t_templateParameter ); //$NON-NLS-1$ specDef2.addTemplateParameter( X ); factory = table.newTemplateFactory(); @@ -2551,25 +2559,25 @@ public class ParserSymbolTableTemplateTests extends TestCase { factory.pushTemplate( specDef1 ); args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_type, 0, X ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, X ) ); symbol = factory.lookupTemplateId( "A", args ); //$NON-NLS-1$ factory.pushTemplateId( symbol, args ); look = factory.lookupMethodForDefinition( "f", new ArrayList() ); //$NON-NLS-1$ assertEquals( look, f3 ); - IParameterizedSymbol f3Def = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f3.setTypeSymbol( f3Def ); + IParameterizedSymbol f3Def = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f3.setForwardSymbol( f3Def ); factory.addSymbol( f3Def ); - ISymbol c3 = table.newSymbol( "c", TypeInfo.t_float ); //$NON-NLS-1$ + ISymbol c3 = table.newSymbol( "c", ITypeInfo.t_float ); //$NON-NLS-1$ f3Def.addSymbol( c3 ); //A< int, char > a1; args = new ArrayList(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -2582,12 +2590,12 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IContainerSymbol)look).qualifiedLookup( "c" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), c1 ); - assertTrue( look.isType( TypeInfo.t_int ) ); + assertTrue( look.isType( ITypeInfo.t_int ) ); //A< int, int > a2; args.clear(); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -2600,12 +2608,12 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IContainerSymbol)look).qualifiedLookup( "c" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), c2 ); - assertTrue( look.isType( TypeInfo.t_char ) ); + assertTrue( look.isType( ITypeInfo.t_char ) ); //A< char, int > a3; args.clear(); - args.add( new TypeInfo( TypeInfo.t_char, 0, null ) ); - args.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ) ); + args.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().lookupTemplateId( "A", args ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); @@ -2618,7 +2626,7 @@ public class ParserSymbolTableTemplateTests extends TestCase { look = ((IContainerSymbol)look).qualifiedLookup( "c" ); //$NON-NLS-1$ assertTrue( look.isTemplateInstance() ); assertEquals( look.getInstantiatedSymbol(), c3 ); - assertTrue( look.isType( TypeInfo.t_float ) ); + assertTrue( look.isType( ITypeInfo.t_float ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java index 356d6398cf1..e8b8b4a7a48 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java @@ -36,15 +36,15 @@ import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol; 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.ISymbolASTExtension; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo; import org.eclipse.cdt.internal.core.parser.pst.IUsingDeclarationSymbol; import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException; import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension; import org.eclipse.cdt.internal.core.parser.pst.TypeFilter; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.OperatorExpression; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; +import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider; + @@ -59,6 +59,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; public class ParserSymbolTableTest extends TestCase { public ParserSymbolTable table = null; + public TypeInfoProvider provider = null; public ParserSymbolTableTest( String arg ) { @@ -71,6 +72,7 @@ public class ParserSymbolTableTest extends TestCase { public ParserSymbolTable newTable( ParserLanguage language, ParserMode mode ){ table = new ParserSymbolTable( language, mode ); + provider = TypeInfoProvider.getProvider( table ); return table; } /** @@ -83,6 +85,7 @@ public class ParserSymbolTableTest extends TestCase { newTable(); //create the symbol table ISymbol x = table.newSymbol( "x" ); //$NON-NLS-1$ + x.setTypeInfo( TypeInfoProvider.newTypeInfo() ); IContainerSymbol compUnit = table.getCompilationUnit(); compUnit.addSymbol( x ); @@ -106,7 +109,7 @@ public class ParserSymbolTableTest extends TestCase { public void testSimpleLookup() throws Exception{ newTable(); //new symbol table - ISymbol x = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol x = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( x ); ISymbol look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$ @@ -126,7 +129,7 @@ public class ParserSymbolTableTest extends TestCase { public void testSimpleSetGetObject() throws Exception{ newTable(); - IContainerSymbol x = table.newContainerSymbol( "x", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol x = table.newContainerSymbol( "x", ITypeInfo.t_namespace ); //$NON-NLS-1$ ISymbolASTExtension extension = new StandardSymbolExtension(x,null); @@ -150,10 +153,11 @@ public class ParserSymbolTableTest extends TestCase { newTable(); ISymbol firstX = table.newSymbol("x"); //$NON-NLS-1$ + firstX.setTypeInfo( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); table.getCompilationUnit().addSymbol( firstX ); IDerivableContainerSymbol firstClass = table.newDerivableContainerSymbol("class"); //$NON-NLS-1$ - firstClass.setType( TypeInfo.t_class ); + firstClass.setType( ITypeInfo.t_class ); table.getCompilationUnit().addSymbol( firstClass ); ISymbol look = firstClass.lookup( "x" ); //$NON-NLS-1$ @@ -182,7 +186,7 @@ public class ParserSymbolTableTest extends TestCase { table.getCompilationUnit().addSymbol( x ); IDerivableContainerSymbol decl = table.newDerivableContainerSymbol("class"); //$NON-NLS-1$ - decl.setType( TypeInfo.t_class ); + decl.setType( ITypeInfo.t_class ); table.getCompilationUnit().addSymbol( decl ); ISymbol look = decl.lookup( "x" ); //$NON-NLS-1$ @@ -201,13 +205,13 @@ public class ParserSymbolTableTest extends TestCase { newTable(); IDerivableContainerSymbol parent = table.newDerivableContainerSymbol("parent"); //$NON-NLS-1$ - parent.setType( TypeInfo.t_class ); + parent.setType( ITypeInfo.t_class ); IDerivableContainerSymbol class1 = table.newDerivableContainerSymbol("class"); //$NON-NLS-1$ - class1.setType( TypeInfo.t_class ); + class1.setType( ITypeInfo.t_class ); class1.addParent( parent ); - ISymbol decl = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol decl = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ parent.addSymbol( decl ); table.getCompilationUnit().addSymbol( parent ); @@ -236,7 +240,7 @@ public class ParserSymbolTableTest extends TestCase { IDerivableContainerSymbol class1 = (IDerivableContainerSymbol) table.getCompilationUnit().lookup( "class" ); //$NON-NLS-1$ class1.addParent( parent2 ); - ISymbol decl = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol decl = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ parent2.addSymbol( decl ); try{ @@ -304,7 +308,7 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); compUnit.addSymbol( c ); - ISymbol x = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol x = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ c.addSymbol( x ); compUnit.addSymbol( decl ); @@ -380,14 +384,14 @@ public class ParserSymbolTableTest extends TestCase { compUnit.addSymbol( c ); compUnit.addSymbol( d ); - IContainerSymbol enum = table.newContainerSymbol( "enum", TypeInfo.t_enumeration ); //$NON-NLS-1$ + IContainerSymbol enum = table.newContainerSymbol( "enum", ITypeInfo.t_enumeration ); //$NON-NLS-1$ - ISymbol enumerator = table.newSymbol( "enumerator", TypeInfo.t_enumerator ); //$NON-NLS-1$ + ISymbol enumerator = table.newSymbol( "enumerator", ITypeInfo.t_enumerator ); //$NON-NLS-1$ - ISymbol stat = table.newSymbol( "static", TypeInfo.t_int ); //$NON-NLS-1$ - stat.getTypeInfo().setBit( true, TypeInfo.isStatic ); + ISymbol stat = table.newSymbol( "static", ITypeInfo.t_int ); //$NON-NLS-1$ + stat.getTypeInfo().setBit( true, ITypeInfo.isStatic ); - ISymbol x = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol x = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ d.addSymbol( enum ); d.addSymbol( stat ); @@ -435,17 +439,20 @@ public class ParserSymbolTableTest extends TestCase { newTable(); IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "class" ); //$NON-NLS-1$ - cls.setType( TypeInfo.t_class ); + cls.setType( ITypeInfo.t_class ); IDerivableContainerSymbol struct = table.newDerivableContainerSymbol("struct"); //$NON-NLS-1$ - struct.setType( TypeInfo.t_struct ); + struct.setType( ITypeInfo.t_struct ); IContainerSymbol union = table.newContainerSymbol("union"); //$NON-NLS-1$ - union.setType( TypeInfo.t_union ); + union.setType( ITypeInfo.t_union ); IDerivableContainerSymbol hideCls = table.newDerivableContainerSymbol( "class" ); //$NON-NLS-1$ + hideCls.setType( ITypeInfo.t_int ); IDerivableContainerSymbol hideStruct = table.newDerivableContainerSymbol("struct"); //$NON-NLS-1$ + hideStruct.setType( ITypeInfo.t_int ); IContainerSymbol hideUnion = table.newContainerSymbol("union"); //$NON-NLS-1$ + hideUnion.setType( ITypeInfo.t_int ); IDerivableContainerSymbol a = table.newDerivableContainerSymbol("a"); //$NON-NLS-1$ IDerivableContainerSymbol b = table.newDerivableContainerSymbol("b"); //$NON-NLS-1$ @@ -463,11 +470,11 @@ public class ParserSymbolTableTest extends TestCase { table.getCompilationUnit().addSymbol( a ); table.getCompilationUnit().addSymbol( b ); - ISymbol look = a.elaboratedLookup( TypeInfo.t_class, "class" ); //$NON-NLS-1$ + ISymbol look = a.elaboratedLookup( ITypeInfo.t_class, "class" ); //$NON-NLS-1$ assertEquals( look, cls ); - look = a.elaboratedLookup( TypeInfo.t_struct, "struct" ); //$NON-NLS-1$ + look = a.elaboratedLookup( ITypeInfo.t_struct, "struct" ); //$NON-NLS-1$ assertEquals( look, struct ); - look = a.elaboratedLookup( TypeInfo.t_union, "union" ); //$NON-NLS-1$ + look = a.elaboratedLookup( ITypeInfo.t_union, "union" ); //$NON-NLS-1$ assertEquals( look, union ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -531,18 +538,18 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol struct = table.newDerivableContainerSymbol("stat"); //$NON-NLS-1$ - struct.setType( TypeInfo.t_struct ); + struct.setType( ITypeInfo.t_struct ); compUnit.addSymbol( struct ); IParameterizedSymbol function = table.newParameterizedSymbol( "stat" ); //$NON-NLS-1$ - function.setType( TypeInfo.t_function ); + function.setType( ITypeInfo.t_function ); compUnit.addSymbol( function ); IParameterizedSymbol f = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f.setType( TypeInfo.t_function ); + f.setType( ITypeInfo.t_function ); compUnit.addSymbol( f ); - ISymbol look = f.elaboratedLookup( TypeInfo.t_struct, "stat" ); //$NON-NLS-1$ + ISymbol look = f.elaboratedLookup( ITypeInfo.t_struct, "stat" ); //$NON-NLS-1$ assertEquals( look, struct ); look = f.lookup( "stat" ); //$NON-NLS-1$ @@ -585,18 +592,18 @@ public class ParserSymbolTableTest extends TestCase { newTable(); IContainerSymbol nsA = table.newContainerSymbol("A"); //$NON-NLS-1$ - nsA.setType( TypeInfo.t_namespace ); + nsA.setType( ITypeInfo.t_namespace ); table.getCompilationUnit().addSymbol( nsA ); ISymbol nsA_i = table.newSymbol("i"); //$NON-NLS-1$ nsA.addSymbol( nsA_i ); IContainerSymbol nsB = table.newContainerSymbol("B"); //$NON-NLS-1$ - nsB.setType( TypeInfo.t_namespace ); + nsB.setType( ITypeInfo.t_namespace ); nsA.addSymbol( nsB ); IContainerSymbol nsC = table.newContainerSymbol("C"); //$NON-NLS-1$ - nsC.setType( TypeInfo.t_namespace ); + nsC.setType( ITypeInfo.t_namespace ); nsB.addSymbol( nsC ); ISymbol nsC_i = table.newSymbol("i"); //$NON-NLS-1$ @@ -607,7 +614,7 @@ public class ParserSymbolTableTest extends TestCase { nsB.addUsingDirective( nsC ); IParameterizedSymbol f1 = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); + f1.setType( ITypeInfo.t_function ); nsB.addSymbol( f1 ); @@ -615,7 +622,7 @@ public class ParserSymbolTableTest extends TestCase { assertEquals( look, nsC_i ); //C::i visible and hides A::i IContainerSymbol nsD = table.newContainerSymbol("D"); //$NON-NLS-1$ - nsD.setType( TypeInfo.t_namespace ); + nsD.setType( ITypeInfo.t_namespace ); nsA.addSymbol( nsD ); look = nsD.lookup("B"); //$NON-NLS-1$ @@ -627,7 +634,7 @@ public class ParserSymbolTableTest extends TestCase { nsD.addUsingDirective( nsC ); IParameterizedSymbol f2 = table.newParameterizedSymbol( "f2" ); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); + f2.setType( ITypeInfo.t_function ); nsD.addSymbol( f2 ); try @@ -642,14 +649,14 @@ public class ParserSymbolTableTest extends TestCase { } IParameterizedSymbol f3 = table.newParameterizedSymbol("f3"); //$NON-NLS-1$ - f3.setType( TypeInfo.t_function ); + f3.setType( ITypeInfo.t_function ); nsA.addSymbol( f3 ); look = f3.lookup("i"); //$NON-NLS-1$ assertEquals( look, nsA_i ); //uses A::i IParameterizedSymbol f4 = table.newParameterizedSymbol("f4"); //$NON-NLS-1$ - f4.setType( TypeInfo.t_function ); + f4.setType( ITypeInfo.t_function ); table.getCompilationUnit().addSymbol( f4 ); look = f4.lookup("i"); //$NON-NLS-1$ @@ -683,7 +690,7 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol nsM = table.newContainerSymbol( "M" ); //$NON-NLS-1$ - nsM.setType( TypeInfo.t_namespace ); + nsM.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsM ); @@ -691,7 +698,7 @@ public class ParserSymbolTableTest extends TestCase { nsM.addSymbol( nsM_i ); IContainerSymbol nsN = table.newContainerSymbol( "N" ); //$NON-NLS-1$ - nsN.setType( TypeInfo.t_namespace ); + nsN.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsN ); @@ -754,30 +761,30 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol nsA = table.newContainerSymbol("A"); //$NON-NLS-1$ - nsA.setType( TypeInfo.t_namespace ); + nsA.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsA ); ISymbol a = table.newSymbol("a"); //$NON-NLS-1$ nsA.addSymbol( a ); IContainerSymbol nsB = table.newContainerSymbol("B"); //$NON-NLS-1$ - nsB.setType( TypeInfo.t_namespace ); + nsB.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsB ); nsB.addUsingDirective( nsA ); IContainerSymbol nsC = table.newContainerSymbol("C"); //$NON-NLS-1$ - nsC.setType( TypeInfo.t_namespace ); + nsC.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsC ); nsC.addUsingDirective( nsA ); IContainerSymbol nsBC = table.newContainerSymbol("BC"); //$NON-NLS-1$ - nsBC.setType( TypeInfo.t_namespace ); + nsBC.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsBC ); nsBC.addUsingDirective( nsB ); nsBC.addUsingDirective( nsC ); IParameterizedSymbol f = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f.setType(TypeInfo.t_function); + f.setType(ITypeInfo.t_function); compUnit.addSymbol( f ); ISymbol look = f.lookupNestedNameSpecifier("BC"); //$NON-NLS-1$ @@ -816,14 +823,14 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol nsB = table.newContainerSymbol( "B" ); //$NON-NLS-1$ - nsB.setType( TypeInfo.t_namespace ); + nsB.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsB ); ISymbol b = table.newSymbol("b"); //$NON-NLS-1$ nsB.addSymbol( b ); IContainerSymbol nsA = table.newContainerSymbol( "A" ); //$NON-NLS-1$ - nsA.setType( TypeInfo.t_namespace ); + nsA.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsA ); nsA.addUsingDirective( nsB ); @@ -882,11 +889,11 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol nsA = table.newContainerSymbol( "A" ); //$NON-NLS-1$ - nsA.setType( TypeInfo.t_namespace ); + nsA.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsA ); IContainerSymbol nsB = table.newContainerSymbol( "B" ); //$NON-NLS-1$ - nsB.setType( TypeInfo.t_namespace ); + nsB.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsB ); nsB.addUsingDirective( nsA ); @@ -932,32 +939,32 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol nsA = table.newContainerSymbol("A"); //$NON-NLS-1$ - nsA.setType( TypeInfo.t_namespace ); + nsA.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsA ); IContainerSymbol structX = table.newContainerSymbol("x"); //$NON-NLS-1$ - structX.setType( TypeInfo.t_struct ); + structX.setType( ITypeInfo.t_struct ); nsA.addSymbol( structX ); ISymbol intX = table.newSymbol("x"); //$NON-NLS-1$ - intX.setType( TypeInfo.t_int ); + intX.setType( ITypeInfo.t_int ); nsA.addSymbol( intX ); ISymbol intY = table.newSymbol("y"); //$NON-NLS-1$ - intY.setType( TypeInfo.t_int ); + intY.setType( ITypeInfo.t_int ); nsA.addSymbol( intY ); IContainerSymbol nsB = table.newContainerSymbol("B"); //$NON-NLS-1$ - nsB.setType( TypeInfo.t_namespace ); + nsB.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsB ); IContainerSymbol structY = table.newContainerSymbol("y"); //$NON-NLS-1$ - structY.setType( TypeInfo.t_struct ); + structY.setType( ITypeInfo.t_struct ); nsB.addSymbol( structY ); IContainerSymbol nsC = table.newContainerSymbol("C"); //$NON-NLS-1$ - nsC.setType( TypeInfo.t_namespace); + nsC.setType( ITypeInfo.t_namespace); compUnit.addSymbol( nsC ); ISymbol look = nsC.lookup("A"); //$NON-NLS-1$ @@ -1007,15 +1014,15 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol nsA = table.newContainerSymbol( "A" ); //$NON-NLS-1$ - nsA.setType( TypeInfo.t_namespace ); + nsA.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( nsA ); IContainerSymbol nsB = table.newContainerSymbol( "B" ); //$NON-NLS-1$ - nsB.setType( TypeInfo.t_namespace ); + nsB.setType( ITypeInfo.t_namespace ); nsA.addSymbol( nsB ); IParameterizedSymbol f1 = table.newParameterizedSymbol("f1"); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); + f1.setType( ITypeInfo.t_function ); nsB.addSymbol( f1 ); nsA.addUsingDirective( nsB ); @@ -1062,19 +1069,19 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B"); //$NON-NLS-1$ - B.setType( TypeInfo.t_struct ); + B.setType( ITypeInfo.t_struct ); compUnit.addSymbol( B ); IParameterizedSymbol f = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f.setType( TypeInfo.t_function ); + f.setType( ITypeInfo.t_function ); B.addSymbol( f ); IContainerSymbol E = table.newContainerSymbol( "E" ); //$NON-NLS-1$ - E.setType( TypeInfo.t_enumeration ); + E.setType( ITypeInfo.t_enumeration ); B.addSymbol( E ); ISymbol e = table.newSymbol( "e" ); //$NON-NLS-1$ - e.setType( TypeInfo.t_enumerator ); + e.setType( ITypeInfo.t_enumerator ); E.addSymbol( e ); /** @@ -1082,15 +1089,15 @@ public class ParserSymbolTableTest extends TestCase { */ IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C" ); //$NON-NLS-1$ - C.setType( TypeInfo.t_class ); + C.setType( ITypeInfo.t_class ); compUnit.addSymbol( C ); IParameterizedSymbol g = table.newParameterizedSymbol( "g" ); //$NON-NLS-1$ - g.setType( TypeInfo.t_function ); + g.setType( ITypeInfo.t_function ); C.addSymbol( g ); IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D" ); //$NON-NLS-1$ - D.setType( TypeInfo.t_struct ); + D.setType( ITypeInfo.t_struct ); ISymbol look = compUnit.lookup( "B" ); //$NON-NLS-1$ assertEquals( look, B ); D.addParent( B ); @@ -1148,12 +1155,12 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); - IContainerSymbol A = table.newContainerSymbol( "A", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol A = table.newContainerSymbol( "A", ITypeInfo.t_namespace ); //$NON-NLS-1$ compUnit.addSymbol( A ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_int, 0, null, false ); A.addSymbol( f1 ); ISymbol look = compUnit.lookupNestedNameSpecifier("A"); //$NON-NLS-1$ @@ -1170,18 +1177,18 @@ public class ParserSymbolTableTest extends TestCase { assertEquals( look, A ); IParameterizedSymbol f2 = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); - f2.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_char, 0, null, false ); + f2.setType( ITypeInfo.t_function ); + f2.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_char, 0, null, false ); A.addSymbol( f2 ); IParameterizedSymbol foo = table.newParameterizedSymbol("foo"); //$NON-NLS-1$ - foo.setType( TypeInfo.t_function ); + foo.setType( ITypeInfo.t_function ); compUnit.addSymbol( foo ); ArrayList paramList = new ArrayList(); - TypeInfo param = new TypeInfo( TypeInfo.t_char, 0, null ); + ITypeInfo param = TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ); paramList.add( param ); look = foo.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ @@ -1189,8 +1196,8 @@ public class ParserSymbolTableTest extends TestCase { assertTrue( usingF.hasSameParameters( f1 ) ); IParameterizedSymbol bar = table.newParameterizedSymbol( "bar" ); //$NON-NLS-1$ - bar.setType( TypeInfo.t_function ); - bar.addParameter( TypeInfo.t_char, 0, null, false ); + bar.setType( ITypeInfo.t_function ); + bar.addParameter( ITypeInfo.t_char, 0, null, false ); compUnit.addSymbol( bar ); look = bar.lookupNestedNameSpecifier( "A" ); //$NON-NLS-1$ @@ -1223,11 +1230,11 @@ public class ParserSymbolTableTest extends TestCase { public void testThisPointer() throws Exception{ newTable(); - IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "class", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "class", ITypeInfo.t_class ); //$NON-NLS-1$ - IParameterizedSymbol fn = table.newParameterizedSymbol("function", TypeInfo.t_function ); //$NON-NLS-1$ - fn.setType( TypeInfo.t_function ); - fn.getTypeInfo().setBit( true, TypeInfo.isConst ); + IParameterizedSymbol fn = table.newParameterizedSymbol("function", ITypeInfo.t_function ); //$NON-NLS-1$ + fn.setType( ITypeInfo.t_function ); + fn.getTypeInfo().setBit( true, ITypeInfo.isConst ); table.getCompilationUnit().addSymbol( cls ); cls.addSymbol( fn ); @@ -1235,10 +1242,10 @@ public class ParserSymbolTableTest extends TestCase { ISymbol look = fn.lookup("this"); //$NON-NLS-1$ assertTrue( look != null ); - assertEquals( look.getType(), TypeInfo.t_type ); + assertEquals( look.getType(), ITypeInfo.t_type ); assertEquals( look.getTypeSymbol(), cls ); - assertTrue( look.getTypeInfo().checkBit( TypeInfo.isConst ) ); - assertEquals( ((PtrOp)look.getPtrOperators().iterator().next()).getType(), TypeInfo.PtrOp.t_pointer ); + assertTrue( look.getTypeInfo().checkBit( ITypeInfo.isConst ) ); + assertEquals( ((ITypeInfo.PtrOp)look.getPtrOperators().iterator().next()).getType(), ITypeInfo.PtrOp.t_pointer ); assertEquals( look.getContainingSymbol(), fn ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -1256,16 +1263,16 @@ public class ParserSymbolTableTest extends TestCase { newTable(); IContainerSymbol cls = table.newContainerSymbol("class"); //$NON-NLS-1$ - cls.setType( TypeInfo.t_class ); + cls.setType( ITypeInfo.t_class ); IContainerSymbol enumeration = table.newContainerSymbol("enumeration"); //$NON-NLS-1$ - enumeration.setType( TypeInfo.t_enumeration ); + enumeration.setType( ITypeInfo.t_enumeration ); table.getCompilationUnit().addSymbol( cls ); cls.addSymbol( enumeration ); ISymbol enumerator = table.newSymbol( "enumerator" ); //$NON-NLS-1$ - enumerator.setType( TypeInfo.t_enumerator ); + enumerator.setType( ITypeInfo.t_enumerator ); enumeration.addSymbol( enumerator ); ISymbol look = cls.lookup( "enumerator" ); //$NON-NLS-1$ @@ -1294,18 +1301,18 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol NS = table.newContainerSymbol("NS"); //$NON-NLS-1$ - NS.setType( TypeInfo.t_namespace ); + NS.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( NS ); IDerivableContainerSymbol T = table.newDerivableContainerSymbol("T"); //$NON-NLS-1$ - T.setType( TypeInfo.t_class ); + T.setType( ITypeInfo.t_class ); NS.addSymbol( T ); IParameterizedSymbol f = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f.setType( TypeInfo.t_function ); - f.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ + f.setType( ITypeInfo.t_function ); + f.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ ISymbol look = NS.lookup( "T" ); //$NON-NLS-1$ assertEquals( look, T ); @@ -1319,19 +1326,19 @@ public class ParserSymbolTableTest extends TestCase { assertEquals( look, T ); ISymbol param = table.newSymbol("parm"); //$NON-NLS-1$ - param.setType( TypeInfo.t_type ); + param.setType( ITypeInfo.t_type ); param.setTypeSymbol( look ); compUnit.addSymbol( param ); IParameterizedSymbol main = table.newParameterizedSymbol("main"); //$NON-NLS-1$ - main.setType( TypeInfo.t_function ); - main.setReturnType( table.newSymbol( "", TypeInfo.t_int ) ); //$NON-NLS-1$ + main.setType( ITypeInfo.t_function ); + main.setReturnType( table.newSymbol( "", ITypeInfo.t_int ) ); //$NON-NLS-1$ compUnit.addSymbol( main ); ArrayList paramList = new ArrayList(); look = main.lookup( "parm" ); //$NON-NLS-1$ assertEquals( look, param ); - TypeInfo p = new TypeInfo( TypeInfo.t_type, 0, look ); + ITypeInfo p = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, look ); paramList.add( p ); look = main.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ @@ -1368,17 +1375,17 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IContainerSymbol NS1 = table.newContainerSymbol( "NS1" ); //$NON-NLS-1$ - NS1.setType( TypeInfo.t_namespace ); + NS1.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( NS1 ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_void, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_void, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); NS1.addSymbol( f1 ); IContainerSymbol NS2 = table.newContainerSymbol( "NS2" ); //$NON-NLS-1$ - NS2.setType( TypeInfo.t_namespace ); + NS2.setType( ITypeInfo.t_namespace ); compUnit.addSymbol( NS2 ); @@ -1387,17 +1394,17 @@ public class ParserSymbolTableTest extends TestCase { NS2.addUsingDirective( NS1 ); IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" ); //$NON-NLS-1$ - B.setType( TypeInfo.t_class ); + B.setType( ITypeInfo.t_class ); NS2.addSymbol( B ); IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); - f2.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_void, 0, new PtrOp( PtrOp.t_pointer ), false ); + f2.setType( ITypeInfo.t_function ); + f2.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_void, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); NS2.addSymbol( f2 ); IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" ); //$NON-NLS-1$ - A.setType( TypeInfo.t_class ); + A.setType( ITypeInfo.t_class ); look = compUnit.lookupNestedNameSpecifier( "NS2" ); //$NON-NLS-1$ assertEquals( look, NS2 ); @@ -1410,16 +1417,16 @@ public class ParserSymbolTableTest extends TestCase { look = compUnit.lookup( "A" ); //$NON-NLS-1$ assertEquals( look, A ); ISymbol a = table.newSymbol( "a" ); //$NON-NLS-1$ - a.setType( TypeInfo.t_type ); + a.setType( ITypeInfo.t_type ); a.setTypeSymbol( look ); compUnit.addSymbol( a ); ArrayList paramList = new ArrayList(); look = compUnit.lookup( "a" ); //$NON-NLS-1$ assertEquals( look, a ); - TypeInfo param = new TypeInfo( look.getType(), 0, look, null, false ); + ITypeInfo param = TypeInfoProvider.newTypeInfo( look.getType(), 0, look, null, false ); //new PtrOp( PtrOp.t_reference ) - param.addOperatorExpression( OperatorExpression.addressof ); + param.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); paramList.add( param ); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ @@ -1453,37 +1460,37 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C" ); //$NON-NLS-1$ - C.setType( TypeInfo.t_class ); + C.setType( ITypeInfo.t_class ); compUnit.addSymbol(C); IParameterizedSymbol f1 = table.newParameterizedSymbol("foo"); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); - f1.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_int, 0, null, false ); + f1.setType( ITypeInfo.t_function ); + f1.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_int, 0, null, false ); C.addSymbol( f1 ); IParameterizedSymbol f2 = table.newParameterizedSymbol("foo"); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); - f2.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_int, 0, null, false ); - f2.addParameter( TypeInfo.t_char, 0, null, false ); + f2.setType( ITypeInfo.t_function ); + f2.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_int, 0, null, false ); + f2.addParameter( ITypeInfo.t_char, 0, null, false ); C.addSymbol( f2 ); IParameterizedSymbol f3 = table.newParameterizedSymbol("foo"); //$NON-NLS-1$ - f3.setType( TypeInfo.t_function ); - f3.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ - f3.addParameter( TypeInfo.t_int, 0, null, false ); - f3.addParameter( TypeInfo.t_char, 0, null, false ); - f3.addParameter( C, 0, new PtrOp( PtrOp.t_pointer ), false ); + f3.setType( ITypeInfo.t_function ); + f3.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ + f3.addParameter( ITypeInfo.t_int, 0, null, false ); + f3.addParameter( ITypeInfo.t_char, 0, null, false ); + f3.addParameter( C, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); C.addSymbol( f3 ); ISymbol look = compUnit.lookup("C"); //$NON-NLS-1$ assertEquals( look, C ); ISymbol c = table.newSymbol("c"); //$NON-NLS-1$ - c.setType( TypeInfo.t_type ); + c.setType( ITypeInfo.t_type ); c.setTypeSymbol( look ); - c.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) ); + c.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) ); compUnit.addSymbol( c ); look = compUnit.lookup( "c" ); //$NON-NLS-1$ @@ -1492,9 +1499,9 @@ public class ParserSymbolTableTest extends TestCase { ArrayList paramList = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null ); - TypeInfo p2 = new TypeInfo( TypeInfo.t_char, 0, null ); - TypeInfo p3 = new TypeInfo( TypeInfo.t_type, 0, c ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ); + ITypeInfo p2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ); + ITypeInfo p3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, c ); paramList.add( p1 ); look = C.memberFunctionLookup( "foo", paramList ); //$NON-NLS-1$ @@ -1528,30 +1535,30 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IParameterizedSymbol f1 = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); - f1.addParameter( TypeInfo.t_int, 0, null, false ); + f1.setType( ITypeInfo.t_function ); + f1.addParameter( ITypeInfo.t_int, 0, null, false ); compUnit.addSymbol( f1 ); IParameterizedSymbol f2 = table.newParameterizedSymbol("f"); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); - f2.addParameter( TypeInfo.t_char, 0, null, true ); + f2.setType( ITypeInfo.t_function ); + f2.addParameter( ITypeInfo.t_char, 0, null, true ); compUnit.addSymbol( f2 ); ArrayList paramList = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ); paramList.add( p1 ); ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f1 ); paramList.clear(); - TypeInfo p2 = new TypeInfo( TypeInfo.t_char, 0, null ); + ITypeInfo p2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ); paramList.add( p2 ); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f2 ); paramList.clear(); - TypeInfo p3 = new TypeInfo( TypeInfo.t_bool, 0, null ); + ITypeInfo p3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_bool, 0, null ); paramList.add( p3 ); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f1 ); @@ -1584,47 +1591,47 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" ); //$NON-NLS-1$ - A.setType( TypeInfo.t_class ); + A.setType( ITypeInfo.t_class ); compUnit.addSymbol( A ); IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" ); //$NON-NLS-1$ - B.setType( TypeInfo.t_class ); + B.setType( ITypeInfo.t_class ); B.addParent( A ); compUnit.addSymbol( B ); IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C" ); //$NON-NLS-1$ - C.setType( TypeInfo.t_class ); + C.setType( ITypeInfo.t_class ); C.addParent( B ); compUnit.addSymbol( C ); IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); - f1.addParameter( A, 0, new PtrOp( PtrOp.t_pointer ), false ); + f1.setType( ITypeInfo.t_function ); + f1.addParameter( A, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); compUnit.addSymbol( f1 ); IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); - f2.addParameter( B, 0, new PtrOp( PtrOp.t_pointer ), false ); + f2.setType( ITypeInfo.t_function ); + f2.addParameter( B, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); compUnit.addSymbol( f2 ); ISymbol a = table.newSymbol( "a" ); //$NON-NLS-1$ - a.setType( TypeInfo.t_type ); + a.setType( ITypeInfo.t_type ); a.setTypeSymbol( A ); - a.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) ); + a.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) ); ISymbol c = table.newSymbol( "c" ); //$NON-NLS-1$ - c.setType( TypeInfo.t_type ); + c.setType( ITypeInfo.t_type ); c.setTypeSymbol( C ); - c.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) ); + c.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) ); ArrayList paramList = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, a ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ); paramList.add( p1 ); ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f1 ); paramList.clear(); - TypeInfo p2 = new TypeInfo( TypeInfo.t_type, 0, c ); + ITypeInfo p2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, c ); paramList.add( p2 ); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f2 ); @@ -1636,7 +1643,7 @@ public class ParserSymbolTableTest extends TestCase { * @throws Exception * * class A {}; - * typedef B A *; + * typedef A * B; * * void f( A * ); * void f( A ); @@ -1657,63 +1664,66 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" ); //$NON-NLS-1$ - A.setType( TypeInfo.t_class ); + A.setType( ITypeInfo.t_class ); compUnit.addSymbol( A ); ISymbol B = table.newSymbol( "B" ); //$NON-NLS-1$ - B.setType( TypeInfo.t_type ); + B.setType( ITypeInfo.t_type ); B.setTypeSymbol( A ); - B.getTypeInfo().setBit( true, TypeInfo.isTypedef ); - B.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) ); + B.getTypeInfo().setBit( true, ITypeInfo.isTypedef ); + B.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) ); compUnit.addSymbol( B ); IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); - f1.addParameter( A, 0, new PtrOp( PtrOp.t_pointer ), false ); + f1.setType( ITypeInfo.t_function ); + f1.addParameter( A, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); compUnit.addSymbol( f1 ); IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); + f2.setType( ITypeInfo.t_function ); f2.addParameter( A, 0, null, false ); compUnit.addSymbol( f2 ); ISymbol a = table.newSymbol( "a" ); //$NON-NLS-1$ - a.setType( TypeInfo.t_type ); + a.setType( ITypeInfo.t_type ); a.setTypeSymbol( A ); compUnit.addSymbol( a ); ISymbol b = table.newSymbol( "b" ); //$NON-NLS-1$ - b.setType( TypeInfo.t_type ); + b.setType( ITypeInfo.t_type ); b.setTypeSymbol( B ); compUnit.addSymbol( b ); ISymbol array = table.newSymbol( "array" ); //$NON-NLS-1$ - array.setType( TypeInfo.t_type ); + array.setType( ITypeInfo.t_type ); array.setTypeSymbol( A ); - array.addPtrOperator( new PtrOp( PtrOp.t_array, false, false ) ); + array.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_array, false, false ) ); ArrayList paramList = new ArrayList(); - TypeInfo p = new TypeInfo( TypeInfo.t_type, 0, a ); + ITypeInfo p = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ); paramList.add( p ); ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f2 ); - p.addOperatorExpression( OperatorExpression.addressof ); + p.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f1 ); p.setTypeSymbol( b ); - p.getOperatorExpressions().clear(); + p.getPtrOperators().clear(); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f1 ); - p.addOperatorExpression( OperatorExpression.indirection ); + p = p.getFinalType( null ); + p.applyOperatorExpression( ITypeInfo.OperatorExpression.indirection ); + paramList.clear(); + paramList.add( p ); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f2 ); p.setTypeSymbol( array ); - p.getOperatorExpressions().clear(); + p.getPtrOperators().clear(); look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, f1 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -1741,30 +1751,30 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" ); //$NON-NLS-1$ - A.setType( TypeInfo.t_class ); + A.setType( ITypeInfo.t_class ); compUnit.addSymbol( A ); IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" ); //$NON-NLS-1$ - B.setType( TypeInfo.t_class ); + B.setType( ITypeInfo.t_class ); compUnit.addSymbol( B ); IParameterizedSymbol constructor = table.newParameterizedSymbol("B"); //$NON-NLS-1$ - constructor.setType( TypeInfo.t_constructor ); + constructor.setType( ITypeInfo.t_constructor ); constructor.addParameter( A, 0, null, false ); B.addConstructor( constructor ); IParameterizedSymbol f = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f.setType( TypeInfo.t_function ); + f.setType( ITypeInfo.t_function ); f.addParameter( B, 0, null, false ); compUnit.addSymbol( f ); ISymbol a = table.newSymbol( "a" ); //$NON-NLS-1$ - a.setType( TypeInfo.t_type ); + a.setTypeInfo( TypeInfoProvider.newTypeInfo( ITypeInfo.t_type ) ); a.setTypeSymbol( A ); compUnit.addSymbol( a ); ArrayList paramList = new ArrayList(); - TypeInfo p = new TypeInfo( TypeInfo.t_type, 0, a ); + ITypeInfo p = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ); paramList.add( p ); ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ @@ -1799,35 +1809,35 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); - f1.addParameter( TypeInfo.t_int, TypeInfo.isConst, new PtrOp( PtrOp.t_pointer, false, false ), false ); - f1.addParameter( TypeInfo.t_int, TypeInfo.isShort, null, false ); + f1.setType( ITypeInfo.t_function ); + f1.addParameter( ITypeInfo.t_int, ITypeInfo.isConst, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ), false ); + f1.addParameter( ITypeInfo.t_int, ITypeInfo.isShort, null, false ); compUnit.addSymbol( f1 ); IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); - f2.addParameter( TypeInfo.t_int, 0, new PtrOp( PtrOp.t_pointer ), false ); - f2.addParameter( TypeInfo.t_int, 0, null, false ); + f2.setType( ITypeInfo.t_function ); + f2.addParameter( ITypeInfo.t_int, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); + f2.addParameter( ITypeInfo.t_int, 0, null, false ); compUnit.addSymbol( f2 ); ISymbol i = table.newSymbol( "i" ); //$NON-NLS-1$ - i.setType( TypeInfo.t_int ); + i.setType( ITypeInfo.t_int ); compUnit.addSymbol( i ); ISymbol s = table.newSymbol( "s" ); //$NON-NLS-1$ - s.setType( TypeInfo.t_int ); - s.getTypeInfo().setBit( true, TypeInfo.isShort ); + s.setType( ITypeInfo.t_int ); + s.getTypeInfo().setBit( true, ITypeInfo.isShort ); compUnit.addSymbol( s ); IParameterizedSymbol main = table.newParameterizedSymbol( "main" ); //$NON-NLS-1$ - main.setType( TypeInfo.t_function ); + main.setType( ITypeInfo.t_function ); compUnit.addSymbol( main ); ArrayList params = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, i ); - p1.addOperatorExpression( OperatorExpression.addressof ); - TypeInfo p2 = new TypeInfo( TypeInfo.t_type, 0, s ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, i ); + p1.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); + ITypeInfo p2 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, s ); params.add( p1 ); params.add( p2 ); @@ -1841,21 +1851,21 @@ public class ParserSymbolTableTest extends TestCase { } params.clear(); - TypeInfo p3 = new TypeInfo( TypeInfo.t_int, TypeInfo.isLong, null ); + ITypeInfo p3 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, ITypeInfo.isLong, null ); params.add( p1 ); params.add( p3 ); look = main.unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f2 ); params.clear(); - TypeInfo p4 = new TypeInfo( TypeInfo.t_char, 0, null ); + ITypeInfo p4 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_char, 0, null ); params.add( p1 ); params.add( p4 ); look = main.unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f2 ); params.clear(); - p1 = new TypeInfo( TypeInfo.t_int, TypeInfo.isConst, null, new PtrOp( PtrOp.t_pointer, false, false ), false ); + p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, ITypeInfo.isConst, null, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ), false ); params.add( p1 ); params.add( p3 ); @@ -1894,34 +1904,34 @@ public class ParserSymbolTableTest extends TestCase { IContainerSymbol compUnit = table.getCompilationUnit(); IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" ); //$NON-NLS-1$ - B.setType( TypeInfo.t_class ); + B.setType( ITypeInfo.t_class ); compUnit.addSymbol( B ); IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" ); //$NON-NLS-1$ - A.setType( TypeInfo.t_class ); + A.setType( ITypeInfo.t_class ); compUnit.addSymbol( A ); IParameterizedSymbol constructA = table.newParameterizedSymbol( "A" ); //$NON-NLS-1$ - constructA.setType( TypeInfo.t_constructor ); - constructA.addParameter( B, 0, new PtrOp( PtrOp.t_reference ), false ); + constructA.setType( ITypeInfo.t_constructor ); + constructA.addParameter( B, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); A.addConstructor( constructA ); IParameterizedSymbol operator = table.newParameterizedSymbol( "operator A" ); //$NON-NLS-1$ - operator.setType( TypeInfo.t_function ); + operator.setType( ITypeInfo.t_function ); B.addSymbol( operator ); IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f1.setType( TypeInfo.t_function ); + f1.setType( ITypeInfo.t_function ); f1.addParameter( A, 0, null, false ); compUnit.addSymbol( f1 ); ISymbol b = table.newSymbol( "b" ); //$NON-NLS-1$ - b.setType( TypeInfo.t_type ); + b.setType( ITypeInfo.t_type ); b.setTypeSymbol( B ); ArrayList params = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, b ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, b ); params.add( p1 ); ISymbol look = null; @@ -1934,16 +1944,16 @@ public class ParserSymbolTableTest extends TestCase { } IDerivableContainerSymbol C = table.newDerivableContainerSymbol("C"); //$NON-NLS-1$ - C.setType( TypeInfo.t_class ); + C.setType( ITypeInfo.t_class ); compUnit.addSymbol( C ); IParameterizedSymbol constructC = table.newParameterizedSymbol("C"); //$NON-NLS-1$ - constructC.setType( TypeInfo.t_constructor ); - constructC.addParameter( B, 0, new PtrOp( PtrOp.t_reference ), false ); + constructC.setType( ITypeInfo.t_constructor ); + constructC.addParameter( B, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); C.addConstructor( constructC ); IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f2.setType( TypeInfo.t_function ); + f2.setType( ITypeInfo.t_function ); f2.addParameter( C, 0, null, false ); compUnit.addSymbol( f2 ); @@ -1955,7 +1965,7 @@ public class ParserSymbolTableTest extends TestCase { } IParameterizedSymbol f3 = table.newParameterizedSymbol( "f" ); //$NON-NLS-1$ - f3.setType( TypeInfo.t_function ); + f3.setType( ITypeInfo.t_function ); f3.addParameter( B, 0, null, false ); compUnit.addSymbol( f3 ); @@ -2027,7 +2037,7 @@ public class ParserSymbolTableTest extends TestCase { public void testForwardClassDeclaration() throws Exception{ newTable(); - ISymbol forwardSymbol = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + ISymbol forwardSymbol = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ forwardSymbol.setIsForwardDeclaration( true ); table.getCompilationUnit().addSymbol( forwardSymbol ); @@ -2035,23 +2045,23 @@ public class ParserSymbolTableTest extends TestCase { /*...*/ ISymbol lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ - ISymbol otherLookup = table.getCompilationUnit().elaboratedLookup( TypeInfo.t_class, "A" ); //$NON-NLS-1$ + ISymbol otherLookup = table.getCompilationUnit().elaboratedLookup( ITypeInfo.t_class, "A" ); //$NON-NLS-1$ assertEquals( lookup, otherLookup ); assertEquals( lookup, forwardSymbol ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( forwardSymbol ); - a.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + a.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); table.getCompilationUnit().addSymbol( a ); /*...*/ lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ - IDerivableContainerSymbol classA = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol classA = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ assertTrue( lookup.isForwardDeclaration() ); - lookup.setTypeSymbol( classA ); + lookup.setForwardSymbol( classA ); table.getCompilationUnit().addSymbol( classA ); @@ -2062,7 +2072,7 @@ public class ParserSymbolTableTest extends TestCase { lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ assertEquals( lookup, classA ); - lookup = table.getCompilationUnit().elaboratedLookup( TypeInfo.t_class, "A" ); //$NON-NLS-1$ + lookup = table.getCompilationUnit().elaboratedLookup( ITypeInfo.t_class, "A" ); //$NON-NLS-1$ assertEquals( lookup, classA ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); } @@ -2092,65 +2102,65 @@ public class ParserSymbolTableTest extends TestCase { public void testForwardDeclarationUsedAsFunctionParam() throws Exception{ newTable(); - ISymbol forwardSymbol = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + ISymbol forwardSymbol = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ forwardSymbol.setIsForwardDeclaration( true ); table.getCompilationUnit().addSymbol( forwardSymbol ); /*...*/ - IDerivableContainerSymbol classB = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol classB = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ - IParameterizedSymbol fn1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol fn1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ ISymbol lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ assertEquals( lookup, forwardSymbol ); - fn1.addParameter( lookup, 0, new PtrOp( PtrOp.t_pointer ), false ); - fn1.getTypeInfo().setBit( true, TypeInfo.isStatic ); + fn1.addParameter( lookup, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); + fn1.getTypeInfo().setBit( true, ITypeInfo.isStatic ); classB.addSymbol( fn1 ); - IParameterizedSymbol fn2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - fn2.addParameter( TypeInfo.t_int, 0, null, false ); - fn2.getTypeInfo().setBit( true, TypeInfo.isStatic ); + IParameterizedSymbol fn2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + fn2.addParameter( ITypeInfo.t_int, 0, null, false ); + fn2.getTypeInfo().setBit( true, ITypeInfo.isStatic ); classB.addSymbol( fn2 ); table.getCompilationUnit().addSymbol( classB ); /*...*/ - ISymbol a1 = table.newSymbol( "a1", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a1 = table.newSymbol( "a1", ITypeInfo.t_type ); //$NON-NLS-1$ lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ assertEquals( lookup, forwardSymbol ); a1.setTypeSymbol( lookup ); - a1.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + a1.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); table.getCompilationUnit().addSymbol( a1 ); /*...*/ lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ - IDerivableContainerSymbol classA = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol classA = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ assertTrue( lookup.isForwardDeclaration() ); - lookup.setTypeSymbol( classA ); + lookup.setForwardSymbol( classA ); table.getCompilationUnit().addSymbol( classA ); /*..*/ - ISymbol a2 = table.newSymbol( "a2", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a2 = table.newSymbol( "a2", ITypeInfo.t_type ); //$NON-NLS-1$ lookup = table.getCompilationUnit().lookup( "A" ); //$NON-NLS-1$ assertEquals( lookup, classA ); a2.setTypeSymbol( lookup ); - a2.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + a2.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); table.getCompilationUnit().addSymbol( a2 ); /*..*/ ArrayList paramList = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, a1 ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a1 ); paramList.add( p1 ); ISymbol look = classB.memberFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, fn1 ); paramList.clear(); - p1 = new TypeInfo( TypeInfo.t_type, 0, a2 ); + p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a2 ); paramList.add( p1 ); look = classB.memberFunctionLookup( "f", paramList ); //$NON-NLS-1$ assertEquals( look, fn1 ); @@ -2160,16 +2170,16 @@ public class ParserSymbolTableTest extends TestCase { public void testConstructors() throws Exception{ newTable(); - IDerivableContainerSymbol classA = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol classA = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ - IParameterizedSymbol constructor1 = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$ - constructor1.addParameter( classA, 0, new PtrOp( PtrOp.t_reference ), false ); + IParameterizedSymbol constructor1 = table.newParameterizedSymbol( "A", ITypeInfo.t_constructor ); //$NON-NLS-1$ + constructor1.addParameter( classA, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); - IParameterizedSymbol constructor2 = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$ - constructor2.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol constructor2 = table.newParameterizedSymbol( "A", ITypeInfo.t_constructor ); //$NON-NLS-1$ + constructor2.addParameter( ITypeInfo.t_int, 0, null, false ); - IParameterizedSymbol constructor3 = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$ - constructor3.addParameter( TypeInfo.t_char, 0, null, false ); + IParameterizedSymbol constructor3 = table.newParameterizedSymbol( "A", ITypeInfo.t_constructor ); //$NON-NLS-1$ + constructor3.addParameter( ITypeInfo.t_char, 0, null, false ); classA.addConstructor( constructor1 ); classA.addConstructor( constructor2 ); @@ -2185,7 +2195,7 @@ public class ParserSymbolTableTest extends TestCase { } ArrayList paramList = new ArrayList(); - paramList.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + paramList.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); ISymbol lookup = classA.lookupConstructor( paramList ); @@ -2208,14 +2218,14 @@ public class ParserSymbolTableTest extends TestCase { public void testNamespaceAlias() throws Exception{ newTable(); - IContainerSymbol NSA = table.newContainerSymbol( "A", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol NSA = table.newContainerSymbol( "A", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( NSA ); - ISymbol x = table.newSymbol( "x", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol x = table.newSymbol( "x", ITypeInfo.t_int ); //$NON-NLS-1$ NSA.addSymbol( x ); - IContainerSymbol NSB = table.newContainerSymbol( "B", TypeInfo.t_namespace ); //$NON-NLS-1$ - NSB.setTypeSymbol( NSA ); //alias B to A + IContainerSymbol NSB = table.newContainerSymbol( "B", ITypeInfo.t_namespace ); //$NON-NLS-1$ + NSB.setForwardSymbol( NSA ); //alias B to A table.getCompilationUnit().addSymbol( NSB ); @@ -2244,16 +2254,16 @@ public class ParserSymbolTableTest extends TestCase { public void testUsingNamespaceAlias() throws Exception{ newTable(); - IContainerSymbol NSA = table.newContainerSymbol( "A", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol NSA = table.newContainerSymbol( "A", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( NSA ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ NSA.addSymbol( f ); - IContainerSymbol NSB = table.newContainerSymbol( "B", TypeInfo.t_namespace ); //$NON-NLS-1$ - NSB.setTypeSymbol( NSA ); + IContainerSymbol NSB = table.newContainerSymbol( "B", ITypeInfo.t_namespace ); //$NON-NLS-1$ + NSB.setForwardSymbol( NSA ); table.getCompilationUnit().addSymbol( NSB ); //look for function that has no parameters @@ -2279,10 +2289,10 @@ public class ParserSymbolTableTest extends TestCase { public void testBadParameterInfo() throws Exception{ newTable(); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f.setReturnType( table.newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f.setReturnType( table.newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ - IDerivableContainerSymbol a = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol a = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( a ); f.addParameter( a, 0, null, false ); @@ -2291,7 +2301,7 @@ public class ParserSymbolTableTest extends TestCase { ArrayList paramList = new ArrayList (); - TypeInfo param = new TypeInfo( TypeInfo.t_type, 0, null ); + ITypeInfo param = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, null ); paramList.add( param ); @@ -2299,7 +2309,7 @@ public class ParserSymbolTableTest extends TestCase { assertEquals( look, null ); - ISymbol intermediate = table.newSymbol( "", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol intermediate = table.newSymbol( "", ITypeInfo.t_type ); //$NON-NLS-1$ param.setTypeSymbol( intermediate ); @@ -2327,53 +2337,53 @@ public class ParserSymbolTableTest extends TestCase { public void testGetConditionalOperand_bug43106() throws Exception{ newTable(); - IDerivableContainerSymbol clsA = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol clsB = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsA = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsB = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ clsB.addParent( clsA ); table.getCompilationUnit().addSymbol( clsA ); table.getCompilationUnit().addSymbol( clsB ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( clsA ); - ISymbol b = table.newSymbol( "b", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol b = table.newSymbol( "b", ITypeInfo.t_type ); //$NON-NLS-1$ b.setTypeSymbol( clsB ); table.getCompilationUnit().addSymbol( a ); table.getCompilationUnit().addSymbol( b ); - TypeInfo secondOp = new TypeInfo( TypeInfo.t_type, 0, a ); - secondOp.addOperatorExpression( OperatorExpression.addressof ); - TypeInfo thirdOp = new TypeInfo( TypeInfo.t_type, 0, b ); - thirdOp.addOperatorExpression( OperatorExpression.addressof ); + ITypeInfo secondOp = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a ); + secondOp.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); + ITypeInfo thirdOp = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, b ); + thirdOp.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); - TypeInfo returned = table.getConditionalOperand( secondOp, thirdOp ); + ITypeInfo returned = table.getConditionalOperand( secondOp, thirdOp ); assertEquals( returned, secondOp ); - IDerivableContainerSymbol clsC = table.newDerivableContainerSymbol( "C", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsC = table.newDerivableContainerSymbol( "C", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( clsC ); - ISymbol c = table.newSymbol( "c", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol c = table.newSymbol( "c", ITypeInfo.t_type ); //$NON-NLS-1$ c.setTypeSymbol( clsC ); table.getCompilationUnit().addSymbol( c ); - TypeInfo anotherOp = new TypeInfo( TypeInfo.t_type, 0, c ); - anotherOp.addOperatorExpression( OperatorExpression.addressof ); + ITypeInfo anotherOp = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, c ); + anotherOp.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); returned = table.getConditionalOperand( secondOp, anotherOp ); assertEquals( returned, null ); - IParameterizedSymbol constructorA = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$ + IParameterizedSymbol constructorA = table.newParameterizedSymbol( "A", ITypeInfo.t_constructor ); //$NON-NLS-1$ constructorA.addParameter( clsC, 0, null, false ); clsA.addConstructor( constructorA ); - IParameterizedSymbol constructorC = table.newParameterizedSymbol( "C", TypeInfo.t_constructor ); //$NON-NLS-1$ + IParameterizedSymbol constructorC = table.newParameterizedSymbol( "C", ITypeInfo.t_constructor ); //$NON-NLS-1$ constructorC.addParameter( clsA, 0, null, false ); clsC.addConstructor( constructorC ); - secondOp.getOperatorExpressions().clear(); - anotherOp.getOperatorExpressions().clear(); + secondOp.getPtrOperators().clear(); + anotherOp.getPtrOperators().clear(); try{ returned = table.getConditionalOperand( secondOp, anotherOp ); @@ -2402,17 +2412,17 @@ public class ParserSymbolTableTest extends TestCase { public void testDerivedReference() throws Exception{ newTable(); - IDerivableContainerSymbol clsA = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol clsB = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ - IDerivableContainerSymbol clsC = table.newDerivableContainerSymbol( "C", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsA = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsB = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsC = table.newDerivableContainerSymbol( "C", ITypeInfo.t_class ); //$NON-NLS-1$ clsB.addParent( clsA ); clsC.addParent( clsA, false, ASTAccessVisibility.PRIVATE, 0, null ); - ISymbol b = table.newSymbol("b", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol b = table.newSymbol("b", ITypeInfo.t_type ); //$NON-NLS-1$ b.setTypeSymbol( clsB ); - ISymbol c = table.newSymbol("c", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol c = table.newSymbol("c", ITypeInfo.t_type ); //$NON-NLS-1$ c.setTypeSymbol( clsC ); table.getCompilationUnit().addSymbol( clsA ); @@ -2421,26 +2431,26 @@ public class ParserSymbolTableTest extends TestCase { table.getCompilationUnit().addSymbol( b ); table.getCompilationUnit().addSymbol( c ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.addParameter( clsA, 0, new PtrOp( PtrOp.t_reference ), false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.addParameter( clsA, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); table.getCompilationUnit().addSymbol( f1 ); ArrayList parameters = new ArrayList(); - TypeInfo param = new TypeInfo( TypeInfo.t_type, 0, b ); + ITypeInfo param = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, b ); parameters.add( param ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); //$NON-NLS-1$ assertEquals( look, f1 ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( clsB, 0, new PtrOp( PtrOp.t_reference ), false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( clsB, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference ), false ); table.getCompilationUnit().addSymbol( f2 ); look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); //$NON-NLS-1$ assertEquals( look, f2 ); parameters.clear(); - param = new TypeInfo( TypeInfo.t_type, 0, c ); + param = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, c ); parameters.add( param ); try{ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); //$NON-NLS-1$ @@ -2476,25 +2486,25 @@ public class ParserSymbolTableTest extends TestCase { public void testAddCopyConstructor() throws Exception { newTable(); - IDerivableContainerSymbol clsA = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsA = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( clsA ); - ISymbol a = table.newSymbol( "a", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol a = table.newSymbol( "a", ITypeInfo.t_type ); //$NON-NLS-1$ a.setTypeSymbol( clsA ); table.getCompilationUnit().addSymbol( a ); - IDerivableContainerSymbol clsB = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol clsB = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ clsB.addParent( clsA ); table.getCompilationUnit().addSymbol( clsB ); - ISymbol b = table.newSymbol( "b", TypeInfo.t_type ); //$NON-NLS-1$ + ISymbol b = table.newSymbol( "b", ITypeInfo.t_type ); //$NON-NLS-1$ b.setTypeSymbol( clsB ); table.getCompilationUnit().addSymbol( b ); - TypeInfo secondOp = new TypeInfo( TypeInfo.t_type, 0, a, null, false ); - TypeInfo thirdOp = new TypeInfo( TypeInfo.t_type, 0, b, null, false ); + ITypeInfo secondOp = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, a, null, false ); + ITypeInfo thirdOp = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, b, null, false ); - TypeInfo returned = table.getConditionalOperand( secondOp, thirdOp ); + ITypeInfo returned = table.getConditionalOperand( secondOp, thirdOp ); assertEquals( returned, null ); clsA.addCopyConstructor(); @@ -2508,18 +2518,18 @@ public class ParserSymbolTableTest extends TestCase { public void testbug43834() throws Exception{ newTable(); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( f ); ArrayList parameters = new ArrayList(); - TypeInfo param = new TypeInfo( TypeInfo.t_void, 0, null ); + ITypeInfo param = TypeInfoProvider.newTypeInfo( ITypeInfo.t_void, 0, null ); parameters.add( param ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); //$NON-NLS-1$ assertEquals( look, f ); - f.addParameter( TypeInfo.t_void, 0, null, false ); + f.addParameter( ITypeInfo.t_void, 0, null, false ); parameters.clear(); @@ -2544,19 +2554,19 @@ public class ParserSymbolTableTest extends TestCase { */ public void testBug43503_AmbiguousUsing() throws Exception{ newTable(); - IContainerSymbol NSA = table.newContainerSymbol( "A", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol NSA = table.newContainerSymbol( "A", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( NSA ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ NSA.addSymbol( f1 ); - IContainerSymbol NSB = table.newContainerSymbol( "B", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol NSB = table.newContainerSymbol( "B", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( NSB ); - ISymbol f2 = table.newSymbol( "f", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol f2 = table.newSymbol( "f", ITypeInfo.t_int ); //$NON-NLS-1$ NSB.addSymbol( f2 ); - IContainerSymbol NSC = table.newContainerSymbol( "C", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol NSC = table.newContainerSymbol( "C", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( NSC ); NSC.addUsingDirective( NSA ); NSC.addUsingDirective( NSB ); @@ -2580,10 +2590,10 @@ public class ParserSymbolTableTest extends TestCase { public void testBug43503_UnableToResolveFunction() throws Exception{ newTable(); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_int, 0, null, false ); table.getCompilationUnit().addSymbol( f1 ); table.getCompilationUnit().addSymbol( f2 ); @@ -2610,17 +2620,17 @@ public class ParserSymbolTableTest extends TestCase { public void testBug44510() throws Exception{ newTable(); - IParameterizedSymbol init1 = table.newParameterizedSymbol( "initialize", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol init1 = table.newParameterizedSymbol( "initialize", ITypeInfo.t_function ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( init1 ); - IParameterizedSymbol init2 = table.newParameterizedSymbol( "initialize", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol init2 = table.newParameterizedSymbol( "initialize", ITypeInfo.t_function ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new ArrayList() ); //$NON-NLS-1$ assertEquals( look, init1 ); - init1.getTypeInfo().setIsForwardDeclaration( true ); - init1.setTypeSymbol( init2 ); + init1.setIsForwardDeclaration( true ); + init1.setForwardSymbol( init2 ); table.getCompilationUnit().addSymbol( init2 ); @@ -2646,28 +2656,28 @@ public class ParserSymbolTableTest extends TestCase { public void testBug46882() throws Exception{ newTable(); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_int, 0, null, false ); A.addSymbol( f1 ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ A.addSymbol( f2 ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ B.addParent( A ); table.getCompilationUnit().addSymbol( B ); - IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f3.addParameter( TypeInfo.t_char, 0, null, false ); + IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f3.addParameter( ITypeInfo.t_char, 0, null, false ); B.addSymbol( f3 ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); ISymbol look = B.qualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f3 ); @@ -2688,13 +2698,13 @@ public class ParserSymbolTableTest extends TestCase { public void testPrefixLookup_Unqualified() throws Exception { newTable( ParserLanguage.CPP, ParserMode.COMPLETION_PARSE ); - ISymbol aVar = table.newSymbol( "aVar", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol aVar = table.newSymbol( "aVar", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( aVar ); - IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( foo ); - ISymbol anotherVar = table.newSymbol( "anotherVar", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol anotherVar = table.newSymbol( "anotherVar", ITypeInfo.t_int ); //$NON-NLS-1$ foo.addSymbol( anotherVar ); List results = foo.prefixLookup( null, "a", false, null ); //$NON-NLS-1$ @@ -2720,14 +2730,14 @@ public class ParserSymbolTableTest extends TestCase { public void testPrefixLookup_Qualified() throws Exception { newTable( ParserLanguage.CPP, ParserMode.COMPLETION_PARSE ); - ISymbol aVar = table.newSymbol( "aVar", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol aVar = table.newSymbol( "aVar", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( aVar ); - IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( D ); - ISymbol aField = table.newSymbol( "aField", TypeInfo.t_int ); //$NON-NLS-1$ - IParameterizedSymbol aMethod = table.newParameterizedSymbol( "aMethod", TypeInfo.t_function ); //$NON-NLS-1$ + ISymbol aField = table.newSymbol( "aField", ITypeInfo.t_int ); //$NON-NLS-1$ + IParameterizedSymbol aMethod = table.newParameterizedSymbol( "aMethod", ITypeInfo.t_function ); //$NON-NLS-1$ D.addSymbol( aField ); D.addSymbol( aMethod ); @@ -2762,27 +2772,27 @@ public class ParserSymbolTableTest extends TestCase { public void testPrefixLookup_Inheritance() throws Exception { newTable( ParserLanguage.CPP, ParserMode.COMPLETION_PARSE ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A ); - ISymbol aVar = table.newSymbol( "aVar", TypeInfo.t_int ); //$NON-NLS-1$ - ISymbol anotherVar1 = table.newSymbol( "anotherVar", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol aVar = table.newSymbol( "aVar", ITypeInfo.t_int ); //$NON-NLS-1$ + ISymbol anotherVar1 = table.newSymbol( "anotherVar", ITypeInfo.t_int ); //$NON-NLS-1$ A.addSymbol( aVar ); A.addSymbol( anotherVar1 ); - IParameterizedSymbol af1 = table.newParameterizedSymbol( "af", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol af1 = table.newParameterizedSymbol( "af", ITypeInfo.t_function ); //$NON-NLS-1$ A.addSymbol( af1 ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ B.addParent( A ); table.getCompilationUnit().addSymbol( B ); - ISymbol anotherVar2 = table.newSymbol( "anotherVar", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol anotherVar2 = table.newSymbol( "anotherVar", ITypeInfo.t_int ); //$NON-NLS-1$ B.addSymbol( anotherVar2 ); - IParameterizedSymbol af2 = table.newParameterizedSymbol( "af", TypeInfo.t_function ); //$NON-NLS-1$ - af2.addParameter( TypeInfo.t_char, 0, null, false ); + IParameterizedSymbol af2 = table.newParameterizedSymbol( "af", ITypeInfo.t_function ); //$NON-NLS-1$ + af2.addParameter( ITypeInfo.t_char, 0, null, false ); B.addSymbol( af2 ); @@ -2824,28 +2834,28 @@ public class ParserSymbolTableTest extends TestCase { public void testPrefixLookup_Ambiguities() throws Exception{ newTable( ParserLanguage.CPP, ParserMode.COMPLETION_PARSE ); - ISymbol aa = table.newSymbol( "aa", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol aa = table.newSymbol( "aa", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( aa ); - IContainerSymbol ns = table.newContainerSymbol( "", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol ns = table.newContainerSymbol( "", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( ns ); - IContainerSymbol U = table.newContainerSymbol( "U", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol U = table.newContainerSymbol( "U", ITypeInfo.t_namespace ); //$NON-NLS-1$ ns.addSymbol( U ); - ISymbol a1 = table.newSymbol( "a", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol a1 = table.newSymbol( "a", ITypeInfo.t_int ); //$NON-NLS-1$ U.addSymbol( a1 ); - IContainerSymbol V = table.newContainerSymbol( "V", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol V = table.newContainerSymbol( "V", ITypeInfo.t_namespace ); //$NON-NLS-1$ ns.addSymbol( V ); - ISymbol a2 = table.newSymbol( "a", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol a2 = table.newSymbol( "a", ITypeInfo.t_int ); //$NON-NLS-1$ V.addSymbol( a2 ); - IContainerSymbol W = table.newContainerSymbol( "W", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol W = table.newContainerSymbol( "W", ITypeInfo.t_namespace ); //$NON-NLS-1$ ns.addSymbol( W ); - ISymbol a3 = table.newSymbol( "a", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol a3 = table.newSymbol( "a", ITypeInfo.t_int ); //$NON-NLS-1$ W.addSymbol( a3 ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ ns.addSymbol( f ); f.addUsingDirective( U ); @@ -2875,13 +2885,13 @@ public class ParserSymbolTableTest extends TestCase { public void testQualifiedUnqualifiedLookup() throws Exception{ newTable(); - ISymbol i = table.newSymbol( "i", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol i = table.newSymbol( "i", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( i ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A ); - IParameterizedSymbol g = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol g = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ A.addSymbol( g ); assertEquals( null, A.qualifiedLookup( "i" ) ); //$NON-NLS-1$ @@ -2905,12 +2915,12 @@ public class ParserSymbolTableTest extends TestCase { public void testVisibilityDetermination() throws Exception{ newTable(); - IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( D ); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ - ISymbol i = table.newSymbol( "i", TypeInfo.t_int ); //$NON-NLS-1$ - ISymbol j = table.newSymbol( "j", TypeInfo.t_int ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ + ISymbol i = table.newSymbol( "i", ITypeInfo.t_int ); //$NON-NLS-1$ + ISymbol j = table.newSymbol( "j", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A ); @@ -2937,11 +2947,11 @@ public class ParserSymbolTableTest extends TestCase { extension = new StandardSymbolExtension( j, (ASTSymbol) field ); j.setASTExtension( extension ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ B.addParent( A, false, ASTAccessVisibility.PRIVATE, 0, null ); table.getCompilationUnit().addSymbol( B ); - IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C", ITypeInfo.t_class ); //$NON-NLS-1$ C.addParent( B ); C.addParent( A ); table.getCompilationUnit().addSymbol( C ); @@ -2971,31 +2981,31 @@ public class ParserSymbolTableTest extends TestCase { */ public void testPrefixFiltering() throws Exception{ newTable( ParserLanguage.CPP, ParserMode.COMPLETION_PARSE ); - IDerivableContainerSymbol a1 = table.newDerivableContainerSymbol( "a1", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol a1 = table.newDerivableContainerSymbol( "a1", ITypeInfo.t_struct ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( a1 ); - IParameterizedSymbol aFoo = table.newParameterizedSymbol( "aFoo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol aFoo = table.newParameterizedSymbol( "aFoo", ITypeInfo.t_function ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( aFoo ); - ISymbol aa = table.newSymbol( "aa", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol aa = table.newSymbol( "aa", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( aa ); - IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A2", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A2 = table.newDerivableContainerSymbol( "A2", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A2 ); - IDerivableContainerSymbol a3 = table.newDerivableContainerSymbol( "a3", TypeInfo.t_struct ); //$NON-NLS-1$ + IDerivableContainerSymbol a3 = table.newDerivableContainerSymbol( "a3", ITypeInfo.t_struct ); //$NON-NLS-1$ A2.addSymbol( a3 ); - ISymbol a3_int = table.newSymbol( "a3", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol a3_int = table.newSymbol( "a3", ITypeInfo.t_int ); //$NON-NLS-1$ A2.addSymbol( a3_int ); - IParameterizedSymbol aF = table.newParameterizedSymbol( "aF", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol aF = table.newParameterizedSymbol( "aF", ITypeInfo.t_function ); //$NON-NLS-1$ A2.addSymbol( aF ); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ A2.addSymbol( f ); - ISymbol aLocal = table.newSymbol( "aLocal", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol aLocal = table.newSymbol( "aLocal", ITypeInfo.t_int ); //$NON-NLS-1$ f.addSymbol( aLocal ); List results = f.prefixLookup( new TypeFilter( LookupKind.STRUCTURES ), "A", false, null ); //$NON-NLS-1$ @@ -3048,14 +3058,14 @@ public class ParserSymbolTableTest extends TestCase { public void testBug43110_Ellipses() throws Exception{ newTable(); - IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ foo.setHasVariableArgs( true ); table.getCompilationUnit().addSymbol( foo ); List params = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ); params.add( p1 ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$ @@ -3074,18 +3084,18 @@ public class ParserSymbolTableTest extends TestCase { public void testBug43110_EllipsesRanking() throws Exception{ newTable(); - IParameterizedSymbol foo1 = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol foo1 = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ foo1.setHasVariableArgs( true ); table.getCompilationUnit().addSymbol( foo1 ); - IParameterizedSymbol foo2 = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ - foo2.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol foo2 = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ + foo2.addParameter( ITypeInfo.t_int, 0, null, false ); table.getCompilationUnit().addSymbol( foo2 ); List params = new ArrayList(); - TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null ); + ITypeInfo p1 = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ); params.add( p1 ); ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$ @@ -3104,11 +3114,11 @@ public class ParserSymbolTableTest extends TestCase { public void testBug43110_ElipsesRanking_2() throws Exception{ newTable(); - IParameterizedSymbol foo1 = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ - foo1.addParameter( TypeInfo.t_int, 0, null, true ); + IParameterizedSymbol foo1 = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ + foo1.addParameter( ITypeInfo.t_int, 0, null, true ); table.getCompilationUnit().addSymbol( foo1 ); - IParameterizedSymbol foo2 = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol foo2 = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ foo2.setHasVariableArgs( true ); table.getCompilationUnit().addSymbol( foo2 ); @@ -3132,20 +3142,20 @@ public class ParserSymbolTableTest extends TestCase { public void testIterator_1() throws Exception{ newTable(); - ISymbol global = table.newSymbol( "global", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol global = table.newSymbol( "global", ITypeInfo.t_int ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( global ); - IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( cls ); - IParameterizedSymbol constructor = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$ + IParameterizedSymbol constructor = table.newParameterizedSymbol( "A", ITypeInfo.t_constructor ); //$NON-NLS-1$ cls.addConstructor( constructor ); - ISymbol var = table.newSymbol( "var", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol var = table.newSymbol( "var", ITypeInfo.t_int ); //$NON-NLS-1$ cls.addSymbol( var ); - IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ cls.addSymbol( foo ); @@ -3179,25 +3189,25 @@ public class ParserSymbolTableTest extends TestCase { public void testIterator_2() throws Exception{ newTable(); - IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", ITypeInfo.t_function ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( foo ); - IContainerSymbol nsA = table.newContainerSymbol( "A", TypeInfo.t_namespace ); //$NON-NLS-1$ + IContainerSymbol nsA = table.newContainerSymbol( "A", ITypeInfo.t_namespace ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( nsA ); - IParameterizedSymbol bar1 = table.newParameterizedSymbol( "bar", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol bar1 = table.newParameterizedSymbol( "bar", ITypeInfo.t_function ); //$NON-NLS-1$ nsA.addSymbol( bar1 ); - IParameterizedSymbol bar2 = table.newParameterizedSymbol( "bar", TypeInfo.t_function ); //$NON-NLS-1$ - bar2.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol bar2 = table.newParameterizedSymbol( "bar", ITypeInfo.t_function ); //$NON-NLS-1$ + bar2.addParameter( ITypeInfo.t_int, 0, null, false ); nsA.addSymbol( bar2 ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B", TypeInfo.t_class); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B", ITypeInfo.t_class); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( B ); B.addCopyConstructor(); - IParameterizedSymbol func = table.newParameterizedSymbol( "func", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol func = table.newParameterizedSymbol( "func", ITypeInfo.t_function ); //$NON-NLS-1$ B.addSymbol( func ); IUsingDirectiveSymbol using = func.addUsingDirective( nsA ); @@ -3225,7 +3235,7 @@ public class ParserSymbolTableTest extends TestCase { ISymbol copy = (ISymbol) iter.next(); assertTrue( copy instanceof IParameterizedSymbol ); assertEquals( copy.getName(), "B" ); //$NON-NLS-1$ - assertEquals( copy.getType(), TypeInfo.t_constructor ); + assertEquals( copy.getType(), ITypeInfo.t_constructor ); assertEquals( iter.next(), func ); assertFalse( iter.hasNext() ); @@ -3253,22 +3263,22 @@ public class ParserSymbolTableTest extends TestCase { */ public void testLongLong() throws Exception{ newTable(); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_int, TypeInfo.isLongLong, null, false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_int, ITypeInfo.isLongLong, null, false ); table.getCompilationUnit().addSymbol( f1 ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_int, TypeInfo.isLong, null, false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_int, ITypeInfo.isLong, null, false ); table.getCompilationUnit().addSymbol( f2 ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLong, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, ITypeInfo.isLong, null ) ); IParameterizedSymbol lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( lookup, f2 ); params.clear(); - params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLongLong, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, ITypeInfo.isLongLong, null ) ); lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( lookup, f1 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -3291,34 +3301,34 @@ public class ParserSymbolTableTest extends TestCase { public void testComplex() throws Exception{ newTable(); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f.addParameter( TypeInfo.t_float, TypeInfo.isComplex, null, false ); + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f.addParameter( ITypeInfo.t_float, ITypeInfo.isComplex, null, false ); table.getCompilationUnit().addSymbol( f ); - IParameterizedSymbol g = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ - g.addParameter( TypeInfo.t_float, 0, null, false ); + IParameterizedSymbol g = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ + g.addParameter( ITypeInfo.t_float, 0, null, false ); table.getCompilationUnit().addSymbol( g ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isComplex, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_float, ITypeInfo.isComplex, null ) ); IParameterizedSymbol lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( lookup, f ); params.clear(); - params.add( new TypeInfo( TypeInfo.t_float, 0, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_float, 0, null ) ); lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( lookup, f ); params.clear(); - params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isComplex, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_float, ITypeInfo.isComplex, null ) ); lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "g", params ); //$NON-NLS-1$ assertEquals( lookup, g ); params.clear(); - params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isImaginary, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_float, ITypeInfo.isImaginary, null ) ); lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "g", params ); //$NON-NLS-1$ assertEquals( lookup, g ); @@ -3330,18 +3340,18 @@ public class ParserSymbolTableTest extends TestCase { public void test_Bool() throws Exception{ newTable(); - IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f.addParameter( TypeInfo.t__Bool, 0, null, false ); + IParameterizedSymbol f = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f.addParameter( ITypeInfo.t__Bool, 0, null, false ); table.getCompilationUnit().addSymbol( f ); - IParameterizedSymbol g = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ - g.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol g = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ + g.addParameter( ITypeInfo.t_int, 0, null, false ); table.getCompilationUnit().addSymbol( g ); List params = new ArrayList(); - params.add( new TypeInfo( TypeInfo.t__Bool, 0, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t__Bool, 0, null ) ); IParameterizedSymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f ); @@ -3350,7 +3360,7 @@ public class ParserSymbolTableTest extends TestCase { assertEquals( look, g ); params.clear(); - params.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -3367,14 +3377,14 @@ public class ParserSymbolTableTest extends TestCase { public void testBug47636FunctionParameterComparisons_1() throws Exception{ newTable(); - ISymbol Int = table.newSymbol( "Int", TypeInfo.t_type ); //$NON-NLS-1$ - Int.getTypeInfo().setBit( true, TypeInfo.isTypedef ); - Int.setTypeSymbol( table.newSymbol( ParserSymbolTable.EMPTY_NAME, TypeInfo.t_int ) ); + ISymbol Int = table.newSymbol( "Int", ITypeInfo.t_type ); //$NON-NLS-1$ + Int.getTypeInfo().setBit( true, ITypeInfo.isTypedef ); + Int.setTypeSymbol( table.newSymbol( ParserSymbolTable.EMPTY_NAME, ITypeInfo.t_int ) ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_int, 0, null, false ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ f2.addParameter( Int, 0, null, false ); assertTrue( f1.hasSameParameters( f2 ) ); @@ -3388,11 +3398,11 @@ public class ParserSymbolTableTest extends TestCase { public void testBug47636FunctionParameterComparisons_2() throws Exception{ newTable(); - IParameterizedSymbol g1 = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ - g1.addParameter( TypeInfo.t_char, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol g1 = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ + g1.addParameter( ITypeInfo.t_char, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); - IParameterizedSymbol g2 = table.newParameterizedSymbol( "g", TypeInfo.t_function ); //$NON-NLS-1$ - g2.addParameter( TypeInfo.t_char, 0, new PtrOp( PtrOp.t_array ), false ); + IParameterizedSymbol g2 = table.newParameterizedSymbol( "g", ITypeInfo.t_function ); //$NON-NLS-1$ + g2.addParameter( ITypeInfo.t_char, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_array ), false ); assertTrue( g1.hasSameParameters( g2 ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -3405,14 +3415,14 @@ public class ParserSymbolTableTest extends TestCase { public void testBug47636FunctionParameterComparisons_3() throws Exception{ newTable(); - IParameterizedSymbol f = table.newParameterizedSymbol( ParserSymbolTable.EMPTY_NAME, TypeInfo.t_function ); - f.setReturnType( table.newSymbol( ParserSymbolTable.EMPTY_NAME, TypeInfo.t_int ) ); + IParameterizedSymbol f = table.newParameterizedSymbol( ParserSymbolTable.EMPTY_NAME, ITypeInfo.t_function ); + f.setReturnType( table.newSymbol( ParserSymbolTable.EMPTY_NAME, ITypeInfo.t_int ) ); - IParameterizedSymbol h1 = table.newParameterizedSymbol( "h", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol h1 = table.newParameterizedSymbol( "h", ITypeInfo.t_function ); //$NON-NLS-1$ h1.addParameter( f, 0, null, false ); - IParameterizedSymbol h2 = table.newParameterizedSymbol( "h", TypeInfo.t_function ); //$NON-NLS-1$ - h2.addParameter( f, 0, new PtrOp( PtrOp.t_pointer ), false ); + IParameterizedSymbol h2 = table.newParameterizedSymbol( "h", ITypeInfo.t_function ); //$NON-NLS-1$ + h2.addParameter( f, 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ), false ); assertTrue( h1.hasSameParameters( h2 ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -3425,11 +3435,11 @@ public class ParserSymbolTableTest extends TestCase { public void testBug47636FunctionParameterComparisons_4() throws Exception{ newTable(); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f1.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f1.addParameter( ITypeInfo.t_int, 0, null, false ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_int, TypeInfo.isConst, null, false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_int, ITypeInfo.isConst, null, false ); assertTrue( f1.hasSameParameters( f2 ) ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 ); @@ -3438,21 +3448,21 @@ public class ParserSymbolTableTest extends TestCase { public void testBug52111RemoveSymbol() throws Exception{ newTable(); - IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", ITypeInfo.t_class ); //$NON-NLS-1$ table.getCompilationUnit().addSymbol( A ); - ISymbol i = table.newSymbol( "i", TypeInfo.t_int ); //$NON-NLS-1$ + ISymbol i = table.newSymbol( "i", ITypeInfo.t_int ); //$NON-NLS-1$ A.addSymbol( i ); - IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ + IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ A.addSymbol( f1 ); - IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function ); //$NON-NLS-1$ - f2.addParameter( TypeInfo.t_int, 0, null, false ); + IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", ITypeInfo.t_function ); //$NON-NLS-1$ + f2.addParameter( ITypeInfo.t_int, 0, null, false ); A.addSymbol( f2 ); - IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class ); //$NON-NLS-1$ + IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", ITypeInfo.t_class ); //$NON-NLS-1$ B.addParent( A ); table.getCompilationUnit().addSymbol( B ); @@ -3489,7 +3499,7 @@ public class ParserSymbolTableTest extends TestCase { look = B.qualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertNull( look ); - params.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); + params.add( TypeInfoProvider.newTypeInfo( ITypeInfo.t_int, 0, null ) ); look = B.qualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ assertEquals( look, f2 ); diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index f07932465ef..c2fb175fd0e 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -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 Part of PR 68246. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java index 839e1a0e9db..8f9be1b1d93 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java @@ -257,7 +257,54 @@ public interface IASTExpression extends ISourceElementCallbackDelegate, IASTNode 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 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IASTFactoryExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IASTFactoryExtension.java index 91703cb4ce9..5caf91ecdf5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IASTFactoryExtension.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IASTFactoryExtension.java @@ -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.Kind; 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.TypeInfo; /** * @author jcamelon @@ -53,7 +53,7 @@ public interface IASTFactoryExtension { * @param typeId * @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); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/GCCASTExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/GCCASTExtension.java index be1fa7f34fe..68893827b2b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/GCCASTExtension.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/GCCASTExtension.java @@ -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.gcc.ASTGCCDesignator; 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.TypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider; /** * @author jcamelon @@ -68,35 +69,34 @@ public abstract class GCCASTExtension implements IASTFactoryExtension { /* (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) */ - public TypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId) { - TypeInfo info = null; + public ITypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId) { + ITypeInfo info = null; if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID || kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION ) { - info = new TypeInfo(); - info.setType(TypeInfo.t_int); - info.setBit(true, TypeInfo.isUnsigned); + info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_int ); + info.setBit(true, ITypeInfo.isUnsigned); } else if( kind == IASTGCCExpression.Kind.RELATIONAL_MAX || kind == IASTGCCExpression.Kind.RELATIONAL_MIN ) { 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 ) { 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 ) { if( lhs instanceof ASTExpression ) - info = new TypeInfo( ((ASTExpression)lhs).getResultType().getResult() ); + info = TypeInfoProvider.newTypeInfo( ((ASTExpression)lhs).getResultType().getResult() ); } if( info != null ) return info; - return new TypeInfo(); + return TypeInfoProvider.newTypeInfo(); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java index 48c62127cd5..82c5249784b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTExpression.java @@ -23,8 +23,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId; 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.ISymbol; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; -import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider; /** * @author jcamelon @@ -177,13 +177,13 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression public IContainerSymbol getLookupQualificationSymbol() throws LookupError { ExpressionResult result = getResultType(); - TypeInfo type = (result != null ) ? result.getResult() : null; + ITypeInfo type = (result != null ) ? result.getResult() : null; IContainerSymbol containerSymbol = null; if( type != null && type.getTypeSymbol() != null ){ TypeInfoProvider provider = type.getTypeSymbol().getSymbolTable().getTypeInfoProvider(); type = type.getFinalType( provider ); - if( type.isType( TypeInfo.t_type ) && + if( type.isType( ITypeInfo.t_type ) && type.getTypeSymbol() != null && type.getTypeSymbol() instanceof IContainerSymbol ) { containerSymbol = (IContainerSymbol) type.getTypeSymbol(); @@ -196,15 +196,15 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression public boolean shouldFilterLookupResult( ISymbol symbol ){ ExpressionResult result = getResultType(); - TypeInfo type = ( result != null ) ? result.getResult() : null; + ITypeInfo type = ( result != null ) ? result.getResult() : null; if( type != null ){ boolean answer = false; TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider(); 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; - if( type.checkBit( TypeInfo.isVolatile ) && !symbol.getTypeInfo().checkBit( TypeInfo.isVolatile ) ) + if( type.checkBit( ITypeInfo.isVolatile ) && !symbol.getTypeInfo().checkBit( ITypeInfo.isVolatile ) ) answer = true; provider.returnTypeInfo( type ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java index e13310175a6..a5bbebfab0b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java @@ -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.NamedOffsets; 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 @@ -79,7 +79,7 @@ public class ASTFunction extends ASTScope implements IASTFunction */ public boolean isInline() { - return symbol.getTypeInfo().checkBit( TypeInfo.isInline ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isInline ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTFunction#isFriend() @@ -93,7 +93,7 @@ public class ASTFunction extends ASTScope implements IASTFunction */ public boolean isStatic() { - return symbol.getTypeInfo().checkBit( TypeInfo.isStatic ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isStatic ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java index 037ed86559d..0f51b271b10 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java @@ -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.IParameterizedSymbol; 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.ParserSymbolTableError; 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.TypeInfo; /** * @author jcamelon @@ -78,14 +78,14 @@ public class ASTMethod extends ASTFunction implements IASTMethod */ public boolean isVirtual() { - return symbol.getTypeInfo().checkBit( TypeInfo.isVirtual ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isVirtual ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isExplicit() */ public boolean isExplicit() { - return symbol.getTypeInfo().checkBit( TypeInfo.isExplicit); + return symbol.getTypeInfo().checkBit( ITypeInfo.isExplicit); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isConstructor() @@ -106,14 +106,14 @@ public class ASTMethod extends ASTFunction implements IASTMethod */ public boolean isConst() { - return symbol.getTypeInfo().checkBit( TypeInfo.isConst); + return symbol.getTypeInfo().checkBit( ITypeInfo.isConst); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVolatile() */ public boolean isVolatile() { - return symbol.getTypeInfo().checkBit( TypeInfo.isVolatile ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isVolatile ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isPureVirtual() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSimpleTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSimpleTypeSpecifier.java index e90e4d091a2..3a523498930 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSimpleTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSimpleTypeSpecifier.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; 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.pst.ISymbol; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo; /** * @author jcamelon @@ -49,23 +49,23 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe */ public Type getType() { - if( symbol.getType() == TypeInfo.t_int ) + if( symbol.getType() == ITypeInfo.t_int ) return IASTSimpleTypeSpecifier.Type.INT; - if( symbol.getType() == TypeInfo.t_double ) + if( symbol.getType() == ITypeInfo.t_double ) return IASTSimpleTypeSpecifier.Type.DOUBLE; - if( symbol.getType() == TypeInfo.t_float ) + if( symbol.getType() == ITypeInfo.t_float ) return IASTSimpleTypeSpecifier.Type.FLOAT; - if( symbol.getType() == TypeInfo.t_bool ) + if( symbol.getType() == ITypeInfo.t_bool ) return IASTSimpleTypeSpecifier.Type.BOOL; - if( symbol.getType() == TypeInfo.t_type ) + if( symbol.getType() == ITypeInfo.t_type ) return IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; - if( symbol.getType() == TypeInfo.t_char ) + if( symbol.getType() == ITypeInfo.t_char ) return IASTSimpleTypeSpecifier.Type.CHAR; - if( symbol.getType() == TypeInfo.t_void ) + if( symbol.getType() == ITypeInfo.t_void ) return IASTSimpleTypeSpecifier.Type.VOID; - if( symbol.getType() == TypeInfo.t_wchar_t) + if( symbol.getType() == ITypeInfo.t_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.UNSPECIFIED; @@ -83,28 +83,28 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe */ public boolean isLong() { - return symbol.getTypeInfo().checkBit( TypeInfo.isLong ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isLong ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isShort() */ public boolean isShort() { - return symbol.getTypeInfo().checkBit( TypeInfo.isShort ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isShort ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isSigned() */ public boolean isSigned() { - return symbol.getTypeInfo().checkBit( TypeInfo.isSigned); + return symbol.getTypeInfo().checkBit( ITypeInfo.isSigned); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isUnsigned() */ public boolean isUnsigned() { - return symbol.getTypeInfo().checkBit( TypeInfo.isUnsigned ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isUnsigned ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isTypename() @@ -139,7 +139,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe */ public boolean isComplex() { - return symbol.getTypeInfo().checkBit( TypeInfo.isComplex ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isComplex ); } /* (non-Javadoc) @@ -147,7 +147,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe */ public boolean isImaginary() { - return symbol.getTypeInfo().checkBit( TypeInfo.isImaginary ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isImaginary ); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbol.java index 99b0e3a2fcd..e03d493281e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTSymbol.java @@ -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.ISymbol; 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.TypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider; /** * @author jcamelon @@ -44,8 +44,8 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner, public IContainerSymbol getLookupQualificationSymbol() throws LookupError { ISymbol sym = getSymbol(); IContainerSymbol result = null; - ParserSymbolTable.TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider(); - TypeInfo info = null; + TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider(); + ITypeInfo info = null; try{ info = sym.getTypeInfo().getFinalType( provider ); @@ -53,7 +53,7 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner, 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(); else if( sym instanceof IContainerSymbol ) result = (IContainerSymbol) sym; @@ -64,18 +64,18 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner, public boolean shouldFilterLookupResult( ISymbol sym ){ boolean result = false; - ParserSymbolTable.TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider(); - TypeInfo info = null; + TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider(); + ITypeInfo info = null; try{ info = getSymbol().getTypeInfo().getFinalType( provider ); } catch( ParserSymbolTableError e ){ return true; } - if( info.checkBit( TypeInfo.isConst ) && !sym.getTypeInfo().checkBit( TypeInfo.isConst ) ) + if( info.checkBit( ITypeInfo.isConst ) && !sym.getTypeInfo().checkBit( ITypeInfo.isConst ) ) result = true; - if( info.checkBit( TypeInfo.isVolatile ) && !sym.getTypeInfo().checkBit( TypeInfo.isVolatile ) ) + if( info.checkBit( ITypeInfo.isVolatile ) && !sym.getTypeInfo().checkBit( ITypeInfo.isVolatile ) ) result = true; provider.returnTypeInfo( info ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTemplateParameter.java index 9c298bba285..ee4d150e827 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTemplateParameter.java @@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId; import org.eclipse.cdt.core.parser.ast.IReferenceManager; 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.TypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo; /** * @author aniefer @@ -67,11 +67,11 @@ public class ASTTemplateParameter extends ASTSymbol implements IASTTemplateParam * @see org.eclipse.cdt.core.parser.ast.IASTTemplateParameter#getTemplateParameterKind() */ public ParamKind getTemplateParameterKind() { - TypeInfo.eType type = symbol.getTypeInfo().getTemplateParameterType(); - if( type == TypeInfo.t_typeName ) + ITypeInfo.eType type = symbol.getTypeInfo().getTemplateParameterType(); + if( type == ITypeInfo.t_typeName ) //TODO: difference between class & typename? return ParamKind.TYPENAME; - else if( type == TypeInfo.t_template ) + else if( type == ITypeInfo.t_template ) return ParamKind.TEMPLATE_LIST; else return ParamKind.PARAMETER; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java index ea100559091..4e8898ec139 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java @@ -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.NamedOffsets; 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 @@ -64,35 +64,35 @@ public class ASTVariable extends ASTSymbol implements IASTVariable */ public boolean isAuto() { - return symbol.getTypeInfo().checkBit( TypeInfo.isAuto ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isAuto ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isRegister() */ public boolean isRegister() { - return symbol.getTypeInfo().checkBit( TypeInfo.isRegister); + return symbol.getTypeInfo().checkBit( ITypeInfo.isRegister); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isStatic() */ public boolean isStatic() { - return symbol.getTypeInfo().checkBit( TypeInfo.isStatic); + return symbol.getTypeInfo().checkBit( ITypeInfo.isStatic); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isExtern() */ public boolean isExtern() { - return symbol.getTypeInfo().checkBit( TypeInfo.isExtern ); + return symbol.getTypeInfo().checkBit( ITypeInfo.isExtern ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTVariable#isMutable() */ public boolean isMutable() { - return symbol.getTypeInfo().checkBit( TypeInfo.isMutable); + return symbol.getTypeInfo().checkBit( ITypeInfo.isMutable); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTVariable#getAbstractDeclaration() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java index 8045488fa1c..ea7734b58f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java @@ -91,6 +91,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension; import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner; import org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory; import org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo; import org.eclipse.cdt.internal.core.parser.pst.IUsingDeclarationSymbol; import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol; import org.eclipse.cdt.internal.core.parser.pst.NamespaceSymbolExtension; @@ -99,10 +100,8 @@ 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.StandardSymbolExtension; import org.eclipse.cdt.internal.core.parser.pst.TemplateSymbolExtension; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider; import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException; -import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.util.TraceUtil; @@ -117,7 +116,7 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil; public class CompleteParseASTFactory extends BaseASTFactory implements IASTFactory { protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private final static List SUBSCRIPT; + private final static ITypeInfo.OperatorExpression SUBSCRIPT; private final static IProblemFactory problemFactory = new ASTProblemFactory(); private final IFilenameProvider fileProvider; private final ParserMode mode; @@ -129,8 +128,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto static { - SUBSCRIPT = new ArrayList(1); - SUBSCRIPT.add( TypeInfo.OperatorExpression.subscript ); + SUBSCRIPT = ITypeInfo.OperatorExpression.subscript; } static private class LookupType extends Enum { @@ -207,9 +205,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto protected boolean validParameterList(List parameters){ Iterator i = parameters.iterator(); while (i.hasNext()){ - TypeInfo info = (TypeInfo)i.next(); + ITypeInfo info = (ITypeInfo)i.next(); if (info != null){ - if((info.getType() == TypeInfo.t_type) + if((info.getType() == ITypeInfo.t_type) && (info.getTypeSymbol() == null)) return false; }else @@ -218,18 +216,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return true; } - private ISymbol lookupElement (IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, LookupType lookupType ) throws ASTSemanticException { + private ISymbol lookupElement (IContainerSymbol startingScope, String name, ITypeInfo.eType type, List parameters, LookupType lookupType ) throws ASTSemanticException { return lookupElement( startingScope, name, type, parameters, null, lookupType ); } - private ISymbol lookupElement (IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, List arguments, LookupType lookupType ) throws ASTSemanticException { + private ISymbol lookupElement (IContainerSymbol startingScope, String name, ITypeInfo.eType type, List parameters, List arguments, LookupType lookupType ) throws ASTSemanticException { ISymbol result = null; if( startingScope == null ) return null; try { - if((type == TypeInfo.t_function) || (type == TypeInfo.t_constructor)){ + if((type == ITypeInfo.t_function) || (type == ITypeInfo.t_constructor)){ // looking for a function if(validParameterList(parameters)) - if(type == TypeInfo.t_constructor){ + if(type == ITypeInfo.t_constructor){ IDerivableContainerSymbol startingDerivableScope = (IDerivableContainerSymbol) startingScope; result = startingDerivableScope.lookupConstructor( new LinkedList(parameters)); } @@ -271,10 +269,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException{ - return lookupQualifiedName(startingScope, name, TypeInfo.t_any, null, 0, references, throwOnError, lookup ); + return lookupQualifiedName(startingScope, name, ITypeInfo.t_any, null, 0, references, throwOnError, lookup ); } - protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException + protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, ITypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException { ISymbol result = null; if( name == null && throwOnError ) @@ -303,13 +301,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return lookupQualifiedName(startingScope, name, references, throwOnError, LookupType.UNQUALIFIED); } protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException{ - return lookupQualifiedName(startingScope, name, TypeInfo.t_any, null, references, throwOnError, lookup ); + return lookupQualifiedName(startingScope, name, ITypeInfo.t_any, null, references, throwOnError, lookup ); } - protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, TypeInfo.eType type, List parameters, List references, boolean throwOnError ) throws ASTSemanticException{ + protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, ITypeInfo.eType type, List parameters, List references, boolean throwOnError ) throws ASTSemanticException{ return lookupQualifiedName( startingScope, name, type, parameters, references, throwOnError, LookupType.UNQUALIFIED ); } - protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, TypeInfo.eType type, List parameters, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException + protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, ITypeInfo.eType type, List parameters, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException { ISymbol result = null; IToken firstSymbol = null; @@ -631,12 +629,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( namespaceSymbol != null ) { - if( namespaceSymbol.getType() != TypeInfo.t_namespace ) + if( namespaceSymbol.getType() != ITypeInfo.t_namespace ) handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, identifier, nameOffset, nameEndOffset, nameLineNumber, true ); } else { - namespaceSymbol = pst.newContainerSymbol( identifier, TypeInfo.t_namespace ); + namespaceSymbol = pst.newContainerSymbol( identifier, ITypeInfo.t_namespace ); if( identifier.equals( EMPTY_STRING ) ) namespaceSymbol.setContainingSymbol( pstScope ); else @@ -733,7 +731,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto int startingLine, int nameOffset, int nameEndOffset, int nameLine) throws ASTSemanticException { IContainerSymbol currentScopeSymbol = scopeToSymbol(scope); - TypeInfo.eType pstType = classKindToTypeInfo(kind); + ITypeInfo.eType pstType = classKindToTypeInfo(kind); List references = new ArrayList(); String newSymbolName = EMPTY_STRING; @@ -784,9 +782,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( classSymbol != null && classSymbol.getType() != pstType ) { boolean isError = true; - if( classSymbol.isType( TypeInfo.t_class, TypeInfo.t_union ) ) + if( classSymbol.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ) { - if ( ( pstType == TypeInfo.t_class || pstType == TypeInfo.t_struct || pstType == TypeInfo.t_union ) ) + if ( ( pstType == ITypeInfo.t_class || pstType == ITypeInfo.t_struct || pstType == ITypeInfo.t_union ) ) isError = false; } @@ -797,7 +795,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto IDerivableContainerSymbol newSymbol = pst.newDerivableContainerSymbol( newSymbolName, pstType ); if( classSymbol != null ) - classSymbol.setTypeSymbol( newSymbol ); + classSymbol.setForwardSymbol( newSymbol ); List args = null; if( isTemplateId ){ @@ -839,7 +837,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { exp = (ASTExpression) iter.next(); - TypeInfo info = exp.getResultType().getResult(); + ITypeInfo info = exp.getResultType().getResult(); list.add( info ); } @@ -894,18 +892,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } return true; } - protected TypeInfo.eType classKindToTypeInfo(ASTClassKind kind) + protected ITypeInfo.eType classKindToTypeInfo(ASTClassKind kind) { - TypeInfo.eType pstType = null; + ITypeInfo.eType pstType = null; if( kind == ASTClassKind.CLASS ) - pstType = TypeInfo.t_class; + pstType = ITypeInfo.t_class; else if( kind == ASTClassKind.STRUCT ) - pstType = TypeInfo.t_struct; + pstType = ITypeInfo.t_struct; else if( kind == ASTClassKind.UNION ) - pstType = TypeInfo.t_union; + pstType = ITypeInfo.t_union; else if( kind == ASTClassKind.ENUM ) - pstType = TypeInfo.t_enumeration; + pstType = ITypeInfo.t_enumeration; // else // assert false : kind ; return pstType; @@ -970,20 +968,20 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto ASTSymbol definition = i.hasNext() ? (ASTSymbol) i.next() : null; // assert (symbol != null ) : "createReference cannot be called on null symbol "; - if( symbol.getTypeInfo().checkBit( TypeInfo.isTypedef ) || + if( symbol.getTypeInfo().checkBit( ITypeInfo.isTypedef ) || symbol.getASTExtension().getPrimaryDeclaration() instanceof IASTTypedefDeclaration ) return cache.getReference( offset, declaration); - else if( symbol.getType() == TypeInfo.t_namespace ) + else if( symbol.getType() == ITypeInfo.t_namespace ) return cache.getReference( offset, declaration); - else if( symbol.getType() == TypeInfo.t_class || - symbol.getType() == TypeInfo.t_struct || - symbol.getType() == TypeInfo.t_union ) + else if( symbol.getType() == ITypeInfo.t_class || + symbol.getType() == ITypeInfo.t_struct || + symbol.getType() == ITypeInfo.t_union ) return cache.getReference( offset, (ISourceElementCallbackDelegate)symbol.getASTExtension().getPrimaryDeclaration() ); - else if( symbol.getType() == TypeInfo.t_enumeration ) + else if( symbol.getType() == ITypeInfo.t_enumeration ) return cache.getReference( offset, (IASTEnumerationSpecifier)symbol.getASTExtension().getPrimaryDeclaration() ); - else if( symbol.getType() == TypeInfo.t_enumerator ) + else if( symbol.getType() == ITypeInfo.t_enumerator ) return cache.getReference( offset, declaration ); - else if(( symbol.getType() == TypeInfo.t_function ) || (symbol.getType() == TypeInfo.t_constructor)) + else if(( symbol.getType() == ITypeInfo.t_function ) || (symbol.getType() == ITypeInfo.t_constructor)) { ASTNode referenced = (definition != null) ? definition : declaration; if( referenced instanceof IASTMethod ) @@ -991,26 +989,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return cache.getReference( offset, (IASTMethod)referenced ); return cache.getReference( offset, (IASTFunction)referenced ); } - else if( ( symbol.getType() == TypeInfo.t_type ) || - ( symbol.getType() == TypeInfo.t_bool )|| - ( symbol.getType() == TypeInfo.t_char ) || - ( symbol.getType() == TypeInfo.t_wchar_t )|| - ( symbol.getType() == TypeInfo.t_int ) || - ( symbol.getType() == TypeInfo.t_float )|| - ( symbol.getType() == TypeInfo.t_double ) || - ( symbol.getType() == TypeInfo.t_void ) || - ( symbol.getType() == TypeInfo.t__Bool) || - ( symbol.getType() == TypeInfo.t_templateParameter ) ) + else if( ( symbol.getType() == ITypeInfo.t_type ) || + ( symbol.getType() == ITypeInfo.t_bool )|| + ( symbol.getType() == ITypeInfo.t_char ) || + ( symbol.getType() == ITypeInfo.t_wchar_t )|| + ( symbol.getType() == ITypeInfo.t_int ) || + ( symbol.getType() == ITypeInfo.t_float )|| + ( symbol.getType() == ITypeInfo.t_double ) || + ( symbol.getType() == ITypeInfo.t_void ) || + ( symbol.getType() == ITypeInfo.t__Bool) || + ( symbol.getType() == ITypeInfo.t_templateParameter ) ) { - if( symbol.getContainingSymbol().getType() == TypeInfo.t_class || - symbol.getContainingSymbol().getType() == TypeInfo.t_struct || - symbol.getContainingSymbol().getType() == TypeInfo.t_union ) + if( symbol.getContainingSymbol().getType() == ITypeInfo.t_class || + symbol.getContainingSymbol().getType() == ITypeInfo.t_struct || + symbol.getContainingSymbol().getType() == ITypeInfo.t_union ) { return cache.getReference( offset, (definition != null ? definition : declaration )); } - else if( ( symbol.getContainingSymbol().getType() == TypeInfo.t_function || - symbol.getContainingSymbol().getType() == TypeInfo.t_constructor ) && + else if( ( symbol.getContainingSymbol().getType() == ITypeInfo.t_function || + symbol.getContainingSymbol().getType() == ITypeInfo.t_constructor ) && symbol.getContainingSymbol() instanceof IParameterizedSymbol && ((IParameterizedSymbol)symbol.getContainingSymbol()).getParameterList() != null && ((IParameterizedSymbol)symbol.getContainingSymbol()).getParameterList().contains( symbol ) ) @@ -1042,7 +1040,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto int startingLine, int nameOffset, int nameEndOffset, int nameLine) throws ASTSemanticException { IContainerSymbol containerSymbol = scopeToSymbol(scope); - TypeInfo.eType pstType = TypeInfo.t_enumeration; + ITypeInfo.eType pstType = ITypeInfo.t_enumeration; IDerivableContainerSymbol classSymbol = pst.newDerivableContainerSymbol( name, pstType ); try @@ -1071,7 +1069,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { IContainerSymbol enumerationSymbol = (IContainerSymbol)((ISymbolOwner)enumeration).getSymbol(); - ISymbol enumeratorSymbol = pst.newSymbol( name, TypeInfo.t_enumerator ); + ISymbol enumeratorSymbol = pst.newSymbol( name, ITypeInfo.t_enumerator ); try { enumerationSymbol.addSymbol( enumeratorSymbol ); @@ -1156,7 +1154,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto try { symbol = typeId.getTypeSymbol(); - if( symbol.isType( TypeInfo.t_type ) ) + if( symbol.isType( ITypeInfo.t_type ) ) symbol = symbol.getTypeSymbol(); } catch (ASTNotImplementedException e) { return; @@ -1187,9 +1185,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } private boolean createConstructorReference( ISymbol classSymbol, ASTExpression expressionList, ITokenDuple duple, List references ){ - if( classSymbol != null && classSymbol.getTypeInfo().checkBit( TypeInfo.isTypedef ) ){ + if( classSymbol != null && classSymbol.getTypeInfo().checkBit( ITypeInfo.isTypedef ) ){ TypeInfoProvider provider = pst.getTypeInfoProvider(); - TypeInfo info = classSymbol.getTypeInfo().getFinalType( provider ); + ITypeInfo info = classSymbol.getTypeInfo().getFinalType( provider ); classSymbol = info.getTypeSymbol(); provider.returnTypeInfo( info ); } @@ -1303,9 +1301,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto parameters.add(expResult.getResult()); } if( functionScope.equals( startingScope ) ) - symbol = lookupQualifiedName(functionScope, functionId, TypeInfo.t_function, parameters, references, false); + symbol = lookupQualifiedName(functionScope, functionId, ITypeInfo.t_function, parameters, references, false); else - symbol = lookupQualifiedName(functionScope, functionId, TypeInfo.t_function, parameters, references, false, LookupType.QUALIFIED ); + symbol = lookupQualifiedName(functionScope, functionId, ITypeInfo.t_function, parameters, references, false, LookupType.QUALIFIED ); } return symbol; @@ -1324,10 +1322,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto private IContainerSymbol getSearchScope (Kind kind, IASTExpression lhs, IContainerSymbol startingScope) throws ASTSemanticException{ if( kind.isPostfixMemberReference() ) { - TypeInfo lhsInfo = ((ASTExpression)lhs).getResultType().getResult(); + ITypeInfo lhsInfo = ((ASTExpression)lhs).getResultType().getResult(); if(lhsInfo != null){ TypeInfoProvider provider = pst.getTypeInfoProvider(); - TypeInfo info = null; + ITypeInfo info = null; try{ info = lhsInfo.getFinalType( provider ); } catch ( ParserSymbolTableError e ){ @@ -1349,21 +1347,21 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto /* * Conditional Expression conversion */ - protected TypeInfo conditionalExpressionConversions(TypeInfo second, TypeInfo third){ - TypeInfo info = new TypeInfo(); + protected ITypeInfo conditionalExpressionConversions(ITypeInfo second, ITypeInfo third){ + ITypeInfo info = null; if(second.equals(third)){ info = second; return info; } - if((second.getType() == TypeInfo.t_void) && (third.getType() != TypeInfo.t_void)){ + if((second.getType() == ITypeInfo.t_void) && (third.getType() != ITypeInfo.t_void)){ info = third; return info; } - if((second.getType() != TypeInfo.t_void) && (third.getType() == TypeInfo.t_void)){ + if((second.getType() != ITypeInfo.t_void) && (third.getType() == ITypeInfo.t_void)){ info = second; return info; } - if((second.getType() == TypeInfo.t_void) && (third.getType() == TypeInfo.t_void)){ + if((second.getType() == ITypeInfo.t_void) && (third.getType() == ITypeInfo.t_void)){ info = second; return info; } @@ -1379,77 +1377,77 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto * Apply the usual arithmetic conversions to find out the result of an expression * that has a lhs and a rhs as indicated in the specs (section 5.Expressions, page 64) */ - protected TypeInfo usualArithmeticConversions( IASTScope scope, TypeInfo lhs, TypeInfo rhs) throws ASTSemanticException{ + protected ITypeInfo usualArithmeticConversions( IASTScope scope, ITypeInfo lhs, ITypeInfo rhs) throws ASTSemanticException{ // if you have a variable of type basic type, then we need to go to the basic type first - while( (lhs.getType() == TypeInfo.t_type) && (lhs.getTypeSymbol() != null)){ + while( (lhs.getType() == ITypeInfo.t_type) && (lhs.getTypeSymbol() != null)){ lhs = lhs.getTypeSymbol().getTypeInfo(); } - while( (rhs.getType() == TypeInfo.t_type) && (rhs.getTypeSymbol() != null)){ + while( (rhs.getType() == ITypeInfo.t_type) && (rhs.getTypeSymbol() != null)){ rhs = rhs.getTypeSymbol().getTypeInfo(); } - if( !lhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) && - !rhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) ) + if( !lhs.isType(ITypeInfo.t__Bool, ITypeInfo.t_enumerator ) && + !rhs.isType(ITypeInfo.t__Bool, ITypeInfo.t_enumerator ) ) { handleProblem( scope, IProblem.SEMANTIC_INVALID_CONVERSION_TYPE, null ); } - TypeInfo info = new TypeInfo(); + ITypeInfo info = TypeInfoProvider.newTypeInfo( ); if( - ( lhs.checkBit(TypeInfo.isLong) && lhs.getType() == TypeInfo.t_double) - || ( rhs.checkBit(TypeInfo.isLong) && rhs.getType() == TypeInfo.t_double) + ( lhs.checkBit(ITypeInfo.isLong) && lhs.getType() == ITypeInfo.t_double) + || ( rhs.checkBit(ITypeInfo.isLong) && rhs.getType() == ITypeInfo.t_double) ){ - info.setType(TypeInfo.t_double); - info.setBit(true, TypeInfo.isLong); + info.setType(ITypeInfo.t_double); + info.setBit(true, ITypeInfo.isLong); return info; } else if( - ( lhs.getType() == TypeInfo.t_double ) - || ( rhs.getType() == TypeInfo.t_double ) + ( lhs.getType() == ITypeInfo.t_double ) + || ( rhs.getType() == ITypeInfo.t_double ) ){ - info.setType(TypeInfo.t_double); + info.setType(ITypeInfo.t_double); return info; } else if ( - ( lhs.getType() == TypeInfo.t_float ) - || ( rhs.getType() == TypeInfo.t_float ) + ( lhs.getType() == ITypeInfo.t_float ) + || ( rhs.getType() == ITypeInfo.t_float ) ){ - info.setType(TypeInfo.t_float); + info.setType(ITypeInfo.t_float); return info; } else { // perform intergral promotions (Specs section 4.5) - info.setType(TypeInfo.t_int); + info.setType(ITypeInfo.t_int); } if( - ( lhs.checkBit(TypeInfo.isUnsigned) && lhs.checkBit(TypeInfo.isLong)) - || ( rhs.checkBit(TypeInfo.isUnsigned) && rhs.checkBit(TypeInfo.isLong)) + ( lhs.checkBit(ITypeInfo.isUnsigned) && lhs.checkBit(ITypeInfo.isLong)) + || ( rhs.checkBit(ITypeInfo.isUnsigned) && rhs.checkBit(ITypeInfo.isLong)) ){ - info.setBit(true, TypeInfo.isUnsigned); - info.setBit(true, TypeInfo.isLong); + info.setBit(true, ITypeInfo.isUnsigned); + info.setBit(true, ITypeInfo.isLong); return info; } else if( - ( lhs.checkBit(TypeInfo.isUnsigned) && rhs.checkBit(TypeInfo.isLong) ) - || ( rhs.checkBit(TypeInfo.isUnsigned) && lhs.checkBit(TypeInfo.isLong) ) + ( lhs.checkBit(ITypeInfo.isUnsigned) && rhs.checkBit(ITypeInfo.isLong) ) + || ( rhs.checkBit(ITypeInfo.isUnsigned) && lhs.checkBit(ITypeInfo.isLong) ) ){ - info.setBit(true, TypeInfo.isUnsigned); - info.setBit(true, TypeInfo.isLong); + info.setBit(true, ITypeInfo.isUnsigned); + info.setBit(true, ITypeInfo.isLong); return info; } else if ( - ( lhs.checkBit(TypeInfo.isLong)) - || ( rhs.checkBit(TypeInfo.isLong)) + ( lhs.checkBit(ITypeInfo.isLong)) + || ( rhs.checkBit(ITypeInfo.isLong)) ){ - info.setBit(true, TypeInfo.isLong); + info.setBit(true, ITypeInfo.isLong); return info; } else if ( - ( lhs.checkBit(TypeInfo.isUnsigned) ) - || ( rhs.checkBit(TypeInfo.isUnsigned) ) + ( lhs.checkBit(ITypeInfo.isUnsigned) ) + || ( rhs.checkBit(ITypeInfo.isUnsigned) ) ){ - info.setBit(true, TypeInfo.isUnsigned); + info.setBit(true, ITypeInfo.isUnsigned); return info; } else { // it should be both = int @@ -1457,36 +1455,32 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } } - private TypeInfo addToInfo(ASTExpression exp, boolean flag, int mask) + private ITypeInfo modifyTypeInfo(ASTExpression exp, Kind kind) { // assert exp != null : exp; - TypeInfo info = exp.getResultType().getResult(); - info.setBit(flag, mask); + ITypeInfo info = exp.getResultType().getResult(); + + //short added to a type + if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT ){ + info.setBit( true, ITypeInfo.isShort); + } + // long added to a type + if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG ){ + info.setBit( true, ITypeInfo.isLong); + } + // signed added to a type + if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED ){ + info.setBit( true, ITypeInfo.isUnsigned); + } + // unsigned added to a type + if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED ){ + info.setBit( true, ITypeInfo.isUnsigned); + } + return info; } - protected ExpressionResult getExpressionResultType( - IASTScope scope, - Kind kind, IASTExpression lhs, - IASTExpression rhs, - IASTExpression thirdExpression, - IASTTypeId typeId, - String literal, - ISymbol symbol) throws ASTSemanticException{ - - - TypeInfo info = new TypeInfo(); - - if( extension.canHandleExpressionKind( kind )) - { - extension.getExpressionResultType( kind, lhs, rhs, typeId ); - return new ExpressionResult( info ); - } - - ExpressionResult result = null; - if( literal != null && !literal.equals(EMPTY_STRING) && kind.isLiteral() ){ - info.setDefault( literal ); - } + private void constructBasicType( TypeInfoProvider provider, Kind kind ){ // types that resolve to void if ((kind == IASTExpression.Kind.PRIMARY_EMPTY) || (kind == IASTExpression.Kind.THROWEXPRESSION) @@ -1495,67 +1489,46 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto || (kind == IASTExpression.Kind.DELETE_CASTEXPRESSION) || (kind == IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION) ){ - info.setType(TypeInfo.t_void); - result = new ExpressionResult(info); - return result; + provider.setType( ITypeInfo.t_void ); } // types that resolve to int if ((kind == IASTExpression.Kind.PRIMARY_INTEGER_LITERAL) || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT) ){ - info.setType(TypeInfo.t_int); - result = new ExpressionResult(info); - return result; + provider.setType( ITypeInfo.t_int ); } + // size of is always unsigned int - if ((kind == IASTExpression.Kind.UNARY_SIZEOF_TYPEID) + if((kind == IASTExpression.Kind.UNARY_SIZEOF_TYPEID) || (kind == IASTExpression.Kind.UNARY_SIZEOF_UNARYEXPRESSION) ){ - info.setType(TypeInfo.t_int); - info.setBit(true, TypeInfo.isUnsigned); - result = new ExpressionResult(info); - return result; + provider.setType( ITypeInfo.t_int ); + provider.setTypeBits( ITypeInfo.isUnsigned ); } + // types that resolve to char - if( (kind == IASTExpression.Kind.PRIMARY_CHAR_LITERAL) - || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR)){ - info.setType(TypeInfo.t_char); - // check that this is really only one literal - if(literal.length() > 1){ - // this is a string - info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer)); - } - result = new ExpressionResult(info); - return result; - } - // types that resolve to string - if (kind == IASTExpression.Kind.PRIMARY_STRING_LITERAL){ - info.setType(TypeInfo.t_char); - info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer)); - result = new ExpressionResult(info); - return result; - } + if((kind == IASTExpression.Kind.PRIMARY_CHAR_LITERAL) + || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR) + || (kind == IASTExpression.Kind.PRIMARY_STRING_LITERAL) + ){ + provider.setType( ITypeInfo.t_char ); + } // types that resolve to float - if( (kind == IASTExpression.Kind.PRIMARY_FLOAT_LITERAL) + if((kind == IASTExpression.Kind.PRIMARY_FLOAT_LITERAL) || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT)){ - info.setType(TypeInfo.t_float); - result = new ExpressionResult(info); - return result; + provider.setType( ITypeInfo.t_float ); } - // types that resolve to double + //types that resolve to double if( kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE){ - info.setType(TypeInfo.t_double); - result = new ExpressionResult(info); - return result; - } - // types that resolve to wchar + provider.setType( ITypeInfo.t_double ); + + } + //types that resolve to wchar if(kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART){ - info.setType(TypeInfo.t_wchar_t); - result = new ExpressionResult(info); - return result; + provider.setType( ITypeInfo.t_wchar_t ); } // types that resolve to bool - if( (kind == IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL) + if((kind == IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL) || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL) || (kind == IASTExpression.Kind.RELATIONAL_GREATERTHAN) || (kind == IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO) @@ -1567,38 +1540,61 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto || (kind == IASTExpression.Kind.LOGICALOREXPRESSION) ) { - info.setType(TypeInfo.t_bool); - result = new ExpressionResult(info); - return result; + provider.setType(ITypeInfo.t_bool); } - // short added to a type - if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT ){ - info = addToInfo((ASTExpression)lhs, true, TypeInfo.isShort); - result = new ExpressionResult(info); - return result; + } + protected ExpressionResult getExpressionResultType( + IASTScope scope, + Kind kind, IASTExpression lhs, + IASTExpression rhs, + IASTExpression thirdExpression, + IASTTypeId typeId, + String literal, + ISymbol symbol) throws ASTSemanticException + { + ITypeInfo info = null; + ExpressionResult result = null; + + if( extension.canHandleExpressionKind( kind )) + { + info = extension.getExpressionResultType( kind, lhs, rhs, typeId ); + return new ExpressionResult( info ); } - // long added to a type - if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG ){ - info = addToInfo((ASTExpression)lhs, true, TypeInfo.isLong); - result = new ExpressionResult(info); - return result; + + //basic types + if( kind.isBasicType() ){ + TypeInfoProvider provider = TypeInfoProvider.getProvider( pst ); + provider.beginTypeConstruction(); + + if( literal != null && !literal.equals(EMPTY_STRING) && kind.isLiteral() ){ + provider.setDefaultObj( literal ); + } + + constructBasicType( provider, kind ); + + info = provider.completeConstruction(); + + //types that need a pointer + if( kind == IASTExpression.Kind.PRIMARY_STRING_LITERAL || + (literal.length() > 1 && ( kind == IASTExpression.Kind.PRIMARY_CHAR_LITERAL || + kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR )) ) + { + info.addPtrOperator(new ITypeInfo.PtrOp(ITypeInfo.PtrOp.t_pointer)); + } + + return new ExpressionResult( info ); } - // signed added to a type - if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED ){ - info = addToInfo((ASTExpression)lhs, false, TypeInfo.isUnsigned); - result = new ExpressionResult(info); - return result; - } - // unsigned added to a type - if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED ){ - info = addToInfo((ASTExpression)lhs, true, TypeInfo.isUnsigned); - result = new ExpressionResult(info); - return result; + + // modifications to existing types + if( kind.isPostfixSimpleType() ){ + info = modifyTypeInfo( (ASTExpression)lhs, kind ); + return new ExpressionResult( info ); } + // Id expressions resolve to t_type, symbol already looked up if( kind == IASTExpression.Kind.ID_EXPRESSION ) { - info.setType(TypeInfo.t_type); + info = TypeInfoProvider.newTypeInfo(ITypeInfo.t_type); info.setTypeSymbol(symbol); result = new ExpressionResult(info); if (symbol == null) @@ -1614,8 +1610,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto info = left.getResultType().getResult(); if (info != null){ - info.addOperatorExpression( TypeInfo.OperatorExpression.addressof ); info = info.getFinalType( null ); + info.applyOperatorExpression( ITypeInfo.OperatorExpression.addressof ); } else handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); @@ -1630,8 +1626,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); info = left.getResultType().getResult(); if (info != null){ - info.addOperatorExpression( TypeInfo.OperatorExpression.indirection ); info = info.getFinalType( null ); + info.applyOperatorExpression( ITypeInfo.OperatorExpression.indirection ); }else handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); @@ -1646,8 +1642,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto info = left.getResultType().getResult(); if ((info != null)) { - info.addOperatorExpression( TypeInfo.OperatorExpression.subscript ); info = info.getFinalType( null ); + info.applyOperatorExpression( ITypeInfo.OperatorExpression.subscript ); }else { handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); } @@ -1661,7 +1657,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto || (kind == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP) ){ if(symbol != null){ - info = new TypeInfo(symbol.getTypeInfo()); + info = TypeInfoProvider.newTypeInfo( symbol.getTypeInfo() ); } result = new ExpressionResult(info); return result; @@ -1675,8 +1671,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); info = right.getResultType().getResult(); if ((info != null) && (symbol != null)){ - info.addOperatorExpression( TypeInfo.OperatorExpression.indirection ); info.setTypeSymbol(symbol); + info = info.getFinalType( null ); + info.applyOperatorExpression( ITypeInfo.OperatorExpression.indirection ); + } else handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); @@ -1687,7 +1685,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if (kind == IASTExpression.Kind.PRIMARY_THIS){ if(symbol != null) { - info.setType(TypeInfo.t_type); + info = TypeInfoProvider.newTypeInfo(ITypeInfo.t_type); info.setTypeSymbol(symbol); } else handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); @@ -1701,8 +1699,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto ASTExpression right = (ASTExpression)rhs; ASTExpression third = (ASTExpression)thirdExpression; if((right != null ) && (third != null)){ - TypeInfo rightType =right.getResultType().getResult(); - TypeInfo thirdType =third.getResultType().getResult(); + ITypeInfo rightType =right.getResultType().getResult(); + ITypeInfo thirdType =third.getResultType().getResult(); if((rightType != null) && (thirdType != null)){ info = conditionalExpressionConversions(rightType, thirdType); } else @@ -1721,7 +1719,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto try { info = typeId.getTypeSymbol().getTypeInfo(); - info.addPtrOperator( new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer)); + info.addPtrOperator( new ITypeInfo.PtrOp(ITypeInfo.PtrOp.t_pointer)); } catch (ASTNotImplementedException e) { @@ -1743,8 +1741,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto ASTExpression left = (ASTExpression)lhs; ASTExpression right = (ASTExpression)rhs; if((left != null ) && (right != null)){ - TypeInfo leftType =left.getResultType().getResult(); - TypeInfo rightType =right.getResultType().getResult(); + ITypeInfo leftType =left.getResultType().getResult(); + ITypeInfo rightType =right.getResultType().getResult(); info = usualArithmeticConversions( scope, leftType, rightType); } else @@ -1796,7 +1794,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto || ( kind == IASTExpression.Kind.POSTFIX_CONST_CAST ) ){ try{ - info = new TypeInfo(typeId.getTypeSymbol().getTypeInfo()); + info = TypeInfoProvider.newTypeInfo(typeId.getTypeSymbol().getTypeInfo()); }catch (ASTNotImplementedException e) { // will never happen @@ -1808,11 +1806,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if(kind == IASTExpression.Kind.EXPRESSIONLIST){ result = new ExpressionResultList(); if(lhs != null){ - TypeInfo leftType = ((ASTExpression)lhs).getResultType().getResult(); + ITypeInfo leftType = ((ASTExpression)lhs).getResultType().getResult(); result.setResult(leftType); } if(rhs != null){ - TypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult(); + ITypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult(); result.setResult(rightType); } return result; @@ -1823,12 +1821,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol; ISymbol returnTypeSymbol = psymbol.getReturnType(); if(returnTypeSymbol != null){ - info.setType(returnTypeSymbol.getType()); - info.setTypeSymbol(returnTypeSymbol); + info = TypeInfoProvider.newTypeInfo(returnTypeSymbol.getTypeInfo()); + //info.setTypeSymbol(returnTypeSymbol); }else { // this is call to a constructor } - } + } else { + info = TypeInfoProvider.newTypeInfo(); + } result = new ExpressionResult(info); if(symbol == null) result.setFailedToDereference(true); @@ -1853,7 +1853,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto || ( kind == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) ) { if(symbol != null){ - info.setType(TypeInfo.t_type); + info = TypeInfoProvider.newTypeInfo(ITypeInfo.t_type); info.setTypeSymbol(symbol); } else handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); @@ -1968,24 +1968,24 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return query; } - TypeInfo.eType type = null; + ITypeInfo.eType type = null; if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME ) - type = TypeInfo.t_type; + type = ITypeInfo.t_type; else if( kind == IASTSimpleTypeSpecifier.Type.BOOL ) - type = TypeInfo.t_bool; + type = ITypeInfo.t_bool; else if( kind == IASTSimpleTypeSpecifier.Type.CHAR ) - type = TypeInfo.t_char; + type = ITypeInfo.t_char; else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE ||kind == IASTSimpleTypeSpecifier.Type.FLOAT ) - type = TypeInfo.t_double; + type = ITypeInfo.t_double; else if( kind == IASTSimpleTypeSpecifier.Type.INT ) - type = TypeInfo.t_int; + type = ITypeInfo.t_int; else if( kind == IASTSimpleTypeSpecifier.Type.VOID ) - type = TypeInfo.t_void; + type = ITypeInfo.t_void; else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T) - type = TypeInfo.t_wchar_t; + type = ITypeInfo.t_wchar_t; else if( kind == IASTSimpleTypeSpecifier.Type._BOOL ) - type = TypeInfo.t__Bool; + type = ITypeInfo.t__Bool; List references = ( kind == Type.CLASS_OR_TYPENAME ) ? new ArrayList( DEFAULT_QUALIFIEDNAME_REFERENCE_SIZE ): null; ISymbol s = pst.newSymbol( EMPTY_STRING, type ); @@ -2052,12 +2052,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto s.setTypeSymbol( typeSymbol ); } - s.getTypeInfo().setBit( isLong, TypeInfo.isLong ); - s.getTypeInfo().setBit( isShort, TypeInfo.isShort); - s.getTypeInfo().setBit( isUnsigned, TypeInfo.isUnsigned ); - s.getTypeInfo().setBit( isComplex, TypeInfo.isComplex ); - s.getTypeInfo().setBit( isImaginary, TypeInfo.isImaginary ); - s.getTypeInfo().setBit( isSigned, TypeInfo.isSigned ); + s.getTypeInfo().setBit( isLong, ITypeInfo.isLong ); + s.getTypeInfo().setBit( isShort, ITypeInfo.isShort); + s.getTypeInfo().setBit( isUnsigned, ITypeInfo.isUnsigned ); + s.getTypeInfo().setBit( isComplex, ITypeInfo.isComplex ); + s.getTypeInfo().setBit( isImaginary, ITypeInfo.isImaginary ); + s.getTypeInfo().setBit( isSigned, ITypeInfo.isSigned ); IASTSimpleTypeSpecifier result = new ASTSimpleTypeSpecifier( s, false, typeNameAsString, references ); if( kind != Type.CLASS_OR_TYPENAME ) @@ -2108,9 +2108,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto parentScope = ((IDeferredTemplateInstance) symbol).getTemplate().getTemplatedSymbol(); if((parentScope != null) && - ( (parentScope.getType() == TypeInfo.t_class) - || (parentScope.getType() == TypeInfo.t_struct) - || (parentScope.getType() == TypeInfo.t_union)) + ( (parentScope.getType() == ITypeInfo.t_class) + || (parentScope.getType() == ITypeInfo.t_struct) + || (parentScope.getType() == ITypeInfo.t_union)) ){ if( parentScope.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier ){ //we are trying to define a member of a class for which we only have a forward declaration @@ -2143,7 +2143,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } } - IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.extractNameFromTemplateId(), TypeInfo.t_function ); + IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.extractNameFromTemplateId(), ITypeInfo.t_function ); setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol); symbol.setHasVariableArgs( hasVariableArguments ); @@ -2169,13 +2169,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto IParameterizedSymbol functionDeclaration = null; functionDeclaration = - (IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getImage(), TypeInfo.t_function, functionParameters, 0, null, false, LookupType.FORDEFINITION ); + (IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getImage(), ITypeInfo.t_function, functionParameters, 0, null, false, LookupType.FORDEFINITION ); - if( functionDeclaration != null && symbol.isType( TypeInfo.t_function )){ + if( functionDeclaration != null && symbol.isType( ITypeInfo.t_function )){ previouslyDeclared = true; if( isFunctionDefinition ){ - functionDeclaration.setTypeSymbol( symbol ); + functionDeclaration.setForwardSymbol( symbol ); } } @@ -2203,9 +2203,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto boolean isStatic, IParameterizedSymbol symbol) { - symbol.getTypeInfo().setBit( isInline, TypeInfo.isInline ); - symbol.getTypeInfo().setBit( isFriend, TypeInfo.isFriend ); - symbol.getTypeInfo().setBit( isStatic, TypeInfo.isStatic ); + symbol.getTypeInfo().setBit( isInline, ITypeInfo.isInline ); + symbol.getTypeInfo().setBit( isFriend, ITypeInfo.isFriend ); + symbol.getTypeInfo().setBit( isStatic, ITypeInfo.isStatic ); } /** @@ -2220,67 +2220,69 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } } - protected TypeInfo getParameterTypeInfo( IASTAbstractDeclaration absDecl)throws ASTSemanticException{ - TypeInfo type = new TypeInfo(); + protected ITypeInfo getParameterTypeInfo( IASTAbstractDeclaration absDecl)throws ASTSemanticException{ + TypeInfoProvider provider = TypeInfoProvider.getProvider( pst ); + provider.beginTypeConstruction(); if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ) { IASTSimpleTypeSpecifier simpleType = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()); IASTSimpleTypeSpecifier.Type kind = simpleType.getType(); if( kind == IASTSimpleTypeSpecifier.Type.BOOL ) - type.setType(TypeInfo.t_bool); + provider.setType(ITypeInfo.t_bool); else if( kind == IASTSimpleTypeSpecifier.Type.CHAR ) - type.setType(TypeInfo.t_char); + provider.setType(ITypeInfo.t_char); else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE ) - type.setType(TypeInfo.t_double); + provider.setType(ITypeInfo.t_double); else if( kind == IASTSimpleTypeSpecifier.Type.FLOAT ) - type.setType(TypeInfo.t_float); + provider.setType(ITypeInfo.t_float); else if( kind == IASTSimpleTypeSpecifier.Type.INT ) - type.setType(TypeInfo.t_int); + provider.setType(ITypeInfo.t_int); else if( kind == IASTSimpleTypeSpecifier.Type.VOID ) - type.setType(TypeInfo.t_void); + provider.setType(ITypeInfo.t_void); else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T) - type.setType(TypeInfo.t_wchar_t); + provider.setType(ITypeInfo.t_wchar_t); else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME ) - type.setType(TypeInfo.t_type); + provider.setType(ITypeInfo.t_type); else if( kind == IASTSimpleTypeSpecifier.Type._BOOL ){ - type.setType( TypeInfo.t__Bool ); + provider.setType( ITypeInfo.t__Bool ); } // else // assert false : "Unexpected IASTSimpleTypeSpecifier.Type"; - setTypeBitFlags(type, simpleType); + setTypeBitFlags(provider, simpleType); } else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier ) { - type.setType( TypeInfo.t_type ); - type.setTypeSymbol( ((ASTClassSpecifier)absDecl.getTypeSpecifier()).getSymbol() ); + provider.setType( ITypeInfo.t_type ); + provider.setTypeSymbol( ((ASTClassSpecifier)absDecl.getTypeSpecifier()).getSymbol() ); } else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier ) { - type.setType( TypeInfo.t_type ); - type.setTypeSymbol( ((ASTEnumerationSpecifier)absDecl.getTypeSpecifier()).getSymbol() ); + provider.setType( ITypeInfo.t_type ); + provider.setTypeSymbol( ((ASTEnumerationSpecifier)absDecl.getTypeSpecifier()).getSymbol() ); } else if( absDecl.getTypeSpecifier() instanceof IASTElaboratedTypeSpecifier ) { - type.setType( TypeInfo.t_type ); - type.setTypeSymbol( ((ASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol() ); + provider.setType( ITypeInfo.t_type ); + provider.setTypeSymbol( ((ASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol() ); } // else -// assert false : this; - return type; +// assert false : this; + + return provider.completeConstruction(); } /** * @param type * @param simpleType */ - private void setTypeBitFlags(TypeInfo type, IASTSimpleTypeSpecifier simpleType) { - type.setBit( simpleType.isLong(), TypeInfo.isLong); - type.setBit( simpleType.isShort(), TypeInfo.isShort); - type.setBit( simpleType.isUnsigned(), TypeInfo.isUnsigned); - type.setBit( simpleType.isComplex(), TypeInfo.isComplex); - type.setBit( simpleType.isImaginary(), TypeInfo.isImaginary); - type.setBit( simpleType.isSigned(), TypeInfo.isSigned); + private void setTypeBitFlags(TypeInfoProvider provider, IASTSimpleTypeSpecifier simpleType) { + provider.setBit( simpleType.isLong(), ITypeInfo.isLong); + provider.setBit( simpleType.isShort(), ITypeInfo.isShort); + provider.setBit( simpleType.isUnsigned(), ITypeInfo.isUnsigned); + provider.setBit( simpleType.isComplex(), ITypeInfo.isComplex); + provider.setBit( simpleType.isImaginary(), ITypeInfo.isImaginary); + provider.setBit( simpleType.isSigned(), ITypeInfo.isSigned); } /** @@ -2293,8 +2295,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return; // now determined by another function - TypeInfo info = getParameterTypeInfo( absDecl ); - TypeInfo.eType type = info.getType(); + ITypeInfo info = getParameterTypeInfo( absDecl ); + ITypeInfo.eType type = info.getType(); ISymbol xrefSymbol = info.getTypeSymbol(); List newReferences = null; @@ -2307,7 +2309,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto newReferences = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getReferences(); } - infoBits = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol().getTypeInfo().getTypeInfo(); + infoBits = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol().getTypeInfo().getTypeBits(); } else if( absDecl.getTypeSpecifier() instanceof ASTElaboratedTypeSpecifier ) { @@ -2337,9 +2339,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto paramSymbol.setTypeSymbol( xrefSymbol ); } - paramSymbol.getTypeInfo().setTypeInfo( infoBits ); - paramSymbol.getTypeInfo().setBit( absDecl.isConst(), TypeInfo.isConst ); - paramSymbol.getTypeInfo().setBit( absDecl.isVolatile(), TypeInfo.isVolatile ); + paramSymbol.getTypeInfo().setTypeBits( infoBits ); + paramSymbol.getTypeInfo().setBit( absDecl.isConst(), ITypeInfo.isConst ); + paramSymbol.getTypeInfo().setBit( absDecl.isVolatile(), ITypeInfo.isVolatile ); setPointerOperators( paramSymbol, absDecl.getPointerOperators(), absDecl.getArrayModifiers() ); @@ -2369,15 +2371,15 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { ASTPointerOperator pointerOperator = (ASTPointerOperator)pointerOpsIterator.next(); if( pointerOperator == ASTPointerOperator.REFERENCE ) - symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference )); + symbol.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference )); else if( pointerOperator == ASTPointerOperator.POINTER ) - symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer )); + symbol.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer )); else if( pointerOperator == ASTPointerOperator.CONST_POINTER ) - symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer, true, false )); + symbol.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, true, false )); else if( pointerOperator == ASTPointerOperator.VOLATILE_POINTER ) - symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer, false, true)); + symbol.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, true)); else if( pointerOperator == ASTPointerOperator.RESTRICT_POINTER ) - symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer )); + symbol.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer )); // else // assert false : pointerOperator; } @@ -2385,7 +2387,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto while( arrayModsIterator.hasNext() ) { arrayModsIterator.next(); - symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_array )); + symbol.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_array )); } } @@ -2469,7 +2471,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto methodName = nameDuple.toString(); } - symbol = pst.newParameterizedSymbol( methodName, TypeInfo.t_function ); + symbol = pst.newParameterizedSymbol( methodName, ITypeInfo.t_function ); setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol); setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit ); symbol.setHasVariableArgs( hasVariableArguments ); @@ -2518,30 +2520,30 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } functionDeclaration = (IParameterizedSymbol) lookupQualifiedName( ownerScope, nameDuple, - isConstructor ? TypeInfo.t_constructor : TypeInfo.t_function, + isConstructor ? ITypeInfo.t_constructor : ITypeInfo.t_function, functionParameters, null, false, isFriend ? LookupType.FORFRIENDSHIP : LookupType.FORDEFINITION ); - previouslyDeclared = ( functionDeclaration != null ) && functionDeclaration.isType( isConstructor ? TypeInfo.t_constructor : TypeInfo.t_function ); + previouslyDeclared = ( functionDeclaration != null ) && functionDeclaration.isType( isConstructor ? ITypeInfo.t_constructor : ITypeInfo.t_function ); if( isFriend ) { - if( functionDeclaration != null && functionDeclaration.isType( isConstructor ? TypeInfo.t_constructor : TypeInfo.t_function )) + if( functionDeclaration != null && functionDeclaration.isType( isConstructor ? ITypeInfo.t_constructor : ITypeInfo.t_function )) { - symbol.setTypeSymbol( functionDeclaration ); + symbol.setForwardSymbol( functionDeclaration ); // friend declaration, has no real visibility, set private visibility = ASTAccessVisibility.PRIVATE; - } else if( ownerScope.getContainingSymbol().isType( TypeInfo.t_constructor ) || - ownerScope.getContainingSymbol().isType( TypeInfo.t_function ) || - ownerScope.getContainingSymbol().isType( TypeInfo.t_block ) ) + } else if( ownerScope.getContainingSymbol().isType( ITypeInfo.t_constructor ) || + ownerScope.getContainingSymbol().isType( ITypeInfo.t_function ) || + ownerScope.getContainingSymbol().isType( ITypeInfo.t_block ) ) { //only needs to be previously declared if we are in a local class handleProblem( IProblem.SEMANTIC_ILLFORMED_FRIEND, nameDuple.toString(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber(), true ); } - } else if( functionDeclaration != null && functionDeclaration.isType( isConstructor ? TypeInfo.t_constructor : TypeInfo.t_function ) ) + } else if( functionDeclaration != null && functionDeclaration.isType( isConstructor ? ITypeInfo.t_constructor : ITypeInfo.t_function ) ) { - functionDeclaration.setTypeSymbol( symbol ); + functionDeclaration.setForwardSymbol( symbol ); // set the definition visibility = declaration visibility // ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next(); visibility = ((IASTMethod)(functionDeclaration.getASTExtension().getPrimaryDeclaration())).getVisiblity(); @@ -2564,7 +2566,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } else { - symbol.setType( TypeInfo.t_constructor ); + symbol.setType( ITypeInfo.t_constructor ); ((IDerivableContainerSymbol)ownerScope).addConstructor( symbol ); } } @@ -2602,7 +2604,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { ASTConstructorMemberInitializer realInitializer = ((ASTConstructorMemberInitializer)initializer); IDerivableContainerSymbol container = (IDerivableContainerSymbol) symbol.getContainingSymbol(); - lookupQualifiedName(container, initializer.getName(), TypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED); + lookupQualifiedName(container, initializer.getName(), ITypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED); // TODO try and resolve parameter references now in the expression list } } @@ -2623,10 +2625,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto */ protected void setMethodTypeInfoBits(IParameterizedSymbol symbol, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit) { - symbol.getTypeInfo().setBit( isConst, TypeInfo.isConst ); - symbol.getTypeInfo().setBit( isVolatile, TypeInfo.isVolatile ); - symbol.getTypeInfo().setBit( isVirtual, TypeInfo.isVirtual ); - symbol.getTypeInfo().setBit( isExplicit, TypeInfo.isExplicit ); + symbol.getTypeInfo().setBit( isConst, ITypeInfo.isConst ); + symbol.getTypeInfo().setBit( isVolatile, ITypeInfo.isVolatile ); + symbol.getTypeInfo().setBit( isVirtual, ITypeInfo.isVirtual ); + symbol.getTypeInfo().setBit( isExplicit, ITypeInfo.isExplicit ); } /* (non-Javadoc) @@ -2666,9 +2668,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto else if( symbol instanceof IDeferredTemplateInstance ) parentScope = ((IDeferredTemplateInstance) symbol).getTemplate().getTemplatedSymbol(); - if( (parentScope != null) && ( (parentScope.getType() == TypeInfo.t_class) || - (parentScope.getType() == TypeInfo.t_struct)|| - (parentScope.getType() == TypeInfo.t_union) ) ) + if( (parentScope != null) && ( (parentScope.getType() == ITypeInfo.t_class) || + (parentScope.getType() == ITypeInfo.t_struct)|| + (parentScope.getType() == ITypeInfo.t_union) ) ) { IASTScope fieldParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration(); @@ -2704,10 +2706,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( variableDeclaration != null && newSymbol.getType() == variableDeclaration.getType() ) { - if( !newSymbol.isType( TypeInfo.t_type ) || - (newSymbol.isType( TypeInfo.t_type ) && newSymbol.getTypeSymbol() != variableDeclaration.getTypeSymbol() ) ) + if( !newSymbol.isType( ITypeInfo.t_type ) || + (newSymbol.isType( ITypeInfo.t_type ) && newSymbol.getTypeSymbol() != variableDeclaration.getTypeSymbol() ) ) { - variableDeclaration.setTypeSymbol( newSymbol ); + variableDeclaration.setForwardSymbol( newSymbol ); previouslyDeclared = true; } } @@ -2746,7 +2748,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( currentSymbol == null ) return; - TypeInfo currentTypeInfo = new TypeInfo( currentSymbol.getTypeInfo() ); + ITypeInfo currentTypeInfo = TypeInfoProvider.newTypeInfo( currentSymbol.getTypeInfo() ); Iterator designators = clause.getDesignators(); while( designators.hasNext() ) { @@ -2779,14 +2781,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } // we have found the correct field - currentTypeInfo = new TypeInfo( lookup.getTypeInfo() ); + currentTypeInfo = TypeInfoProvider.newTypeInfo( lookup.getTypeInfo() ); if( lookup.getTypeInfo() == null ) break; currentSymbol = lookup.getTypeSymbol(); } else if( designator.getKind() == IASTDesignator.DesignatorKind.SUBSCRIPT ) - currentTypeInfo.applyOperatorExpressions( SUBSCRIPT ); + currentTypeInfo.applyOperatorExpression( SUBSCRIPT ); } } @@ -2809,13 +2811,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto boolean isStatic, ISymbol newSymbol) { - newSymbol.getTypeInfo().setBit( isMutable, TypeInfo.isMutable ); - newSymbol.getTypeInfo().setBit( isAuto, TypeInfo.isAuto ); - newSymbol.getTypeInfo().setBit( isExtern, TypeInfo.isExtern ); - newSymbol.getTypeInfo().setBit( isRegister, TypeInfo.isRegister ); - newSymbol.getTypeInfo().setBit( isStatic, TypeInfo.isStatic ); - newSymbol.getTypeInfo().setBit( abstractDeclaration.isConst(), TypeInfo.isConst ); - newSymbol.getTypeInfo().setBit( abstractDeclaration.isVolatile(), TypeInfo.isVolatile ); + newSymbol.getTypeInfo().setBit( isMutable, ITypeInfo.isMutable ); + newSymbol.getTypeInfo().setBit( isAuto, ITypeInfo.isAuto ); + newSymbol.getTypeInfo().setBit( isExtern, ITypeInfo.isExtern ); + newSymbol.getTypeInfo().setBit( isRegister, ITypeInfo.isRegister ); + newSymbol.getTypeInfo().setBit( isStatic, ITypeInfo.isStatic ); + newSymbol.getTypeInfo().setBit( abstractDeclaration.isConst(), ITypeInfo.isConst ); + newSymbol.getTypeInfo().setBit( abstractDeclaration.isVolatile(), ITypeInfo.isVolatile ); } protected ISymbol cloneSimpleTypeSymbol( @@ -2841,20 +2843,20 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } else if( abstractDeclaration.getTypeSpecifier() instanceof ASTClassSpecifier ) { - symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type); + symbolToBeCloned = pst.newSymbol(name, ITypeInfo.t_type); symbolToBeCloned.setTypeSymbol(((ASTClassSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol()); } else if( abstractDeclaration.getTypeSpecifier() instanceof ASTElaboratedTypeSpecifier ) { ASTElaboratedTypeSpecifier elab = ((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier()); - symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type); + symbolToBeCloned = pst.newSymbol(name, ITypeInfo.t_type); symbolToBeCloned.setTypeSymbol(elab.getSymbol()); if( elab.getSymbol() != null && references != null ) addReference( references, createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) ); } else if ( abstractDeclaration.getTypeSpecifier() instanceof ASTEnumerationSpecifier ) { - symbolToBeCloned = pst.newSymbol( name, TypeInfo.t_type ); + symbolToBeCloned = pst.newSymbol( name, ITypeInfo.t_type ); symbolToBeCloned.setTypeSymbol(((ASTEnumerationSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol()); } if( symbolToBeCloned != null ){ @@ -2932,11 +2934,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( fieldDeclaration != null && newSymbol.getType() == fieldDeclaration.getType() ) { - if( !newSymbol.isType( TypeInfo.t_type ) || - (newSymbol.isType( TypeInfo.t_type ) && newSymbol.getTypeSymbol() != fieldDeclaration.getTypeSymbol() ) ) + if( !newSymbol.isType( ITypeInfo.t_type ) || + (newSymbol.isType( ITypeInfo.t_type ) && newSymbol.getTypeSymbol() != fieldDeclaration.getTypeSymbol() ) ) { previouslyDeclared = true; - fieldDeclaration.setTypeSymbol( newSymbol ); + fieldDeclaration.setForwardSymbol( newSymbol ); // // set the definition visibility = declaration visibility // ASTReference reference = (ASTReference) fieldReferences.iterator().next(); visibility = ((IASTField)fieldDeclaration.getASTExtension().getPrimaryDeclaration()).getVisiblity(); @@ -3002,11 +3004,21 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endingLine ) throws ASTSemanticException { ISymbol symbol = null; + + TypeInfoProvider provider = TypeInfoProvider.getProvider( pst ); + provider.beginTypeConstruction(); + + if( defaultValue != null ){ + try { + provider.setDefaultObj( defaultValue.getTypeSymbol().getTypeInfo() ); + } catch ( ASTNotImplementedException e1 ) { + } + } if( kind == ParamKind.TEMPLATE_LIST ){ ITemplateSymbol template = pst.newTemplateSymbol( identifier ); - template.setType( TypeInfo.t_templateParameter ); - template.getTypeInfo().setTemplateParameterType( TypeInfo.t_template ); - + provider.setType( ITypeInfo.t_templateParameter ); + provider.setTemplateParameterType( ITypeInfo.t_template ); + template.setTypeInfo( provider.completeConstruction() ); Iterator iter = parms.iterator(); while (iter.hasNext()){ ASTTemplateParameter param = (ASTTemplateParameter)iter.next(); @@ -3020,12 +3032,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } else { if( kind == ParamKind.CLASS || kind == ParamKind.TYPENAME ){ - symbol = pst.newSymbol( identifier, TypeInfo.t_templateParameter ); - symbol.getTypeInfo().setTemplateParameterType( TypeInfo.t_typeName ); + symbol = pst.newSymbol( identifier ); + provider.setType( ITypeInfo.t_templateParameter ); + provider.setTemplateParameterType( ITypeInfo.t_typeName ); + symbol.setTypeInfo( provider.completeConstruction() ); } else /*ParamKind.PARAMETER*/ { symbol = cloneSimpleTypeSymbol( parameter.getName(), parameter, null ); - symbol.getTypeInfo().setTemplateParameterType( symbol.getType() ); - symbol.setType( TypeInfo.t_templateParameter ); + provider.setTemplateParameterType( symbol.getType() ); + provider.setType( ITypeInfo.t_templateParameter ); + provider.setTypeSymbol( symbol.getTypeSymbol() ); + ITypeInfo info = provider.completeConstruction(); + info.addPtrOperator( symbol.getPtrOperators() ); + info.setTypeBits( symbol.getTypeInfo().getTypeBits() ); + symbol.setTypeInfo( info ); } } @@ -3034,14 +3053,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto codeScope.addSymbol( symbol ); } catch (ParserSymbolTableException e) { } - - if( defaultValue != null ){ - try { - symbol.getTypeInfo().setDefault( defaultValue.getTypeSymbol().getTypeInfo() ); - } catch (ASTNotImplementedException e1) { - } - } - + ASTTemplateParameter ast = new ASTTemplateParameter( symbol, defaultValue, parameter, parms, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endingLine ); attachSymbolExtension( symbol, ast, false ); @@ -3092,13 +3104,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto setPointerOperators( typeSymbol, mapping.getPointerOperators(), mapping.getArrayModifiers() ); - if( typeSymbol.getType() != TypeInfo.t_type ){ - ISymbol newSymbol = pst.newSymbol( name, TypeInfo.t_type); - newSymbol.getTypeInfo().setBit( true,TypeInfo.isTypedef ); + if( typeSymbol.getType() != ITypeInfo.t_type ){ + ISymbol newSymbol = pst.newSymbol( name, ITypeInfo.t_type); + newSymbol.getTypeInfo().setBit( true,ITypeInfo.isTypedef ); newSymbol.setTypeSymbol( typeSymbol ); typeSymbol = newSymbol; } else { - typeSymbol.getTypeInfo().setBit( true,TypeInfo.isTypedef ); + typeSymbol.getTypeInfo().setBit( true,ITypeInfo.isTypedef ); } List references = new ArrayList(); @@ -3146,7 +3158,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto IContainerSymbol currentScopeSymbol = scopeToSymbol(scope); IContainerSymbol originalScope = currentScopeSymbol; - TypeInfo.eType pstType = classKindToTypeInfo(kind); + ITypeInfo.eType pstType = classKindToTypeInfo(kind); List references = new ArrayList(); IToken nameToken = name.getFirstToken(); String newSymbolName = EMPTY_STRING; @@ -3290,11 +3302,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto ISymbol namespaceSymbol = lookupQualifiedName( startingSymbol, alias, references, true ); - if( namespaceSymbol.getType() != TypeInfo.t_namespace ) + if( namespaceSymbol.getType() != ITypeInfo.t_namespace ) handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, alias.toString(), startingOffset, endOffset, startingLine, true ); - ISymbol newSymbol = pst.newContainerSymbol( identifier, TypeInfo.t_namespace ); - newSymbol.setTypeSymbol( namespaceSymbol ); + ISymbol newSymbol = pst.newContainerSymbol( identifier, ITypeInfo.t_namespace ); + newSymbol.setForwardSymbol( namespaceSymbol ); try { @@ -3318,7 +3330,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto public IASTCodeScope createNewCodeBlock(IASTScope scope) { IContainerSymbol symbol = scopeToSymbol( scope ); - IContainerSymbol newScope = pst.newContainerSymbol(EMPTY_STRING, TypeInfo.t_block); + IContainerSymbol newScope = pst.newContainerSymbol(EMPTY_STRING, ITypeInfo.t_block); newScope.setContainingSymbol(symbol); newScope.setIsTemplateMember( symbol.isTemplateMember() ); @@ -3376,8 +3388,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto // won't get thrown } if( lookupSymbol == null ) return false; - if( lookupSymbol.isType( TypeInfo.t_type, TypeInfo.t_enumeration ) || - (lookupSymbol.isType( TypeInfo.t_templateParameter ) && lookupSymbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ) || + if( lookupSymbol.isType( ITypeInfo.t_type, ITypeInfo.t_enumeration ) || + (lookupSymbol.isType( ITypeInfo.t_templateParameter ) && lookupSymbol.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ) || (lookupSymbol.getASTExtension() != null && lookupSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTTypedefDeclaration ) ) { return true; @@ -3415,29 +3427,29 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto * @param id * @return */ - public static TypeInfo.eType getTypeKind(IASTTypeId id) + public static ITypeInfo.eType getTypeKind(IASTTypeId id) { IASTSimpleTypeSpecifier.Type type = id.getKind(); if( type == IASTSimpleTypeSpecifier.Type.BOOL ) - return TypeInfo.t_bool; + return ITypeInfo.t_bool; else if( type == IASTSimpleTypeSpecifier.Type._BOOL ) - return TypeInfo.t__Bool; + return ITypeInfo.t__Bool; else if( type == IASTSimpleTypeSpecifier.Type.CHAR ) - return TypeInfo.t_char; + return ITypeInfo.t_char; else if ( type == IASTSimpleTypeSpecifier.Type.WCHAR_T ) - return TypeInfo.t_wchar_t; + return ITypeInfo.t_wchar_t; else if( type == IASTSimpleTypeSpecifier.Type.DOUBLE ) - return TypeInfo.t_double; + return ITypeInfo.t_double; else if( type == IASTSimpleTypeSpecifier.Type.FLOAT ) - return TypeInfo.t_float; + return ITypeInfo.t_float; else if( type == IASTSimpleTypeSpecifier.Type.INT ) - return TypeInfo.t_int; + return ITypeInfo.t_int; else if( type == IASTSimpleTypeSpecifier.Type.VOID ) - return TypeInfo.t_void; + return ITypeInfo.t_void; else if( id.isShort() || id.isLong() || id.isUnsigned() || id.isSigned() ) - return TypeInfo.t_int; + return ITypeInfo.t_int; else - return TypeInfo.t_type; + return ITypeInfo.t_type; } protected ISymbol createSymbolForTypeId( IASTScope scope, IASTTypeId id ) throws ASTSemanticException @@ -3447,16 +3459,16 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto ASTTypeId typeId = (ASTTypeId)id; ISymbol result = pst.newSymbol( EMPTY_STRING, CompleteParseASTFactory.getTypeKind(id)); - result.getTypeInfo().setBit( id.isConst(), TypeInfo.isConst ); - result.getTypeInfo().setBit( id.isVolatile(), TypeInfo.isVolatile ); + result.getTypeInfo().setBit( id.isConst(), ITypeInfo.isConst ); + result.getTypeInfo().setBit( id.isVolatile(), ITypeInfo.isVolatile ); - result.getTypeInfo().setBit( id.isShort(), TypeInfo.isShort); - result.getTypeInfo().setBit( id.isLong(), TypeInfo.isLong); - result.getTypeInfo().setBit( id.isUnsigned(), TypeInfo.isUnsigned); - result.getTypeInfo().setBit( id.isSigned(), TypeInfo.isSigned ); + result.getTypeInfo().setBit( id.isShort(), ITypeInfo.isShort); + result.getTypeInfo().setBit( id.isLong(), ITypeInfo.isLong); + result.getTypeInfo().setBit( id.isUnsigned(), ITypeInfo.isUnsigned); + result.getTypeInfo().setBit( id.isSigned(), ITypeInfo.isSigned ); List refs = new ArrayList(); - if( result.getType() == TypeInfo.t_type ) + if( result.getType() == ITypeInfo.t_type ) { ISymbol typeSymbol = lookupQualifiedName( scopeToSymbol(scope), typeId.getTokenDuple(), refs, true ); if( typeSymbol == null /*|| typeSymbol.getType() == TypeInfo.t_type*/ ) @@ -3558,8 +3570,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto classSymbol = (IContainerSymbol) lookupQualifiedName(scopeToSymbol( scope ), duple, null, false ); } catch (ASTSemanticException e) { } - if( classSymbol != null && classSymbol.getTypeInfo().checkBit( TypeInfo.isTypedef ) ){ - TypeInfo info = classSymbol.getTypeInfo().getFinalType( pst.getTypeInfoProvider() ); + if( classSymbol != null && classSymbol.getTypeInfo().checkBit( ITypeInfo.isTypedef ) ){ + ITypeInfo info = classSymbol.getTypeInfo().getFinalType( pst.getTypeInfoProvider() ); classSymbol = (IContainerSymbol) info.getTypeSymbol(); pst.getTypeInfoProvider().returnTypeInfo( info ); } @@ -3650,7 +3662,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto public boolean validateIndirectMemberOperation(IASTNode node) { List pointerOps = null; TypeInfoProvider provider = pst.getTypeInfoProvider(); - TypeInfo typeInfo = null; + ITypeInfo typeInfo = null; if( ( node instanceof ISymbolOwner ) ) { ISymbol symbol = ((ISymbolOwner) node).getSymbol(); @@ -3660,9 +3672,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } else if( node instanceof ASTExpression ) { - ISymbol typeSymbol = ((ASTExpression)node).getResultType().getResult().getTypeSymbol(); - if( typeSymbol != null ){ - typeInfo = typeSymbol.getTypeInfo().getFinalType( provider ); + ITypeInfo info = ((ASTExpression)node).getResultType().getResult(); + if( info != null ){ + typeInfo = info.getFinalType( provider ); pointerOps = typeInfo.getPtrOperators(); provider.returnTypeInfo( typeInfo ); } @@ -3671,8 +3683,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return false; if( pointerOps == null || pointerOps.isEmpty() ) return false; - TypeInfo.PtrOp lastOperator = (PtrOp) pointerOps.get( pointerOps.size() - 1 ); - if( lastOperator.getType() == TypeInfo.PtrOp.t_array || lastOperator.getType() == TypeInfo.PtrOp.t_pointer ) return true; + ITypeInfo.PtrOp lastOperator = (ITypeInfo.PtrOp) pointerOps.get( pointerOps.size() - 1 ); + if( lastOperator.getType() == ITypeInfo.PtrOp.t_array || lastOperator.getType() == ITypeInfo.PtrOp.t_pointer ) return true; return false; } @@ -3685,24 +3697,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { ISymbol symbol = ((ISymbolOwner) node).getSymbol(); TypeInfoProvider provider = pst.getTypeInfoProvider(); - TypeInfo info = symbol.getTypeInfo().getFinalType( provider ); + ITypeInfo info = symbol.getTypeInfo().getFinalType( provider ); pointerOps = info.getPtrOperators(); provider.returnTypeInfo( info ); } else if( node instanceof ASTExpression ) { - ISymbol typeSymbol = ((ASTExpression)node).getResultType().getResult().getTypeSymbol(); - if( typeSymbol != null ) - { - pointerOps = typeSymbol.getPtrOperators(); + ITypeInfo info = ((ASTExpression)node).getResultType().getResult(); + if( info != null ){ + TypeInfoProvider provider = pst.getTypeInfoProvider(); + info = info.getFinalType( provider ); + pointerOps = info.getPtrOperators(); + provider.returnTypeInfo( info ); } } else return false; if( pointerOps == null || pointerOps.isEmpty() ) return true; - TypeInfo.PtrOp lastOperator = (PtrOp) pointerOps.get( pointerOps.size() - 1 ); - if( lastOperator.getType() == TypeInfo.PtrOp.t_reference ) return true; + ITypeInfo.PtrOp lastOperator = (ITypeInfo.PtrOp) pointerOps.get( pointerOps.size() - 1 ); + if( lastOperator.getType() == ITypeInfo.PtrOp.t_reference ) return true; return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResult.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResult.java index 90af18f10e7..09deaaa9cf6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResult.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResult.java @@ -10,7 +10,8 @@ ***********************************************************************/ 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 @@ -19,26 +20,26 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; public class ExpressionResult { - private TypeInfo result; + private ITypeInfo result; private boolean failedToDereference = false; ExpressionResult(){ - result = new TypeInfo(); + result = TypeInfoProvider.newTypeInfo(); } - ExpressionResult(TypeInfo result){ + ExpressionResult(ITypeInfo result){ this.result = result; } /** * @return */ -public TypeInfo getResult() { +public ITypeInfo getResult() { return result; } /** * @param info */ -public void setResult(TypeInfo info) { +public void setResult(ITypeInfo info) { result = info; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResultList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResultList.java index 1531f0cac41..f63b15c7df7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResultList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ExpressionResultList.java @@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete; import java.util.ArrayList; import java.util.List; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo; /** * @author hamer @@ -27,15 +27,15 @@ public class ExpressionResultList extends ExpressionResult { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionResult#getResult() */ - public TypeInfo getResult() { + public ITypeInfo getResult() { // TODO Auto-generated method stub - return (TypeInfo)resultList.get(0); + return (ITypeInfo)resultList.get(0); } /* (non-Javadoc) * @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 resultList.add(info); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicSymbol.java index 813ebbd3d9f..7075dec5853 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicSymbol.java @@ -16,28 +16,19 @@ package org.eclipse.cdt.internal.core.parser.pst; import java.util.List; import java.util.Map; - - public class BasicSymbol extends ExtensibleSymbol implements ISymbol { public BasicSymbol( ParserSymbolTable table, String name ){ super( table ); _name = name; - _typeInfo = new TypeInfo(); - } + } - public BasicSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){ - super( table, obj ); - _name = name; - _typeInfo = new TypeInfo(); - } - - public BasicSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ) + public BasicSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ) { super( table ); _name = name; - _typeInfo = new TypeInfo( typeInfo, 0, null ); + _typeInfo = TypeInfoProvider.newTypeInfo( typeInfo ); } public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{ @@ -60,27 +51,27 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol _depth = scope.getDepth() + 1; } - public void setType(TypeInfo.eType t){ + public void setType(ITypeInfo.eType t){ getTypeInfo().setType( t ); } - public TypeInfo.eType getType(){ + public ITypeInfo.eType getType(){ return getTypeInfo().getType(); } - public boolean isType( TypeInfo.eType type ){ - return getTypeInfo().isType( type, TypeInfo.t_undef ); + public boolean isType( ITypeInfo.eType type ){ + 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 ); } public ISymbol getTypeSymbol(){ ISymbol symbol = getTypeInfo().getTypeSymbol(); - if( symbol != null && symbol.getTypeInfo().isForwardDeclaration() && symbol.getTypeSymbol() != null ){ - return symbol.getTypeSymbol(); + if( symbol != null && symbol.isForwardDeclaration() && symbol.getForwardSymbol() != null ){ + return symbol.getForwardSymbol(); } return symbol; @@ -90,22 +81,27 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol getTypeInfo().setTypeSymbol( type ); } - public TypeInfo getTypeInfo(){ - return _typeInfo; + public ITypeInfo getTypeInfo(){ + return ( _typeInfo != null ) ? _typeInfo : (_typeInfo = new TypeInfo()); } - public void setTypeInfo( TypeInfo info ) { + public void setTypeInfo( ITypeInfo info ) { _typeInfo = info; } public boolean isForwardDeclaration(){ - return getTypeInfo().isForwardDeclaration(); + return _isForwardDeclaration; } 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 */ @@ -118,10 +114,10 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol } else if( size == 0 ) return 0; else { - TypeInfo.PtrOp op1 = null, op2 = null; + ITypeInfo.PtrOp op1 = null, op2 = null; for( int i = 0; i > size; i++ ){ - op1 = (TypeInfo.PtrOp)symbol.getTypeInfo().getPtrOperators().get(i); - op2 = (TypeInfo.PtrOp)getTypeInfo().getPtrOperators().get(i); + op1 = (ITypeInfo.PtrOp)symbol.getTypeInfo().getPtrOperators().get(i); + op2 = (ITypeInfo.PtrOp)getTypeInfo().getPtrOperators().get(i); if( op1.compareCVTo( op2 ) != 0 ){ return -1; @@ -135,7 +131,7 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol public List getPtrOperators(){ return getTypeInfo().getPtrOperators(); } - public void addPtrOperator( TypeInfo.PtrOp ptrOp ){ + public void addPtrOperator( ITypeInfo.PtrOp ptrOp ){ getTypeInfo().addPtrOperator( ptrOp ); } public void preparePtrOperatros(int numPtrOps) { @@ -154,13 +150,13 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol _isTemplateMember = isMember; } public boolean isTemplateInstance(){ - return ( _instantiatedSymbol != null ); + return ( _symbolDef != null ); } public ISymbol getInstantiatedSymbol(){ - return _instantiatedSymbol; + return _symbolDef; } public void setInstantiatedSymbol( ISymbol symbol ){ - _instantiatedSymbol = symbol; + _symbolDef = symbol; } public boolean getIsInvisible(){ @@ -171,13 +167,14 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol } 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 boolean _isInvisible = false; //used by friend declarations (11.4-9) 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) @@ -186,7 +183,7 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol public Object clone() { BasicSymbol s = (BasicSymbol) super.clone(); - s._typeInfo = new TypeInfo( s._typeInfo ); + s._typeInfo = TypeInfoProvider.newTypeInfo( s._typeInfo ); return s; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicTypeInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicTypeInfo.java new file mode 100644 index 00000000000..504d56f2c6a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/BasicTypeInfo.java @@ -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; +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java index c30aea2203e..e22499e918c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ContainerSymbol.java @@ -47,11 +47,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { super( table, name ); } - protected ContainerSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){ - super( table, name, obj ); - } - - protected ContainerSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ){ + protected ContainerSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){ super( table, name, typeInfo ); } @@ -93,7 +89,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { newContainer._contents.add( containedSymbol ); } else { ISymbol symbol = (ISymbol) containedSymbol; - if( symbol.isForwardDeclaration() && symbol.getTypeSymbol() != null ){ + if( symbol.isForwardDeclaration() && symbol.getForwardSymbol() != null ){ continue; } @@ -134,7 +130,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { newSymbol.setContainingSymbol( newContainer ); 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 ); } else { if( newContainer.getContainedSymbols().containsKey( newSymbol.getName() ) ){ @@ -168,10 +164,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { IContainerSymbol containing = this; //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 //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 //enumeration 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 ) ) { 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 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 ); } } //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() ) ){ throw new ParserSymbolTableException( ParserSymbolTableException.r_RedeclaredTemplateParam ); } @@ -245,7 +241,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { ((ContainerSymbol)containing).putInContainedSymbols( obj.getName(), obj ); } - obj.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template ); + obj.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template ); 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) */ 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 ); } //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 ); } //handle namespace aliasing - ISymbol alias = namespace.getTypeSymbol(); - if( alias != null && alias.isType( TypeInfo.t_namespace ) ){ + ISymbol alias = namespace.getForwardSymbol(); + if( alias != null && alias.isType( ITypeInfo.t_namespace ) ){ namespace = (IContainerSymbol) alias; } @@ -450,15 +446,15 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String) */ - public ISymbol elaboratedLookup( final TypeInfo.eType type, String name ) throws ParserSymbolTableException{ + public ISymbol elaboratedLookup( final ITypeInfo.eType type, String name ) throws ParserSymbolTableException{ LookupData data = new LookupData( name ){ 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 ); return filter; } private TypeFilter filter = null; - private final TypeInfo.eType t = type; + private final ITypeInfo.eType t = type; }; ParserSymbolTable.lookup( data, this ); @@ -537,9 +533,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { IContainerSymbol container = this; //handle namespace aliases - if( container.isType( TypeInfo.t_namespace ) ){ - ISymbol symbol = container.getTypeSymbol(); - if( symbol != null && symbol.isType( TypeInfo.t_namespace ) ){ + if( container.isType( ITypeInfo.t_namespace ) ){ + ISymbol symbol = container.getForwardSymbol(); + if( symbol != null && symbol.isType( ITypeInfo.t_namespace ) ){ container = (IContainerSymbol) symbol; } } @@ -561,9 +557,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { IContainerSymbol container = this; //handle namespace aliases - if( container.isType( TypeInfo.t_namespace ) ){ - ISymbol symbol = container.getTypeSymbol(); - if( symbol != null && symbol.isType( TypeInfo.t_namespace ) ){ + if( container.isType( ITypeInfo.t_namespace ) ){ + ISymbol symbol = container.getForwardSymbol(); + if( symbol != null && symbol.isType( ITypeInfo.t_namespace ) ){ container = (IContainerSymbol) symbol; } } @@ -596,10 +592,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { private IContainerSymbol lookupNestedNameSpecifier(String name, IContainerSymbol inSymbol ) throws ParserSymbolTableException{ ISymbol foundSymbol = null; - final TypeFilter filter = new TypeFilter( TypeInfo.t_namespace ); - filter.addAcceptedType( TypeInfo.t_class ); - filter.addAcceptedType( TypeInfo.t_struct ); - filter.addAcceptedType( TypeInfo.t_union ); + final TypeFilter filter = new TypeFilter( ITypeInfo.t_namespace ); + filter.addAcceptedType( ITypeInfo.t_class ); + filter.addAcceptedType( ITypeInfo.t_struct ); + filter.addAcceptedType( ITypeInfo.t_union ); LookupData data = new LookupData( name ){ public TypeFilter getFilter() { return typeFilter; } @@ -636,10 +632,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType) */ - public ISymbol qualifiedLookup( String name, final TypeInfo.eType t ) throws ParserSymbolTableException{ + public ISymbol qualifiedLookup( String name, final ITypeInfo.eType t ) throws ParserSymbolTableException{ LookupData data = new LookupData( name ){ 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 ); @@ -687,11 +683,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { //collect associated namespaces & classes. int size = ( parameters == null ) ? 0 : parameters.size(); - TypeInfo param = null; + ITypeInfo param = null; ISymbol paramType = null; for( int i = 0; i < size; i++ ){ - param = (TypeInfo) parameters.get(i); - TypeInfo info = ParserSymbolTable.getFlatTypeInfo( param, getSymbolTable().getTypeInfoProvider() ); + param = (ITypeInfo) parameters.get(i); + ITypeInfo info = ParserSymbolTable.getFlatTypeInfo( param, getSymbolTable().getTypeInfoProvider() ); paramType = info.getTypeSymbol(); 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 //are those associated with the member type together with those associated with X if( param.hasPtrOperators() && param.getPtrOperators().size() == 1 ){ - TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().get(0); - if( op.getType() == TypeInfo.PtrOp.t_pointer && - paramType.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) ) + ITypeInfo.PtrOp op = (ITypeInfo.PtrOp)param.getPtrOperators().get(0); + if( op.getType() == ITypeInfo.PtrOp.t_pointer && + paramType.getContainingSymbol().isType( ITypeInfo.t_class, ITypeInfo.t_union ) ) { 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 //associated scopes - if( found == null || found.getContainingSymbol().getType() != TypeInfo.t_class ){ + if( found == null || found.getContainingSymbol().getType() != ITypeInfo.t_class ){ // if( found != null ){ // data.foundItems.add( found ); // } @@ -808,11 +804,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { ParserSymbolTable.lookup( data, this ); ISymbol found = getSymbolTable().resolveAmbiguities( data ); if( found != null ){ - if( (found.isType( TypeInfo.t_templateParameter ) && found.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template) || - found.isType( TypeInfo.t_template ) ) + if( (found.isType( ITypeInfo.t_templateParameter ) && found.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template) || + found.isType( ITypeInfo.t_template ) ) { 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 ); } } @@ -872,7 +868,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { ParserSymbolTable.lookup( data, this ); 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 ) ){ List temp = ((IDerivableContainerSymbol)this).getConstructors(); int size = temp.size(); @@ -914,7 +910,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { getSymbolTable().resolveFunction( data, (List) obj ); list.addAll( (List) obj ); } else{ - if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) ) + if( paramList != null && ((ISymbol)obj).isType( ITypeInfo.t_function ) ) { if( tempList == null ) tempList = new ArrayList(1); @@ -958,7 +954,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { IContainerSymbol container = 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 ) ) { return true; @@ -986,10 +982,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { if( symbol instanceof IDerivableContainerSymbol ){ IContainerSymbol container = this.getContainingSymbol(); - while( container != null && container.isType( TypeInfo.t_block ) ){ + while( container != null && container.isType( ITypeInfo.t_block ) ){ 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; } @@ -999,9 +995,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { int size = friends.size(); for( int i = 0; i < size; i++ ){ ISymbol friend = (ISymbol) friends.get(i); - ISymbol typeSymbol = friend.getTypeSymbol(); - if( friend == this || typeSymbol == this || - friend == container || ( container != null && typeSymbol == container ) ) + ISymbol forwardSymbol = friend.getForwardSymbol(); + if( friend == this || forwardSymbol == this || + friend == container || ( container != null && forwardSymbol == container ) ) { return true; } @@ -1011,9 +1007,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { } private IContainerSymbol getScopeForCTag( IContainerSymbol container ){ - while( !container.isType( TypeInfo.t_namespace ) && - !container.isType( TypeInfo.t_function ) && - !container.isType( TypeInfo.t_block ) ) + while( !container.isType( ITypeInfo.t_namespace ) && + !container.isType( ITypeInfo.t_function ) && + !container.isType( ITypeInfo.t_block ) ) { container = container.getContainingSymbol(); } @@ -1022,11 +1018,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { protected void addToContents( IExtensibleSymbol symbol ){ if( _contents == Collections.EMPTY_LIST ){ - if( isType( TypeInfo.t_namespace ) ) + if( isType( ITypeInfo.t_namespace ) ) _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 ); - else if( isType( TypeInfo.t_function ) ) + else if( isType( ITypeInfo.t_function ) ) _contents = new ArrayList( 16 ); else _contents = new ArrayList( 8 ); @@ -1063,11 +1059,12 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol { if( !alreadyReturned.contains( extensible ) ){ if( extensible instanceof ISymbol ){ ISymbol symbol = (ISymbol) extensible; - if( symbol.isForwardDeclaration() && symbol.getTypeSymbol() != null && - symbol.getTypeSymbol().getContainingSymbol() == ContainerSymbol.this ) + ISymbol forward = symbol.getForwardSymbol(); + if( symbol.isForwardDeclaration() && forward != null && + forward.getContainingSymbol() == ContainerSymbol.this ) { - alreadyReturned.add( symbol.getTypeSymbol() ); - next = symbol.getTypeSymbol(); + alreadyReturned.add( forward ); + next = forward; return true; } } else if( extensible instanceof IUsingDeclarationSymbol ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java index 6125fc6d3ac..e766fcb6343 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java @@ -52,13 +52,13 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe List newArgs = new ArrayList( args.size() ); int size = args.size(); 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 ) ); } ITemplateSymbol deferredTemplate = getTemplate(); - if( deferredTemplate.isType( TypeInfo.t_templateParameter ) && argMap.containsKey( deferredTemplate ) ){ - TypeInfo i = (TypeInfo) argMap.get( deferredTemplate ); + if( deferredTemplate.isType( ITypeInfo.t_templateParameter ) && argMap.containsKey( deferredTemplate ) ){ + ITypeInfo i = (ITypeInfo) argMap.get( deferredTemplate ); deferredTemplate = (ITemplateSymbol) i.getTypeSymbol(); } @@ -69,7 +69,7 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe return instance; } - public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ){ + public boolean isType( ITypeInfo.eType type, ITypeInfo.eType upperType ){ ISymbol symbol = _template.getTemplatedSymbol(); if( symbol != null ) 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(); if( symbol != null ) return symbol.getType(); return super.getType(); } - public TypeInfo getTypeInfo(){ + public ITypeInfo getTypeInfo(){ ISymbol symbol = _template.getTemplatedSymbol(); if( symbol != null ) return symbol.getTypeInfo(); return super.getTypeInfo(); } - public boolean isType( TypeInfo.eType type ){ + public boolean isType( ITypeInfo.eType type ){ return _template.getTemplatedSymbol().isType( type ); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java index 3155b0d10d3..fcd61a2f9b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java @@ -34,12 +34,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva protected DerivableContainerSymbol( ParserSymbolTable table, String name ){ super( table, name ); } - - protected DerivableContainerSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){ - super( table, name, obj ); - } - - protected DerivableContainerSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ){ + + protected DerivableContainerSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){ super( table, name, typeInfo ); } @@ -73,8 +69,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva if( parent instanceof IDeferredTemplateInstance ){ template.registerDeferredInstatiation( newSymbol, parent, ITemplateSymbol.DeferredKind.PARENT, argMap ); - } else if( parent.isType( TypeInfo.t_templateParameter ) && argMap.containsKey( parent ) ){ - TypeInfo info = (TypeInfo) argMap.get( parent ); + } else if( parent.isType( ITypeInfo.t_templateParameter ) && argMap.containsKey( parent ) ){ + ITypeInfo info = (ITypeInfo) argMap.get( parent ); parent = info.getTypeSymbol(); } 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 ){ - if( constructor.isType( TypeInfo.t_constructor ) ) + if( constructor.isType( ITypeInfo.t_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) */ 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 ); List constructors = getConstructors(); @@ -184,7 +180,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva } constructor.setContainingSymbol( this ); - constructor.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template ); + constructor.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template ); addThis( constructor ); @@ -205,24 +201,25 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva paramType = TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) getContainingSymbol() ); } - TypeInfo param = getSymbolTable().getTypeInfoProvider().getTypeInfo(); - param.setType( TypeInfo.t_type ); - param.setBit( true, TypeInfo.isConst ); + ITypeInfo param = TypeInfoProvider.getProvider(getSymbolTable()).getTypeInfo( ITypeInfo.t_type ); + param.setType( ITypeInfo.t_type ); + param.setBit( true, ITypeInfo.isConst ); 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 ); IParameterizedSymbol constructor = null; try{ constructor = lookupConstructor( parameters ); } catch ( ParserSymbolTableException e ){ + /* nothing */ } finally { getSymbolTable().getTypeInfoProvider().returnTypeInfo( param ); } if( constructor == null ){ - constructor = getSymbolTable().newParameterizedSymbol( getName(), TypeInfo.t_constructor ); - constructor.addParameter( this, TypeInfo.isConst, new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference, false, false ), false ); + constructor = getSymbolTable().newParameterizedSymbol( getName(), ITypeInfo.t_constructor ); + constructor.addParameter( this, ITypeInfo.isConst, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_reference, false, false ), false ); addConstructor( constructor ); } @@ -274,13 +271,13 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva return false; } - TypeInfo type = obj.getTypeInfo(); - if( ( !type.isType( TypeInfo.t_function ) && !type.isType( TypeInfo.t_constructor) ) || - type.checkBit( TypeInfo.isStatic ) ){ + ITypeInfo type = obj.getTypeInfo(); + if( ( !type.isType( ITypeInfo.t_function ) && !type.isType( ITypeInfo.t_constructor) ) || + type.checkBit( ITypeInfo.isStatic ) ){ 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 //of function will have them from the original declaration 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 //check its contents 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.setCVQualifier( obj.getCVQualifier() ); - TypeInfo.PtrOp ptr = new TypeInfo.PtrOp(); - ptr.setType( TypeInfo.PtrOp.t_pointer ); - thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( TypeInfo.isConst ), TypeInfo.isConst ); - thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( TypeInfo.isVolatile ), TypeInfo.isVolatile ); + ITypeInfo.PtrOp ptr = new ITypeInfo.PtrOp(); + ptr.setType( ITypeInfo.PtrOp.t_pointer ); + thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( ITypeInfo.isConst ), ITypeInfo.isConst ); + thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( ITypeInfo.isVolatile ), ITypeInfo.isVolatile ); thisObj.addPtrOperator(ptr); @@ -336,11 +333,11 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva //its not, it goes in the innermost enclosing namespace IContainerSymbol enclosing = getContainingSymbol(); - boolean local = enclosing.isType( TypeInfo.t_constructor ) || - enclosing.isType( TypeInfo.t_function ) || - enclosing.isType( TypeInfo.t_block ); + boolean local = enclosing.isType( ITypeInfo.t_constructor ) || + enclosing.isType( ITypeInfo.t_function ) || + enclosing.isType( ITypeInfo.t_block ); - while( enclosing != null && !enclosing.isType( TypeInfo.t_namespace ) ){ + while( enclosing != null && !enclosing.isType( ITypeInfo.t_namespace ) ){ enclosing = enclosing.getContainingSymbol(); } @@ -349,6 +346,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva try { enclosing.addSymbol( friend ); } catch (ParserSymbolTableException e) { + /* nothing */ } } @@ -369,8 +367,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva */ public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException{ IContainerSymbol enclosing = getContainingSymbol(); - if( enclosing != null && enclosing.isType( TypeInfo.t_namespace, TypeInfo.t_union ) ){ - while( enclosing != null && ( enclosing.getType() != TypeInfo.t_namespace) ) + if( enclosing != null && enclosing.isType( ITypeInfo.t_namespace, ITypeInfo.t_union ) ){ + while( enclosing != null && ( enclosing.getType() != ITypeInfo.t_namespace) ) { enclosing = enclosing.getContainingSymbol(); } @@ -391,8 +389,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva IContainerSymbol enclosing = getContainingSymbol(); - if( enclosing != null && enclosing.isType( TypeInfo.t_namespace, TypeInfo.t_union ) ){ - while( enclosing != null && ( enclosing.getType() != TypeInfo.t_namespace) ) + if( enclosing != null && enclosing.isType( ITypeInfo.t_namespace, ITypeInfo.t_union ) ){ + while( enclosing != null && ( enclosing.getType() != ITypeInfo.t_namespace) ) { enclosing = enclosing.getContainingSymbol(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java index 039fbc9c0cc..3b7395d2674 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java @@ -98,13 +98,13 @@ public interface IContainerSymbol extends ISymbol { * IDerivableContainerSymbol * r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree */ - public ISymbol elaboratedLookup( 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 lookupMemberForDefinition( String name ) throws ParserSymbolTableException; public IParameterizedSymbol lookupMethodForDefinition( String name, List parameters ) throws ParserSymbolTableException; public IContainerSymbol lookupNestedNameSpecifier( String name ) throws ParserSymbolTableException; public ISymbol qualifiedLookup( String name ) throws ParserSymbolTableException; - public ISymbol qualifiedLookup( String name, 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 memberFunctionLookup( String name, List parameters ) throws ParserSymbolTableException; public IParameterizedSymbol qualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java index 78c4c29aee3..64b1181a3d6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java @@ -29,8 +29,8 @@ import java.util.Map; public interface IParameterizedSymbol extends IContainerSymbol { public void addParameter( ISymbol param ); - public void addParameter( TypeInfo.eType type, int info, TypeInfo.PtrOp ptrOp, boolean hasDefault ); - public void addParameter( ISymbol typeSymbol, 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, ITypeInfo.PtrOp ptrOp, boolean hasDefault ); public Map getParameterMap(); public List getParameterList(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java index 702195bb7d8..1a0e2c88f89 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java @@ -26,7 +26,7 @@ import java.util.List; */ public interface ISpecializedSymbol extends ITemplateSymbol { - public void addArgument( TypeInfo arg ); + public void addArgument( ITypeInfo arg ); public List getArgumentList(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java index d2b59e0e3e6..a2667d5a2eb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java @@ -39,21 +39,23 @@ public interface ISymbol extends Cloneable, IExtensibleSymbol { public IContainerSymbol getContainingSymbol(); public void setContainingSymbol( IContainerSymbol containing ); - public boolean isType( TypeInfo.eType type ); - public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ); - public TypeInfo.eType getType(); - public void setType(TypeInfo.eType t); - public TypeInfo getTypeInfo(); - public void setTypeInfo( TypeInfo info ); + public boolean isType( ITypeInfo.eType type ); + public boolean isType( ITypeInfo.eType type, ITypeInfo.eType upperType ); + public ITypeInfo.eType getType(); + public void setType(ITypeInfo.eType t); + public ITypeInfo getTypeInfo(); + public void setTypeInfo( ITypeInfo info ); public ISymbol getTypeSymbol(); public void setTypeSymbol( ISymbol type ); public boolean isForwardDeclaration(); public void setIsForwardDeclaration( boolean forward ); + public void setForwardSymbol( ISymbol forward ); + public ISymbol getForwardSymbol(); public int compareCVQualifiersTo( ISymbol symbol ); public List getPtrOperators(); - public void addPtrOperator( TypeInfo.PtrOp ptrOp ); + public void addPtrOperator( ITypeInfo.PtrOp ptrOp ); public boolean isTemplateInstance(); public ISymbol getInstantiatedSymbol(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ITypeInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ITypeInfo.java new file mode 100644 index 00000000000..e146e3ecff0 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ITypeInfo.java @@ -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 ); +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java index 54999f21f86..ed42893ab94 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParameterizedSymbol.java @@ -22,8 +22,6 @@ import java.util.Map; import java.util.TreeMap; 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 @@ -37,11 +35,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz super( table, name ); } - protected ParameterizedSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){ - super( table, name, obj ); - } - - protected ParameterizedSymbol( ParserSymbolTable table, String name, TypeInfo.eType typeInfo ){ + protected ParameterizedSymbol( ParserSymbolTable table, String name, ITypeInfo.eType typeInfo ){ super( table, name, typeInfo ); } @@ -66,10 +60,10 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz ParameterizedSymbol newParameterized = (ParameterizedSymbol) super.instantiate( template, argMap ); if( _returnType != null ){ - if( _returnType.isType( TypeInfo.t_templateParameter ) ){ + if( _returnType.isType( ITypeInfo.t_templateParameter ) ){ if( argMap.containsKey( _returnType ) ){ 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 ); } } else { @@ -81,7 +75,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz } //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(); int size = params.size(); @@ -148,7 +142,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz } param.setContainingSymbol( this ); - param.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template ); + param.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template ); // Command command = new AddParameterCommand( this, param ); // getSymbolTable().pushCommand( command ); @@ -157,14 +151,11 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz /* (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) */ - 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); - TypeInfo t = param.getTypeInfo(); - t.setTypeInfo( info ); - t.setType( type ); - t.addPtrOperator( ptrOp ); - t.setHasDefault( hasDefault ); + ITypeInfo t = TypeInfoProvider.newTypeInfo( type, info, ptrOp, hasDefault ); + param.setTypeInfo( t ); addParameter( param ); } @@ -172,15 +163,11 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz /* (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) */ - 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); - TypeInfo nfo = param.getTypeInfo(); - nfo.setTypeInfo( info ); - nfo.setType( TypeInfo.t_type ); - nfo.setTypeSymbol( typeSymbol ); - nfo.addPtrOperator( ptrOp ); - nfo.setHasDefault( hasDefault ); + ITypeInfo nfo = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, info, typeSymbol, ptrOp, hasDefault ); + param.setTypeInfo( nfo ); addParameter( param ); } @@ -225,8 +212,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz List params = getParameterList(); List functionParams = function.getParameterList(); - TypeInfo info = null; - TypeInfo fInfo = null; + ITypeInfo info = null; + ITypeInfo fInfo = null; TypeInfoProvider provider = getSymbolTable().getTypeInfoProvider(); @@ -241,33 +228,33 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz info = ParserSymbolTable.getFlatTypeInfo( info, 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 //only the second and subsequent array dimensions are significant in parameter types ListIterator ptrs = nfo.getPtrOperators().listIterator(); if( ptrs.hasNext() ){ - PtrOp op = (PtrOp) ptrs.next(); - if( op.getType() == PtrOp.t_array ){ + ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) ptrs.next(); + if( op.getType() == ITypeInfo.PtrOp.t_array ){ 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 - if( nfo.isType( TypeInfo.t_type ) && nfo.getTypeSymbol() != null && - nfo.getTypeSymbol().isType( TypeInfo.t_function ) ) + if( nfo.isType( ITypeInfo.t_type ) && nfo.getTypeSymbol() != null && + nfo.getTypeSymbol().isType( ITypeInfo.t_function ) ) { 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) if( nfo.getPtrOperators().size() == 0 ){ - nfo.setBit( false, TypeInfo.isConst ); - nfo.setBit( false, TypeInfo.isVolatile ); + nfo.setBit( false, ITypeInfo.isConst ); + nfo.setBit( false, ITypeInfo.isVolatile ); } 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.setVolatile( false ); } @@ -295,7 +282,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz public void setReturnType( ISymbol type ){ _returnType = type; _returnType.setContainingSymbol( this ); - _returnType.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template ); + _returnType.setIsTemplateMember( isTemplateMember() || getType() == ITypeInfo.t_template ); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java index 78ab84c6e77..32f53d59df5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java @@ -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.IASTNode; import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; /** * @author aniefer @@ -49,7 +48,7 @@ public class ParserSymbolTable { */ public ParserSymbolTable( ParserLanguage language, ParserMode mode ) { super(); - _compilationUnit = newContainerSymbol( EMPTY_NAME, TypeInfo.t_namespace ); + _compilationUnit = newContainerSymbol( EMPTY_NAME, ITypeInfo.t_namespace ); _language = language; _mode = mode; } @@ -62,7 +61,7 @@ public class ParserSymbolTable { if( name == null ) name = EMPTY_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; return new ContainerSymbol( this, name, type ); } @@ -71,7 +70,7 @@ public class ParserSymbolTable { if( name == null ) name = EMPTY_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; return new BasicSymbol( this, name, type ); } @@ -80,7 +79,7 @@ public class ParserSymbolTable { if( name == null ) name = EMPTY_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; return new DerivableContainerSymbol( this, name, type ); } @@ -88,7 +87,7 @@ public class ParserSymbolTable { if( name == null ) name = EMPTY_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; return new ParameterizedSymbol( this, name, type ); } @@ -116,9 +115,9 @@ public class ParserSymbolTable { static protected void lookup( LookupData data, IContainerSymbol inSymbol ) throws ParserSymbolTableException { //handle namespace aliases - if( inSymbol.isType( TypeInfo.t_namespace ) ){ - ISymbol symbol = inSymbol.getTypeSymbol(); - if( symbol != null && symbol.isType( TypeInfo.t_namespace ) ){ + if( inSymbol.isType( ITypeInfo.t_namespace ) ){ + ISymbol symbol = inSymbol.getForwardSymbol(); + if( symbol != null && symbol.isType( ITypeInfo.t_namespace ) ){ inSymbol = (IContainerSymbol) symbol; } } @@ -457,8 +456,8 @@ public class ParserSymbolTable { return true; } - TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider(); - TypeInfo typeInfo = ParserSymbolTable.getFlatTypeInfo( symbol.getTypeInfo(), provider ); + TypeInfoProvider provider = TypeInfoProvider.getProvider( symbol.getSymbolTable() ); + ITypeInfo typeInfo = ParserSymbolTable.getFlatTypeInfo( symbol.getTypeInfo(), provider ); boolean accept = data.getFilter().shouldAccept( symbol, typeInfo ) || data.getFilter().shouldAccept( symbol ); provider.returnTypeInfo( typeInfo ); @@ -491,13 +490,13 @@ public class ParserSymbolTable { if( ( data.returnInvisibleSymbols || !symbol.getIsInvisible() ) && checkType( data, symbol ) ){ foundSymbol = symbol; - if( foundSymbol.isType( TypeInfo.t_function ) ){ - if( foundSymbol.isForwardDeclaration() && foundSymbol.getTypeSymbol() != null && - foundSymbol.getTypeSymbol().getContainingSymbol() == foundSymbol.getContainingSymbol() ) + if( foundSymbol.isType( ITypeInfo.t_function ) ){ + if( foundSymbol.isForwardDeclaration() && foundSymbol.getForwardSymbol() != null && + 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 ); } else { functionSet.add( foundSymbol ); @@ -505,14 +504,14 @@ public class ParserSymbolTable { } else { //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 ){ cls = (IContainerSymbol) foundSymbol; } 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 = (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) } else { if( data.isPrefixLookup() ){ @@ -738,8 +737,8 @@ public class ParserSymbolTable { ISymbol symbol = ( objList != null ) ? (ISymbol) objList.get(0) : ( ISymbol )obj1; int idx = 1; while( symbol != null ) { - TypeInfo type = ((ISymbol)obj1).getTypeInfo(); - if( !type.checkBit( TypeInfo.isStatic ) && !type.isType( TypeInfo.t_enumerator ) ){ + ITypeInfo type = ((ISymbol)obj1).getTypeInfo(); + if( !type.checkBit( ITypeInfo.isStatic ) && !type.isType( ITypeInfo.t_enumerator ) ){ return false; } @@ -788,10 +787,10 @@ public class ParserSymbolTable { * it finds the name to be a function name" */ protected static boolean isValidOverload( ISymbol origSymbol, ISymbol newSymbol ){ - TypeInfo.eType origType = origSymbol.getType(); - TypeInfo.eType newType = newSymbol.getType(); + ITypeInfo.eType origType = origSymbol.getType(); + ITypeInfo.eType newType = newSymbol.getType(); - if( origType == TypeInfo.t_template ){ + if( origType == ITypeInfo.t_template ){ ITemplateSymbol template = (ITemplateSymbol) origSymbol; origSymbol = template.getTemplatedSymbol(); if( origSymbol == null ) @@ -799,7 +798,7 @@ public class ParserSymbolTable { origType = origSymbol.getType(); } - if( newType == TypeInfo.t_template ){ + if( newType == ITypeInfo.t_template ){ ITemplateSymbol template = (ITemplateSymbol) newSymbol; newSymbol = template.getTemplatedSymbol(); if( newSymbol == null ) @@ -808,8 +807,8 @@ public class ParserSymbolTable { } //handle forward decls - if( origSymbol.getTypeInfo().isForwardDeclaration() ){ - if( origSymbol.getTypeSymbol() == newSymbol ) + if( origSymbol.isForwardDeclaration() ){ + if( origSymbol.getForwardSymbol() == newSymbol ) return true; //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 ... - ( newType == TypeInfo.t_type || (newType.compareTo( TypeInfo.t_function ) >= 0 /*&& newType <= TypeInfo.typeMask*/) ) ){ + if( (origType.compareTo(ITypeInfo.t_class) >= 0 && origType.compareTo(ITypeInfo.t_enumeration) <= 0) && //class name or enumeration ... + ( newType == ITypeInfo.t_type || (newType.compareTo( ITypeInfo.t_function ) >= 0 /*&& newType <= TypeInfo.typeMask*/) ) ){ return true; } @@ -835,7 +834,7 @@ public class ParserSymbolTable { if( origList.size() == 1 ){ return isValidOverload( (ISymbol)origList.get(0), newSymbol ); } else if ( origList.size() > 1 ){ - if( newSymbol.isType( TypeInfo.t_template ) ){ + if( newSymbol.isType( ITypeInfo.t_template ) ){ ITemplateSymbol template = (ITemplateSymbol) newSymbol; 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 //must be functions. So make sure the newDecl is a function before even //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; } //Iterator iter = origList.iterator(); ISymbol symbol = (ISymbol) origList.get(0); int numSymbols = origList.size(); - if( symbol.isType( TypeInfo.t_template ) ){ + if( symbol.isType( ITypeInfo.t_template ) ){ IParameterizedSymbol template = (IParameterizedSymbol) symbol; symbol = (ISymbol) template.getContainedSymbols().get( template.getName() ); } @@ -859,7 +858,7 @@ public class ParserSymbolTable { int idx = 1; while( valid && idx < numSymbols ){ symbol = (ISymbol) origList.get(idx++); - if( symbol.isType( TypeInfo.t_template ) ){ + if( symbol.isType( ITypeInfo.t_template ) ){ ITemplateSymbol template = (ITemplateSymbol) symbol; symbol = template.getTemplatedSymbol(); } @@ -874,21 +873,21 @@ public class ParserSymbolTable { } private static boolean isValidFunctionOverload( IParameterizedSymbol origSymbol, IParameterizedSymbol newSymbol ){ - if( ( !origSymbol.isType( TypeInfo.t_function ) && !origSymbol.isType( TypeInfo.t_constructor ) ) || - ( ! newSymbol.isType( TypeInfo.t_function ) && ! newSymbol.isType( TypeInfo.t_constructor ) ) ){ + if( ( !origSymbol.isType( ITypeInfo.t_function ) && !origSymbol.isType( ITypeInfo.t_constructor ) ) || + ( ! newSymbol.isType( ITypeInfo.t_function ) && ! newSymbol.isType( ITypeInfo.t_constructor ) ) ){ return false; } //handle forward decls - if( origSymbol.getTypeInfo().isForwardDeclaration() && - origSymbol.getTypeSymbol() == newSymbol ) + if( origSymbol.isForwardDeclaration() && + origSymbol.getForwardSymbol() == newSymbol ) { return true; } if( origSymbol.hasSameParameters( newSymbol ) ){ //functions with the same name and same parameter types cannot be overloaded if any of them //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; } @@ -940,12 +939,12 @@ public class ParserSymbolTable { functionList.addAll( (List) object ); } else { ISymbol symbol = (ISymbol) object; - if( symbol.isType( TypeInfo.t_function ) ){ + if( symbol.isType( ITypeInfo.t_function ) ){ functionList = new ArrayList(1); functionList.add( symbol ); } else { 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(); if( resolvedSymbol instanceof ISpecializedSymbol ){ @@ -1004,7 +1003,7 @@ public class ParserSymbolTable { } else if ( numFns == 2 ){ for (int i = 0; i < numFns; 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() ) ){ return (IParameterizedSymbol) fn.getTypeSymbol(); } @@ -1021,9 +1020,9 @@ public class ParserSymbolTable { Cost [] bestFnCost = null; //the cost of the best function Cost [] currFnCost = null; //the cost for the current function - TypeInfo source = null; //parameter we are called with - TypeInfo target = null; //function's parameter - TypeInfo voidInfo = null; //used to compare f() and f(void) + ITypeInfo source = null; //parameter we are called with + ITypeInfo target = null; //function's parameter + ITypeInfo voidInfo = null; //used to compare f() and f(void) int comparison; 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 targetParameters = null; //the current function's parameters - TypeInfoProvider infoProvider = getTypeInfoProvider(); + TypeInfoProvider infoProvider = TypeInfoProvider.getProvider( this ); if( numSourceParams == 0 ){ //f() is the same as f( void ) sourceParameters = new ArrayList(1); - voidInfo = infoProvider.getTypeInfo(); - voidInfo.setType( TypeInfo.t_void ); + voidInfo = infoProvider.getTypeInfo( ITypeInfo.t_void ); + voidInfo.setType( ITypeInfo.t_void ); sourceParameters.add( voidInfo ); numSourceParams = 1; } else { @@ -1056,10 +1055,10 @@ public class ParserSymbolTable { currFn = (IParameterizedSymbol) functions.get( fnIdx ); if( bestFn != null ){ - if( bestFn.isForwardDeclaration() && bestFn.getTypeSymbol() == currFn ){ + if( bestFn.isForwardDeclaration() && bestFn.getForwardSymbol() == currFn ){ bestFn = currFn; continue; - } else if( currFn.isForwardDeclaration() && currFn.getTypeSymbol() == bestFn ){ + } else if( currFn.isForwardDeclaration() && currFn.getForwardSymbol() == bestFn ){ continue; } } @@ -1069,7 +1068,7 @@ public class ParserSymbolTable { //the only way we get here and have no parameters, is if we are looking //for a function that takes void parameters ie f( void ) targetParameters = new ArrayList(1); - targetParameters.add( currFn.getSymbolTable().newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$ + targetParameters.add( currFn.getSymbolTable().newSymbol( "", ITypeInfo.t_void ) ); //$NON-NLS-1$ } else { targetParameters = currFn.getParameterList(); } @@ -1083,7 +1082,7 @@ public class ParserSymbolTable { boolean varArgs = false; for( int j = 0; j < numSourceParams; j++ ){ - source = (TypeInfo) sourceParameters.get(j); + source = (ITypeInfo) sourceParameters.get(j); if( j < numTargetParams ) target = ((ISymbol)targetParameters.get(j)).getTypeInfo(); @@ -1093,7 +1092,7 @@ public class ParserSymbolTable { if( varArgs ){ cost = new Cost( infoProvider, source, null ); 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 cost = new Cost( infoProvider, source, target ); cost.rank = Cost.IDENTITY_RANK; @@ -1258,12 +1257,12 @@ public class ParserSymbolTable { return function.getParameterList().isEmpty(); } //create a new function that has params as its parameters, then use IParameterizedSymbol.hasSameParameters - IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME, TypeInfo.t_function ); + IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME, ITypeInfo.t_function ); int size = params.size(); for( int i = 0; i < size; i++ ){ ISymbol param = function.getSymbolTable().newSymbol( EMPTY_NAME ); - param.setTypeInfo( (TypeInfo) params.get(i) ); + param.setTypeInfo( (ITypeInfo) params.get(i) ); tempFn.addParameter( param ); } @@ -1289,7 +1288,7 @@ public class ParserSymbolTable { //sanity check if( obj instanceof IParameterizedSymbol ){ 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-- ); size--; continue; @@ -1314,12 +1313,12 @@ public class ParserSymbolTable { //check for void else if( numParameters == 0 && num == 1 ){ ISymbol param = (ISymbol)function.getParameterList().get(0); - if( param.isType( TypeInfo.t_void ) ) + if( param.isType( ITypeInfo.t_void ) ) continue; } else if( numParameters == 1 && num == 0 ){ - TypeInfo paramType = (TypeInfo) data.getParameters().get(0); - if( paramType.isType( TypeInfo.t_void ) ) + ITypeInfo paramType = (ITypeInfo) data.getParameters().get(0); + if( paramType.isType( ITypeInfo.t_void ) ) continue; } @@ -1341,7 +1340,7 @@ public class ParserSymbolTable { continue; } List params = function.getParameterList(); - TypeInfo param; + ITypeInfo param; for( int j = num - 1; j > ( numParameters - num); j-- ){ param = ((ISymbol)params.get(j)).getTypeInfo(); 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 //which it is defined. if it is a class member, its associated class is the member's //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() ); } } @@ -1526,7 +1525,7 @@ public class ParserSymbolTable { //TODO: what about IDeferredTemplateInstance parents? if( base instanceof IDerivableContainerSymbol ){ classes.add( base ); - if( base.getContainingSymbol().getType() == TypeInfo.t_namespace ){ + if( base.getContainingSymbol().getType() == ITypeInfo.t_namespace ){ classes.add( base.getContainingSymbol()); } @@ -1541,11 +1540,11 @@ public class ParserSymbolTable { boolean okToAdd = false; //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; } //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(); try{ @@ -1553,7 +1552,7 @@ public class ParserSymbolTable { if( obj.getContainingSymbol().getType() == context.getType() ){ 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 container = container.getContainingSymbol(); okToAdd = ( container instanceof IDerivableContainerSymbol ) @@ -1561,7 +1560,7 @@ public class ParserSymbolTable { : false; } //an enumerator for an enumeration - else if ( obj.getType() == TypeInfo.t_enumerator ){ + else if ( obj.getType() == ITypeInfo.t_enumerator ){ container = container.getContainingSymbol(); okToAdd = ( container instanceof IDerivableContainerSymbol ) ? ( hasBaseClass( context, container ) > 0 ) @@ -1577,14 +1576,14 @@ public class ParserSymbolTable { 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 - if( source.isType( TypeInfo.t_type ) ){ + if( source.isType( ITypeInfo.t_type ) ){ source = getFlatTypeInfo( source, null ); } - if( target.isType( TypeInfo.t_type ) ){ + if( target.isType( ITypeInfo.t_type ) ){ target = getFlatTypeInfo( target, null ); } @@ -1596,19 +1595,19 @@ public class ParserSymbolTable { return cost; } - TypeInfo.PtrOp op = null; + ITypeInfo.PtrOp op = null; if( cost.getSource().hasPtrOperators() ){ List sourcePtrs = cost.getSource().getPtrOperators(); - TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)sourcePtrs.get( 0 ); - if( ptr.getType() == TypeInfo.PtrOp.t_reference ){ + ITypeInfo.PtrOp ptr = (ITypeInfo.PtrOp)sourcePtrs.get( 0 ); + if( ptr.getType() == ITypeInfo.PtrOp.t_reference ){ sourcePtrs.remove( 0 ); } int size = sourcePtrs.size(); for( int i = 0; i < size; i++ ){ - op = (TypeInfo.PtrOp) sourcePtrs.get( 0 ); - if( op.getType() == TypeInfo.PtrOp.t_array ){ - op.setType( TypeInfo.PtrOp.t_pointer ); + op = (ITypeInfo.PtrOp) sourcePtrs.get( 0 ); + if( op.getType() == ITypeInfo.PtrOp.t_array ){ + op.setType( ITypeInfo.PtrOp.t_pointer ); } } } @@ -1616,17 +1615,17 @@ public class ParserSymbolTable { if( cost.getTarget().hasPtrOperators() ){ List targetPtrs = cost.getTarget().getPtrOperators(); //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); cost.targetHadReference = true; } int size = targetPtrs.size(); for( int i = 0; i < size; i++ ){ - op = (TypeInfo.PtrOp) targetPtrs.get(0); - if( op.getType() == TypeInfo.PtrOp.t_array ){ - op.setType( TypeInfo.PtrOp.t_pointer ); + op = (ITypeInfo.PtrOp) targetPtrs.get(0); + if( op.getType() == ITypeInfo.PtrOp.t_array ){ + op.setType( ITypeInfo.PtrOp.t_pointer ); } } } @@ -1646,20 +1645,20 @@ public class ParserSymbolTable { int size = sourcePtrs.size(); int size2 = targetPtrs.size(); - TypeInfo.PtrOp op1 = null, op2 = null; + ITypeInfo.PtrOp op1 = null, op2 = null; boolean canConvert = true; if( size != size2 ){ canConvert = false; } else if( size > 0 ){ - op1 = (TypeInfo.PtrOp) sourcePtrs.get(0); - op2 = (TypeInfo.PtrOp) targetPtrs.get(0); + op1 = (ITypeInfo.PtrOp) sourcePtrs.get(0); + op2 = (ITypeInfo.PtrOp) targetPtrs.get(0); boolean constInEveryCV2k = true; for( int j= 1; j < size; j++ ){ - op1 = (TypeInfo.PtrOp) sourcePtrs.get(j); - op2 = (TypeInfo.PtrOp) targetPtrs.get(j); + op1 = (ITypeInfo.PtrOp) sourcePtrs.get(j); + op2 = (ITypeInfo.PtrOp) targetPtrs.get(j); //pointer types must be similar if( op1.getType() != op2.getType() ){ @@ -1684,8 +1683,8 @@ public class ParserSymbolTable { } } - if( ( cost.getSource().checkBit( TypeInfo.isConst ) && !cost.getTarget().checkBit( TypeInfo.isConst ) ) || - ( cost.getSource().checkBit( TypeInfo.isVolatile ) && !cost.getTarget().checkBit( TypeInfo.isVolatile ) ) ) + if( ( cost.getSource().checkBit( ITypeInfo.isConst ) && !cost.getTarget().checkBit( ITypeInfo.isConst ) ) || + ( cost.getSource().checkBit( ITypeInfo.isVolatile ) && !cost.getTarget().checkBit( ITypeInfo.isVolatile ) ) ) { canConvert = false; } @@ -1713,23 +1712,23 @@ public class ParserSymbolTable { * 4.6 float can be promoted to double */ static private void promotion( Cost cost ){ - TypeInfo src = cost.getSource(); - TypeInfo trg = cost.getTarget(); + ITypeInfo src = cost.getSource(); + 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 )) && - (trg.isType( TypeInfo.t_int ) || trg.isType( TypeInfo.t_double )) ) + if( (src.isType( ITypeInfo.t__Bool, ITypeInfo.t_float ) || src.isType( ITypeInfo.t_enumeration )) && + (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 return; } - if( src.isType( TypeInfo.t_float ) ){ - cost.promotion = trg.isType( TypeInfo.t_double ) ? 1 : 0; + if( src.isType( ITypeInfo.t_float ) ){ + cost.promotion = trg.isType( ITypeInfo.t_double ) ? 1 : 0; } 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 { @@ -1747,8 +1746,8 @@ public class ParserSymbolTable { * */ static private void conversion( Cost cost ){ - TypeInfo src = cost.getSource(); - TypeInfo trg = cost.getTarget(); + ITypeInfo src = cost.getSource(); + ITypeInfo trg = cost.getTarget(); int temp = -1; @@ -1759,17 +1758,17 @@ public class ParserSymbolTable { return; } if( src.hasPtrOperators() && src.getPtrOperators().size() == 1 ){ - TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)src.getPtrOperators().get(0); - ISymbol srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeSymbol() : null; - ISymbol trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeSymbol() : null; - if( ptr.getType() == TypeInfo.PtrOp.t_pointer ){ - if( srcDecl == null || (trgDecl == null && !trg.isType( TypeInfo.t_void )) ){ + ITypeInfo.PtrOp ptr = (ITypeInfo.PtrOp)src.getPtrOperators().get(0); + ISymbol srcDecl = src.isType( ITypeInfo.t_type ) ? src.getTypeSymbol() : null; + ISymbol trgDecl = trg.isType( ITypeInfo.t_type ) ? trg.getTypeSymbol() : null; + if( ptr.getType() == ITypeInfo.PtrOp.t_pointer ){ + if( srcDecl == null || (trgDecl == null && !trg.isType( ITypeInfo.t_void )) ){ return; } //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" - if( trg.isType( TypeInfo.t_void ) ){ + if( trg.isType( ITypeInfo.t_void ) ){ cost.rank = Cost.CONVERSION_RANK; cost.conversion = 1; cost.detail = 2; @@ -1791,7 +1790,7 @@ public class ParserSymbolTable { cost.detail = 1; 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, //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 @@ -1799,8 +1798,8 @@ public class ParserSymbolTable { return; } - TypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (TypeInfo.PtrOp)trg.getPtrOperators().get(0) : null; - if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == TypeInfo.PtrOp.t_memberPointer ){ + ITypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (ITypeInfo.PtrOp)trg.getPtrOperators().get(0) : null; + if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == ITypeInfo.PtrOp.t_memberPointer ){ try { temp = hasBaseClass( ptr.getMemberOf(), srcPtr.getMemberOf() ); } catch (ParserSymbolTableException e) { @@ -1815,12 +1814,12 @@ public class ParserSymbolTable { } else if( !src.hasPtrOperators() ) { //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. - if( src.isType( TypeInfo.t__Bool, TypeInfo.t_int ) || - src.isType( TypeInfo.t_float, TypeInfo.t_double ) || - src.isType( TypeInfo.t_enumeration ) ) + if( src.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) || + src.isType( ITypeInfo.t_float, ITypeInfo.t_double ) || + src.isType( ITypeInfo.t_enumeration ) ) { - if( trg.isType( TypeInfo.t__Bool, TypeInfo.t_int ) || - trg.isType( TypeInfo.t_float, TypeInfo.t_double ) ) + if( trg.isType( ITypeInfo.t__Bool, ITypeInfo.t_int ) || + trg.isType( ITypeInfo.t_float, ITypeInfo.t_double ) ) { cost.rank = Cost.CONVERSION_RANK; cost.conversion = 1; @@ -1830,11 +1829,11 @@ public class ParserSymbolTable { } static private void derivedToBaseConversion( Cost cost ) throws ParserSymbolTableException{ - TypeInfo src = cost.getSource(); - TypeInfo trg = cost.getTarget(); + ITypeInfo src = cost.getSource(); + ITypeInfo trg = cost.getTarget(); - ISymbol srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeSymbol() : null; - ISymbol trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeSymbol() : null; + ISymbol srcDecl = src.isType( ITypeInfo.t_type ) ? src.getTypeSymbol() : null; + ISymbol trgDecl = trg.isType( ITypeInfo.t_type ) ? trg.getTypeSymbol() : null; if( !src.hasSamePtrs( trg ) || srcDecl == null || trgDecl == null || !cost.targetHadReference ){ return; @@ -1848,8 +1847,8 @@ public class ParserSymbolTable { } } - protected Cost checkStandardConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException{ - Cost cost = lvalue_to_rvalue( getTypeInfoProvider(), source, target ); + protected Cost checkStandardConversionSequence( ITypeInfo source, ITypeInfo target ) throws ParserSymbolTableException{ + Cost cost = lvalue_to_rvalue( TypeInfoProvider.getProvider( this ), source, target ); if( cost.getSource() == null || cost.getTarget() == null ){ return cost; @@ -1868,7 +1867,7 @@ public class ParserSymbolTable { } //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() ) ){ ISymbol srcSymbol = cost.getSource().getTypeSymbol(); ISymbol trgSymbol = cost.getTarget().getTypeSymbol(); @@ -1880,7 +1879,7 @@ public class ParserSymbolTable { } } } 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; } @@ -1897,14 +1896,14 @@ public class ParserSymbolTable { try{ derivedToBaseConversion( cost ); } catch ( ParserSymbolTableException e ){ - cost.release( getTypeInfoProvider() ); + cost.release( TypeInfoProvider.getProvider( this ) ); throw e; } return cost; } - private Cost checkUserDefinedConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException { + private Cost checkUserDefinedConversionSequence( ITypeInfo source, ITypeInfo target ) throws ParserSymbolTableException { Cost cost = null; Cost constructorCost = null; Cost conversionCost = null; @@ -1915,12 +1914,12 @@ public class ParserSymbolTable { IParameterizedSymbol conversion = null; //constructors - if( target.getType() == TypeInfo.t_type ){ + if( target.getType() == ITypeInfo.t_type ){ targetDecl = target.getTypeSymbol(); if( targetDecl == null ){ 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){ public List getParameters() { return parameters; } public TypeFilter getFilter() { return CONSTRUCTOR_FILTER; } @@ -1938,18 +1937,19 @@ public class ParserSymbolTable { ArrayList constructors = new ArrayList( container.getConstructors() ); constructor = resolveFunction( data, constructors ); } - if( constructor != null && constructor.getTypeInfo().checkBit( TypeInfo.isExplicit ) ){ + if( constructor != null && constructor.getTypeInfo().checkBit( ITypeInfo.isExplicit ) ){ constructor = null; } } } + TypeInfoProvider provider = TypeInfoProvider.getProvider( this ); //conversion operators - if( source.getType() == TypeInfo.t_type ){ - source = getFlatTypeInfo( source, getTypeInfoProvider() ); + if( source.getType() == ITypeInfo.t_type ){ + source = getFlatTypeInfo( source, provider ); sourceDecl = ( source != null ) ? source.getTypeSymbol() : null; - getTypeInfoProvider().returnTypeInfo( source ); + provider.returnTypeInfo( source ); if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){ String name = target.toString(); @@ -1968,18 +1968,16 @@ public class ParserSymbolTable { try { if( constructor != null ){ - TypeInfo info = getTypeInfoProvider().getTypeInfo(); - info.setType( TypeInfo.t_type ); + ITypeInfo info = provider.getTypeInfo( ITypeInfo.t_type ); info.setTypeSymbol( constructor.getContainingSymbol() ); constructorCost = checkStandardConversionSequence( info, target ); - getTypeInfoProvider().returnTypeInfo( info ); + provider.returnTypeInfo( info ); } if( conversion != null ){ - TypeInfo info = getTypeInfoProvider().getTypeInfo(); - info.setType( target.getType() ); + ITypeInfo info = provider.getTypeInfo( target.getType() ); info.setTypeSymbol( target.getTypeSymbol() ); conversionCost = checkStandardConversionSequence( info, target ); - getTypeInfoProvider().returnTypeInfo( info ); + provider.returnTypeInfo( info ); } //if both are valid, then the conversion is ambiguous @@ -2002,9 +2000,9 @@ public class ParserSymbolTable { } } finally { if( constructorCost != null && constructorCost != cost ) - constructorCost.release( getTypeInfoProvider() ); + constructorCost.release( provider ); if( conversionCost != null && conversionCost != cost ) - conversionCost.release( getTypeInfoProvider() ); + conversionCost.release( provider ); } return cost; } @@ -2021,9 +2019,9 @@ public class ParserSymbolTable { * - 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 ) */ - public TypeInfo getConditionalOperand( TypeInfo secondOp, TypeInfo thirdOp ) throws ParserSymbolTableException{ + public ITypeInfo getConditionalOperand( ITypeInfo secondOp, ITypeInfo thirdOp ) throws ParserSymbolTableException{ Cost thirdCost = null, secondCost = null; - TypeInfo temp = null; + ITypeInfo temp = null; TypeInfoProvider provider = getTypeInfoProvider(); try{ //can secondOp convert to thirdOp ? @@ -2081,24 +2079,25 @@ public class ParserSymbolTable { * The top level TypeInfo represents modifications to the object and the * remaining TypeInfo's represent the object. */ - static protected TypeInfo getFlatTypeInfo( TypeInfo topInfo, TypeInfoProvider infoProvider ){ - TypeInfo returnInfo = null; - TypeInfo info = null; + static protected ITypeInfo getFlatTypeInfo( ITypeInfo topInfo, TypeInfoProvider infoProvider ){ + ITypeInfo returnInfo = null; + ITypeInfo info = null; - if( topInfo.getType() == TypeInfo.t_type && topInfo.getTypeSymbol() != null ){ - if( infoProvider != null ) returnInfo = infoProvider.getTypeInfo(); - else returnInfo = new TypeInfo(); + if( topInfo.getType() == ITypeInfo.t_type && topInfo.getTypeSymbol() != null ){ + if( infoProvider != null ) returnInfo = infoProvider.getTypeInfo( ITypeInfo.t_type ); + else returnInfo = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type ); - returnInfo.setTypeInfo( topInfo.getTypeInfo() ); + returnInfo.setTypeBits( topInfo.getTypeBits() ); ISymbol typeSymbol = topInfo.getTypeSymbol(); info = typeSymbol.getTypeInfo(); int j = 0; - while( info.getTypeSymbol() != null && ( info.getType() == TypeInfo.t_type || info.isForwardDeclaration() ) ){ - typeSymbol = info.getTypeSymbol(); + while( (info.getTypeSymbol() != null && info.getType() == ITypeInfo.t_type) || + (typeSymbol != null && typeSymbol.isForwardDeclaration() && typeSymbol.getForwardSymbol() != null ) ){ + typeSymbol = info.isType( ITypeInfo.t_type) ? info.getTypeSymbol() : typeSymbol.getForwardSymbol(); 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(); if( ++j > TYPE_LOOP_THRESHOLD ){ if( infoProvider != null ) @@ -2107,46 +2106,33 @@ public class ParserSymbolTable { } } - if( info.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) || info.isType( TypeInfo.t_function ) ){ - returnInfo.setType( TypeInfo.t_type ); + if( info.isType( ITypeInfo.t_class, ITypeInfo.t_enumeration ) || info.isType( ITypeInfo.t_function ) ){ + returnInfo.setType( ITypeInfo.t_type ); returnInfo.setTypeSymbol( typeSymbol ); } 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.setTypeSymbol( null ); returnInfo.addPtrOperator( info.getPtrOperators() ); } - if( returnInfo.isType( TypeInfo.t_templateParameter ) ){ + if( returnInfo.isType( ITypeInfo.t_templateParameter ) ){ returnInfo.setTypeSymbol( typeSymbol ); } - returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() ); if( topInfo.hasPtrOperators() ){ - TypeInfo.PtrOp topPtr = (PtrOp) topInfo.getPtrOperators().get(0); - TypeInfo.PtrOp ptr = new PtrOp( topPtr.getType(), topPtr.isConst(), topPtr.isVolatile() ); - returnInfo.addPtrOperator( ptr ); + returnInfo.addPtrOperator( topInfo.getPtrOperators() ); } } else { if( infoProvider != null ){ - returnInfo = infoProvider.getTypeInfo(); + returnInfo = infoProvider.getTypeInfo( topInfo.getType() ); returnInfo.copy( topInfo ); } else - returnInfo = new TypeInfo( topInfo ); - returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() ); - returnInfo.getOperatorExpressions().clear(); + returnInfo = TypeInfoProvider.newTypeInfo( topInfo ); } return returnInfo; } - /** - * @return - */ - public TypeInfoProvider getTypeInfoProvider() { - return _provider; - } - - private TypeInfoProvider _provider = new TypeInfoProvider(); private IContainerSymbol _compilationUnit; private ParserLanguage _language; private ParserMode _mode; @@ -2163,6 +2149,10 @@ public class ParserSymbolTable { return _mode; } + public TypeInfoProvider getTypeInfoProvider(){ + return TypeInfoProvider.getProvider( this ); + } + // protected void pushCommand( Command command ){ // undoList.addFirst( command ); // } @@ -2214,9 +2204,9 @@ public class ParserSymbolTable { static protected class LookupData { - protected static final TypeFilter ANY_FILTER = new TypeFilter( TypeInfo.t_any ); - protected static final TypeFilter CONSTRUCTOR_FILTER = new TypeFilter( TypeInfo.t_constructor ); - protected static final TypeFilter FUNCTION_FILTER = new TypeFilter( TypeInfo.t_function ); + protected static final TypeFilter ANY_FILTER = new TypeFilter( ITypeInfo.t_any ); + protected static final TypeFilter CONSTRUCTOR_FILTER = new TypeFilter( ITypeInfo.t_constructor ); + protected static final TypeFilter FUNCTION_FILTER = new TypeFilter( ITypeInfo.t_function ); public String name; public Map usingDirectives; @@ -2241,7 +2231,7 @@ public class ParserSymbolTable { //this LookupData public boolean isPrefixLookup(){ return false;} //prefix lookup 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 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 @@ -2253,18 +2243,19 @@ public class ParserSymbolTable { static protected class Cost { - public Cost( TypeInfoProvider provider, TypeInfo s, TypeInfo t ){ - source = provider.getTypeInfo(); - if( s != null ) + public Cost( TypeInfoProvider provider, ITypeInfo s, ITypeInfo t ){ + if( s != null ){ + source = provider.getTypeInfo( s.getType() ); source.copy( s ); - - target = provider.getTypeInfo(); - if( t != null ) + } + if( t != null ){ + target = provider.getTypeInfo( t.getType() ); target.copy( t ); + } } - private TypeInfo source; - private TypeInfo target; + private ITypeInfo source; + private ITypeInfo target; public boolean targetHadReference = false; @@ -2336,12 +2327,12 @@ public class ParserSymbolTable { ListIterator iter1 = cost.getTarget().getPtrOperators().listIterator( size ); ListIterator iter2 = getTarget().getPtrOperators().listIterator( size2 ); - TypeInfo.PtrOp op1 = null, op2 = null; + ITypeInfo.PtrOp op1 = null, op2 = null; int subOrSuper = 0; for( int i = ( size < size2 ) ? size : size2; i > 0; i-- ){ - op1 = (TypeInfo.PtrOp)iter1.previous(); - op2 = (TypeInfo.PtrOp)iter2.previous(); + op1 = (ITypeInfo.PtrOp)iter1.previous(); + op2 = (ITypeInfo.PtrOp)iter2.previous(); if( subOrSuper == 0) subOrSuper = op1.compareCVTo( op2 ); @@ -2370,14 +2361,14 @@ public class ParserSymbolTable { /** * @return Returns the source. */ - public TypeInfo getSource() { + public ITypeInfo getSource() { return source; } /** * @return Returns the target. */ - public TypeInfo getTarget() { + public ITypeInfo getTarget() { 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, //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; for( int i = 0; i < numParents; i++ ){ parent = (IParentSymbol) parents.get(i); @@ -2455,62 +2446,4 @@ public class ParserSymbolTable { } 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; - } - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java index 552aca66742..32828a2553d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/SpecializedSymbol.java @@ -29,10 +29,6 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym super( table, name ); } - protected SpecializedSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){ - super( table, name, obj ); - } - public Object clone(){ SpecializedSymbol copy = (SpecializedSymbol)super.clone(); @@ -67,16 +63,16 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym int numSpecArgs = specArgs.size(); for( int i = 0; i < numSpecArgs; i++ ){ - TypeInfo info = (TypeInfo) specArgs.get(i); - TypeInfo mappedInfo = (TypeInfo) arguments.get(i); + ITypeInfo info = (ITypeInfo) specArgs.get(i); + ITypeInfo mappedInfo = (ITypeInfo) arguments.get(i); //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 ); } 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(); param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() ); @@ -141,7 +137,7 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym /* (non-Javadoc) * @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 ) _argumentList = new ArrayList(4); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java index 4b14414bcc0..7595a8ad68b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateEngine.java @@ -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.ParserSymbolTable.Cost; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; /** * @author aniefer */ 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 ) return info; - if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() == null ) + if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol() == null ) 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(); - TypeInfo newInfo = new TypeInfo( info ); + ITypeInfo newInfo = TypeInfoProvider.newTypeInfo( info ); //newInfo.setTypeSymbol( deferred.instantiate( template, argMap ) ); template.registerDeferredInstatiation( newInfo, deferred, ITemplateSymbol.DeferredKind.TYPE_SYMBOL, argMap ); newInfo.setTypeSymbol( deferred ); return newInfo; - } else if( info.isType( TypeInfo.t_type ) && - info.getTypeSymbol().isType( TypeInfo.t_templateParameter ) && + } else if( info.isType( ITypeInfo.t_type ) && + info.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) && 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() ){ targetInfo.addPtrOperator( info.getPtrOperators() ); } - if( info.checkBit( TypeInfo.isConst ) ) - targetInfo.setBit( true, TypeInfo.isConst ); + if( info.checkBit( ITypeInfo.isConst ) ) + targetInfo.setBit( true, ITypeInfo.isConst ); - if( info.checkBit( TypeInfo.isVolatile ) ) - targetInfo.setBit( true, TypeInfo.isVolatile ); + if( info.checkBit( ITypeInfo.isVolatile ) ) + targetInfo.setBit( true, ITypeInfo.isVolatile ); return targetInfo; - } else if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol().isType( TypeInfo.t_function ) ){ - TypeInfo newInfo = new TypeInfo( info ); + } else if( info.isType( ITypeInfo.t_type ) && info.getTypeSymbol().isType( ITypeInfo.t_function ) ){ + ITypeInfo newInfo = TypeInfoProvider.newTypeInfo( info ); newInfo.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) ); 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 ) ); } @@ -74,7 +73,7 @@ public final class TemplateEngine { * @param symbol * @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(); if( !(instance instanceof IDeferredTemplateInstance ) ) template.removeInstantiation( (IContainerSymbol) instance ); @@ -105,12 +104,12 @@ public final class TemplateEngine { int specArgsSize = specArgs.size(); HashMap map = new HashMap(); - TypeInfo info1 = null, info2 = null; + ITypeInfo info1 = null, info2 = null; boolean match = true; for( int j = 0; j < specArgsSize; j++ ){ - info1 = (TypeInfo) specArgs.get(j); - info2 = (TypeInfo) args.get(j); + info1 = (ITypeInfo) specArgs.get(j); + info2 = (ITypeInfo) args.get(j); ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME ); sym1.setTypeInfo( info1 ); @@ -140,17 +139,17 @@ public final class TemplateEngine { return bestMatch; } - static protected boolean matchTemplateParameterAndArgument( ISymbol param, TypeInfo arg ){ + static protected boolean matchTemplateParameterAndArgument( ISymbol param, ITypeInfo arg ){ if( !isValidArgument(param, arg) ){ return false; } - if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){ + if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){ return true; - } else if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){ + } else if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){ 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; } @@ -178,12 +177,18 @@ public final class TemplateEngine { return true; } else { Cost cost = null; + TypeInfoProvider provider = TypeInfoProvider.getProvider( param.getSymbolTable() ); try{ + ITypeInfo info = provider.getTypeInfo( param.getTypeInfo().getTemplateParameterType() ); try { - TypeInfo info = new TypeInfo( param.getTypeInfo() ); + info.copy( param.getTypeInfo() ); info.setType( info.getTemplateParameterType() ); cost = param.getSymbolTable().checkStandardConversionSequence( arg, info ); + provider.returnTypeInfo( info ); } catch (ParserSymbolTableException e) { + //nothing + } finally { + provider.returnTypeInfo( info ); } if( cost == null || cost.rank != Cost.NO_MATCH_RANK ){ @@ -191,16 +196,16 @@ public final class TemplateEngine { } } finally{ if( cost != null ) - cost.release( param.getSymbolTable().getTypeInfoProvider() ); + cost.release( provider ); } } return true; } - static private boolean isValidArgument(ISymbol param, TypeInfo arg) { - if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){ + static private boolean isValidArgument(ISymbol param, ITypeInfo arg) { + if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){ //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(); if( symbol.getName().equals( ParserSymbolTable.EMPTY_NAME ) ){ return false; @@ -208,15 +213,15 @@ public final class TemplateEngine { return false; } } - } else if ( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){ - + } else if ( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){ + //TODO } else { 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( op != null && op.getType() == PtrOp.t_reference ){ - if( arg.isType( TypeInfo.t_type ) && arg.getTypeSymbol() != null ){ + if( op != null && op.getType() == ITypeInfo.PtrOp.t_reference ){ + if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol() != null ){ if( arg.getTypeSymbol().getName().equals( ParserSymbolTable.EMPTY_NAME ) ){ return false; } @@ -225,17 +230,17 @@ public final class TemplateEngine { } 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 //name of an object with external linkage excluding nonstatic class members - if( (argOp != null && argOp.getType() == PtrOp.t_pointer ) || - ( arg.isType( TypeInfo.t_type ) ) ) + if( (argOp != null && argOp.getType() == ITypeInfo.PtrOp.t_pointer ) || + ( arg.isType( ITypeInfo.t_type ) ) ) { ISymbol symbol = arg.getTypeSymbol(); - if ( symbol != null && symbol.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) ){ - if( !symbol.isType( TypeInfo.t_class, TypeInfo.t_union ) ){ - if( !symbol.getTypeInfo().checkBit( TypeInfo.isStatic ) ){ + if ( symbol != null && symbol.getContainingSymbol().isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){ + if( !symbol.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){ + if( !symbol.getTypeInfo().checkBit( ITypeInfo.isStatic ) ){ return false; } } @@ -245,16 +250,16 @@ public final class TemplateEngine { } //integral or enumeration type - if( op == null && ( arg.isType( TypeInfo.t_bool, TypeInfo.t_int ) || - arg.isType( TypeInfo.t_enumerator ) ) ) + if( op == null && ( arg.isType( ITypeInfo.t_bool, ITypeInfo.t_int ) || + arg.isType( ITypeInfo.t_enumerator ) ) ) { return true; } //name of a non-type template parameter - if( arg.isType( TypeInfo.t_templateParameter ) && - arg.getTemplateParameterType() != TypeInfo.t_typeName && - arg.getTemplateParameterType() != TypeInfo.t_template ) + if( arg.isType( ITypeInfo.t_templateParameter ) && + arg.getTemplateParameterType() != ITypeInfo.t_typeName && + arg.getTemplateParameterType() != ITypeInfo.t_template ) { return true; } @@ -263,25 +268,25 @@ public final class TemplateEngine { return true; } - static protected boolean hasExternalLinkage( TypeInfo type ){ - if( ! type.isType( TypeInfo.t_type ) ) + static protected boolean hasExternalLinkage( ITypeInfo type ){ + if( ! type.isType( ITypeInfo.t_type ) ) return false; return !hasNoLinkage( type ); } - static protected boolean hasInternalLinkage( TypeInfo type ){ + static protected boolean hasInternalLinkage( ITypeInfo type ){ return !hasNoLinkage( type ); } - static protected boolean hasNoLinkage( TypeInfo type ){ - if( type.isType( TypeInfo.t_type ) ){ + static protected boolean hasNoLinkage( ITypeInfo type ){ + if( type.isType( ITypeInfo.t_type ) ){ ISymbol symbol = type.getTypeSymbol(); if( symbol.getContainingSymbol() == null ){ return true; //a temporary } - return symbol.getContainingSymbol().isType( TypeInfo.t_function ); + return symbol.getContainingSymbol().isType( ITypeInfo.t_function ); } return false; @@ -293,20 +298,20 @@ public final class TemplateEngine { * @param pSymbol * @return */ - static private TypeInfo getParameterTypeForDeduction( ISymbol pSymbol ){ - TypeInfo p = new TypeInfo( pSymbol.getTypeInfo () ); + static private ITypeInfo getParameterTypeForDeduction( ISymbol pSymbol ){ + ITypeInfo p = TypeInfoProvider.newTypeInfo( pSymbol.getTypeInfo () ); List pPtrs = p.getPtrOperators(); if( pPtrs.size() > 0 ){ - PtrOp pOp = (PtrOp) pPtrs.get( 0 ); - if( pOp.getType() == PtrOp.t_reference || pOp.getType() == PtrOp.t_undef_ptr ){ + ITypeInfo.PtrOp pOp = (ITypeInfo.PtrOp) pPtrs.get( 0 ); + if( pOp.getType() == ITypeInfo.PtrOp.t_reference || pOp.getType() == ITypeInfo.PtrOp.t_undef_ptr ){ pPtrs.remove( 0 ); } else { - PtrOp newOp = new PtrOp( pOp.getType(), false, false ); + ITypeInfo.PtrOp newOp = new ITypeInfo.PtrOp( pOp.getType(), false, false ); pPtrs.set( 0, newOp ); } } else { - p.setBit( false, TypeInfo.isConst ); - p.setBit( false, TypeInfo.isVolatile ); + p.setBit( false, ITypeInfo.isConst ); + p.setBit( false, ITypeInfo.isVolatile ); } @@ -322,32 +327,32 @@ public final class TemplateEngine { * @param aInfo * @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 ){ ISymbol aSymbol = a.getTypeSymbol(); - if( a.getType() == TypeInfo.t_type ){ + if( a.getType() == ITypeInfo.t_type ){ if( aSymbol == null ){ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument ); - } else if( aSymbol.isType( TypeInfo.t_function ) && a.getPtrOperators().size() == 0 ){ - a.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + } else if( aSymbol.isType( ITypeInfo.t_function ) && a.getPtrOperators().size() == 0 ){ + a.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); } } List aPtrs = a.getPtrOperators(); if( aPtrs.size() > 0 ){ - PtrOp pOp = (PtrOp) aPtrs.get( 0 ); + ITypeInfo.PtrOp pOp = (ITypeInfo.PtrOp) aPtrs.get( 0 ); - if( pOp.getType() == PtrOp.t_array ){ - aPtrs.set( 0, new PtrOp( PtrOp.t_pointer, false, false ) ); + if( pOp.getType() == ITypeInfo.PtrOp.t_array ){ + aPtrs.set( 0, new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer, false, false ) ); } else { - aPtrs.set( 0, new PtrOp( pOp.getType(), false, false ) ); + aPtrs.set( 0, new ITypeInfo.PtrOp( pOp.getType(), false, false ) ); } } else { - a.setBit( false, TypeInfo.isConst ); - a.setBit( false, TypeInfo.isVolatile ); + a.setBit( false, ITypeInfo.isConst ); + a.setBit( false, ITypeInfo.isVolatile ); } } @@ -437,30 +442,30 @@ public final class TemplateEngine { 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; boolean pIsAReferenceType = false; 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; } - TypeInfo p = getParameterTypeForDeduction( pSymbol ); + ITypeInfo p = getParameterTypeForDeduction( pSymbol ); a = getArgumentTypeForDeduction( a, pIsAReferenceType ); - if( p.isType( TypeInfo.t_type ) ){ + if( p.isType( ITypeInfo.t_type ) ){ symbol = p.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 ); if( symbol instanceof IDeferredTemplateInstance || symbol.isTemplateInstance() ){ return deduceFromTemplateTemplateArguments(map, symbol, aSymbol); } - if( symbol.isType( TypeInfo.t_templateParameter ) ){ - if( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){ + if( symbol.isType( ITypeInfo.t_templateParameter ) ){ + if( symbol.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){ //a = getFlatTypeInfo( a ); List aPtrs = a.getPtrOperators(); List pPtrs = p.getPtrOperators(); @@ -475,13 +480,13 @@ public final class TemplateEngine { if( pSize != aSize ) return false; - PtrOp pOp = null; - PtrOp aOp = null; + ITypeInfo.PtrOp pOp = null; + ITypeInfo.PtrOp aOp = null; int aIdx = 0; for( int i = 0; i < pSize; i++ ){ - pOp = (PtrOp) pPtrs.get(i); - aOp = (PtrOp) aPtrs.get(aIdx++); + pOp = (ITypeInfo.PtrOp) pPtrs.get(i); + aOp = (ITypeInfo.PtrOp) aPtrs.get(aIdx++); if( pOp.getType() == aOp.getType() ){ if( !pOp.equals( aOp ) ) return false; @@ -492,22 +497,22 @@ public final class TemplateEngine { } } //cvlist T - if( p.checkBit( TypeInfo.isConst ) ){ - if( !a.checkBit( TypeInfo.isConst ) ) + if( p.checkBit( ITypeInfo.isConst ) ){ + if( !a.checkBit( ITypeInfo.isConst ) ) return false; - a.setBit( false, TypeInfo.isConst); + a.setBit( false, ITypeInfo.isConst); } - if( p.checkBit( TypeInfo.isVolatile ) ){ - if( !a.checkBit( TypeInfo.isVolatile ) ) + if( p.checkBit( ITypeInfo.isVolatile ) ){ + if( !a.checkBit( ITypeInfo.isVolatile ) ) return false; - a.setBit( false, TypeInfo.isVolatile); + a.setBit( false, ITypeInfo.isVolatile); } //T return deduceArgument( map, symbol, a ); - } else if ( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){ - + } else if ( symbol.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){ + //TODO } else { //non-type parameter if( symbol.getTypeInfo().getTemplateParameterType() == a.getType() ){ @@ -517,9 +522,9 @@ public final class TemplateEngine { } } //T (*) ( ), T ( T::* ) ( T ), & variations - else if( symbol.isType( TypeInfo.t_function ) ){ + else if( symbol.isType( ITypeInfo.t_function ) ){ if( !(aSymbol instanceof IParameterizedSymbol)|| - !aSymbol.isType( TypeInfo.t_function ) ) + !aSymbol.isType( ITypeInfo.t_function ) ) { return false; } @@ -533,9 +538,9 @@ public final class TemplateEngine { List pPtrs = p.getPtrOperators(); if( pPtrs.size() != 0 ){ - PtrOp op = (PtrOp) pPtrs.get(0); - if( op.getType() == PtrOp.t_memberPointer ){ - TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() ); + ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) pPtrs.get(0); + if( op.getType() == ITypeInfo.PtrOp.t_memberPointer ){ + ITypeInfo info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, aFunction.getContainingSymbol() ); if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){ return false; } @@ -549,7 +554,7 @@ public final class TemplateEngine { } int size = pParams.size(); 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 ) ){ 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 ); } if( p.getType() == a.getType() ){ @@ -621,10 +626,10 @@ public final class TemplateEngine { sym = (ISymbol) obj; } else { 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 { if( !deduceTemplateArgument( map, sym, arg ) ){ @@ -676,7 +681,7 @@ public final class TemplateEngine { } ISymbol templateSymbol = template.getTemplatedSymbol(); - if( !templateSymbol.isType( TypeInfo.t_function ) ){ + if( !templateSymbol.isType( ITypeInfo.t_function ) ){ return null; } @@ -693,7 +698,7 @@ public final class TemplateEngine { int size = pList.size(); for( int i = 0; i < size; i++ ){ 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; } } catch (ParserSymbolTableException e) { @@ -704,12 +709,12 @@ public final class TemplateEngine { 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 ); if( map.containsKey( p ) ){ - TypeInfo current = (TypeInfo)map.get( p ); + ITypeInfo current = (ITypeInfo)map.get( p ); return current.equals( a ); } map.put( p, a ); @@ -733,7 +738,7 @@ public final class TemplateEngine { ITemplateSymbol template1 = spec1; ITemplateSymbol template2 = spec2; - if( decl.isType( TypeInfo.t_class, TypeInfo.t_union ) ) { + if( decl.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ) { template1 = classTemplateSpecializationToFunctionTemplate( spec1 ); template2 = classTemplateSpecializationToFunctionTemplate( spec2 ); } @@ -805,22 +810,22 @@ public final class TemplateEngine { static private Map createMapForFunctionTemplateOrdering( ITemplateSymbol template ){ HashMap map = new HashMap(); - TypeInfo val = null; + ITypeInfo val = null; List paramList = template.getParameterList(); int size = paramList.size(); for( int i = 0; i < size; i++ ){ ISymbol param = (ISymbol) paramList.get( i ); //template type parameter - if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){ - val = new TypeInfo( TypeInfo.t_type, 0, template.getSymbolTable().newSymbol( "", TypeInfo.t_class ) ); //$NON-NLS-1$ + if( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_typeName ){ + val = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, template.getSymbolTable().newSymbol( "", ITypeInfo.t_class ) ); //$NON-NLS-1$ } //template parameter - else if ( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ) { - + else if ( param.getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ) { + //TODO } //non type parameter else { - val = new TypeInfo( param.getTypeInfo().getTemplateParameterType(), 0, null ); + val = TypeInfoProvider.newTypeInfo( param.getTypeInfo().getTemplateParameterType() ); } map.put( param, val ); } @@ -844,13 +849,13 @@ public final class TemplateEngine { //TODO clean up this ((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{ transformed.addSymbol( function ); } catch ( ParserSymbolTableException e ){ //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() ) ); @@ -859,22 +864,22 @@ public final class TemplateEngine { return transformed; } - static private TypeInfo transformTypeInfo( Object obj, Map argumentMap ){ - TypeInfo info = null; + static private ITypeInfo transformTypeInfo( Object obj, Map argumentMap ){ + ITypeInfo info = null; if( obj instanceof ISymbol ){ - info = new TypeInfo( TypeInfo.t_type, 0, (ISymbol) obj ); + info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, (ISymbol) obj ); } else { - info = (TypeInfo) obj; + info = (ITypeInfo) obj; } if( argumentMap == null ) return info; - if( info.isType( TypeInfo.t_type ) && - info.getTypeSymbol().isType( TypeInfo.t_templateParameter ) && - argumentMap.containsKey( info.getTypeSymbol() ) ) + if( info.isType( ITypeInfo.t_type ) && + info.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) && + 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() ) newType.addPtrOperator( info.getPtrOperators() ); @@ -907,8 +912,8 @@ public final class TemplateEngine { List instanceArgs = new ArrayList( templateParams.size() ); for( int i = 0; i < numTemplateParams; i++ ){ ISymbol param = (ISymbol) templateParams.get(i); - TypeInfo arg = (TypeInfo) ( i < numTemplateArgs ? templateArguments.get(i) : null); - TypeInfo mapped = (TypeInfo) map.get( param ); + ITypeInfo arg = (ITypeInfo) ( i < numTemplateArgs ? templateArguments.get(i) : null); + ITypeInfo mapped = (ITypeInfo) map.get( param ); if( arg != null && mapped != null ) if( arg.equals( mapped ) ) @@ -952,7 +957,7 @@ public final class TemplateEngine { } else if( !parameters.isEmpty() ){ int size = parameters.size(); 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; break; } @@ -1025,12 +1030,12 @@ public final class TemplateEngine { int a1Size = a1.size(); for( int i = 0; i < a1Size; i++ ){ - TypeInfo t1 = (TypeInfo) a1.get( i ); - TypeInfo t2 = (TypeInfo) a2.get( i ); + ITypeInfo t1 = (ITypeInfo) a1.get( i ); + ITypeInfo t2 = (ITypeInfo) a2.get( i ); if( t1.equals( t2 ) ){ 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(); if( m[0].containsKey( s1 ) && m[1].containsKey( s2 ) && m[0].get( s1 ).equals( m[1].get( s2 ) ) ) continue; @@ -1097,7 +1102,7 @@ public final class TemplateEngine { */ 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; } @@ -1115,7 +1120,7 @@ public final class TemplateEngine { } containing = containing.getContainingSymbol(); - if( containing != null && !containing.isTemplateMember() || !containing.isType( TypeInfo.t_template ) ){ + if( containing != null && !containing.isTemplateMember() || !containing.isType( ITypeInfo.t_template ) ){ break; } } @@ -1129,7 +1134,7 @@ public final class TemplateEngine { int size = params.size(); List args = new ArrayList( size ); 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 ); @@ -1154,14 +1159,14 @@ public final class TemplateEngine { static protected boolean canAddTemplate( IContainerSymbol containing, ITemplateSymbol template ){ //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; } //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(); - 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; } } @@ -1178,7 +1183,7 @@ public final class TemplateEngine { for( int i = 0; i < numParams; i++ ){ ISymbol param = (ISymbol) params.get(i); if( i < numArgs ){ - TypeInfo arg = (TypeInfo) arguments.get(i); + ITypeInfo arg = (ITypeInfo) arguments.get(i); if( matchTemplateParameterAndArgument( param, arg ) ){ actualArgs.add( arg ); } else { @@ -1220,7 +1225,7 @@ public final class TemplateEngine { int numArgs = args.size(); for( int i = 0; i < numParams && i < numArgs; 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.get( param ).equals( arg )){ continue outer; @@ -1250,9 +1255,9 @@ public final class TemplateEngine { int numArgs = ( args != null ) ? args.size() : 0; for( int i = 0; i < numParams; i++ ){ ISymbol param = (ISymbol) params.get(i); - TypeInfo arg = null; + ITypeInfo arg = null; if( i < numArgs ){ - arg = (TypeInfo) args.get(i); + arg = (ITypeInfo) args.get(i); } else { if( map == null ){ map = deduceTemplateArgumentsUsingParameterList( template, fn ); @@ -1260,7 +1265,7 @@ public final class TemplateEngine { return null; } 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 ){ - 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() ) { return false; @@ -1303,11 +1308,11 @@ public final class TemplateEngine { ITemplateSymbol t1 = getContainingTemplate( p1 ); 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(); 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 pt2 = (ITemplateSymbol)p2.getTypeSymbol(); return checkTemplateParameterListsAreEquivalent( pt1.getParameterList(), pt2.getParameterList() ); @@ -1343,8 +1348,8 @@ public final class TemplateEngine { return false; for( int i = 0; i < size; i++ ){ - TypeInfo info1 = (TypeInfo) args.get(i); - TypeInfo info2 = (TypeInfo) args2.get(i); + ITypeInfo info1 = (ITypeInfo) args.get(i); + ITypeInfo info2 = (ITypeInfo) args2.get(i); if( ! info1.equals( info2 ) ) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java index 4a1c54197ba..974078ca1be 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateFactory.java @@ -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.ASTTemplateInstantiation; 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 @@ -84,7 +82,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor size = args.size(); spec.prepareArguments( size ); for( int i = 0; i < size; i++){ - spec.addArgument( (TypeInfo) args.get(i) ); + spec.addArgument( (ITypeInfo) args.get(i) ); } spec.addSymbol( symbol ); @@ -114,7 +112,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor int templatesSize = templates.size(), templatesIdx = 0; for( int i = 0; i < size; i++ ){ sym = (ISymbol) symbols.get( i ); - if( !sym.getContainingSymbol().isType( TypeInfo.t_template ) ){ + if( !sym.getContainingSymbol().isType( ITypeInfo.t_template ) ){ symbols.remove( i-- ); size--; } 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 ) previous = lookupFunctionTemplateId( symbol.getName(), argList, args, false ); else previous = lookupMethodForDefinition( symbol.getName(), argList ); - } else if ( symbol.isType( TypeInfo.t_constructor ) ){ + } else if ( symbol.isType( ITypeInfo.t_constructor ) ){ previous = lookupConstructor( argList ); } else { previous = lookupMemberForDefinition( symbol.getName() ); @@ -318,7 +316,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor ISymbol instantiated = sym.getInstantiatedSymbol(); if( instantiated != null ){ IContainerSymbol container = instantiated.getContainingSymbol(); - if( container.isType( TypeInfo.t_template ) ){ + if( container.isType( ITypeInfo.t_template ) ){ ((ITemplateSymbol) container ).removeInstantiation( sym ); } } @@ -363,7 +361,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#elaboratedLookup(org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType, java.lang.String) */ - public ISymbol elaboratedLookup(eType type, String name) throws ParserSymbolTableException { + public ISymbol elaboratedLookup(ITypeInfo.eType type, String name) throws ParserSymbolTableException { ListIterator iter = templates.listIterator( templates.size() ); while( iter.hasPrevious() ){ ITemplateSymbol template = (ITemplateSymbol) iter.previous(); @@ -425,7 +423,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#qualifiedLookup(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.TypeInfo.eType) */ - public ISymbol qualifiedLookup(String name, eType t) throws ParserSymbolTableException { + public ISymbol qualifiedLookup(String name, ITypeInfo.eType t) throws ParserSymbolTableException { return getContainingSymbol().qualifiedLookup( name, t ); } @@ -517,7 +515,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor int templateIdx = 0; for( int i = 0; i < numSymbols; i++ ){ ISymbol symbol = (ISymbol) symbols.get(i); - if( symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){ + if( symbol.getContainingSymbol().isType( ITypeInfo.t_template ) ){ if( templateIdx < numTemplates ) templateIdx++; else @@ -556,21 +554,21 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @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; } /* (non-Javadoc) * @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; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDeclaration(java.lang.String, org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol) */ - public IUsingDeclarationSymbol addUsingDeclaration(String name, IContainerSymbol declContext) throws ParserSymbolTableException { + public IUsingDeclarationSymbol addUsingDeclaration(String name, IContainerSymbol declContext) { return null; } @@ -584,7 +582,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#prefixLookup(org.eclipse.cdt.internal.core.parser.pst.TypeFilter, java.lang.String, boolean) */ - public List prefixLookup(TypeFilter filter, String prefix, boolean qualified, List paramList) throws ParserSymbolTableException { + public List prefixLookup(TypeFilter filter, String prefix, boolean qualified, List paramList) { return null; } /* (non-Javadoc) @@ -611,7 +609,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @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; } @@ -619,6 +617,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setName(java.lang.String) */ public void setName(String name) { + /* nothing */ } /* (non-Javadoc) @@ -631,41 +630,43 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @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; } /* (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) */ - public boolean isType(eType type, eType upperType) { + public boolean isType(ITypeInfo.eType type, ITypeInfo.eType upperType) { return false; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getType() */ - public eType getType() { + public ITypeInfo.eType getType() { return null; } /* (non-Javadoc) * @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) * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#getTypeInfo() */ - public TypeInfo getTypeInfo() { + public ITypeInfo getTypeInfo() { return null; } /* (non-Javadoc) * @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) @@ -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) */ public void setTypeSymbol(ISymbol type) { + /* nothing */ } /* (non-Javadoc) @@ -692,6 +694,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsForwardDeclaration(boolean) */ public void setIsForwardDeclaration(boolean forward) { + /* nothing */ } /* (non-Javadoc) @@ -711,7 +714,8 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @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) @@ -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) */ public void setInstantiatedSymbol(ISymbol symbol) { + /* nothing */ } /* (non-Javadoc) @@ -745,6 +750,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsTemplateMember(boolean) */ public void setIsTemplateMember(boolean isMember) { + /* nothing */ } /* (non-Javadoc) @@ -765,18 +771,21 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#setIsInvisible(boolean) */ public void setIsInvisible(boolean invisible) { + /* nothing */ } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol) */ public void addParent(ISymbol parent) { + /* nothing */ } /* (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) */ public void addParent(ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references) { + /* nothing */ } /* (non-Javadoc) @@ -796,13 +805,15 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor /* (non-Javadoc) * @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) * @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addCopyConstructor() */ - public void addCopyConstructor() throws ParserSymbolTableException { + public void addCopyConstructor() { + /* nothing */ } /* (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) */ public void addFriend(ISymbol friend) { + /* nothing */ } /* (non-Javadoc) * @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; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupFunctionForFriendship(java.lang.String, java.util.List) */ - public IParameterizedSymbol lookupFunctionForFriendship(String name, List parameters) throws ParserSymbolTableException { + public IParameterizedSymbol lookupFunctionForFriendship(String name, List parameters) { return null; } @@ -843,5 +855,20 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor * @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#preparePtrOperatros(int) */ 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; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateParameterTypeInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateParameterTypeInfo.java new file mode 100644 index 00000000000..17a0041eaae --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateParameterTypeInfo.java @@ -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; +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java index bd45b640489..ab5f551e125 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java @@ -17,8 +17,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; - /** * @author aniefer * @@ -28,11 +26,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymbol { protected TemplateSymbol ( ParserSymbolTable table, String name ){ - super( table, name, TypeInfo.t_template ); - } - - protected TemplateSymbol( ParserSymbolTable table, String name, ISymbolASTExtension obj ){ - super( table, name, obj ); + super( table, name, ITypeInfo.t_template ); } 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) */ public ISymbol instantiate( List arguments ) throws ParserSymbolTableException{ - if( getType() != TypeInfo.t_template && - ( getType() != TypeInfo.t_templateParameter || - getTypeInfo().getTemplateParameterType() != TypeInfo.t_template ) ) + if( getType() != ITypeInfo.t_template && + ( getType() != ITypeInfo.t_templateParameter || + getTypeInfo().getTemplateParameterType() != ITypeInfo.t_template ) ) { return null; } @@ -84,7 +78,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb HashMap map = new HashMap(); ISymbol param = null; - TypeInfo arg = null; + ITypeInfo arg = null; List actualArgs = new ArrayList( numParams ); ISymbol templatedSymbol = template.getTemplatedSymbol(); @@ -98,27 +92,27 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() ); 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( arg.isType( TypeInfo.t_type ) ){ + if( arg.isType( ITypeInfo.t_type ) ){ if( arg.getTypeSymbol() == null ) 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 ); } } else { Object obj = param.getTypeInfo().getDefault(); - if( obj != null && obj instanceof TypeInfo ){ - arg = (TypeInfo) obj; - if( arg.isType( TypeInfo.t_type ) && arg.getTypeSymbol().isType( TypeInfo.t_templateParameter ) ){ + if( obj != null && obj instanceof ITypeInfo ){ + arg = (ITypeInfo) obj; + if( arg.isType( ITypeInfo.t_type ) && arg.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) ){ if( map.containsKey( arg.getTypeSymbol() ) ){ - arg = (TypeInfo) map.get( arg.getTypeSymbol() ); + arg = (ITypeInfo) map.get( arg.getTypeSymbol() ); } else { 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(); - arg = new TypeInfo( arg ); + arg = TypeInfoProvider.newTypeInfo( arg ); arg.setTypeSymbol( deferred.instantiate( this, map ) ); } } else { @@ -138,7 +132,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb if( instance != null ){ return instance; } - if( template.isType( TypeInfo.t_templateParameter ) ){ + if( template.isType( ITypeInfo.t_templateParameter ) ){ //template template parameter. must defer instantiation return deferredInstance( arguments ); } @@ -177,8 +171,8 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb for( int i = 0; i < size; i++ ){ param = (ISymbol) parameters.get(i); Object obj = param.getTypeInfo().getDefault(); - if( obj instanceof TypeInfo ){ - param.getTypeInfo().setDefault( TemplateEngine.instantiateTypeInfo( (TypeInfo) obj, template, argMap ) ); + if( obj instanceof ITypeInfo ){ + 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 { - if( isType( TypeInfo.t_template ) || getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){ + if( isType( ITypeInfo.t_template ) || getTypeInfo().getTemplateParameterType() == ITypeInfo.t_template ){ if( !isAllowableTemplateParameter( param ) ){ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateParameter ); } @@ -201,17 +195,17 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb } private boolean isAllowableTemplateParameter( ISymbol param ) { - if( !param.isType( TypeInfo.t_templateParameter ) ) + if( !param.isType( ITypeInfo.t_templateParameter ) ) return false; if( !getName().equals( ParserSymbolTable.EMPTY_NAME ) && param.getName().equals( getName() ) ){ return false; } - if( param.getTypeInfo().getTemplateParameterType() != TypeInfo.t_typeName && - param.getTypeInfo().getTemplateParameterType() != TypeInfo.t_template ) + if( param.getTypeInfo().getTemplateParameterType() != ITypeInfo.t_typeName && + 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: //integral or enumeration type //pointer to object or pointer to function @@ -221,13 +215,13 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb //14.1-7 //A non-type template-parameter shall not be declared to have floating point, class or void type if( info.getPtrOperators().size() == 0 ) - if( info.getTemplateParameterType() == TypeInfo.t_float || - info.getTemplateParameterType() == TypeInfo.t_double || - info.getTemplateParameterType() == TypeInfo.t_class || - info.getTemplateParameterType() == TypeInfo.t_struct || - info.getTemplateParameterType() == TypeInfo.t_union || - info.getTemplateParameterType() == TypeInfo.t_enumeration || - info.getTemplateParameterType() == TypeInfo.t_void ) + if( info.getTemplateParameterType() == ITypeInfo.t_float || + info.getTemplateParameterType() == ITypeInfo.t_double || + info.getTemplateParameterType() == ITypeInfo.t_class || + info.getTemplateParameterType() == ITypeInfo.t_struct || + info.getTemplateParameterType() == ITypeInfo.t_union || + info.getTemplateParameterType() == ITypeInfo.t_enumeration || + info.getTemplateParameterType() == ITypeInfo.t_void ) { return false; } @@ -238,12 +232,12 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb private void modifyTemplateParameter( ISymbol param ){ List ptrs = param.getPtrOperators(); if( ptrs.size() > 0 ){ - PtrOp op = (PtrOp) ptrs.get( 0 ); - if( op.getType() == PtrOp.t_array ){ - op.setType( PtrOp.t_pointer ); + ITypeInfo.PtrOp op = (ITypeInfo.PtrOp) ptrs.get( 0 ); + if( op.getType() == ITypeInfo.PtrOp.t_array ){ + op.setType( ITypeInfo.PtrOp.t_pointer ); } - } else if ( param.isType( TypeInfo.t_type ) && param.getTypeSymbol().isType( TypeInfo.t_function ) ){ - param.addPtrOperator( new PtrOp( PtrOp.t_pointer ) ); + } else if ( param.isType( ITypeInfo.t_type ) && param.getTypeSymbol().isType( ITypeInfo.t_function ) ){ + param.addPtrOperator( new ITypeInfo.PtrOp( ITypeInfo.PtrOp.t_pointer ) ); } } @@ -286,7 +280,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb ISymbol found = null; 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(); int size = params.size(); List fnArgs = new ArrayList( size ); @@ -298,6 +292,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb found = getTemplatedSymbol().lookupMemberForDefinition( symbol.getName() ); } } catch (ParserSymbolTableException e) { + /* nothing */ } if( found == null && getTemplatedSymbol().getName().equals( symbol.getName() ) ){ found = getTemplatedSymbol(); @@ -311,7 +306,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb if( found != null ){ //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 - if( found.getTypeInfo().isForwardDeclaration() && found.getTypeSymbol() == symbol ) + if( found.isForwardDeclaration() && found.getForwardSymbol() == symbol ) found.setTypeSymbol( null ); //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]; p.instantiateDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] ); } 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++; } @@ -485,7 +480,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb ParameterizedSymbol p = (ParameterizedSymbol) objs[0]; p.discardDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] ); } 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(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java index fc6f3896da9..de74acfe4a0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java @@ -28,7 +28,7 @@ public class TypeFilter { acceptedTypes.addAll( types ); } - public TypeFilter( TypeInfo.eType type ){ + public TypeFilter( ITypeInfo.eType type ){ acceptedTypes.add( type ); } @@ -37,7 +37,7 @@ public class TypeFilter { populatedAcceptedTypes( kind ); } - public void addAcceptedType( TypeInfo.eType type ){ + public void addAcceptedType( ITypeInfo.eType type ){ acceptedTypes.add( type ); } @@ -46,16 +46,16 @@ public class TypeFilter { acceptedKinds.add( kind ); } - public boolean willAccept( TypeInfo.eType type ){ - return( acceptedTypes.contains( TypeInfo.t_any ) || + public boolean willAccept( ITypeInfo.eType type ){ + return( acceptedTypes.contains( ITypeInfo.t_any ) || acceptedTypes.contains( type ) ); } public boolean shouldAccept( ISymbol symbol ){ return shouldAccept( symbol, symbol.getTypeInfo() ); } - public boolean shouldAccept( ISymbol symbol, TypeInfo typeInfo ){ - if( acceptedTypes.contains( TypeInfo.t_any ) ){ + public boolean shouldAccept( ISymbol symbol, ITypeInfo typeInfo ){ + if( acceptedTypes.contains( ITypeInfo.t_any ) ){ return true; } @@ -65,11 +65,11 @@ public class TypeFilter { IContainerSymbol container = symbol.getContainingSymbol(); - boolean symbolIsMember = container.isType( TypeInfo.t_class, TypeInfo.t_union ); - boolean symbolIsLocal = container.isType( TypeInfo.t_constructor, TypeInfo.t_function ) || - container.isType( TypeInfo.t_block ); + boolean symbolIsMember = container.isType( ITypeInfo.t_class, ITypeInfo.t_union ); + boolean symbolIsLocal = container.isType( ITypeInfo.t_constructor, ITypeInfo.t_function ) || + container.isType( ITypeInfo.t_block ); - if( typeInfo.isType( TypeInfo.t_function ) ) + if( typeInfo.isType( ITypeInfo.t_function ) ) { if( ( acceptedKinds.contains( LookupKind.FUNCTIONS ) && !symbolIsMember ) || ( acceptedKinds.contains( LookupKind.METHODS ) && symbolIsMember ) ) @@ -78,7 +78,7 @@ public class TypeFilter { } 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 ) || acceptedKinds.contains( LookupKind.TYPES ) ) { @@ -86,7 +86,7 @@ public class TypeFilter { } 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 ) || ( acceptedKinds.contains( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal ) || @@ -106,22 +106,22 @@ public class TypeFilter { * @param lookupKind */ private void populatedAcceptedTypes(LookupKind kind) { - if ( kind == LookupKind.ALL ) { acceptedTypes.add( TypeInfo.t_any ); } - else if ( kind == LookupKind.STRUCTURES ) { acceptedTypes.add( TypeInfo.t_class ); - acceptedTypes.add( TypeInfo.t_struct ); - acceptedTypes.add( TypeInfo.t_union ); } - else if ( kind == LookupKind.STRUCTS ) { acceptedTypes.add( TypeInfo.t_struct ); } - else if ( kind == LookupKind.UNIONS ) { acceptedTypes.add( TypeInfo.t_union ); } - else if ( kind == LookupKind.CLASSES ) { acceptedTypes.add( TypeInfo.t_class ); } - else if ( kind == LookupKind.CONSTRUCTORS ){ acceptedTypes.add( TypeInfo.t_constructor ); } - else if ( kind == LookupKind.NAMESPACES ) { acceptedTypes.add( TypeInfo.t_namespace ); } - else if ( kind == LookupKind.ENUMERATIONS ){ acceptedTypes.add( TypeInfo.t_enumeration ); } - else if ( kind == LookupKind.ENUMERATORS ) { acceptedTypes.add( TypeInfo.t_enumerator ); } + if ( kind == LookupKind.ALL ) { acceptedTypes.add( ITypeInfo.t_any ); } + else if ( kind == LookupKind.STRUCTURES ) { acceptedTypes.add( ITypeInfo.t_class ); + acceptedTypes.add( ITypeInfo.t_struct ); + acceptedTypes.add( ITypeInfo.t_union ); } + else if ( kind == LookupKind.STRUCTS ) { acceptedTypes.add( ITypeInfo.t_struct ); } + else if ( kind == LookupKind.UNIONS ) { acceptedTypes.add( ITypeInfo.t_union ); } + else if ( kind == LookupKind.CLASSES ) { acceptedTypes.add( ITypeInfo.t_class ); } + else if ( kind == LookupKind.CONSTRUCTORS ){ acceptedTypes.add( ITypeInfo.t_constructor ); } + else if ( kind == LookupKind.NAMESPACES ) { acceptedTypes.add( ITypeInfo.t_namespace ); } + else if ( kind == LookupKind.ENUMERATIONS ){ acceptedTypes.add( ITypeInfo.t_enumeration ); } + else if ( kind == LookupKind.ENUMERATORS ) { acceptedTypes.add( ITypeInfo.t_enumerator ); } // else if ( kind == LookupKind.TYPEDEFS ) { acceptedTypes.add( TypeInfo.t_type ); } - else if ( kind == LookupKind.TYPES ) { acceptedTypes.add( TypeInfo.t_class ); - acceptedTypes.add( TypeInfo.t_struct ); - acceptedTypes.add( TypeInfo.t_union ); - acceptedTypes.add( TypeInfo.t_enumeration ); } + else if ( kind == LookupKind.TYPES ) { acceptedTypes.add( ITypeInfo.t_class ); + acceptedTypes.add( ITypeInfo.t_struct ); + acceptedTypes.add( ITypeInfo.t_union ); + acceptedTypes.add( ITypeInfo.t_enumeration ); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java index 5c12a2bc60b..5653601359d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java @@ -10,575 +10,86 @@ ***********************************************************************/ 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; -import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider; - - -public class TypeInfo { - public TypeInfo(){ +public class TypeInfo extends BasicTypeInfo implements ITypeInfo{ + public TypeInfo(){ super(); } - public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol ){ - super(); - _typeBits = bits; - _type = type; - _typeDeclaration = symbol; - } + public ISymbol getTypeSymbol() { + return _typeDeclaration; + } - public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol, TypeInfo.PtrOp op, boolean hasDefault ){ - super(); - _typeBits = bits; - _type = type; - _typeDeclaration = symbol; - if( op != null ){ - _ptrOperators = new ArrayList(2); - _ptrOperators.add( op ); - } else { - _ptrOperators = Collections.EMPTY_LIST; - } - _hasDefaultValue = hasDefault; - } - - public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol, TypeInfo.PtrOp op, Object def ){ - super(); - _typeBits = bits; - _type = type; - _typeDeclaration = symbol; - if( op != null ){ - _ptrOperators = new ArrayList( 1 ); - _ptrOperators.add( op ); - } else { - _ptrOperators = Collections.EMPTY_LIST; - } - _hasDefaultValue = true; - setDefault( def ); - } + public void setTypeSymbol( ISymbol type ) { + _typeDeclaration = type; + } + + public boolean getHasDefault() { + return _hasDefaultValue; + } - public TypeInfo( TypeInfo info ){ - super(); - - _typeBits = info._typeBits; - _type = info._type; - _typeDeclaration = info._typeDeclaration; - _ptrOperators = ( info._ptrOperators == Collections.EMPTY_LIST ) ? info._ptrOperators : (ArrayList)((ArrayList)info._ptrOperators).clone(); - _hasDefaultValue = info._hasDefaultValue; - _defaultValue = info._defaultValue; - } + public void setHasDefault( boolean def ) { + _hasDefaultValue = def; + } - public static final int isAuto = 0x00001; - public static final int isRegister = 0x00002; - public static final int isStatic = 0x00004; - public static final int isExtern = 0x00008; - public static final int isMutable = 0x00010; - public static final int isInline = 0x00020; - public static final int isVirtual = 0x00040; - public static final int isExplicit = 0x00080; - public static final int isTypedef = 0x00100; - public static final int isFriend = 0x00200; - public static final int isConst = 0x00400; - public static final int isVolatile = 0x00800; - public static final int isUnsigned = 0x01000; - public static final int isShort = 0x02000; - public static final int isLong = 0x04000; - public static final int isForward = 0x08000; - public static final int isComplex = 0x10000; - public static final int isImaginary= 0x20000; - public static final int isLongLong = 0x40000; - public static final int isSigned = 0x80000; - - // Types (maximum type is typeMask - // Note that these should be considered ordered and if you change - // the order, you should consider the ParserSymbolTable uses - public static final TypeInfo.eType t_any = new TypeInfo.eType( -1 ); //don't care - 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 ); - public static final TypeInfo.eType t_class = new TypeInfo.eType( 3 ); - 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 void clear() { + super.clear(); + _typeDeclaration = null; + _hasDefaultValue = false; + } - 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; - } + public void copy( ITypeInfo t ) { + super.copy( t ); + _typeDeclaration = t.getTypeSymbol(); + _hasDefaultValue = t.getHasDefault(); + } - 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 equals( Object t ) { + if( !super.equals( t ) ){ + return false; + } + + ITypeInfo type = (ITypeInfo)t; + + boolean result = true; + ISymbol symbol = type.getTypeSymbol(); + if( _typeDeclaration != null && symbol != null ){ + if( _typeDeclaration.isType( t__Bool, t_void ) && + symbol.isType( t__Bool, t_void ) ) + { + //if typeDeclaration is a basic type, then only need the types the same + result &= ( _typeDeclaration.getType() == symbol.getType() ); + } else if( _typeDeclaration.isType( t_function ) && + symbol.isType( t_function ) ) + { + //function pointers... functions must have same parameter lists and return types + IParameterizedSymbol f1 = (IParameterizedSymbol) _typeDeclaration; + IParameterizedSymbol f2 = (IParameterizedSymbol) symbol; + + 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( t_templateParameter ) && + symbol.isType( t_templateParameter ) ) + { + //template parameters + result &= TemplateEngine.templateParametersAreEquivalent( _typeDeclaration, symbol ); + } else if ( _typeDeclaration instanceof IDeferredTemplateInstance && + symbol instanceof IDeferredTemplateInstance ) + { + result &= TemplateEngine.deferedInstancesAreEquivalent( (IDeferredTemplateInstance) _typeDeclaration, (IDeferredTemplateInstance)symbol ); + }else { + //otherwise, its a user defined type, need the decls the same + result &= ( _typeDeclaration == symbol ); + } + } else { + result &= ( _typeDeclaration == symbol ); + } + return result; + } - 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; + private ISymbol _typeDeclaration = null; + private boolean _hasDefaultValue = false; } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java new file mode 100644 index 00000000000..d356368c317 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java @@ -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; + } +} \ No newline at end of file