1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Make the TypeInfoProvider non-static

This commit is contained in:
Andrew Niefer 2004-06-01 21:52:40 +00:00
parent a464b6bbf5
commit cb4ec57f90
11 changed files with 292 additions and 271 deletions

View file

@ -108,7 +108,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
look = instance.lookup( "i" ); //$NON-NLS-1$ look = instance.lookup( "i" ); //$NON-NLS-1$
assertEquals( look, i ); assertEquals( look, i );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -166,7 +166,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), t ); assertEquals( look.getInstantiatedSymbol(), t );
assertTrue( look.isType( TypeInfo.t_int ) ); assertTrue( look.isType( TypeInfo.t_int ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -236,7 +236,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), u ); assertEquals( look.getInstantiatedSymbol(), u );
assertTrue( look.isType( TypeInfo.t_char ) ); assertTrue( look.isType( TypeInfo.t_char ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -310,7 +310,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( look, f2 ); assertEquals( look, f2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
@ -362,7 +362,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
look = f.lookup( "i" ); //$NON-NLS-1$ look = f.lookup( "i" ); //$NON-NLS-1$
assertEquals( look, parami ); assertEquals( look, parami );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -451,7 +451,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
look = table.getCompilationUnit().lookupTemplateId( "S", args ); //$NON-NLS-1$ look = table.getCompilationUnit().lookupTemplateId( "S", args ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), S ); assertEquals( look.getInstantiatedSymbol(), S );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -483,7 +483,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
ISymbol look = table.getCompilationUnit().lookupTemplateId( "String", args ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().lookupTemplateId( "String", args ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), string ); assertEquals( look.getInstantiatedSymbol(), string );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -534,7 +534,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
} catch( ParserSymbolTableException e ){ } catch( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateArgument ); assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateArgument );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -590,7 +590,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
ISymbol look = table.getCompilationUnit().lookupTemplateId( "X", args ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().lookupTemplateId( "X", args ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), X ); assertEquals( look.getInstantiatedSymbol(), X );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -670,7 +670,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
args.add( arg ); args.add( arg );
assertNotNull( table.getCompilationUnit().lookupTemplateId( "X", args ) ); //$NON-NLS-1$ assertNotNull( table.getCompilationUnit().lookupTemplateId( "X", args ) ); //$NON-NLS-1$
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -720,7 +720,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
ISymbol look = table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().lookupTemplateId( "B", args ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), B ); assertEquals( look.getInstantiatedSymbol(), B );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -841,7 +841,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertEquals( look.getType(), TypeInfo.t_int ); assertEquals( look.getType(), TypeInfo.t_int );
assertEquals( look.getTypeInfo().checkBit( TypeInfo.isLong ), true ); assertEquals( look.getTypeInfo().checkBit( TypeInfo.isLong ), true );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -955,7 +955,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_BadTemplate ); assertEquals( e.reason, ParserSymbolTableException.r_BadTemplate );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1032,7 +1032,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), i ); assertEquals( look.getInstantiatedSymbol(), i );
assertEquals( look.getType(), TypeInfo.t_int ); assertEquals( look.getType(), TypeInfo.t_int );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1106,7 +1106,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isType( TypeInfo.t_float ) ); assertTrue( look.isType( TypeInfo.t_float ) );
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), newS ); assertEquals( look.getInstantiatedSymbol(), newS );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1213,7 +1213,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.getInstantiatedSymbol().isTemplateInstance() ); assertTrue( look.getInstantiatedSymbol().isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol().getInstantiatedSymbol(), u ); assertEquals( look.getInstantiatedSymbol().getInstantiatedSymbol(), u );
assertTrue( look.isType( TypeInfo.t_int ) ); assertTrue( look.isType( TypeInfo.t_int ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1261,7 +1261,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
f.getTypeInfo().setBit( true, TypeInfo.isVirtual ); f.getTypeInfo().setBit( true, TypeInfo.isVirtual );
A.addSymbol( f ); A.addSymbol( f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1324,7 +1324,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look != null ); assertTrue( look != null );
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), A2 ); assertEquals( look.getInstantiatedSymbol(), A2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1487,7 +1487,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1551,7 +1551,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), f3 ); assertEquals( look.getInstantiatedSymbol(), f3 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1599,7 +1599,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
} catch( ParserSymbolTableException e ){ } catch( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1681,7 +1681,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "h", params ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "h", params ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), h1 ); assertEquals( look.getInstantiatedSymbol(), h1 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1720,7 +1720,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
TypeInfo type = (TypeInfo) iter.next(); TypeInfo type = (TypeInfo) iter.next();
assertTrue( type.isType( TypeInfo.t_type ) ); assertTrue( type.isType( TypeInfo.t_type ) );
assertEquals( type.getTypeSymbol(), T ); assertEquals( type.getTypeSymbol(), T );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1759,7 +1759,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), Y2 ); assertEquals( look.getInstantiatedSymbol(), Y2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1819,7 +1819,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
} catch( ParserSymbolTableException e ){ } catch( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateParameter ); assertEquals( e.reason, ParserSymbolTableException.r_BadTemplateParameter );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
@ -1897,7 +1897,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
flook = look.qualifiedFunctionLookup( "f", args ); //$NON-NLS-1$ flook = look.qualifiedFunctionLookup( "f", args ); //$NON-NLS-1$
assertEquals( flook, f3 ); assertEquals( flook, f3 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1965,7 +1965,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), newSort ); assertEquals( look.getInstantiatedSymbol(), newSort );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2053,7 +2053,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", args ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", args ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), f5 ); assertEquals( look.getInstantiatedSymbol(), f5 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
@ -2142,7 +2142,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", argList ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", argList ); //$NON-NLS-1$
assertTrue( look.isTemplateInstance()); assertTrue( look.isTemplateInstance());
assertEquals( look.getInstantiatedSymbol(), f ); assertEquals( look.getInstantiatedSymbol(), f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2224,7 +2224,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
arg.setTypeSymbol( g3 ); arg.setTypeSymbol( g3 );
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", argList ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", argList ); //$NON-NLS-1$
assertEquals( look, null ); assertEquals( look, null );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
* template< class T > void f( const T * ){} * template< class T > void f( const T * ){}
@ -2274,7 +2274,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( op.isConst() ); assertTrue( op.isConst() );
assertEquals( op.getType(), PtrOp.t_pointer ); assertEquals( op.getType(), PtrOp.t_pointer );
assertFalse( iter.hasNext() ); assertFalse( iter.hasNext() );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2392,7 +2392,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
//both are the template function instantiated with int, should be the same instance. //both are the template function instantiated with int, should be the same instance.
assertEquals( look, look2 ); assertEquals( look, look2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
@ -2619,6 +2619,6 @@ public class ParserSymbolTableTemplateTests extends TestCase {
assertTrue( look.isTemplateInstance() ); assertTrue( look.isTemplateInstance() );
assertEquals( look.getInstantiatedSymbol(), c3 ); assertEquals( look.getInstantiatedSymbol(), c3 );
assertTrue( look.isType( TypeInfo.t_float ) ); assertTrue( look.isType( TypeInfo.t_float ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
} }

View file

@ -95,7 +95,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( false, iter.hasNext() ); assertEquals( false, iter.hasNext() );
assertEquals( x, contained ); assertEquals( x, contained );
assertEquals( contained.getName(), "x" ); //$NON-NLS-1$ assertEquals( contained.getName(), "x" ); //$NON-NLS-1$
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -112,7 +112,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$
assertEquals( x, look ); assertEquals( x, look );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
public void testLookupNonExistant() throws Exception{ public void testLookupNonExistant() throws Exception{
@ -120,7 +120,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = table.getCompilationUnit().lookup("boo"); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().lookup("boo"); //$NON-NLS-1$
assertEquals( look, null ); assertEquals( look, null );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
public void testSimpleSetGetObject() throws Exception{ public void testSimpleSetGetObject() throws Exception{
@ -137,7 +137,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$
assertEquals( look.getASTExtension(), extension ); assertEquals( look.getASTExtension(), extension );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -167,7 +167,7 @@ public class ParserSymbolTableTest extends TestCase {
look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$ look = table.getCompilationUnit().lookup( "x" ); //$NON-NLS-1$
assertEquals( look, firstX ); assertEquals( look, firstX );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -188,7 +188,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = decl.lookup( "x" ); //$NON-NLS-1$ ISymbol look = decl.lookup( "x" ); //$NON-NLS-1$
assertEquals( x, look ); assertEquals( x, look );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -215,7 +215,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = class1.lookup( "x" ); //$NON-NLS-1$ ISymbol look = class1.lookup( "x" ); //$NON-NLS-1$
assertEquals( look, decl ); assertEquals( look, decl );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -246,7 +246,7 @@ public class ParserSymbolTableTest extends TestCase {
catch ( ParserSymbolTableException e ){ catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -272,7 +272,7 @@ public class ParserSymbolTableTest extends TestCase {
} catch ( ParserSymbolTableException e) { } catch ( ParserSymbolTableException e) {
assertEquals( e.reason, ParserSymbolTableException.r_CircularInheritance ); assertEquals( e.reason, ParserSymbolTableException.r_CircularInheritance );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
* testVirtualParentLookup * testVirtualParentLookup
@ -314,7 +314,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = decl.lookup( "x" ); //$NON-NLS-1$ ISymbol look = decl.lookup( "x" ); //$NON-NLS-1$
assertEquals( look, x ); assertEquals( look, x );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -349,7 +349,7 @@ public class ParserSymbolTableTest extends TestCase {
catch( ParserSymbolTableException e){ catch( ParserSymbolTableException e){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -423,7 +423,7 @@ public class ParserSymbolTableTest extends TestCase {
catch ( ParserSymbolTableException e){ catch ( ParserSymbolTableException e){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -470,7 +470,7 @@ public class ParserSymbolTableTest extends TestCase {
look = a.elaboratedLookup( TypeInfo.t_union, "union" ); //$NON-NLS-1$ look = a.elaboratedLookup( TypeInfo.t_union, "union" ); //$NON-NLS-1$
assertEquals( look, union ); assertEquals( look, union );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -508,7 +508,7 @@ public class ParserSymbolTableTest extends TestCase {
look = type.lookup("member"); //$NON-NLS-1$ look = type.lookup("member"); //$NON-NLS-1$
assertEquals( look, member ); assertEquals( look, member );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -547,7 +547,7 @@ public class ParserSymbolTableTest extends TestCase {
look = f.lookup( "stat" ); //$NON-NLS-1$ look = f.lookup( "stat" ); //$NON-NLS-1$
assertEquals( look, function ); assertEquals( look, function );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -654,7 +654,7 @@ public class ParserSymbolTableTest extends TestCase {
look = f4.lookup("i"); //$NON-NLS-1$ look = f4.lookup("i"); //$NON-NLS-1$
assertEquals( look, null );//neither i is visible here. assertEquals( look, null );//neither i is visible here.
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
* *
@ -721,7 +721,7 @@ public class ParserSymbolTableTest extends TestCase {
look = ((IContainerSymbol) look).qualifiedLookup("i"); //ok //$NON-NLS-1$ look = ((IContainerSymbol) look).qualifiedLookup("i"); //ok //$NON-NLS-1$
assertEquals( look, nsN_i ); assertEquals( look, nsN_i );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -784,7 +784,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( look, nsBC ); assertEquals( look, nsBC );
look = ((IContainerSymbol)look).qualifiedLookup("a"); //$NON-NLS-1$ look = ((IContainerSymbol)look).qualifiedLookup("a"); //$NON-NLS-1$
assertEquals( look, a ); assertEquals( look, a );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -851,7 +851,7 @@ public class ParserSymbolTableTest extends TestCase {
look = lookB.qualifiedLookup("b"); //$NON-NLS-1$ look = lookB.qualifiedLookup("b"); //$NON-NLS-1$
assertEquals( look, b ); assertEquals( look, b );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -899,7 +899,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = f.lookup("i"); //$NON-NLS-1$ ISymbol look = f.lookup("i"); //$NON-NLS-1$
assertEquals( look, null ); assertEquals( look, null );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -984,7 +984,7 @@ public class ParserSymbolTableTest extends TestCase {
} catch ( ParserSymbolTableException e ) { } catch ( ParserSymbolTableException e ) {
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1029,7 +1029,7 @@ public class ParserSymbolTableTest extends TestCase {
//but notice if you wanted to do A::f1 as a function call, it is ok //but notice if you wanted to do A::f1 as a function call, it is ok
look = lookA.qualifiedLookup( "f1" ); //$NON-NLS-1$ look = lookA.qualifiedLookup( "f1" ); //$NON-NLS-1$
assertEquals( look, f1 ); assertEquals( look, f1 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1116,7 +1116,7 @@ public class ParserSymbolTableTest extends TestCase {
catch ( ParserSymbolTableException exception ){ catch ( ParserSymbolTableException exception ){
assertTrue( true ); assertTrue( true );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1209,7 +1209,7 @@ public class ParserSymbolTableTest extends TestCase {
look = bar.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = bar.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertTrue( look != null ); assertTrue( look != null );
assertEquals( look, list.get( index ) ); assertEquals( look, list.get( index ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1241,7 +1241,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( ((PtrOp)look.getPtrOperators().iterator().next()).getType(), TypeInfo.PtrOp.t_pointer ); assertEquals( ((PtrOp)look.getPtrOperators().iterator().next()).getType(), TypeInfo.PtrOp.t_pointer );
assertEquals( look.getContainingSymbol(), fn ); assertEquals( look.getContainingSymbol(), fn );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1272,7 +1272,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( look, enumerator ); assertEquals( look, enumerator );
assertEquals( look.getContainingSymbol(), cls ); assertEquals( look.getContainingSymbol(), cls );
assertEquals( look.getTypeSymbol(), enumeration ); assertEquals( look.getTypeSymbol(), enumeration );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1336,7 +1336,7 @@ public class ParserSymbolTableTest extends TestCase {
look = main.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = main.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, f ); assertEquals( look, f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1424,7 +1424,7 @@ public class ParserSymbolTableTest extends TestCase {
look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, f2 ); assertEquals( look, f2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1507,7 +1507,7 @@ public class ParserSymbolTableTest extends TestCase {
paramList.add( p3 ); paramList.add( p3 );
look = C.memberFunctionLookup( "foo", paramList ); //$NON-NLS-1$ look = C.memberFunctionLookup( "foo", paramList ); //$NON-NLS-1$
assertEquals( look, f3 ); assertEquals( look, f3 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1558,7 +1558,7 @@ public class ParserSymbolTableTest extends TestCase {
look = compUnit.unqualifiedFunctionLookup( "f", null ); //$NON-NLS-1$ look = compUnit.unqualifiedFunctionLookup( "f", null ); //$NON-NLS-1$
assertEquals( look, f2 ); assertEquals( look, f2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1628,7 +1628,7 @@ public class ParserSymbolTableTest extends TestCase {
paramList.add( p2 ); paramList.add( p2 );
look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, f2 ); assertEquals( look, f2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1716,7 +1716,7 @@ public class ParserSymbolTableTest extends TestCase {
p.getOperatorExpressions().clear(); p.getOperatorExpressions().clear();
look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, f1 ); assertEquals( look, f1 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1769,7 +1769,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, f ); assertEquals( look, f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1861,7 +1861,7 @@ public class ParserSymbolTableTest extends TestCase {
params.add( p3 ); params.add( p3 );
look = main.unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ look = main.unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( look, f1 ); assertEquals( look, f1 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -1961,7 +1961,7 @@ public class ParserSymbolTableTest extends TestCase {
look = compUnit.unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ look = compUnit.unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( look, f3 ); assertEquals( look, f3 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
// public void testMarkRollback() throws Exception{ // public void testMarkRollback() throws Exception{
@ -2064,7 +2064,7 @@ public class ParserSymbolTableTest extends TestCase {
lookup = table.getCompilationUnit().elaboratedLookup( TypeInfo.t_class, "A" ); //$NON-NLS-1$ lookup = table.getCompilationUnit().elaboratedLookup( TypeInfo.t_class, "A" ); //$NON-NLS-1$
assertEquals( lookup, classA ); assertEquals( lookup, classA );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2154,7 +2154,7 @@ public class ParserSymbolTableTest extends TestCase {
paramList.add( p1 ); paramList.add( p1 );
look = classB.memberFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = classB.memberFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, fn1 ); assertEquals( look, fn1 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
public void testConstructors() throws Exception{ public void testConstructors() throws Exception{
@ -2190,7 +2190,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol lookup = classA.lookupConstructor( paramList ); ISymbol lookup = classA.lookupConstructor( paramList );
assertEquals( lookup, constructor2 ); assertEquals( lookup, constructor2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2224,7 +2224,7 @@ public class ParserSymbolTableTest extends TestCase {
lookup = NSB.lookup( "x" ); //$NON-NLS-1$ lookup = NSB.lookup( "x" ); //$NON-NLS-1$
assertEquals( lookup, x ); assertEquals( lookup, x );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2265,7 +2265,7 @@ public class ParserSymbolTableTest extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, f ); assertEquals( look, f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2306,7 +2306,7 @@ public class ParserSymbolTableTest extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", paramList ); //$NON-NLS-1$
assertEquals( look, null ); assertEquals( look, null );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2349,7 +2349,7 @@ public class ParserSymbolTableTest extends TestCase {
TypeInfo thirdOp = new TypeInfo( TypeInfo.t_type, 0, b ); TypeInfo thirdOp = new TypeInfo( TypeInfo.t_type, 0, b );
thirdOp.addOperatorExpression( OperatorExpression.addressof ); thirdOp.addOperatorExpression( OperatorExpression.addressof );
TypeInfo returned = ParserSymbolTable.getConditionalOperand( secondOp, thirdOp ); TypeInfo returned = table.getConditionalOperand( secondOp, thirdOp );
assertEquals( returned, secondOp ); assertEquals( returned, secondOp );
IDerivableContainerSymbol clsC = table.newDerivableContainerSymbol( "C", TypeInfo.t_class ); //$NON-NLS-1$ IDerivableContainerSymbol clsC = table.newDerivableContainerSymbol( "C", TypeInfo.t_class ); //$NON-NLS-1$
@ -2361,7 +2361,7 @@ public class ParserSymbolTableTest extends TestCase {
TypeInfo anotherOp = new TypeInfo( TypeInfo.t_type, 0, c ); TypeInfo anotherOp = new TypeInfo( TypeInfo.t_type, 0, c );
anotherOp.addOperatorExpression( OperatorExpression.addressof ); anotherOp.addOperatorExpression( OperatorExpression.addressof );
returned = ParserSymbolTable.getConditionalOperand( secondOp, anotherOp ); returned = table.getConditionalOperand( secondOp, anotherOp );
assertEquals( returned, null ); assertEquals( returned, null );
IParameterizedSymbol constructorA = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$ IParameterizedSymbol constructorA = table.newParameterizedSymbol( "A", TypeInfo.t_constructor ); //$NON-NLS-1$
@ -2376,12 +2376,12 @@ public class ParserSymbolTableTest extends TestCase {
anotherOp.getOperatorExpressions().clear(); anotherOp.getOperatorExpressions().clear();
try{ try{
returned = ParserSymbolTable.getConditionalOperand( secondOp, anotherOp ); returned = table.getConditionalOperand( secondOp, anotherOp );
assertTrue( false ); assertTrue( false );
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
//good //good
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2448,7 +2448,7 @@ public class ParserSymbolTableTest extends TestCase {
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
//good //good
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2494,15 +2494,15 @@ public class ParserSymbolTableTest extends TestCase {
TypeInfo secondOp = new TypeInfo( TypeInfo.t_type, 0, a, null, false ); TypeInfo secondOp = new TypeInfo( TypeInfo.t_type, 0, a, null, false );
TypeInfo thirdOp = new TypeInfo( TypeInfo.t_type, 0, b, null, false ); TypeInfo thirdOp = new TypeInfo( TypeInfo.t_type, 0, b, null, false );
TypeInfo returned = ParserSymbolTable.getConditionalOperand( secondOp, thirdOp ); TypeInfo returned = table.getConditionalOperand( secondOp, thirdOp );
assertEquals( returned, null ); assertEquals( returned, null );
clsA.addCopyConstructor(); clsA.addCopyConstructor();
clsB.addCopyConstructor(); clsB.addCopyConstructor();
returned = ParserSymbolTable.getConditionalOperand( secondOp, thirdOp ); returned = table.getConditionalOperand( secondOp, thirdOp );
assertEquals( returned, secondOp ); assertEquals( returned, secondOp );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
public void testbug43834() throws Exception{ public void testbug43834() throws Exception{
@ -2525,7 +2525,7 @@ public class ParserSymbolTableTest extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", parameters ); //$NON-NLS-1$
assertEquals( look, f ); assertEquals( look, f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2567,7 +2567,7 @@ public class ParserSymbolTableTest extends TestCase {
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous ); assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2594,7 +2594,7 @@ public class ParserSymbolTableTest extends TestCase {
} catch( ParserSymbolTableException e ){ } catch( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_UnableToResolveFunction ); assertEquals( e.reason, ParserSymbolTableException.r_UnableToResolveFunction );
} }
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2627,7 +2627,7 @@ public class ParserSymbolTableTest extends TestCase {
look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new ArrayList() ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new ArrayList() ); //$NON-NLS-1$
assertEquals( look, init2 ); assertEquals( look, init2 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2675,7 +2675,7 @@ public class ParserSymbolTableTest extends TestCase {
params.clear(); params.clear();
look = B.qualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ look = B.qualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( look, null ); assertEquals( look, null );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2703,7 +2703,7 @@ public class ParserSymbolTableTest extends TestCase {
assertTrue( results.contains( aVar ) ); assertTrue( results.contains( aVar ) );
assertTrue( results.contains( anotherVar ) ); assertTrue( results.contains( anotherVar ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2741,7 +2741,7 @@ public class ParserSymbolTableTest extends TestCase {
assertTrue( results.contains( aField ) ); assertTrue( results.contains( aField ) );
assertTrue( results.contains( aMethod ) ); assertTrue( results.contains( aMethod ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2795,7 +2795,7 @@ public class ParserSymbolTableTest extends TestCase {
assertTrue( results.contains( aVar ) ); assertTrue( results.contains( aVar ) );
assertTrue( results.contains( anotherVar2 ) ); assertTrue( results.contains( anotherVar2 ) );
assertTrue( results.contains( af2 ) ); assertTrue( results.contains( af2 ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2857,7 +2857,7 @@ public class ParserSymbolTableTest extends TestCase {
assertTrue( results != null ); assertTrue( results != null );
assertEquals( results.size(), 1 ); assertEquals( results.size(), 1 );
assertTrue( results.contains( aa ) ); assertTrue( results.contains( aa ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2886,7 +2886,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( null, A.qualifiedLookup( "i" ) ); //$NON-NLS-1$ assertEquals( null, A.qualifiedLookup( "i" ) ); //$NON-NLS-1$
assertEquals( i, g.lookup( "i" ) ); //$NON-NLS-1$ assertEquals( i, g.lookup( "i" ) ); //$NON-NLS-1$
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -2951,7 +2951,7 @@ public class ParserSymbolTableTest extends TestCase {
assertTrue( table.getCompilationUnit().isVisible(i, C ) ); assertTrue( table.getCompilationUnit().isVisible(i, C ) );
assertTrue( D.isVisible( j, A ) ); assertTrue( D.isVisible( j, A ) );
assertFalse( D.isVisible( j, B ) ); assertFalse( D.isVisible( j, B ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3035,7 +3035,7 @@ public class ParserSymbolTableTest extends TestCase {
results = f.prefixLookup( new TypeFilter( LookupKind.FIELDS), "a", false, null ); //$NON-NLS-1$ results = f.prefixLookup( new TypeFilter( LookupKind.FIELDS), "a", false, null ); //$NON-NLS-1$
assertEquals( results.size(), 1 ); assertEquals( results.size(), 1 );
assertTrue( results.contains( a3_int ) ); assertTrue( results.contains( a3_int ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3061,7 +3061,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$
assertEquals( foo, look ); assertEquals( foo, look );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3091,7 +3091,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$
assertEquals( foo2, look ); assertEquals( foo2, look );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3117,7 +3117,7 @@ public class ParserSymbolTableTest extends TestCase {
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$ ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params ); //$NON-NLS-1$
assertEquals( foo1, look ); assertEquals( foo1, look );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3160,7 +3160,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( iter.next(), var ); assertEquals( iter.next(), var );
assertEquals( iter.next(), foo ); assertEquals( iter.next(), foo );
assertFalse( iter.hasNext() ); assertFalse( iter.hasNext() );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3239,7 +3239,7 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( iter.next(), using ); assertEquals( iter.next(), using );
assertFalse( iter.hasNext() ); assertFalse( iter.hasNext() );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3271,7 +3271,7 @@ public class ParserSymbolTableTest extends TestCase {
params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLongLong, null ) ); params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLongLong, null ) );
lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( lookup, f1 ); assertEquals( lookup, f1 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3324,7 +3324,7 @@ public class ParserSymbolTableTest extends TestCase {
lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( lookup, f ); assertEquals( lookup, f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
public void test_Bool() throws Exception{ public void test_Bool() throws Exception{
@ -3353,7 +3353,7 @@ public class ParserSymbolTableTest extends TestCase {
params.add( new TypeInfo( TypeInfo.t_int, 0, null ) ); params.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params ); //$NON-NLS-1$
assertEquals( look, f ); assertEquals( look, f );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3378,7 +3378,7 @@ public class ParserSymbolTableTest extends TestCase {
f2.addParameter( Int, 0, null, false ); f2.addParameter( Int, 0, null, false );
assertTrue( f1.hasSameParameters( f2 ) ); assertTrue( f1.hasSameParameters( f2 ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3395,7 +3395,7 @@ public class ParserSymbolTableTest extends TestCase {
g2.addParameter( TypeInfo.t_char, 0, new PtrOp( PtrOp.t_array ), false ); g2.addParameter( TypeInfo.t_char, 0, new PtrOp( PtrOp.t_array ), false );
assertTrue( g1.hasSameParameters( g2 ) ); assertTrue( g1.hasSameParameters( g2 ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3415,7 +3415,7 @@ public class ParserSymbolTableTest extends TestCase {
h2.addParameter( f, 0, new PtrOp( PtrOp.t_pointer ), false ); h2.addParameter( f, 0, new PtrOp( PtrOp.t_pointer ), false );
assertTrue( h1.hasSameParameters( h2 ) ); assertTrue( h1.hasSameParameters( h2 ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
/** /**
@ -3432,7 +3432,7 @@ public class ParserSymbolTableTest extends TestCase {
f2.addParameter( TypeInfo.t_int, TypeInfo.isConst, null, false ); f2.addParameter( TypeInfo.t_int, TypeInfo.isConst, null, false );
assertTrue( f1.hasSameParameters( f2 ) ); assertTrue( f1.hasSameParameters( f2 ) );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
public void testBug52111RemoveSymbol() throws Exception{ public void testBug52111RemoveSymbol() throws Exception{
@ -3502,7 +3502,7 @@ public class ParserSymbolTableTest extends TestCase {
assertNull( look ); assertNull( look );
assertEquals( A.getContainedSymbols().size(), 0 ); assertEquals( A.getContainedSymbols().size(), 0 );
assertEquals( ParserSymbolTable.TypeInfoProvider.numAllocated(), 0 ); assertEquals( table.getTypeInfoProvider().numAllocated(), 0 );
} }
} }

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.core.parser.ast.IReferenceManager;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol; import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider;
/** /**
* @author jcamelon * @author jcamelon
@ -175,14 +176,16 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression
ExpressionResult result = getResultType(); ExpressionResult result = getResultType();
TypeInfo type = (result != null ) ? result.getResult() : null; TypeInfo type = (result != null ) ? result.getResult() : null;
IContainerSymbol containerSymbol = null; IContainerSymbol containerSymbol = null;
if( type != null ){
type = type.getFinalType(true); 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( TypeInfo.t_type ) &&
type.getTypeSymbol() != null && type.getTypeSymbol() instanceof IContainerSymbol ) type.getTypeSymbol() != null && type.getTypeSymbol() instanceof IContainerSymbol )
{ {
containerSymbol = (IContainerSymbol) type.getTypeSymbol(); containerSymbol = (IContainerSymbol) type.getTypeSymbol();
} }
type.release(); provider.returnTypeInfo( type );
} }
return containerSymbol; return containerSymbol;
@ -193,18 +196,15 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression
TypeInfo type = ( result != null ) ? result.getResult() : null; TypeInfo type = ( result != null ) ? result.getResult() : null;
if( type != null ){ if( type != null ){
boolean answer = false; boolean answer = false;
type = type.getFinalType(true); TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider();
if( type.checkBit( TypeInfo.isConst ) && !symbol.getTypeInfo().checkBit( TypeInfo.isConst ) ) type = type.getFinalType( provider );
{ if( type.checkBit( TypeInfo.isConst ) && !symbol.getTypeInfo().checkBit( TypeInfo.isConst ) )
answer = true; answer = true;
}
if( type.checkBit( TypeInfo.isVolatile ) && !symbol.getTypeInfo().checkBit( TypeInfo.isVolatile ) ) if( type.checkBit( TypeInfo.isVolatile ) && !symbol.getTypeInfo().checkBit( TypeInfo.isVolatile ) )
{
answer = true; answer = true;
}
type.release(); provider.returnTypeInfo( type );
return answer; return answer;
} }

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol; import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner; import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableError; import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableError;
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
@ -43,9 +44,11 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
public IContainerSymbol getLookupQualificationSymbol() throws LookupError { public IContainerSymbol getLookupQualificationSymbol() throws LookupError {
ISymbol sym = getSymbol(); ISymbol sym = getSymbol();
IContainerSymbol result = null; IContainerSymbol result = null;
ParserSymbolTable.TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider();
TypeInfo info = null; TypeInfo info = null;
try{ try{
info = sym.getTypeInfo().getFinalType(true); info = sym.getTypeInfo().getFinalType( provider );
} catch( ParserSymbolTableError e ){ } catch( ParserSymbolTableError e ){
throw new LookupError(); throw new LookupError();
} }
@ -55,15 +58,16 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
else if( sym instanceof IContainerSymbol ) else if( sym instanceof IContainerSymbol )
result = (IContainerSymbol) sym; result = (IContainerSymbol) sym;
info.release(); provider.returnTypeInfo( info );
return result; return result;
} }
public boolean shouldFilterLookupResult( ISymbol sym ){ public boolean shouldFilterLookupResult( ISymbol sym ){
boolean result = false; boolean result = false;
ParserSymbolTable.TypeInfoProvider provider = sym.getSymbolTable().getTypeInfoProvider();
TypeInfo info = null; TypeInfo info = null;
try{ try{
info = getSymbol().getTypeInfo().getFinalType(true); info = getSymbol().getTypeInfo().getFinalType( provider );
} catch( ParserSymbolTableError e ){ } catch( ParserSymbolTableError e ){
return true; return true;
} }
@ -74,7 +78,7 @@ public abstract class ASTSymbol extends ASTSymbolOwner implements ISymbolOwner,
if( info.checkBit( TypeInfo.isVolatile ) && !sym.getTypeInfo().checkBit( TypeInfo.isVolatile ) ) if( info.checkBit( TypeInfo.isVolatile ) && !sym.getTypeInfo().checkBit( TypeInfo.isVolatile ) )
result = true; result = true;
info.release(); provider.returnTypeInfo( info );
return result; return result;
} }

View file

@ -100,6 +100,7 @@ import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.TemplateSymbolExtension; import org.eclipse.cdt.internal.core.parser.pst.TemplateSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo; import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException; 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.pst.TypeInfo.PtrOp;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory; import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
import org.eclipse.cdt.internal.core.parser.util.TraceUtil; import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
@ -1160,9 +1161,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
private boolean createConstructorReference( ISymbol classSymbol, ASTExpression expressionList, ITokenDuple duple, List references ){ 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( TypeInfo.isTypedef ) ){
TypeInfo info = classSymbol.getTypeInfo().getFinalType(true); TypeInfoProvider provider = pst.getTypeInfoProvider();
TypeInfo info = classSymbol.getTypeInfo().getFinalType( provider );
classSymbol = info.getTypeSymbol(); classSymbol = info.getTypeSymbol();
info.release(); provider.returnTypeInfo( info );
} }
if( classSymbol == null || ! (classSymbol instanceof IDerivableContainerSymbol ) ){ if( classSymbol == null || ! (classSymbol instanceof IDerivableContainerSymbol ) ){
return false; return false;
@ -1294,14 +1296,15 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
TypeInfo lhsInfo = ((ASTExpression)lhs).getResultType().getResult(); TypeInfo lhsInfo = ((ASTExpression)lhs).getResultType().getResult();
if(lhsInfo != null){ if(lhsInfo != null){
TypeInfoProvider provider = pst.getTypeInfoProvider();
TypeInfo info = null; TypeInfo info = null;
try{ try{
info = lhsInfo.getFinalType(true); info = lhsInfo.getFinalType( provider );
} catch ( ParserSymbolTableError e ){ } catch ( ParserSymbolTableError e ){
return null; return null;
} }
ISymbol containingScope = info.getTypeSymbol(); ISymbol containingScope = info.getTypeSymbol();
info.release(); provider.returnTypeInfo( info );
// assert containingScope != null : "Malformed Expression"; // assert containingScope != null : "Malformed Expression";
if( containingScope instanceof IDeferredTemplateInstance ) if( containingScope instanceof IDeferredTemplateInstance )
return ((IDeferredTemplateInstance) containingScope).getTemplate().getTemplatedSymbol(); return ((IDeferredTemplateInstance) containingScope).getTemplate().getTemplatedSymbol();
@ -1335,7 +1338,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return info; return info;
} }
try{ try{
info = ParserSymbolTable.getConditionalOperand(second, third); info = pst.getConditionalOperand(second, third);
return info; return info;
} catch(ParserSymbolTableException e){ } catch(ParserSymbolTableException e){
// empty info // empty info
@ -3519,9 +3522,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} catch (ASTSemanticException e) { } catch (ASTSemanticException e) {
} }
if( classSymbol != null && classSymbol.getTypeInfo().checkBit( TypeInfo.isTypedef ) ){ if( classSymbol != null && classSymbol.getTypeInfo().checkBit( TypeInfo.isTypedef ) ){
TypeInfo info = classSymbol.getTypeInfo().getFinalType(true); TypeInfo info = classSymbol.getTypeInfo().getFinalType( pst.getTypeInfoProvider() );
classSymbol = (IContainerSymbol) info.getTypeSymbol(); classSymbol = (IContainerSymbol) info.getTypeSymbol();
info.release(); pst.getTypeInfoProvider().returnTypeInfo( info );
} }
if( classSymbol == null || ! (classSymbol instanceof IDerivableContainerSymbol ) ){ if( classSymbol == null || ! (classSymbol instanceof IDerivableContainerSymbol ) ){
return null; return null;
@ -3607,38 +3610,31 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
*/ */
public boolean validateIndirectMemberOperation(IASTNode node) { public boolean validateIndirectMemberOperation(IASTNode node) {
List pointerOps = null; List pointerOps = null;
TypeInfoProvider provider = pst.getTypeInfoProvider();
TypeInfo typeInfo = null; TypeInfo typeInfo = null;
if( ( node instanceof ISymbolOwner ) ) if( ( node instanceof ISymbolOwner ) )
{ {
ISymbol symbol = ((ISymbolOwner) node).getSymbol(); ISymbol symbol = ((ISymbolOwner) node).getSymbol();
typeInfo = symbol.getTypeInfo().getFinalType(true); typeInfo = symbol.getTypeInfo().getFinalType( provider );
pointerOps = typeInfo.getPtrOperators(); pointerOps = typeInfo.getPtrOperators();
typeInfo.release(); provider.returnTypeInfo( typeInfo );
} }
else if( node instanceof ASTExpression ) else if( node instanceof ASTExpression )
{ {
ISymbol typeSymbol = ((ASTExpression)node).getResultType().getResult().getTypeSymbol(); ISymbol typeSymbol = ((ASTExpression)node).getResultType().getResult().getTypeSymbol();
if( typeSymbol != null ) if( typeSymbol != null ){
{ typeInfo = typeSymbol.getTypeInfo().getFinalType( provider );
typeInfo = typeSymbol.getTypeInfo().getFinalType(true);
pointerOps = typeInfo.getPtrOperators(); pointerOps = typeInfo.getPtrOperators();
provider.returnTypeInfo( typeInfo );
} }
} }
else else
return false; return false;
try if( pointerOps == null || pointerOps.isEmpty() ) return false;
{ TypeInfo.PtrOp lastOperator = (PtrOp) pointerOps.get( pointerOps.size() - 1 );
if( pointerOps == null || pointerOps.isEmpty() ) return false; if( lastOperator.getType() == TypeInfo.PtrOp.t_array || lastOperator.getType() == TypeInfo.PtrOp.t_pointer ) return true;
TypeInfo.PtrOp lastOperator = (PtrOp) pointerOps.get( pointerOps.size() - 1 ); return false;
if( lastOperator.getType() == TypeInfo.PtrOp.t_array || lastOperator.getType() == TypeInfo.PtrOp.t_pointer ) return true;
return false;
}
finally
{
if( typeInfo != null )
typeInfo.release();
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -3649,9 +3645,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( ( node instanceof ISymbolOwner ) ) if( ( node instanceof ISymbolOwner ) )
{ {
ISymbol symbol = ((ISymbolOwner) node).getSymbol(); ISymbol symbol = ((ISymbolOwner) node).getSymbol();
TypeInfo typeInfo = symbol.getTypeInfo().getFinalType(true); TypeInfoProvider provider = pst.getTypeInfoProvider();
pointerOps = typeInfo.getPtrOperators(); TypeInfo info = symbol.getTypeInfo().getFinalType( provider );
typeInfo.release(); pointerOps = info.getPtrOperators();
provider.returnTypeInfo( info );
} }
else if( node instanceof ASTExpression ) else if( node instanceof ASTExpression )
{ {
@ -3688,7 +3685,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
* @return * @return
*/ */
public boolean validateCaches() { public boolean validateCaches() {
return cache.isBalanced(); return cache.isBalanced() && (pst.getTypeInfoProvider().numAllocated() == 0);
} }
} }

View file

@ -381,7 +381,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
List objList = null; List objList = null;
try{ try{
symbol = ParserSymbolTable.resolveAmbiguities( data ); symbol = getSymbolTable().resolveAmbiguities( data );
} catch ( ParserSymbolTableException e ) { } catch ( ParserSymbolTableException e ) {
if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction ){ if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction ){
throw e; throw e;
@ -463,7 +463,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
ISymbol found = ParserSymbolTable.resolveAmbiguities( data ); ISymbol found = getSymbolTable().resolveAmbiguities( data );
if( isTemplateMember() && found instanceof ITemplateSymbol ) { if( isTemplateMember() && found instanceof ITemplateSymbol ) {
boolean areWithinTemplate = false; boolean areWithinTemplate = false;
@ -490,7 +490,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
ISymbol found = ParserSymbolTable.resolveAmbiguities( data ); ISymbol found = getSymbolTable().resolveAmbiguities( data );
if( isTemplateMember() && found instanceof ITemplateSymbol ) { if( isTemplateMember() && found instanceof ITemplateSymbol ) {
return TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) found ); return TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) found );
@ -546,7 +546,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
data.foundItems = ParserSymbolTable.lookupInContained( data, container ); data.foundItems = ParserSymbolTable.lookupInContained( data, container );
if( data.foundItems != null ) if( data.foundItems != null )
return ParserSymbolTable.resolveAmbiguities( data ); return getSymbolTable().resolveAmbiguities( data );
return null; return null;
} }
@ -571,7 +571,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
data.foundItems = ParserSymbolTable.lookupInContained( data, container ); data.foundItems = ParserSymbolTable.lookupInContained( data, container );
if( data.foundItems != null ){ if( data.foundItems != null ){
ISymbol symbol = ParserSymbolTable.resolveAmbiguities( data ); ISymbol symbol = getSymbolTable().resolveAmbiguities( data );
return (IParameterizedSymbol) (( symbol instanceof IParameterizedSymbol ) ? symbol : null); return (IParameterizedSymbol) (( symbol instanceof IParameterizedSymbol ) ? symbol : null);
} }
@ -609,7 +609,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
data.foundItems = ParserSymbolTable.lookupInContained( data, inSymbol ); data.foundItems = ParserSymbolTable.lookupInContained( data, inSymbol );
if( data.foundItems != null ){ if( data.foundItems != null ){
foundSymbol = ParserSymbolTable.resolveAmbiguities( data ); foundSymbol = getSymbolTable().resolveAmbiguities( data );
} }
if( foundSymbol == null && inSymbol.getContainingSymbol() != null ){ if( foundSymbol == null && inSymbol.getContainingSymbol() != null ){
@ -630,7 +630,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
data.qualified = true; data.qualified = true;
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
return ParserSymbolTable.resolveAmbiguities( data ); return getSymbolTable().resolveAmbiguities( data );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -651,7 +651,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
data.qualified = true; data.qualified = true;
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
return ParserSymbolTable.resolveAmbiguities( data ); return getSymbolTable().resolveAmbiguities( data );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -691,9 +691,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
ISymbol paramType = null; ISymbol paramType = null;
for( int i = 0; i < size; i++ ){ for( int i = 0; i < size; i++ ){
param = (TypeInfo) parameters.get(i); param = (TypeInfo) parameters.get(i);
TypeInfo info = ParserSymbolTable.getFlatTypeInfo( param, true ); TypeInfo info = ParserSymbolTable.getFlatTypeInfo( param, getSymbolTable().getTypeInfoProvider() );
paramType = info.getTypeSymbol(); paramType = info.getTypeSymbol();
info.release(); getSymbolTable().getTypeInfoProvider().returnTypeInfo( info );
if( paramType == null ){ if( paramType == null ){
continue; continue;
@ -724,7 +724,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
ISymbol found = ParserSymbolTable.resolveAmbiguities( data ); ISymbol found = getSymbolTable().resolveAmbiguities( data );
//if we haven't found anything, or what we found is not a class member, consider the //if we haven't found anything, or what we found is not a class member, consider the
//associated scopes //associated scopes
@ -751,7 +751,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
} }
} }
found = ParserSymbolTable.resolveAmbiguities( data ); found = getSymbolTable().resolveAmbiguities( data );
} }
if( found instanceof IParameterizedSymbol ) if( found instanceof IParameterizedSymbol )
@ -779,7 +779,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
public TypeFilter getFilter() { return FUNCTION_FILTER; } public TypeFilter getFilter() { return FUNCTION_FILTER; }
}; };
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
return (IParameterizedSymbol) ParserSymbolTable.resolveAmbiguities( data ); return (IParameterizedSymbol) getSymbolTable().resolveAmbiguities( data );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -795,7 +795,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
return (IParameterizedSymbol) ParserSymbolTable.resolveAmbiguities( data ); return (IParameterizedSymbol) getSymbolTable().resolveAmbiguities( data );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -806,7 +806,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
LookupData data = new LookupData( name ); LookupData data = new LookupData( name );
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
ISymbol found = ParserSymbolTable.resolveAmbiguities( data ); ISymbol found = getSymbolTable().resolveAmbiguities( data );
if( found != null ){ if( found != null ){
if( (found.isType( TypeInfo.t_templateParameter ) && found.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template) || if( (found.isType( TypeInfo.t_templateParameter ) && found.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template) ||
found.isType( TypeInfo.t_template ) ) found.isType( TypeInfo.t_template ) )
@ -834,7 +834,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
data.exactFunctionsOnly = forDefinition; data.exactFunctionsOnly = forDefinition;
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
ISymbol found = ParserSymbolTable.resolveAmbiguities( data ); ISymbol found = getSymbolTable().resolveAmbiguities( data );
return found; return found;
} }
@ -885,7 +885,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
if( data.foundItems == null || data.foundItems.isEmpty() ){ if( data.foundItems == null || data.foundItems.isEmpty() ){
if( constructors != null ){ if( constructors != null ){
if( paramList != null ){ if( paramList != null ){
ParserSymbolTable.resolveFunction( data, constructors ); getSymbolTable().resolveFunction( data, constructors );
return constructors; return constructors;
} }
return constructors; return constructors;
@ -911,7 +911,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
if( obj instanceof List ){ if( obj instanceof List ){
//a list must be all functions? //a list must be all functions?
if( paramList != null ) if( paramList != null )
ParserSymbolTable.resolveFunction( data, (List) obj ); getSymbolTable().resolveFunction( data, (List) obj );
list.addAll( (List) obj ); list.addAll( (List) obj );
} else{ } else{
if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) ) if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) )
@ -921,7 +921,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
else else
tempList.clear(); tempList.clear();
tempList.add( obj ); tempList.add( obj );
ParserSymbolTable.resolveFunction( data, tempList ); getSymbolTable().resolveFunction( data, tempList );
list.addAll( tempList ); list.addAll( tempList );
} else { } else {
list.add( obj ); list.add( obj );

View file

@ -184,7 +184,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
paramType = TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) getContainingSymbol() ); paramType = TemplateEngine.instantiateWithinTemplateScope( this, (ITemplateSymbol) getContainingSymbol() );
} }
TypeInfo param = ParserSymbolTable.TypeInfoProvider.getTypeInfo(); TypeInfo param = getSymbolTable().getTypeInfoProvider().getTypeInfo();
param.setType( TypeInfo.t_type ); param.setType( TypeInfo.t_type );
param.setBit( true, TypeInfo.isConst ); param.setBit( true, TypeInfo.isConst );
param.setTypeSymbol( paramType ); param.setTypeSymbol( paramType );
@ -196,7 +196,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
constructor = lookupConstructor( parameters ); constructor = lookupConstructor( parameters );
} catch ( ParserSymbolTableException e ){ } catch ( ParserSymbolTableException e ){
} finally { } finally {
param.release(); getSymbolTable().getTypeInfoProvider().returnTypeInfo( param );
} }
if( constructor == null ){ if( constructor == null ){
@ -223,7 +223,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
constructors = new ArrayList( getConstructors() ); constructors = new ArrayList( getConstructors() );
} }
if( constructors != null ) if( constructors != null )
return ParserSymbolTable.resolveFunction( data, constructors ); return getSymbolTable().resolveFunction( data, constructors );
return null; return null;
} }
@ -363,7 +363,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
}; };
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
return ParserSymbolTable.resolveAmbiguities( data ); return getSymbolTable().resolveAmbiguities( data );
} }
public IParameterizedSymbol lookupFunctionForFriendship( String name, final List parameters ) throws ParserSymbolTableException{ public IParameterizedSymbol lookupFunctionForFriendship( String name, final List parameters ) throws ParserSymbolTableException{
@ -385,7 +385,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
}; };
ParserSymbolTable.lookup( data, this ); ParserSymbolTable.lookup( data, this );
return (IParameterizedSymbol) ParserSymbolTable.resolveAmbiguities( data ); return (IParameterizedSymbol) getSymbolTable().resolveAmbiguities( data );
} }

View file

@ -22,6 +22,7 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider;
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp; import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
/** /**
@ -217,6 +218,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
TypeInfo info = null; TypeInfo info = null;
TypeInfo fInfo = null; TypeInfo fInfo = null;
TypeInfoProvider provider = getSymbolTable().getTypeInfoProvider();
for( int i = 0; i < size; i++ ){ for( int i = 0; i < size; i++ ){
ISymbol p = (ISymbol) params.get(i); ISymbol p = (ISymbol) params.get(i);
ISymbol pf = (ISymbol) functionParams.get(i); ISymbol pf = (ISymbol) functionParams.get(i);
@ -225,8 +228,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
fInfo = pf.getTypeInfo(); fInfo = pf.getTypeInfo();
//parameters that differ only in the use of equivalent typedef types are equivalent. //parameters that differ only in the use of equivalent typedef types are equivalent.
info = ParserSymbolTable.getFlatTypeInfo( info, true ); info = ParserSymbolTable.getFlatTypeInfo( info, provider );
fInfo = ParserSymbolTable.getFlatTypeInfo( fInfo, true ); fInfo = ParserSymbolTable.getFlatTypeInfo( fInfo, provider );
for( TypeInfo nfo = info; nfo != null; nfo = fInfo ){ for( TypeInfo nfo = info; nfo != null; nfo = fInfo ){
//an array declaration is adjusted to become a pointer declaration //an array declaration is adjusted to become a pointer declaration
@ -265,8 +268,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
boolean equals = info.equals( fInfo ); boolean equals = info.equals( fInfo );
info.release(); provider.returnTypeInfo( info );
fInfo.release(); provider.returnTypeInfo( fInfo );
if( ! equals ) if( ! equals )
return false; return false;

View file

@ -455,9 +455,10 @@ public class ParserSymbolTable {
return true; return true;
} }
TypeInfo typeInfo = ParserSymbolTable.getFlatTypeInfo( symbol.getTypeInfo(), true ); TypeInfoProvider provider = symbol.getSymbolTable().getTypeInfoProvider();
TypeInfo typeInfo = ParserSymbolTable.getFlatTypeInfo( symbol.getTypeInfo(), provider );
boolean accept = data.getFilter().shouldAccept( symbol, typeInfo ) || data.getFilter().shouldAccept( symbol ); boolean accept = data.getFilter().shouldAccept( symbol, typeInfo ) || data.getFilter().shouldAccept( symbol );
typeInfo.release(); provider.returnTypeInfo( typeInfo );
return accept; return accept;
} }
@ -920,7 +921,7 @@ public class ParserSymbolTable {
* all, when looking for functions with no parameters, an empty list must be * all, when looking for functions with no parameters, an empty list must be
* provided in data.parameters. * provided in data.parameters.
*/ */
static protected ISymbol resolveAmbiguities( LookupData data ) throws ParserSymbolTableException{ protected ISymbol resolveAmbiguities( LookupData data ) throws ParserSymbolTableException{
ISymbol resolvedSymbol = null; ISymbol resolvedSymbol = null;
if( data.foundItems == null || data.foundItems.isEmpty() || data.isPrefixLookup() ){ if( data.foundItems == null || data.foundItems.isEmpty() || data.isPrefixLookup() ){
@ -970,7 +971,7 @@ public class ParserSymbolTable {
return resolvedSymbol; return resolvedSymbol;
} }
static protected IParameterizedSymbol resolveFunction( LookupData data, List functions ) throws ParserSymbolTableException{ protected IParameterizedSymbol resolveFunction( LookupData data, List functions ) throws ParserSymbolTableException{
if( functions == null ){ if( functions == null ){
return null; return null;
} }
@ -1035,10 +1036,12 @@ public class ParserSymbolTable {
List sourceParameters = null; //the parameters the function is being called with List sourceParameters = null; //the parameters the function is being called with
List targetParameters = null; //the current function's parameters List targetParameters = null; //the current function's parameters
TypeInfoProvider infoProvider = getTypeInfoProvider();
if( numSourceParams == 0 ){ if( numSourceParams == 0 ){
//f() is the same as f( void ) //f() is the same as f( void )
sourceParameters = new ArrayList(1); sourceParameters = new ArrayList(1);
voidInfo = TypeInfoProvider.getTypeInfo(); voidInfo = infoProvider.getTypeInfo();
voidInfo.setType( TypeInfo.t_void ); voidInfo.setType( TypeInfo.t_void );
sourceParameters.add( voidInfo ); sourceParameters.add( voidInfo );
numSourceParams = 1; numSourceParams = 1;
@ -1086,14 +1089,14 @@ public class ParserSymbolTable {
varArgs = true; varArgs = true;
if( varArgs ){ if( varArgs ){
cost = new Cost( source, null ); cost = new Cost( infoProvider, source, null );
cost.rank = Cost.ELLIPSIS_CONVERSION; cost.rank = Cost.ELLIPSIS_CONVERSION;
} else if ( target.getHasDefault() && source.isType( TypeInfo.t_void ) && !source.hasPtrOperators() ){ } else if ( target.getHasDefault() && source.isType( TypeInfo.t_void ) && !source.hasPtrOperators() ){
//source is just void, ie no parameter, if target had a default, then use that //source is just void, ie no parameter, if target had a default, then use that
cost = new Cost( source, target ); cost = new Cost( infoProvider, source, target );
cost.rank = Cost.IDENTITY_RANK; cost.rank = Cost.IDENTITY_RANK;
} else if( source.equals( target ) ){ } else if( source.equals( target ) ){
cost = new Cost( source, target ); cost = new Cost( infoProvider, source, target );
cost.rank = Cost.IDENTITY_RANK; //exact match, no cost cost.rank = Cost.IDENTITY_RANK; //exact match, no cost
} else { } else {
try{ try{
@ -1104,17 +1107,17 @@ public class ParserSymbolTable {
if( cost.rank == Cost.NO_MATCH_RANK && !data.forUserDefinedConversion ){ if( cost.rank == Cost.NO_MATCH_RANK && !data.forUserDefinedConversion ){
temp = checkUserDefinedConversionSequence( source, target ); temp = checkUserDefinedConversionSequence( source, target );
if( temp != null ){ if( temp != null ){
cost.release(); cost.release( infoProvider );
cost = temp; cost = temp;
} }
} }
} catch( ParserSymbolTableException e ) { } catch( ParserSymbolTableException e ) {
if( cost != null ) { cost.release(); cost = null; } if( cost != null ) { cost.release( infoProvider ); cost = null; }
if( temp != null ) { temp.release(); temp = null; } if( temp != null ) { temp.release( infoProvider ); temp = null; }
throw e; throw e;
} catch( ParserSymbolTableError e ) { } catch( ParserSymbolTableError e ) {
if( cost != null ) { cost.release(); cost = null; } if( cost != null ) { cost.release( infoProvider ); cost = null; }
if( temp != null ) { temp.release(); temp = null; } if( temp != null ) { temp.release( infoProvider ); temp = null; }
throw e; throw e;
} }
} }
@ -1157,7 +1160,7 @@ public class ParserSymbolTable {
//during a prefix lookup, we don't need to rank the functions //during a prefix lookup, we don't need to rank the functions
if( data.isPrefixLookup() ){ if( data.isPrefixLookup() ){
releaseCosts( currFnCost ); releaseCosts( currFnCost, infoProvider );
continue; continue;
} }
@ -1183,12 +1186,12 @@ public class ParserSymbolTable {
ambiguous = false; ambiguous = false;
} }
} catch( ParserSymbolTableException e ) { } catch( ParserSymbolTableException e ) {
if( currFnCost != null ) releaseCosts( currFnCost ); if( currFnCost != null ) releaseCosts( currFnCost, infoProvider );
if( bestFnCost != null ) releaseCosts( bestFnCost ); if( bestFnCost != null ) releaseCosts( bestFnCost, infoProvider );
throw e; throw e;
} catch( ParserSymbolTableError e ) { } catch( ParserSymbolTableError e ) {
if( currFnCost != null ) releaseCosts( currFnCost ); if( currFnCost != null ) releaseCosts( currFnCost, infoProvider );
if( bestFnCost != null ) releaseCosts( bestFnCost ); if( bestFnCost != null ) releaseCosts( bestFnCost, infoProvider );
throw e; throw e;
} }
} }
@ -1208,29 +1211,29 @@ public class ParserSymbolTable {
if( hasBetter ){ if( hasBetter ){
//the new best function. //the new best function.
ambiguous = false; ambiguous = false;
releaseCosts( bestFnCost ); releaseCosts( bestFnCost, infoProvider );
bestFnCost = currFnCost; bestFnCost = currFnCost;
bestHasAmbiguousParam = currHasAmbiguousParam; bestHasAmbiguousParam = currHasAmbiguousParam;
currFnCost = null; currFnCost = null;
bestFn = currFn; bestFn = currFn;
} else { } else {
releaseCosts( currFnCost ); releaseCosts( currFnCost, infoProvider );
} }
} else { } else {
releaseCosts( currFnCost ); releaseCosts( currFnCost, infoProvider );
} }
} }
} finally { } finally {
if( currFnCost != null ){ if( currFnCost != null ){
releaseCosts( currFnCost ); releaseCosts( currFnCost, infoProvider );
currFnCost = null; currFnCost = null;
} }
if( bestFnCost != null ){ if( bestFnCost != null ){
releaseCosts( bestFnCost ); releaseCosts( bestFnCost, infoProvider );
bestFnCost = null; bestFnCost = null;
} }
if( voidInfo != null ) if( voidInfo != null )
voidInfo.release(); infoProvider.returnTypeInfo( voidInfo );
} }
if( ambiguous || bestHasAmbiguousParam ){ if( ambiguous || bestHasAmbiguousParam ){
@ -1239,11 +1242,11 @@ public class ParserSymbolTable {
return bestFn; return bestFn;
} }
static private void releaseCosts( Cost [] costs ){ static private void releaseCosts( Cost [] costs, TypeInfoProvider provider ){
if( costs != null ) { if( costs != null && provider != null) {
for( int i = 0; i < costs.length; i++ ){ for( int i = 0; i < costs.length; i++ ){
if( costs[i] != null ) if( costs[i] != null )
costs[i].release(); costs[i].release( provider );
} }
} }
} }
@ -1572,11 +1575,11 @@ public class ParserSymbolTable {
return okToAdd; return okToAdd;
} }
static private Cost lvalue_to_rvalue( TypeInfo source, TypeInfo target ){ static private Cost lvalue_to_rvalue( TypeInfoProvider provider, TypeInfo source, TypeInfo target ){
//lvalues will have type t_type //lvalues will have type t_type
if( source.isType( TypeInfo.t_type ) ){ if( source.isType( TypeInfo.t_type ) ){
source = getFlatTypeInfo( source, false ); source = getFlatTypeInfo( source, null );
} }
if( target.isType( TypeInfo.t_type ) ){ if( target.isType( TypeInfo.t_type ) ){
@ -1588,7 +1591,7 @@ public class ParserSymbolTable {
} }
} }
Cost cost = new Cost( source, target ); Cost cost = new Cost( provider, source, target );
//if either source or target is null here, then there was a problem //if either source or target is null here, then there was a problem
//with the parameters and we can't match them. //with the parameters and we can't match them.
@ -1848,8 +1851,8 @@ public class ParserSymbolTable {
} }
} }
static protected Cost checkStandardConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException{ protected Cost checkStandardConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException{
Cost cost = lvalue_to_rvalue( source, target ); Cost cost = lvalue_to_rvalue( getTypeInfoProvider(), source, target );
if( cost.getSource() == null || cost.getTarget() == null ){ if( cost.getSource() == null || cost.getTarget() == null ){
return cost; return cost;
@ -1893,13 +1896,18 @@ public class ParserSymbolTable {
if( cost.rank > -1 ) if( cost.rank > -1 )
return cost; return cost;
derivedToBaseConversion( cost ); try{
derivedToBaseConversion( cost );
} catch ( ParserSymbolTableException e ){
cost.release( getTypeInfoProvider() );
throw e;
}
return cost; return cost;
} }
static private Cost checkUserDefinedConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException { private Cost checkUserDefinedConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException {
Cost cost = null; Cost cost = null;
Cost constructorCost = null; Cost constructorCost = null;
Cost conversionCost = null; Cost conversionCost = null;
@ -1942,9 +1950,9 @@ public class ParserSymbolTable {
//conversion operators //conversion operators
if( source.getType() == TypeInfo.t_type ){ if( source.getType() == TypeInfo.t_type ){
source = getFlatTypeInfo( source, true ); source = getFlatTypeInfo( source, getTypeInfoProvider() );
sourceDecl = ( source != null ) ? source.getTypeSymbol() : null; sourceDecl = ( source != null ) ? source.getTypeSymbol() : null;
source.release(); getTypeInfoProvider().returnTypeInfo( source );
if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){ if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){
String name = target.toString(); String name = target.toString();
@ -1963,18 +1971,18 @@ public class ParserSymbolTable {
try { try {
if( constructor != null ){ if( constructor != null ){
TypeInfo info = TypeInfoProvider.getTypeInfo(); TypeInfo info = getTypeInfoProvider().getTypeInfo();
info.setType( TypeInfo.t_type ); info.setType( TypeInfo.t_type );
info.setTypeSymbol( constructor.getContainingSymbol() ); info.setTypeSymbol( constructor.getContainingSymbol() );
constructorCost = checkStandardConversionSequence( info, target ); constructorCost = checkStandardConversionSequence( info, target );
info.release(); getTypeInfoProvider().returnTypeInfo( info );
} }
if( conversion != null ){ if( conversion != null ){
TypeInfo info = TypeInfoProvider.getTypeInfo(); TypeInfo info = getTypeInfoProvider().getTypeInfo();
info.setType( target.getType() ); info.setType( target.getType() );
info.setTypeSymbol( target.getTypeSymbol() ); info.setTypeSymbol( target.getTypeSymbol() );
conversionCost = checkStandardConversionSequence( info, target ); conversionCost = checkStandardConversionSequence( info, target );
info.release(); getTypeInfoProvider().returnTypeInfo( info );
} }
//if both are valid, then the conversion is ambiguous //if both are valid, then the conversion is ambiguous
@ -1997,9 +2005,9 @@ public class ParserSymbolTable {
} }
} finally { } finally {
if( constructorCost != null && constructorCost != cost ) if( constructorCost != null && constructorCost != cost )
constructorCost.release(); constructorCost.release( getTypeInfoProvider() );
if( conversionCost != null && conversionCost != cost ) if( conversionCost != null && conversionCost != cost )
conversionCost.release(); conversionCost.release( getTypeInfoProvider() );
} }
return cost; return cost;
} }
@ -2016,31 +2024,31 @@ public class ParserSymbolTable {
* - If neither can be converted, further checking must be done (return null) * - If neither can be converted, further checking must be done (return null)
* - If exactly one conversion is possible, that conversion is applied ( return the other TypeInfo ) * - If exactly one conversion is possible, that conversion is applied ( return the other TypeInfo )
*/ */
static public TypeInfo getConditionalOperand( TypeInfo secondOp, TypeInfo thirdOp ) throws ParserSymbolTableException{ public TypeInfo getConditionalOperand( TypeInfo secondOp, TypeInfo thirdOp ) throws ParserSymbolTableException{
Cost thirdCost = null, secondCost = null; Cost thirdCost = null, secondCost = null;
TypeInfo temp = null; TypeInfo temp = null;
TypeInfoProvider provider = getTypeInfoProvider();
try{ try{
//can secondOp convert to thirdOp ? //can secondOp convert to thirdOp ?
temp = getFlatTypeInfo( thirdOp, true ); temp = getFlatTypeInfo( thirdOp, provider );
secondCost = checkStandardConversionSequence( secondOp, temp ); secondCost = checkStandardConversionSequence( secondOp, temp );
if( secondCost.rank == Cost.NO_MATCH_RANK ){ if( secondCost.rank == Cost.NO_MATCH_RANK ){
secondCost.release(); secondCost.release( provider );
secondCost = checkUserDefinedConversionSequence( secondOp, temp ); secondCost = checkUserDefinedConversionSequence( secondOp, temp );
} }
temp.release(); getTypeInfoProvider().returnTypeInfo( temp );
temp = getFlatTypeInfo( secondOp, true ); temp = getFlatTypeInfo( secondOp, provider );
thirdCost = checkStandardConversionSequence( thirdOp, temp ); thirdCost = checkStandardConversionSequence( thirdOp, temp );
if( thirdCost.rank == Cost.NO_MATCH_RANK ){ if( thirdCost.rank == Cost.NO_MATCH_RANK ){
thirdCost.release(); thirdCost.release( provider );
thirdCost = checkUserDefinedConversionSequence( thirdOp, temp ); thirdCost = checkUserDefinedConversionSequence( thirdOp, temp );
} }
} finally { } finally {
if( thirdCost != null ) thirdCost.release(); if( thirdCost != null ) thirdCost.release( provider );
if( secondCost != null ) secondCost.release(); if( secondCost != null ) secondCost.release( provider );
if( temp != null ) temp.release(); if( temp != null ) provider.returnTypeInfo( temp );
} }
boolean canConvertSecond = ( secondCost != null && secondCost.rank != Cost.NO_MATCH_RANK ); boolean canConvertSecond = ( secondCost != null && secondCost.rank != Cost.NO_MATCH_RANK );
@ -2070,19 +2078,19 @@ public class ParserSymbolTable {
/** /**
* *
* @param usePool TODO * @param infoProvider - if using the pool, an instance of the symbol table must be provided
* @param decl * @param decl
* @return TypeInfo * @return TypeInfo
* The top level TypeInfo represents modifications to the object and the * The top level TypeInfo represents modifications to the object and the
* remaining TypeInfo's represent the object. * remaining TypeInfo's represent the object.
*/ */
static protected TypeInfo getFlatTypeInfo( TypeInfo topInfo, boolean usePool ){ static protected TypeInfo getFlatTypeInfo( TypeInfo topInfo, TypeInfoProvider infoProvider ){
TypeInfo returnInfo = null; TypeInfo returnInfo = null;
TypeInfo info = null; TypeInfo info = null;
if( topInfo.getType() == TypeInfo.t_type && topInfo.getTypeSymbol() != null ){ if( topInfo.getType() == TypeInfo.t_type && topInfo.getTypeSymbol() != null ){
if( usePool ) returnInfo = TypeInfoProvider.getTypeInfo(); if( infoProvider != null ) returnInfo = infoProvider.getTypeInfo();
else returnInfo = new TypeInfo(); else returnInfo = new TypeInfo();
returnInfo.setTypeInfo( topInfo.getTypeInfo() ); returnInfo.setTypeInfo( topInfo.getTypeInfo() );
ISymbol typeSymbol = topInfo.getTypeSymbol(); ISymbol typeSymbol = topInfo.getTypeSymbol();
@ -2096,8 +2104,8 @@ public class ParserSymbolTable {
returnInfo.setTypeInfo( ( returnInfo.getTypeInfo() | info.getTypeInfo() ) & ~TypeInfo.isTypedef & ~TypeInfo.isForward ); returnInfo.setTypeInfo( ( returnInfo.getTypeInfo() | info.getTypeInfo() ) & ~TypeInfo.isTypedef & ~TypeInfo.isForward );
info = typeSymbol.getTypeInfo(); info = typeSymbol.getTypeInfo();
if( ++j > TYPE_LOOP_THRESHOLD ){ if( ++j > TYPE_LOOP_THRESHOLD ){
if( usePool ) if( infoProvider != null )
returnInfo.release(); infoProvider.returnTypeInfo( returnInfo );
throw new ParserSymbolTableError(); throw new ParserSymbolTableError();
} }
} }
@ -2122,8 +2130,8 @@ public class ParserSymbolTable {
returnInfo.addPtrOperator( ptr ); returnInfo.addPtrOperator( ptr );
} }
} else { } else {
if( usePool ){ if( infoProvider != null ){
returnInfo = TypeInfoProvider.getTypeInfo(); returnInfo = infoProvider.getTypeInfo();
returnInfo.copy( topInfo ); returnInfo.copy( topInfo );
} else } else
returnInfo = new TypeInfo( topInfo ); returnInfo = new TypeInfo( topInfo );
@ -2132,6 +2140,14 @@ public class ParserSymbolTable {
return returnInfo; return returnInfo;
} }
/**
* @return
*/
public TypeInfoProvider getTypeInfoProvider() {
return _provider;
}
private TypeInfoProvider _provider = new TypeInfoProvider();
private IContainerSymbol _compilationUnit; private IContainerSymbol _compilationUnit;
private ParserLanguage _language; private ParserLanguage _language;
private ParserMode _mode; private ParserMode _mode;
@ -2238,12 +2254,12 @@ public class ParserSymbolTable {
static protected class Cost static protected class Cost
{ {
public Cost( TypeInfo s, TypeInfo t ){ public Cost( TypeInfoProvider provider, TypeInfo s, TypeInfo t ){
source = TypeInfoProvider.getTypeInfo(); source = provider.getTypeInfo();
if( s != null ) if( s != null )
source.copy( s ); source.copy( s );
target = TypeInfoProvider.getTypeInfo(); target = provider.getTypeInfo();
if( t != null ) if( t != null )
target.copy( t ); target.copy( t );
} }
@ -2273,9 +2289,9 @@ public class ParserSymbolTable {
public static final int USERDEFINED_CONVERSION_RANK = 4; public static final int USERDEFINED_CONVERSION_RANK = 4;
public static final int ELLIPSIS_CONVERSION = 5; public static final int ELLIPSIS_CONVERSION = 5;
public void release(){ public void release( TypeInfoProvider provider ){
getSource().release(); provider.returnTypeInfo( getSource() );
getTarget().release(); provider.returnTypeInfo( getTarget() );
} }
public int compare( Cost cost ){ public int compare( Cost cost ){
@ -2443,12 +2459,12 @@ public class ParserSymbolTable {
public static class TypeInfoProvider public static class TypeInfoProvider
{ {
private static final int POOL_SIZE = 16; private final int POOL_SIZE = 16;
private static final TypeInfo [] pool; private final TypeInfo [] pool;
private static final boolean [] free; private final boolean [] free;
private static int firstFreeHint = 0; private int firstFreeHint = 0;
static public TypeInfoProvider()
{ {
pool = new TypeInfo[ POOL_SIZE ]; pool = new TypeInfo[ POOL_SIZE ];
free = new boolean[POOL_SIZE]; free = new boolean[POOL_SIZE];
@ -2459,7 +2475,7 @@ public class ParserSymbolTable {
} }
} }
public static synchronized TypeInfo getTypeInfo() public TypeInfo getTypeInfo()
{ {
for( int i = firstFreeHint; i < POOL_SIZE; ++i ) for( int i = firstFreeHint; i < POOL_SIZE; ++i )
{ {
@ -2474,7 +2490,7 @@ public class ParserSymbolTable {
return new TypeInfo(); return new TypeInfo();
} }
public static synchronized void returnTypeInfo( TypeInfo t ) public void returnTypeInfo( TypeInfo t )
{ {
for( int i = 0; i < POOL_SIZE; i++ ){ for( int i = 0; i < POOL_SIZE; i++ ){
if( pool[i] == t ){ if( pool[i] == t ){
@ -2489,14 +2505,13 @@ public class ParserSymbolTable {
//else it was one allocated outside the pool //else it was one allocated outside the pool
} }
public static synchronized int numAllocated(){ public int numAllocated(){
// int num = 0; int num = 0;
// for( int i = 0; i < POOL_SIZE; i++ ){ for( int i = 0; i < POOL_SIZE; i++ ){
// if( !free[i] ) if( !free[i] )
// num++; num++;
// } }
// return num; return num;
return 0;
} }
} }
} }

View file

@ -170,7 +170,7 @@ public final class TemplateEngine {
try { try {
TypeInfo info = new TypeInfo( param.getTypeInfo() ); TypeInfo info = new TypeInfo( param.getTypeInfo() );
info.setType( info.getTemplateParameterType() ); info.setType( info.getTemplateParameterType() );
cost = ParserSymbolTable.checkStandardConversionSequence( arg, info ); cost = param.getSymbolTable().checkStandardConversionSequence( arg, info );
} catch (ParserSymbolTableException e) { } catch (ParserSymbolTableException e) {
} }
@ -179,7 +179,7 @@ public final class TemplateEngine {
} }
} finally{ } finally{
if( cost != null ) if( cost != null )
cost.release(); cost.release( param.getSymbolTable().getTypeInfoProvider() );
} }
} }
return true; return true;
@ -312,7 +312,7 @@ public final class TemplateEngine {
*/ */
static private TypeInfo getArgumentTypeForDeduction( TypeInfo aInfo, boolean pIsAReferenceType ) throws ParserSymbolTableException{ static private TypeInfo getArgumentTypeForDeduction( TypeInfo aInfo, boolean pIsAReferenceType ) throws ParserSymbolTableException{
TypeInfo a = ParserSymbolTable.getFlatTypeInfo( aInfo, false ); TypeInfo a = ParserSymbolTable.getFlatTypeInfo( aInfo, null );
if( !pIsAReferenceType ){ if( !pIsAReferenceType ){
ISymbol aSymbol = a.getTypeSymbol(); ISymbol aSymbol = a.getTypeSymbol();
@ -694,7 +694,7 @@ public final class TemplateEngine {
static private boolean deduceArgument( Map map, ISymbol p, TypeInfo a ){ static private boolean deduceArgument( Map map, ISymbol p, TypeInfo a ){
a = ParserSymbolTable.getFlatTypeInfo( a, false ); a = ParserSymbolTable.getFlatTypeInfo( a, null );
if( map.containsKey( p ) ){ if( map.containsKey( p ) ){
TypeInfo current = (TypeInfo)map.get( p ); TypeInfo current = (TypeInfo)map.get( p );

View file

@ -16,6 +16,7 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import org.eclipse.cdt.core.parser.Enum; import org.eclipse.cdt.core.parser.Enum;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfoProvider;
public class TypeInfo { public class TypeInfo {
@ -287,12 +288,13 @@ public class TypeInfo {
/** /**
* *
* @param usePool - whether or not use to the pool, if true, TypeInfo.release() must * @param infoProvider - TypeInfoProvider to use if pooling the TypeInfo created, if null,
* be called on the returned TypeInfo when itis no longer needed * pooling is not used. If pooling is used, TypeInfoProvider.returnTypeInfo
* must be called when the TypeInfo is no longer needed
* @return * @return
*/ */
public TypeInfo getFinalType(boolean usePool){ public TypeInfo getFinalType(TypeInfoProvider infoProvider){
return ParserSymbolTable.getFlatTypeInfo( this, usePool ); return ParserSymbolTable.getFlatTypeInfo( this, infoProvider );
} }
/** /**
* *
@ -565,9 +567,9 @@ public class TypeInfo {
_operatorExpressions = Collections.EMPTY_LIST; _operatorExpressions = Collections.EMPTY_LIST;
} }
public void release() { // public void release() {
ParserSymbolTable.TypeInfoProvider.returnTypeInfo( this ); // ParserSymbolTable.TypeInfoProvider.returnTypeInfo( this );
} // }
private int _typeBits = 0; private int _typeBits = 0;