mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
performance changes, use ArrayList instead of LinkedList, reduce use of iterators. saves 5%
This commit is contained in:
parent
c092fa64d2
commit
361017e5d4
18 changed files with 791 additions and 740 deletions
|
@ -10,8 +10,8 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -88,7 +88,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
table.getCompilationUnit().addSymbol( B );
|
||||
|
||||
TypeInfo type = new TypeInfo( TypeInfo.t_type, 0, B );
|
||||
LinkedList args = new LinkedList();
|
||||
ArrayList args = new ArrayList();
|
||||
args.add( type );
|
||||
|
||||
IContainerSymbol instance = (IContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args );
|
||||
|
@ -145,7 +145,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
table.getCompilationUnit().addSymbol( B );
|
||||
|
||||
TypeInfo type = new TypeInfo( TypeInfo.t_int, 0 , null );
|
||||
LinkedList args = new LinkedList();
|
||||
ArrayList args = new ArrayList();
|
||||
args.add( type );
|
||||
|
||||
look = table.getCompilationUnit().lookupTemplateId( "A", args );
|
||||
|
@ -217,7 +217,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
X.addSymbol( u );
|
||||
|
||||
TypeInfo type = new TypeInfo( TypeInfo.t_char, 0, null );
|
||||
LinkedList args = new LinkedList();
|
||||
ArrayList args = new ArrayList();
|
||||
args.add( type );
|
||||
IDerivableContainerSymbol lookX = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "X", args );
|
||||
assertTrue( lookX.isTemplateInstance() );
|
||||
|
@ -272,7 +272,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class );
|
||||
table.getCompilationUnit().addSymbol( B );
|
||||
|
||||
LinkedList args = new LinkedList();
|
||||
ArrayList args = new ArrayList();
|
||||
TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, B );
|
||||
args.add( arg );
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
f3.addParameter( TypeInfo.t_int, 0, null, false );
|
||||
table.getCompilationUnit().addSymbol( f3 );
|
||||
|
||||
args = new LinkedList();
|
||||
args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, B ) );
|
||||
IDerivableContainerSymbol lookA2 = (IDerivableContainerSymbol) table.getCompilationUnit().lookupTemplateId( "A", args );
|
||||
assertEquals( lookA2, lookA );
|
||||
|
@ -302,7 +302,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
a.setTypeSymbol( lookA );
|
||||
table.getCompilationUnit().addSymbol( a );
|
||||
|
||||
LinkedList params = new LinkedList();
|
||||
ArrayList params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_type, 0, a ) );
|
||||
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params );
|
||||
|
@ -421,7 +421,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
p.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
||||
table.getCompilationUnit().addSymbol( p );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, p ) );
|
||||
|
||||
look = table.getCompilationUnit().lookupTemplateId( "R", args );
|
||||
|
@ -473,7 +473,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IDerivableContainerSymbol string = table.newDerivableContainerSymbol( "String", TypeInfo.t_class );
|
||||
factory.addSymbol( string );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
ISymbol look = table.getCompilationUnit().lookupTemplateId( "String", args );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), string );
|
||||
|
@ -510,7 +510,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IDerivableContainerSymbol S = table.newDerivableContainerSymbol( "S", TypeInfo.t_struct );
|
||||
f.addSymbol( S );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, S ) );
|
||||
try{
|
||||
f.lookupTemplateId( "X", args );
|
||||
|
@ -560,7 +560,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class );
|
||||
factory.addSymbol( X );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_char, 0, null, new PtrOp( PtrOp.t_pointer ), "Studebaker" ) );
|
||||
|
||||
|
@ -631,7 +631,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
t.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
||||
S.addSymbol( t );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, m );
|
||||
arg.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
|
||||
args.add( arg );
|
||||
|
@ -692,7 +692,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_struct );
|
||||
factory.addSymbol( B );
|
||||
|
||||
List args = new LinkedList( );
|
||||
List args = new ArrayList( );
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, "1" ) );
|
||||
|
||||
try{
|
||||
|
@ -774,7 +774,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C", TypeInfo.t_class );
|
||||
templateC.addSymbol( C );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
|
||||
ISymbol look = templateC.lookupTemplateId( "V", args );
|
||||
|
@ -889,7 +889,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
ISymbol returnType = factory.lookup( "U" );
|
||||
assertEquals( returnType, U );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, U ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, V ) );
|
||||
|
||||
|
@ -897,7 +897,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
assertEquals( look, A );
|
||||
factory.pushTemplateId( look, args );
|
||||
|
||||
IParameterizedSymbol lookF = factory.lookupMethodForDefinition( "f1", new LinkedList() );
|
||||
IParameterizedSymbol lookF = factory.lookupMethodForDefinition( "f1", new ArrayList() );
|
||||
assertEquals( lookF, f1 );
|
||||
assertTrue( lookF.isForwardDeclaration() );
|
||||
|
||||
|
@ -915,7 +915,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
assertTrue( lookA.isTemplateInstance() );
|
||||
assertEquals( lookA.getInstantiatedSymbol(), A );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
look = lookA.qualifiedFunctionLookup( "f1", params );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), defnd );
|
||||
|
@ -980,7 +980,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
factory.pushTemplate( temp );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, U ) );
|
||||
|
||||
IContainerSymbol lookA = factory.lookupTemplateIdForDefinition( "A", args );
|
||||
|
@ -1061,7 +1061,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
factory.pushTemplate( temp );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, paramU ) );
|
||||
|
||||
look = factory.lookupTemplateIdForDefinition( "X", args );
|
||||
|
@ -1151,7 +1151,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
ISymbol lookV = factory.lookup( "V" );
|
||||
assertEquals( lookV, V );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, U ) );
|
||||
|
||||
ISymbol look = factory.lookupTemplateIdForDefinition( "string", args );
|
||||
|
@ -1300,7 +1300,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
spec.addSymbol( A2 );
|
||||
template.addSpecialization( spec );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
|
||||
|
||||
|
@ -1424,7 +1424,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
ITemplateSymbol a = (ITemplateSymbol) table.getCompilationUnit().lookup( "A" );
|
||||
assertEquals( a, template1 );
|
||||
|
||||
LinkedList args = new LinkedList();
|
||||
ArrayList args = new ArrayList();
|
||||
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
|
@ -1527,7 +1527,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
p.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
|
||||
table.getCompilationUnit().addSymbol( p );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_type, 0, p ) );
|
||||
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params );
|
||||
|
@ -1572,7 +1572,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.addSymbol( g2 );
|
||||
|
||||
ISymbol x = table.newSymbol( "x", TypeInfo.t_float );
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_type, 0, x ) );
|
||||
try{
|
||||
table.getCompilationUnit().unqualifiedFunctionLookup( "g", params );
|
||||
|
@ -1630,20 +1630,20 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
T = template2.lookup( "T" );
|
||||
|
||||
IParameterizedSymbol h2 = table.newParameterizedSymbol( "h", TypeInfo.t_function );
|
||||
List argList = new LinkedList();
|
||||
List argList = new ArrayList();
|
||||
argList.add( new TypeInfo( TypeInfo.t_type, 0, T ) );
|
||||
h2.addParameter( templateA.instantiate( argList ), 0, new PtrOp( PtrOp.t_reference ), false );
|
||||
factory.addSymbol( h2 );
|
||||
|
||||
ISymbol z = table.newSymbol( "z", TypeInfo.t_type );
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
ISymbol look = table.getCompilationUnit().lookupTemplateId( "A", args );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), A );
|
||||
z.setTypeSymbol( look );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_type, 0, z ) );
|
||||
look = table.getCompilationUnit().unqualifiedFunctionLookup( "h", params );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
|
@ -1843,7 +1843,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
factory.pushTemplate( temp );
|
||||
|
||||
LinkedList params = new LinkedList(), args = new LinkedList();
|
||||
ArrayList args = new ArrayList();
|
||||
|
||||
factory = table.newTemplateFactory();
|
||||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
|
@ -1910,7 +1910,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
|
||||
IParameterizedSymbol sort = table.newParameterizedSymbol( "sort", TypeInfo.t_function );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, T ) );
|
||||
|
||||
ISymbol arrayLook = factory.lookupTemplateId( "Array", args );
|
||||
|
@ -1989,8 +1989,6 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
|
||||
factory.addSymbol( f2 );
|
||||
|
||||
List params = new LinkedList();
|
||||
|
||||
factory = table.newTemplateFactory();
|
||||
ITemplateSymbol template = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
|
@ -1999,11 +1997,11 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
|
||||
f3.addParameter( TypeInfo.t_int, 0, new PtrOp( PtrOp.t_pointer ), false );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
|
||||
factory.addTemplateId( f3, args );
|
||||
|
||||
args = new LinkedList();
|
||||
args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
|
||||
template = table.newTemplateSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
|
@ -2093,7 +2091,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
table.getCompilationUnit().addSymbol( a );
|
||||
table.getCompilationUnit().addSymbol( b );
|
||||
|
||||
List argList = new LinkedList();
|
||||
List argList = new ArrayList();
|
||||
TypeInfo aParam = new TypeInfo( TypeInfo.t_type, 0, a );
|
||||
TypeInfo bParam = new TypeInfo( TypeInfo.t_type, 0, b );
|
||||
|
||||
|
@ -2188,7 +2186,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
table.getCompilationUnit().addSymbol( g3);
|
||||
|
||||
TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, g1 );
|
||||
List argList = new LinkedList();
|
||||
List argList = new ArrayList();
|
||||
argList.add( arg );
|
||||
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", argList );
|
||||
|
@ -2230,7 +2228,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
ISymbol p = table.newSymbol( "p", TypeInfo.t_int );
|
||||
p.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_type, 0, p ) );
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params );
|
||||
|
||||
|
@ -2293,7 +2291,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.addSymbol( D );
|
||||
|
||||
ISymbol T = templateD.lookup( "T" );
|
||||
List args = new LinkedList ();
|
||||
List args = new ArrayList ();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, T ) );
|
||||
ISymbol look = table.getCompilationUnit().lookupTemplateId( "B", args );
|
||||
assertTrue( look instanceof IDeferredTemplateInstance );
|
||||
|
@ -2432,7 +2430,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
factory.pushTemplate( spec1 );
|
||||
|
||||
List args = new LinkedList();
|
||||
List args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, spec1_T ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, spec1_T ) );
|
||||
|
||||
|
@ -2482,7 +2480,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
assertEquals( ((IDeferredTemplateInstance)symbol).getTemplate(), template );
|
||||
factory.pushTemplateId( symbol, args );
|
||||
|
||||
ISymbol look = factory.lookupMethodForDefinition( "f", new LinkedList() );
|
||||
ISymbol look = factory.lookupMethodForDefinition( "f", new ArrayList() );
|
||||
assertEquals( look, f1 );
|
||||
IParameterizedSymbol f1Def = table.newParameterizedSymbol( "f", TypeInfo.t_function );
|
||||
f1.setTypeSymbol( f1Def );
|
||||
|
@ -2500,14 +2498,14 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
factory.pushTemplate( specDef1 );
|
||||
|
||||
args = new LinkedList();
|
||||
args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, W ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, W ) );
|
||||
|
||||
symbol = factory.lookupTemplateId( "A", args );
|
||||
factory.pushTemplateId( symbol, args );
|
||||
|
||||
look = factory.lookupMethodForDefinition( "f", new LinkedList() );
|
||||
look = factory.lookupMethodForDefinition( "f", new ArrayList() );
|
||||
assertEquals( look, f2 );
|
||||
IParameterizedSymbol f2Def = table.newParameterizedSymbol( "f", TypeInfo.t_function );
|
||||
f2.setTypeSymbol( f2Def );
|
||||
|
@ -2525,14 +2523,14 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
factory.setContainingSymbol( table.getCompilationUnit() );
|
||||
factory.pushTemplate( specDef1 );
|
||||
|
||||
args = new LinkedList();
|
||||
args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_char, 0, null ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, X ) );
|
||||
|
||||
symbol = factory.lookupTemplateId( "A", args );
|
||||
factory.pushTemplateId( symbol, args );
|
||||
|
||||
look = factory.lookupMethodForDefinition( "f", new LinkedList() );
|
||||
look = factory.lookupMethodForDefinition( "f", new ArrayList() );
|
||||
assertEquals( look, f3 );
|
||||
IParameterizedSymbol f3Def = table.newParameterizedSymbol( "f", TypeInfo.t_function );
|
||||
f3.setTypeSymbol( f3Def );
|
||||
|
@ -2542,7 +2540,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
f3Def.addSymbol( c3 );
|
||||
|
||||
//A< int, char > a1;
|
||||
args = new LinkedList();
|
||||
args = new ArrayList();
|
||||
args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
args.add( new TypeInfo( TypeInfo.t_char, 0, null ) );
|
||||
|
||||
|
@ -2550,7 +2548,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), A1 );
|
||||
|
||||
look = ((IContainerSymbol)look).qualifiedFunctionLookup( "f", new LinkedList() );
|
||||
look = ((IContainerSymbol)look).qualifiedFunctionLookup( "f", new ArrayList() );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), f1Def );
|
||||
|
||||
|
@ -2568,7 +2566,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), A2 );
|
||||
|
||||
look = ((IContainerSymbol)look).qualifiedFunctionLookup( "f", new LinkedList() );
|
||||
look = ((IContainerSymbol)look).qualifiedFunctionLookup( "f", new ArrayList() );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), f2Def );
|
||||
|
||||
|
@ -2586,7 +2584,7 @@ public class ParserSymbolTableTemplateTests extends TestCase {
|
|||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), A3 );
|
||||
|
||||
look = ((IContainerSymbol)look).qualifiedFunctionLookup( "f", new LinkedList() );
|
||||
look = ((IContainerSymbol)look).qualifiedFunctionLookup( "f", new ArrayList() );
|
||||
assertTrue( look.isTemplateInstance() );
|
||||
assertEquals( look.getInstantiatedSymbol(), f3Def );
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.core.parser.tests;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -44,7 +43,6 @@ import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeFilter;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.OperatorExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||
|
||||
|
@ -1159,7 +1157,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
foo.setType( TypeInfo.t_function );
|
||||
compUnit.addSymbol( foo );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
TypeInfo param = new TypeInfo( TypeInfo.t_char, 0, null );
|
||||
paramList.add( param );
|
||||
|
||||
|
@ -1304,7 +1302,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
main.setReturnType( table.newSymbol( "", TypeInfo.t_int ) );
|
||||
compUnit.addSymbol( main );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
look = main.lookup( "parm" );
|
||||
assertEquals( look, param );
|
||||
TypeInfo p = new TypeInfo( TypeInfo.t_type, 0, look );
|
||||
|
@ -1389,7 +1387,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
a.setTypeSymbol( look );
|
||||
compUnit.addSymbol( a );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
look = compUnit.lookup( "a" );
|
||||
assertEquals( look, a );
|
||||
TypeInfo param = new TypeInfo( look.getType(), 0, look, null, false );
|
||||
|
@ -1464,7 +1462,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
assertEquals( look, c );
|
||||
assertEquals( look.getTypeSymbol(), C );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null );
|
||||
TypeInfo p2 = new TypeInfo( TypeInfo.t_char, 0, null );
|
||||
|
@ -1510,7 +1508,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
f2.addParameter( TypeInfo.t_char, 0, null, true );
|
||||
compUnit.addSymbol( f2 );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null );
|
||||
paramList.add( p1 );
|
||||
|
||||
|
@ -1589,7 +1587,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
c.setTypeSymbol( C );
|
||||
c.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, a );
|
||||
paramList.add( p1 );
|
||||
ISymbol look = compUnit.unqualifiedFunctionLookup( "f", paramList );
|
||||
|
@ -1663,7 +1661,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
array.setTypeSymbol( A );
|
||||
array.addPtrOperator( new PtrOp( PtrOp.t_array, false, false ) );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
TypeInfo p = new TypeInfo( TypeInfo.t_type, 0, a );
|
||||
paramList.add( p );
|
||||
|
||||
|
@ -1734,7 +1732,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
a.setTypeSymbol( A );
|
||||
compUnit.addSymbol( a );
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
TypeInfo p = new TypeInfo( TypeInfo.t_type, 0, a );
|
||||
paramList.add( p );
|
||||
|
||||
|
@ -1794,7 +1792,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
main.setType( TypeInfo.t_function );
|
||||
compUnit.addSymbol( main );
|
||||
|
||||
LinkedList params = new LinkedList();
|
||||
ArrayList params = new ArrayList();
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, i );
|
||||
p1.addOperatorExpression( OperatorExpression.addressof );
|
||||
TypeInfo p2 = new TypeInfo( TypeInfo.t_type, 0, s );
|
||||
|
@ -1889,7 +1887,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
b.setType( TypeInfo.t_type );
|
||||
b.setTypeSymbol( B );
|
||||
|
||||
LinkedList params = new LinkedList();
|
||||
ArrayList params = new ArrayList();
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, b );
|
||||
params.add( p1 );
|
||||
|
||||
|
@ -1932,56 +1930,56 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
assertEquals( look, f3 );
|
||||
}
|
||||
|
||||
public void testMarkRollback() throws Exception{
|
||||
newTable();
|
||||
|
||||
IDerivableContainerSymbol A = table.newDerivableContainerSymbol("A");
|
||||
A.setType( TypeInfo.t_class );
|
||||
table.getCompilationUnit().addSymbol( A );
|
||||
|
||||
Mark mark = table.setMark();
|
||||
|
||||
ISymbol f = table.newSymbol("f");
|
||||
A.addSymbol( f );
|
||||
|
||||
ISymbol look = A.lookup("f");
|
||||
assertEquals( look, f );
|
||||
|
||||
assertTrue( table.rollBack( mark ) );
|
||||
|
||||
look = A.lookup("f");
|
||||
assertEquals( look, null );
|
||||
|
||||
IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B");
|
||||
B.setType( TypeInfo.t_class );
|
||||
|
||||
mark = table.setMark();
|
||||
table.getCompilationUnit().addSymbol( B );
|
||||
Mark mark2 = table.setMark();
|
||||
A.addParent( B );
|
||||
Mark mark3 = table.setMark();
|
||||
|
||||
IParameterizedSymbol C = table.newParameterizedSymbol("C");
|
||||
C.addParameter( TypeInfo.t_class, 0, null, false );
|
||||
|
||||
assertEquals( C.getParameterList().size(), 1 );
|
||||
table.rollBack( mark3 );
|
||||
assertEquals( C.getParameterList().size(), 0 );
|
||||
assertEquals( A.getParents().size(), 1 );
|
||||
table.rollBack( mark2 );
|
||||
assertEquals( A.getParents().size(), 0 );
|
||||
|
||||
assertFalse( table.commit( mark2 ) );
|
||||
assertFalse( table.rollBack( mark2 ) );
|
||||
|
||||
B.setType( TypeInfo.t_namespace );
|
||||
|
||||
mark = table.setMark();
|
||||
C.addUsingDirective( B );
|
||||
assertEquals( C.getUsingDirectives().size(), 1 );
|
||||
table.rollBack( mark );
|
||||
assertEquals( C.getUsingDirectives().size(), 0 );
|
||||
}
|
||||
// public void testMarkRollback() throws Exception{
|
||||
// newTable();
|
||||
//
|
||||
// IDerivableContainerSymbol A = table.newDerivableContainerSymbol("A");
|
||||
// A.setType( TypeInfo.t_class );
|
||||
// table.getCompilationUnit().addSymbol( A );
|
||||
//
|
||||
// Mark mark = table.setMark();
|
||||
//
|
||||
// ISymbol f = table.newSymbol("f");
|
||||
// A.addSymbol( f );
|
||||
//
|
||||
// ISymbol look = A.lookup("f");
|
||||
// assertEquals( look, f );
|
||||
//
|
||||
// assertTrue( table.rollBack( mark ) );
|
||||
//
|
||||
// look = A.lookup("f");
|
||||
// assertEquals( look, null );
|
||||
//
|
||||
// IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B");
|
||||
// B.setType( TypeInfo.t_class );
|
||||
//
|
||||
// mark = table.setMark();
|
||||
// table.getCompilationUnit().addSymbol( B );
|
||||
// Mark mark2 = table.setMark();
|
||||
// A.addParent( B );
|
||||
// Mark mark3 = table.setMark();
|
||||
//
|
||||
// IParameterizedSymbol C = table.newParameterizedSymbol("C");
|
||||
// C.addParameter( TypeInfo.t_class, 0, null, false );
|
||||
//
|
||||
// assertEquals( C.getParameterList().size(), 1 );
|
||||
// table.rollBack( mark3 );
|
||||
// assertEquals( C.getParameterList().size(), 0 );
|
||||
// assertEquals( A.getParents().size(), 1 );
|
||||
// table.rollBack( mark2 );
|
||||
// assertEquals( A.getParents().size(), 0 );
|
||||
//
|
||||
// assertFalse( table.commit( mark2 ) );
|
||||
// assertFalse( table.rollBack( mark2 ) );
|
||||
//
|
||||
// B.setType( TypeInfo.t_namespace );
|
||||
//
|
||||
// mark = table.setMark();
|
||||
// C.addUsingDirective( B );
|
||||
// assertEquals( C.getUsingDirectives().size(), 1 );
|
||||
// table.rollBack( mark );
|
||||
// assertEquals( C.getUsingDirectives().size(), 0 );
|
||||
// }
|
||||
|
||||
/**
|
||||
* class A;
|
||||
|
@ -2110,7 +2108,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
/*..*/
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_type, 0, a1 );
|
||||
paramList.add( p1 );
|
||||
ISymbol look = classB.memberFunctionLookup( "f", paramList );
|
||||
|
@ -2150,7 +2148,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
assertEquals( e.reason, ParserSymbolTableException.r_InvalidOverload );
|
||||
}
|
||||
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
paramList.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
|
||||
ISymbol lookup = classA.lookupConstructor( paramList );
|
||||
|
@ -2221,7 +2219,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
table.getCompilationUnit().addSymbol( NSB );
|
||||
|
||||
//look for function that has no parameters
|
||||
LinkedList paramList = new LinkedList();
|
||||
ArrayList paramList = new ArrayList();
|
||||
ISymbol look = NSB.qualifiedFunctionLookup( "f", paramList );
|
||||
assertEquals( look, f );
|
||||
|
||||
|
@ -2252,7 +2250,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
table.getCompilationUnit().addSymbol( f );
|
||||
|
||||
LinkedList paramList = new LinkedList ();
|
||||
ArrayList paramList = new ArrayList ();
|
||||
|
||||
TypeInfo param = new TypeInfo( TypeInfo.t_type, 0, null );
|
||||
|
||||
|
@ -2386,7 +2384,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
f1.addParameter( clsA, 0, new PtrOp( PtrOp.t_reference ), false );
|
||||
table.getCompilationUnit().addSymbol( f1 );
|
||||
|
||||
LinkedList parameters = new LinkedList();
|
||||
ArrayList parameters = new ArrayList();
|
||||
TypeInfo param = new TypeInfo( TypeInfo.t_type, 0, b );
|
||||
parameters.add( param );
|
||||
|
||||
|
@ -2470,7 +2468,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function );
|
||||
table.getCompilationUnit().addSymbol( f );
|
||||
|
||||
LinkedList parameters = new LinkedList();
|
||||
ArrayList parameters = new ArrayList();
|
||||
TypeInfo param = new TypeInfo( TypeInfo.t_void, 0, null );
|
||||
parameters.add( param );
|
||||
|
||||
|
@ -2573,7 +2571,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
IParameterizedSymbol init2 = table.newParameterizedSymbol( "initialize", TypeInfo.t_function );
|
||||
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new LinkedList() );
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new ArrayList() );
|
||||
assertEquals( look, init1 );
|
||||
|
||||
init1.getTypeInfo().setIsForwardDeclaration( true );
|
||||
|
@ -2581,7 +2579,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
table.getCompilationUnit().addSymbol( init2 );
|
||||
|
||||
look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new LinkedList() );
|
||||
look = table.getCompilationUnit().unqualifiedFunctionLookup( "initialize", new ArrayList() );
|
||||
|
||||
assertEquals( look, init2 );
|
||||
}
|
||||
|
@ -2622,7 +2620,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
f3.addParameter( TypeInfo.t_char, 0, null, false );
|
||||
B.addSymbol( f3 );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
|
||||
|
||||
ISymbol look = B.qualifiedFunctionLookup( "f", params );
|
||||
|
@ -3000,7 +2998,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
table.getCompilationUnit().addSymbol( foo );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null );
|
||||
params.add( p1 );
|
||||
|
@ -3029,7 +3027,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
foo2.addParameter( TypeInfo.t_int, 0, null, false );
|
||||
table.getCompilationUnit().addSymbol( foo2 );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
|
||||
TypeInfo p1 = new TypeInfo( TypeInfo.t_int, 0, null );
|
||||
params.add( p1 );
|
||||
|
@ -3057,7 +3055,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
foo2.setHasVariableArgs( true );
|
||||
table.getCompilationUnit().addSymbol( foo2 );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
|
||||
ISymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "foo", params );
|
||||
|
||||
|
@ -3203,7 +3201,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
f2.addParameter( TypeInfo.t_int, TypeInfo.isLong, null, false );
|
||||
table.getCompilationUnit().addSymbol( f2 );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_int, TypeInfo.isLong, null ) );
|
||||
|
||||
IParameterizedSymbol lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params );
|
||||
|
@ -3241,7 +3239,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
g.addParameter( TypeInfo.t_float, 0, null, false );
|
||||
table.getCompilationUnit().addSymbol( g );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t_float, TypeInfo.isComplex, null ) );
|
||||
|
||||
IParameterizedSymbol lookup = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params );
|
||||
|
@ -3280,7 +3278,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
table.getCompilationUnit().addSymbol( g );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
params.add( new TypeInfo( TypeInfo.t__Bool, 0, null ) );
|
||||
|
||||
IParameterizedSymbol look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", params );
|
||||
|
@ -3412,7 +3410,7 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
look = B.qualifiedLookup( "i" );
|
||||
assertNull( look );
|
||||
|
||||
List params = new LinkedList();
|
||||
List params = new ArrayList();
|
||||
|
||||
look = B.qualifiedFunctionLookup( "f", params );
|
||||
assertEquals( look, f1 );
|
||||
|
|
|
@ -70,6 +70,13 @@ public class ASTAbstractDeclaration implements IASTAbstractDeclaration
|
|||
if( pointerOperators == null ) return EmptyIterator.EMPTY_ITERATOR;
|
||||
return pointerOperators.iterator();
|
||||
}
|
||||
|
||||
public int getNumPointerOperators(){
|
||||
if( pointerOperators == null )
|
||||
return 0;
|
||||
return pointerOperators.size();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers()
|
||||
*/
|
||||
|
@ -78,6 +85,12 @@ public class ASTAbstractDeclaration implements IASTAbstractDeclaration
|
|||
if( arrayModifiers == null ) return EmptyIterator.EMPTY_ITERATOR;
|
||||
return arrayModifiers.iterator();
|
||||
}
|
||||
|
||||
public int getNumArrayModifiers(){
|
||||
if( arrayModifiers == null )
|
||||
return 0;
|
||||
return arrayModifiers.size();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getParameters()
|
||||
*/
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
||||
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ExtensibleSymbolExtension;
|
||||
|
@ -2062,6 +2063,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
symbol.setHasVariableArgs( hasVariableArguments );
|
||||
|
||||
symbol.prepareForParameters( parameters.size() );
|
||||
setParameter( symbol, returnType, false, references );
|
||||
setParameters( symbol, references, parameters.iterator() );
|
||||
|
||||
|
@ -2380,6 +2382,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
|
||||
symbol.setHasVariableArgs( hasVariableArguments );
|
||||
|
||||
symbol.prepareForParameters( parameters.size() );
|
||||
if( returnType.getTypeSpecifier() != null )
|
||||
setParameter( symbol, returnType, false, references );
|
||||
setParameters( symbol, references, parameters.iterator() );
|
||||
|
@ -2595,6 +2598,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
isRegister,
|
||||
isStatic,
|
||||
newSymbol);
|
||||
|
||||
int numPtrOps = ((ASTAbstractDeclaration)abstractDeclaration).getNumArrayModifiers() +
|
||||
((ASTAbstractDeclaration)abstractDeclaration).getNumPointerOperators();
|
||||
newSymbol.preparePtrOperatros( numPtrOps );
|
||||
setPointerOperators( newSymbol, abstractDeclaration.getPointerOperators(), abstractDeclaration.getArrayModifiers() );
|
||||
|
||||
newSymbol.setIsForwardDeclaration( isStatic || isExtern );
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -119,15 +118,10 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
|||
} else if( size == 0 )
|
||||
return 0;
|
||||
else {
|
||||
|
||||
Iterator iter1 = symbol.getTypeInfo().getPtrOperators().iterator();
|
||||
Iterator iter2 = getTypeInfo().getPtrOperators().iterator();
|
||||
|
||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
op1 = (TypeInfo.PtrOp)iter1.next();
|
||||
op2 = (TypeInfo.PtrOp)iter2.next();
|
||||
for( int i = 0; i > size; i++ ){
|
||||
op1 = (TypeInfo.PtrOp)symbol.getTypeInfo().getPtrOperators().get(i);
|
||||
op2 = (TypeInfo.PtrOp)getTypeInfo().getPtrOperators().get(i);
|
||||
|
||||
if( op1.compareCVTo( op2 ) != 0 ){
|
||||
return -1;
|
||||
|
@ -144,6 +138,10 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
|
|||
public void addPtrOperator( TypeInfo.PtrOp ptrOp ){
|
||||
getTypeInfo().addPtrOperator( ptrOp );
|
||||
}
|
||||
public void preparePtrOperatros(int numPtrOps) {
|
||||
getTypeInfo().preparePtrOperators( numPtrOps );
|
||||
}
|
||||
|
||||
|
||||
public int getDepth(){
|
||||
return _depth;
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
@ -32,7 +33,6 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMember;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Command;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.LookupData;
|
||||
|
||||
/**
|
||||
|
@ -58,14 +58,14 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
public Object clone(){
|
||||
ContainerSymbol copy = (ContainerSymbol)super.clone();
|
||||
|
||||
copy._usingDirectives = (_usingDirectives != ParserSymbolTable.EMPTY_LIST) ? (LinkedList) _usingDirectives.clone() : _usingDirectives;
|
||||
copy._usingDirectives = (_usingDirectives != Collections.EMPTY_LIST) ? (List) ((ArrayList)_usingDirectives).clone() : _usingDirectives;
|
||||
|
||||
if( getSymbolTable().getParserMode() == ParserMode.COMPLETION_PARSE )
|
||||
copy._containedSymbols = ( _containedSymbols != ParserSymbolTable.EMPTY_MAP )? (Map)((TreeMap) _containedSymbols).clone() : _containedSymbols;
|
||||
copy._containedSymbols = ( _containedSymbols != Collections.EMPTY_MAP )? (Map)((TreeMap) _containedSymbols).clone() : _containedSymbols;
|
||||
else
|
||||
copy._containedSymbols = ( _containedSymbols != ParserSymbolTable.EMPTY_MAP )? (Map)((HashMap) _containedSymbols).clone() : _containedSymbols;
|
||||
copy._containedSymbols = ( _containedSymbols != Collections.EMPTY_MAP )? (Map)((HashMap) _containedSymbols).clone() : _containedSymbols;
|
||||
|
||||
copy._contents = (_contents != ParserSymbolTable.EMPTY_LIST) ? (LinkedList) _contents.clone() : _contents;
|
||||
copy._contents = (_contents != Collections.EMPTY_LIST) ? (List) ((ArrayList)_contents).clone() : _contents;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -98,11 +98,12 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
|
||||
if( !template.getExplicitSpecializations().isEmpty() ){
|
||||
List argList = new LinkedList();
|
||||
List params = template.getParameterList();
|
||||
int size = template.getParameterList().size();
|
||||
List argList = new ArrayList( size );
|
||||
boolean hasAllParams = true;
|
||||
Iterator templateParams = template.getParameterList().iterator();
|
||||
while( templateParams.hasNext() ){
|
||||
Object obj = argMap.get( templateParams.next() );
|
||||
for( int i = 0; i < size; i++ ){
|
||||
Object obj = argMap.get( params.get( i ) );
|
||||
if( obj == null ){
|
||||
hasAllParams = false;
|
||||
break;
|
||||
|
@ -141,7 +142,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
if( obj instanceof List ){
|
||||
((List) obj).add( newSymbol );
|
||||
} else {
|
||||
List list = new LinkedList();
|
||||
List list = new ArrayList(4);
|
||||
list.add( obj );
|
||||
list.add( newSymbol );
|
||||
newContainer.putInContainedSymbols( newSymbol.getName(), list );
|
||||
|
@ -211,12 +212,12 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
if( origObj != null )
|
||||
{
|
||||
ISymbol origDecl = null;
|
||||
LinkedList origList = null;
|
||||
ArrayList origList = null;
|
||||
|
||||
if( origObj instanceof ISymbol ){
|
||||
origDecl = (ISymbol)origObj;
|
||||
} else if( origObj.getClass() == LinkedList.class ){
|
||||
origList = (LinkedList)origObj;
|
||||
} else if( origObj.getClass() == ArrayList.class ){
|
||||
origList = (ArrayList)origObj;
|
||||
} else {
|
||||
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
|
||||
}
|
||||
|
@ -228,7 +229,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
if( unnamed || validOverride )
|
||||
{
|
||||
if( origList == null ){
|
||||
origList = new LinkedList();
|
||||
origList = new ArrayList(4);
|
||||
origList.add( origDecl );
|
||||
origList.add( obj );
|
||||
|
||||
|
@ -248,8 +249,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
addToContents( obj );
|
||||
|
||||
Command command = new AddSymbolCommand( obj, containing );
|
||||
getSymbolTable().pushCommand( command );
|
||||
// Command command = new AddSymbolCommand( obj, containing );
|
||||
// getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
public boolean removeSymbol( ISymbol symbol ){
|
||||
|
@ -303,8 +304,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
|
||||
protected void addToUsingDirectives( IExtensibleSymbol symbol ){
|
||||
if( _usingDirectives == ParserSymbolTable.EMPTY_LIST )
|
||||
_usingDirectives = new LinkedList();
|
||||
if( _usingDirectives == Collections.EMPTY_LIST )
|
||||
_usingDirectives = new ArrayList(4);
|
||||
_usingDirectives.add( symbol );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
@ -330,8 +331,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
addToUsingDirectives( usingDirective );
|
||||
addToContents( usingDirective );
|
||||
|
||||
Command command = new AddUsingDirectiveCommand( this, usingDirective );
|
||||
getSymbolTable().pushCommand( command );
|
||||
// Command command = new AddUsingDirectiveCommand( this, usingDirective );
|
||||
// getSymbolTable().pushCommand( command );
|
||||
|
||||
return usingDirective;
|
||||
}
|
||||
|
@ -376,7 +377,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
//then they will be in data.foundItems (since we provided no parameter info);
|
||||
ISymbol symbol = null;
|
||||
ISymbol clone = null;
|
||||
Iterator iter = null;
|
||||
int objListSize = 0;
|
||||
List objList = null;
|
||||
|
||||
try{
|
||||
symbol = ParserSymbolTable.resolveAmbiguities( data );
|
||||
|
@ -392,16 +394,17 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
if( symbol == null ){
|
||||
Object object = data.foundItems.get( data.name );
|
||||
iter = ( object instanceof List ) ? ((List) object).iterator() : null;
|
||||
symbol = ( iter != null && iter.hasNext() ) ? (ISymbol)iter.next() : null;
|
||||
objList = ( object instanceof List ) ? (List) object : null;
|
||||
objListSize = ( objList != null ) ? objList.size() : 0;
|
||||
symbol = ( objListSize > 0 ) ? (ISymbol)objList.get(0) : null;
|
||||
}
|
||||
|
||||
List usingDecs = new LinkedList();
|
||||
List usingRefs = new LinkedList();
|
||||
List usingDecs = new ArrayList( ( objListSize > 0 ) ? objListSize : 1 );
|
||||
List usingRefs = new ArrayList( ( objListSize > 0 ) ? objListSize : 1 );
|
||||
|
||||
UsingDeclarationSymbol usingDeclaration = new UsingDeclarationSymbol( getSymbolTable(), usingRefs, usingDecs );
|
||||
boolean addedUsingToContained = false;
|
||||
|
||||
int idx = 1;
|
||||
while( symbol != null ){
|
||||
if( ParserSymbolTable.okToAddUsingDeclaration( symbol, this ) ){
|
||||
if( ! addedUsingToContained ){
|
||||
|
@ -417,8 +420,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
usingDecs.add( clone );
|
||||
usingRefs.add( symbol );
|
||||
|
||||
if( iter != null && iter.hasNext() ){
|
||||
symbol = (ISymbol) iter.next();
|
||||
if( objList != null && idx < objListSize ){
|
||||
symbol = (ISymbol) objList.get( idx++ );
|
||||
} else {
|
||||
symbol = null;
|
||||
}
|
||||
|
@ -435,7 +438,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
|
||||
protected void putInContainedSymbols( String key, Object obj ){
|
||||
if( _containedSymbols == ParserSymbolTable.EMPTY_MAP ){
|
||||
if( _containedSymbols == Collections.EMPTY_MAP ){
|
||||
if( getSymbolTable().getParserMode() == ParserMode.COMPLETION_PARSE ){
|
||||
_containedSymbols = new TreeMap( new SymbolTableComparator() );
|
||||
} else {
|
||||
|
@ -542,7 +545,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
public IParameterizedSymbol lookupMethodForDefinition( String name, List parameters ) throws ParserSymbolTableException{
|
||||
LookupData data = new LookupData( name, TypeInfo.t_any );
|
||||
data.qualified = true;
|
||||
data.parameters = ( parameters == null ) ? ParserSymbolTable.EMPTY_LIST : parameters;
|
||||
data.parameters = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
data.exactFunctionsOnly = true;
|
||||
|
||||
IContainerSymbol container = this;
|
||||
|
@ -684,7 +687,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
LookupData data = new LookupData( name, TypeInfo.t_function );
|
||||
//if parameters == null, thats no parameters, but we need to distinguish that from
|
||||
//no parameter information at all, so make an empty list.
|
||||
data.parameters = ( parameters == null ) ? ParserSymbolTable.EMPTY_LIST : parameters;
|
||||
data.parameters = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
data.associated = associated;
|
||||
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
|
@ -741,7 +744,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
LookupData data = new LookupData( name, TypeInfo.t_function );
|
||||
//if parameters == null, thats no parameters, but we need to distinguish that from
|
||||
//no parameter information at all, so make an empty list.
|
||||
data.parameters = ( parameters == null ) ? ParserSymbolTable.EMPTY_LIST : parameters;
|
||||
data.parameters = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
return (IParameterizedSymbol) ParserSymbolTable.resolveAmbiguities( data );
|
||||
|
@ -755,7 +758,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
data.qualified = true;
|
||||
//if parameters == null, thats no parameters, but we need to distinguish that from
|
||||
//no parameter information at all, so make an empty list.
|
||||
data.parameters = ( parameters == null ) ? ParserSymbolTable.EMPTY_LIST : parameters;
|
||||
data.parameters = ( parameters == null ) ? Collections.EMPTY_LIST : parameters;
|
||||
|
||||
ParserSymbolTable.lookup( data, this );
|
||||
|
||||
|
@ -818,8 +821,13 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
List constructors = null;
|
||||
if( filter != null && filter.willAccept( TypeInfo.t_constructor ) && (this instanceof IDerivableContainerSymbol) ){
|
||||
if( getName().startsWith( prefix ) )
|
||||
constructors = new LinkedList( ((IDerivableContainerSymbol)this).getConstructors() );
|
||||
if( getName().startsWith( prefix ) ){
|
||||
List temp = ((IDerivableContainerSymbol)this).getConstructors();
|
||||
int size = temp.size();
|
||||
constructors = new ArrayList( size );
|
||||
for( int i = 0; i < size; i++ )
|
||||
constructors.add( temp.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( data.foundItems == null || data.foundItems.isEmpty() ){
|
||||
|
@ -840,7 +848,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
}
|
||||
|
||||
List list = new LinkedList();
|
||||
List list = new ArrayList();
|
||||
|
||||
Iterator iter = data.foundItems.keySet().iterator();
|
||||
Object obj = null;
|
||||
|
@ -857,7 +865,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) )
|
||||
{
|
||||
if( tempList == null )
|
||||
tempList = new LinkedList();
|
||||
tempList = new ArrayList(1);
|
||||
else
|
||||
tempList.clear();
|
||||
tempList.add( obj );
|
||||
|
@ -960,8 +968,16 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
|
||||
protected void addToContents( IExtensibleSymbol symbol ){
|
||||
if( _contents == ParserSymbolTable.EMPTY_LIST )
|
||||
_contents = new LinkedList();
|
||||
if( _contents == Collections.EMPTY_LIST ){
|
||||
if( isType( TypeInfo.t_namespace ) )
|
||||
_contents = new ArrayList( 64 );
|
||||
else if( isType( TypeInfo.t_class ) || isType( TypeInfo.t_struct ) )
|
||||
_contents = new ArrayList( 32 );
|
||||
else if( isType( TypeInfo.t_function ) )
|
||||
_contents = new ArrayList( 16 );
|
||||
else
|
||||
_contents = new ArrayList( 8 );
|
||||
}
|
||||
_contents.add( symbol );
|
||||
}
|
||||
|
||||
|
@ -1049,72 +1065,72 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
|
||||
}
|
||||
static private class AddSymbolCommand extends Command{
|
||||
AddSymbolCommand( ISymbol newDecl, IContainerSymbol context ){
|
||||
_symbol = newDecl;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public void undoIt(){
|
||||
Object obj = _context.getContainedSymbols().get( _symbol.getName() );
|
||||
|
||||
if( obj instanceof LinkedList ){
|
||||
LinkedList list = (LinkedList)obj;
|
||||
ListIterator iter = list.listIterator();
|
||||
int size = list.size();
|
||||
ISymbol item = null;
|
||||
for( int i = 0; i < size; i++ ){
|
||||
item = (ISymbol)iter.next();
|
||||
if( item == _symbol ){
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( list.size() == 1 ){
|
||||
_context.getContainedSymbols().put( _symbol.getName(), list.getFirst() );
|
||||
}
|
||||
} else if( obj instanceof BasicSymbol ){
|
||||
_context.getContainedSymbols().remove( _symbol.getName() );
|
||||
}
|
||||
|
||||
//this is an inefficient way of doing this, we can modify the interfaces if the undo starts
|
||||
//being used often.
|
||||
ContentsIterator iter = (ContentsIterator) _context.getContentsIterator();
|
||||
while( iter.hasNext() ){
|
||||
IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
if( ext == _symbol ){
|
||||
iter.removeSymbol();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final ISymbol _symbol;
|
||||
private final IContainerSymbol _context;
|
||||
}
|
||||
// static private class AddSymbolCommand extends Command{
|
||||
// AddSymbolCommand( ISymbol newDecl, IContainerSymbol context ){
|
||||
// _symbol = newDecl;
|
||||
// _context = context;
|
||||
// }
|
||||
//
|
||||
// public void undoIt(){
|
||||
// Object obj = _context.getContainedSymbols().get( _symbol.getName() );
|
||||
//
|
||||
// if( obj instanceof ArrayList ){
|
||||
// ArrayList list = (ArrayList)obj;
|
||||
// ListIterator iter = list.listIterator();
|
||||
// int size = list.size();
|
||||
// ISymbol item = null;
|
||||
// for( int i = 0; i < size; i++ ){
|
||||
// item = (ISymbol)iter.next();
|
||||
// if( item == _symbol ){
|
||||
// iter.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if( list.size() == 1 ){
|
||||
// _context.getContainedSymbols().put( _symbol.getName(), list.get(0) );
|
||||
// }
|
||||
// } else if( obj instanceof BasicSymbol ){
|
||||
// _context.getContainedSymbols().remove( _symbol.getName() );
|
||||
// }
|
||||
//
|
||||
// //this is an inefficient way of doing this, we can modify the interfaces if the undo starts
|
||||
// //being used often.
|
||||
// ContentsIterator iter = (ContentsIterator) _context.getContentsIterator();
|
||||
// while( iter.hasNext() ){
|
||||
// IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
// if( ext == _symbol ){
|
||||
// iter.removeSymbol();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private final ISymbol _symbol;
|
||||
// private final IContainerSymbol _context;
|
||||
// }
|
||||
|
||||
static private class AddUsingDirectiveCommand extends Command{
|
||||
public AddUsingDirectiveCommand( IContainerSymbol container, IUsingDirectiveSymbol directive ){
|
||||
_decl = container;
|
||||
_directive = directive;
|
||||
}
|
||||
public void undoIt(){
|
||||
_decl.getUsingDirectives().remove( _directive );
|
||||
|
||||
//this is an inefficient way of doing this, we can modify the interfaces if the undo starts
|
||||
//being used often.
|
||||
ContentsIterator iter = (ContentsIterator) _decl.getContentsIterator();
|
||||
while( iter.hasNext() ){
|
||||
IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
if( ext == _directive ){
|
||||
iter.removeSymbol();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private final IContainerSymbol _decl;
|
||||
private final IUsingDirectiveSymbol _directive;
|
||||
}
|
||||
// static private class AddUsingDirectiveCommand extends Command{
|
||||
// public AddUsingDirectiveCommand( IContainerSymbol container, IUsingDirectiveSymbol directive ){
|
||||
// _decl = container;
|
||||
// _directive = directive;
|
||||
// }
|
||||
// public void undoIt(){
|
||||
// _decl.getUsingDirectives().remove( _directive );
|
||||
//
|
||||
// //this is an inefficient way of doing this, we can modify the interfaces if the undo starts
|
||||
// //being used often.
|
||||
// ContentsIterator iter = (ContentsIterator) _decl.getContentsIterator();
|
||||
// while( iter.hasNext() ){
|
||||
// IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
// if( ext == _directive ){
|
||||
// iter.removeSymbol();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private final IContainerSymbol _decl;
|
||||
// private final IUsingDirectiveSymbol _directive;
|
||||
// }
|
||||
|
||||
static protected class SymbolTableComparator implements Comparator{
|
||||
static final private Collator collator = Collator.getInstance();
|
||||
|
@ -1134,9 +1150,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
}
|
||||
|
||||
private LinkedList _contents = ParserSymbolTable.EMPTY_LIST; //ordered list of all contents of this symbol
|
||||
private LinkedList _usingDirectives = ParserSymbolTable.EMPTY_LIST; //collection of nominated namespaces
|
||||
private Map _containedSymbols = ParserSymbolTable.EMPTY_MAP; //declarations contained by us.
|
||||
private List _contents = Collections.EMPTY_LIST; //ordered list of all contents of this symbol
|
||||
private List _usingDirectives = Collections.EMPTY_LIST; //collection of nominated namespaces
|
||||
private Map _containedSymbols = Collections.EMPTY_MAP; //declarations contained by us.
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addTemplateId(org.eclipse.cdt.internal.core.parser.pst.ISymbol, java.util.List)
|
||||
*/
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
|||
public DeferredTemplateInstance( ParserSymbolTable table, ITemplateSymbol template, List args ){
|
||||
super(table, ParserSymbolTable.EMPTY_NAME );
|
||||
_template = template;
|
||||
_arguments = new LinkedList( args );
|
||||
_arguments = new ArrayList( args );
|
||||
|
||||
setContainingSymbol( template );
|
||||
if( template.getTemplatedSymbol() != null )
|
||||
|
@ -50,7 +50,7 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
|||
|
||||
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||
List args = getArguments();
|
||||
List newArgs = new LinkedList();
|
||||
List newArgs = new ArrayList( args.size() );
|
||||
Iterator iter = args.iterator();
|
||||
|
||||
while( iter.hasNext() ){
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Command;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.LookupData;
|
||||
|
||||
/**
|
||||
|
@ -48,9 +48,9 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
public Object clone(){
|
||||
DerivableContainerSymbol copy = (DerivableContainerSymbol)super.clone();
|
||||
|
||||
copy._parentScopes = ( _parentScopes != ParserSymbolTable.EMPTY_LIST ) ? (LinkedList) _parentScopes.clone() : _parentScopes;
|
||||
copy._constructors = ( _constructors != ParserSymbolTable.EMPTY_LIST ) ? (LinkedList) _constructors.clone() : _constructors;
|
||||
copy._friends = ( _friends != ParserSymbolTable.EMPTY_LIST ) ? (LinkedList) _friends.clone() : _friends;
|
||||
copy._parentScopes = ( _parentScopes != Collections.EMPTY_LIST ) ? (List)((ArrayList)_parentScopes).clone() : _parentScopes;
|
||||
copy._constructors = ( _constructors != Collections.EMPTY_LIST ) ? (List)((ArrayList) _constructors).clone() : _constructors;
|
||||
copy._friends = ( _friends != Collections.EMPTY_LIST ) ? (List)((ArrayList) _friends).clone() : _friends;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -122,15 +122,15 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addParent(org.eclipse.cdt.internal.core.parser.pst.ISymbol, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, java.util.List)
|
||||
*/
|
||||
public void addParent( ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references ){
|
||||
if( _parentScopes == ParserSymbolTable.EMPTY_LIST ){
|
||||
_parentScopes = new LinkedList();
|
||||
if( _parentScopes == Collections.EMPTY_LIST ){
|
||||
_parentScopes = new ArrayList(4);
|
||||
}
|
||||
|
||||
ParentWrapper wrapper = new ParentWrapper( parent, virtual, visibility, offset, references );
|
||||
_parentScopes.add( wrapper );
|
||||
|
||||
Command command = new AddParentCommand( this, wrapper );
|
||||
getSymbolTable().pushCommand( command );
|
||||
// Command command = new AddParentCommand( this, wrapper );
|
||||
// getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -169,15 +169,15 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
|
||||
addToContents( constructor );
|
||||
|
||||
Command command = new AddConstructorCommand( constructor, this );
|
||||
getSymbolTable().pushCommand( command );
|
||||
// Command command = new AddConstructorCommand( constructor, this );
|
||||
// getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#addCopyConstructor()
|
||||
*/
|
||||
public void addCopyConstructor() throws ParserSymbolTableException{
|
||||
List parameters = new LinkedList();
|
||||
List parameters = new ArrayList(1);
|
||||
|
||||
ISymbol paramType = this;
|
||||
if( getContainingSymbol() instanceof ITemplateSymbol ){
|
||||
|
@ -212,7 +212,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
|
||||
List constructors = null;
|
||||
if( !getConstructors().isEmpty() ){
|
||||
constructors = new LinkedList( getConstructors() );
|
||||
constructors = new ArrayList( getConstructors() );
|
||||
}
|
||||
if( constructors != null )
|
||||
return ParserSymbolTable.resolveFunction( data, constructors );
|
||||
|
@ -227,8 +227,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
}
|
||||
|
||||
private void addToConstructors( IParameterizedSymbol constructor ){
|
||||
if( _constructors == ParserSymbolTable.EMPTY_LIST )
|
||||
_constructors = new LinkedList();
|
||||
if( _constructors == Collections.EMPTY_LIST )
|
||||
_constructors = new ArrayList(4);
|
||||
_constructors.add( constructor );
|
||||
}
|
||||
/**
|
||||
|
@ -378,59 +378,59 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
return _friends;
|
||||
}
|
||||
private void addToFriends( ISymbol friend ){
|
||||
if( _friends == ParserSymbolTable.EMPTY_LIST ){
|
||||
_friends = new LinkedList();
|
||||
if( _friends == Collections.EMPTY_LIST ){
|
||||
_friends = new ArrayList(4);
|
||||
}
|
||||
_friends.add( friend );
|
||||
}
|
||||
|
||||
static private class AddParentCommand extends Command{
|
||||
public AddParentCommand( IDerivableContainerSymbol container, ParentWrapper wrapper ){
|
||||
_decl = container;
|
||||
_wrapper = wrapper;
|
||||
}
|
||||
|
||||
public void undoIt(){
|
||||
List parents = _decl.getParents();
|
||||
parents.remove( _wrapper );
|
||||
}
|
||||
|
||||
private IDerivableContainerSymbol _decl;
|
||||
private ParentWrapper _wrapper;
|
||||
}
|
||||
|
||||
static private class AddConstructorCommand extends Command{
|
||||
AddConstructorCommand( IParameterizedSymbol newConstr, IDerivableContainerSymbol context ){
|
||||
_constructor = newConstr;
|
||||
_context = context;
|
||||
}
|
||||
public void undoIt(){
|
||||
List constructors = _context.getConstructors();
|
||||
Iterator iter = constructors.listIterator();
|
||||
|
||||
int size = constructors.size();
|
||||
IParameterizedSymbol item = null;
|
||||
for( int i = 0; i < size; i++ ){
|
||||
item = (IParameterizedSymbol)iter.next();
|
||||
if( item == _constructor ){
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ContentsIterator contents = (ContentsIterator) _context.getContentsIterator();
|
||||
while( iter.hasNext() ){
|
||||
IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
if( ext == _constructor ){
|
||||
contents.removeSymbol();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final IParameterizedSymbol _constructor;
|
||||
private final IDerivableContainerSymbol _context;
|
||||
}
|
||||
// static private class AddParentCommand extends Command{
|
||||
// public AddParentCommand( IDerivableContainerSymbol container, ParentWrapper wrapper ){
|
||||
// _decl = container;
|
||||
// _wrapper = wrapper;
|
||||
// }
|
||||
//
|
||||
// public void undoIt(){
|
||||
// List parents = _decl.getParents();
|
||||
// parents.remove( _wrapper );
|
||||
// }
|
||||
//
|
||||
// private IDerivableContainerSymbol _decl;
|
||||
// private ParentWrapper _wrapper;
|
||||
// }
|
||||
//
|
||||
// static private class AddConstructorCommand extends Command{
|
||||
// AddConstructorCommand( IParameterizedSymbol newConstr, IDerivableContainerSymbol context ){
|
||||
// _constructor = newConstr;
|
||||
// _context = context;
|
||||
// }
|
||||
// public void undoIt(){
|
||||
// List constructors = _context.getConstructors();
|
||||
// Iterator iter = constructors.listIterator();
|
||||
//
|
||||
// int size = constructors.size();
|
||||
// IParameterizedSymbol item = null;
|
||||
// for( int i = 0; i < size; i++ ){
|
||||
// item = (IParameterizedSymbol)iter.next();
|
||||
// if( item == _constructor ){
|
||||
// iter.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ContentsIterator contents = (ContentsIterator) _context.getContentsIterator();
|
||||
// while( iter.hasNext() ){
|
||||
// IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
// if( ext == _constructor ){
|
||||
// contents.removeSymbol();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private final IParameterizedSymbol _constructor;
|
||||
// private final IDerivableContainerSymbol _context;
|
||||
// }
|
||||
|
||||
public class ParentWrapper implements IDerivableContainerSymbol.IParentSymbol
|
||||
{
|
||||
|
@ -470,7 +470,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
private final List references;
|
||||
}
|
||||
|
||||
private LinkedList _constructors = ParserSymbolTable.EMPTY_LIST; //constructor list
|
||||
private LinkedList _parentScopes = ParserSymbolTable.EMPTY_LIST; //inherited scopes (is base classes)
|
||||
private LinkedList _friends = ParserSymbolTable.EMPTY_LIST;
|
||||
private List _constructors = Collections.EMPTY_LIST; //constructor list
|
||||
private List _parentScopes = Collections.EMPTY_LIST; //inherited scopes (is base classes)
|
||||
private List _friends = Collections.EMPTY_LIST;
|
||||
}
|
||||
|
|
|
@ -43,4 +43,6 @@ public interface IParameterizedSymbol extends IContainerSymbol {
|
|||
|
||||
public void setHasVariableArgs( boolean var );
|
||||
public boolean hasVariableArgs( );
|
||||
|
||||
public void prepareForParameters(int i);
|
||||
}
|
||||
|
|
|
@ -33,4 +33,9 @@ public interface ISpecializedSymbol extends ITemplateSymbol {
|
|||
public ITemplateSymbol getPrimaryTemplate();
|
||||
public void setPrimaryTemplate( ITemplateSymbol templateSymbol );
|
||||
|
||||
/**
|
||||
* @param size
|
||||
*/
|
||||
public void prepareArguments(int size);
|
||||
|
||||
}
|
||||
|
|
|
@ -64,4 +64,6 @@ public interface ISymbol extends Cloneable, IExtensibleSymbol {
|
|||
public int getDepth();
|
||||
public boolean getIsInvisible();
|
||||
public void setIsInvisible( boolean invisible );
|
||||
|
||||
public void preparePtrOperatros(int numPtrOps);
|
||||
}
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Command;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||
|
||||
/**
|
||||
|
@ -48,12 +48,12 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
public Object clone(){
|
||||
ParameterizedSymbol copy = (ParameterizedSymbol)super.clone();
|
||||
|
||||
copy._parameterList = ( _parameterList != ParserSymbolTable.EMPTY_LIST ) ? (LinkedList) _parameterList.clone() : _parameterList;
|
||||
copy._parameterList = ( _parameterList != Collections.EMPTY_LIST ) ? (List) ((ArrayList)_parameterList).clone() : _parameterList;
|
||||
|
||||
if( getSymbolTable().getParserMode() == ParserMode.COMPLETION_PARSE )
|
||||
copy._parameterMap = ( _parameterMap != ParserSymbolTable.EMPTY_MAP ) ? (Map) ((TreeMap) _parameterMap).clone() : _parameterMap;
|
||||
copy._parameterMap = ( _parameterMap != Collections.EMPTY_MAP ) ? (Map) ((TreeMap) _parameterMap).clone() : _parameterMap;
|
||||
else
|
||||
copy._parameterMap = ( _parameterMap != ParserSymbolTable.EMPTY_MAP ) ? (Map) ((HashMap) _parameterMap).clone() : _parameterMap;
|
||||
copy._parameterMap = ( _parameterMap != Collections.EMPTY_MAP ) ? (Map) ((HashMap) _parameterMap).clone() : _parameterMap;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -104,19 +104,28 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
setReturnType( returnType.instantiate( template, argMap ) );
|
||||
}
|
||||
|
||||
|
||||
public void prepareForParameters( int numParams ){
|
||||
if( _parameterList == Collections.EMPTY_LIST ){
|
||||
_parameterList = new ArrayList( numParams );
|
||||
} else {
|
||||
((ArrayList)_parameterList).ensureCapacity( numParams );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addParameter(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void addParameter( ISymbol param ){
|
||||
if( _parameterList == ParserSymbolTable.EMPTY_LIST )
|
||||
_parameterList = new LinkedList();
|
||||
if( _parameterList == Collections.EMPTY_LIST)
|
||||
_parameterList = new ArrayList(8);
|
||||
|
||||
_parameterList.add( param );
|
||||
|
||||
String name = param.getName();
|
||||
if( name != null && !name.equals(ParserSymbolTable.EMPTY_NAME) )
|
||||
{
|
||||
if( _parameterMap == ParserSymbolTable.EMPTY_MAP ){
|
||||
if( _parameterMap == Collections.EMPTY_MAP ){
|
||||
if( getSymbolTable().getParserMode() == ParserMode.COMPLETION_PARSE )
|
||||
_parameterMap = new TreeMap( new SymbolTableComparator() );
|
||||
else
|
||||
|
@ -130,8 +139,8 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
param.setContainingSymbol( this );
|
||||
param.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
|
||||
Command command = new AddParameterCommand( this, param );
|
||||
getSymbolTable().pushCommand( command );
|
||||
// Command command = new AddParameterCommand( this, param );
|
||||
// getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -287,29 +296,29 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
return _hasVarArgs;
|
||||
}
|
||||
|
||||
static private class AddParameterCommand extends Command{
|
||||
public AddParameterCommand( IParameterizedSymbol container, ISymbol parameter ){
|
||||
_decl = container;
|
||||
_param = parameter;
|
||||
}
|
||||
|
||||
public void undoIt(){
|
||||
_decl.getParameterList().remove( _param );
|
||||
|
||||
String name = _param.getName();
|
||||
if( name != null && !name.equals( ParserSymbolTable.EMPTY_NAME) )
|
||||
{
|
||||
_decl.getParameterMap().remove( name );
|
||||
}
|
||||
}
|
||||
|
||||
private IParameterizedSymbol _decl;
|
||||
private ISymbol _param;
|
||||
}
|
||||
// static private class AddParameterCommand extends Command{
|
||||
// public AddParameterCommand( IParameterizedSymbol container, ISymbol parameter ){
|
||||
// _decl = container;
|
||||
// _param = parameter;
|
||||
// }
|
||||
//
|
||||
// public void undoIt(){
|
||||
// _decl.getParameterList().remove( _param );
|
||||
//
|
||||
// String name = _param.getName();
|
||||
// if( name != null && !name.equals( ParserSymbolTable.EMPTY_NAME) )
|
||||
// {
|
||||
// _decl.getParameterMap().remove( name );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private IParameterizedSymbol _decl;
|
||||
// private ISymbol _param;
|
||||
// }
|
||||
|
||||
|
||||
private LinkedList _parameterList = ParserSymbolTable.EMPTY_LIST; //have my cake
|
||||
private Map _parameterMap = ParserSymbolTable.EMPTY_MAP; //and eat it too
|
||||
private List _parameterList = Collections.EMPTY_LIST; //have my cake
|
||||
private Map _parameterMap = Collections.EMPTY_MAP; //and eat it too
|
||||
private ISymbol _returnType;
|
||||
private boolean _hasVarArgs = false; //whether or not this function has variable arguments
|
||||
}
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
@ -41,8 +42,6 @@ public class ParserSymbolTable {
|
|||
|
||||
public static final int TYPE_LOOP_THRESHOLD = 50;
|
||||
public static final String EMPTY_NAME = ""; //$NON-NLS-1$
|
||||
public static final LinkedList EMPTY_LIST = new LinkedList();
|
||||
public static final Map EMPTY_MAP = new HashMap();
|
||||
public static final String THIS = "this"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
|
@ -124,7 +123,7 @@ public class ParserSymbolTable {
|
|||
}
|
||||
}
|
||||
|
||||
LinkedList transitives = null; //list of transitive using directives
|
||||
ArrayList transitives = null; //list of transitive using directives
|
||||
|
||||
//if this name define in this scope?
|
||||
Map map = null;
|
||||
|
@ -224,30 +223,28 @@ public class ParserSymbolTable {
|
|||
* directives, the effect is as if the using-directives from the second
|
||||
* namespace also appeared in the first.
|
||||
*/
|
||||
static private LinkedList lookupInNominated( LookupData data, IContainerSymbol symbol, LinkedList transitiveDirectives ) throws ParserSymbolTableException{
|
||||
static private ArrayList lookupInNominated( LookupData data, IContainerSymbol symbol, ArrayList transitiveDirectives ) throws ParserSymbolTableException{
|
||||
//if the data.usingDirectives is empty, there is nothing to do.
|
||||
if( data.usingDirectives == null ){
|
||||
return transitiveDirectives;
|
||||
}
|
||||
|
||||
//local variables
|
||||
LinkedList directives = null; //using directives association with declaration
|
||||
Iterator iter = null;
|
||||
ArrayList directives = null; //using directives association with declaration
|
||||
IContainerSymbol temp = null;
|
||||
|
||||
boolean foundSomething = false;
|
||||
int size = 0;
|
||||
|
||||
directives = (LinkedList) data.usingDirectives.remove( symbol );
|
||||
directives = (ArrayList) data.usingDirectives.remove( symbol );
|
||||
|
||||
if( directives == null ){
|
||||
return transitiveDirectives;
|
||||
}
|
||||
|
||||
iter = directives.iterator();
|
||||
size = directives.size();
|
||||
for( int i = size; i > 0; i-- ){
|
||||
temp = (IContainerSymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
temp = (IContainerSymbol) directives.get(i);
|
||||
|
||||
//namespaces are searched at most once
|
||||
if( !data.visited.contains( temp ) ){
|
||||
|
@ -267,7 +264,7 @@ public class ParserSymbolTable {
|
|||
if( (!data.qualified || !foundSomething || data.mode == LookupMode.PREFIX ) && temp.hasUsingDirectives() ){
|
||||
//name wasn't found, add transitive using directives for later consideration
|
||||
if( transitiveDirectives == null )
|
||||
transitiveDirectives = new LinkedList();
|
||||
transitiveDirectives = new ArrayList(4);
|
||||
transitiveDirectives.addAll( temp.getUsingDirectives() );
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +287,7 @@ public class ParserSymbolTable {
|
|||
while( keyIterator.hasNext() ){
|
||||
key = keyIterator.next();
|
||||
if( resultMap.containsKey( key ) ){
|
||||
List list = new LinkedList();
|
||||
List list = new ArrayList();
|
||||
Object obj = resultMap.get( key );
|
||||
|
||||
if ( obj instanceof List ) list.addAll( (List) obj );
|
||||
|
@ -328,7 +325,7 @@ public class ParserSymbolTable {
|
|||
Map declarations = lookIn.getContainedSymbols();
|
||||
|
||||
Iterator iterator = null;
|
||||
if( data.mode == LookupMode.PREFIX && declarations != ParserSymbolTable.EMPTY_MAP ){
|
||||
if( data.mode == LookupMode.PREFIX && declarations != Collections.EMPTY_MAP ){
|
||||
if( declarations instanceof SortedMap ){
|
||||
iterator = ((SortedMap)declarations).tailMap( data.name.toLowerCase() ).keySet().iterator();
|
||||
} else {
|
||||
|
@ -414,7 +411,7 @@ public class ParserSymbolTable {
|
|||
|
||||
}
|
||||
Map parameters = ((IParameterizedSymbol)lookIn).getParameterMap();
|
||||
if( parameters != ParserSymbolTable.EMPTY_MAP ){
|
||||
if( parameters != Collections.EMPTY_MAP ){
|
||||
iterator = null;
|
||||
if( data.mode == LookupMode.PREFIX ){
|
||||
if( parameters instanceof SortedMap ){
|
||||
|
@ -470,15 +467,16 @@ public class ParserSymbolTable {
|
|||
|
||||
ISymbol foundSymbol = null;
|
||||
|
||||
Iterator iter = ( object instanceof List ) ? ((List)object).iterator() : null;
|
||||
ISymbol symbol = ( iter != null ) ? (ISymbol) iter.next() : (ISymbol) object;
|
||||
List objList = ( object instanceof List ) ? (List)object : null;
|
||||
int objListSize = ( objList != null ) ? objList.size() : 0;
|
||||
ISymbol symbol = ( objList != null ) ? (ISymbol) objList.get( 0 ) : (ISymbol) object;
|
||||
|
||||
Set functionSet = new HashSet();
|
||||
Set templateFunctionSet = new HashSet();
|
||||
|
||||
ISymbol obj = null;
|
||||
IContainerSymbol cls = null;
|
||||
|
||||
int idx = 1;
|
||||
while( symbol != null ){
|
||||
if( symbol instanceof ITemplateSymbol ){
|
||||
ISymbol temp = ((ITemplateSymbol)symbol).getTemplatedSymbol();
|
||||
|
@ -540,8 +538,8 @@ public class ParserSymbolTable {
|
|||
}
|
||||
}
|
||||
|
||||
if( iter != null ){
|
||||
symbol = iter.hasNext() ? (ISymbol) iter.next() : null;
|
||||
if( objList != null && idx < objListSize ){
|
||||
symbol = (ISymbol) objList.get( idx++ );
|
||||
} else {
|
||||
symbol = null;
|
||||
}
|
||||
|
@ -603,7 +601,7 @@ public class ParserSymbolTable {
|
|||
return obj;
|
||||
}
|
||||
} else if( numFunctions > 0 ) {
|
||||
return new LinkedList( functionSet );
|
||||
return new ArrayList( functionSet );
|
||||
}
|
||||
|
||||
if( ambiguous ){
|
||||
|
@ -641,7 +639,6 @@ public class ParserSymbolTable {
|
|||
Map symbol = null;
|
||||
Map inherited = null;
|
||||
|
||||
Iterator iterator = null;
|
||||
IDerivableContainerSymbol.IParentSymbol wrapper = null;
|
||||
|
||||
if( scopes == null )
|
||||
|
@ -652,14 +649,11 @@ public class ParserSymbolTable {
|
|||
data.inheritanceChain = new HashSet();
|
||||
|
||||
data.inheritanceChain.add( container );
|
||||
|
||||
iterator = scopes.iterator();
|
||||
|
||||
int size = scopes.size();
|
||||
|
||||
for( int i = size; i > 0; i-- )
|
||||
for( int i = 0; i < size; i++ )
|
||||
{
|
||||
wrapper = (IDerivableContainerSymbol.IParentSymbol) iterator.next();
|
||||
wrapper = (IDerivableContainerSymbol.IParentSymbol) scopes.get(i);
|
||||
ISymbol parent = wrapper.getParent();
|
||||
if( parent == null )
|
||||
continue;
|
||||
|
@ -706,8 +700,9 @@ public class ParserSymbolTable {
|
|||
key = iter.next();
|
||||
if( symbol.containsKey( key ) ){
|
||||
Object obj = symbol.get( key );
|
||||
Iterator objIter = ( obj instanceof List ) ? ((List)obj).iterator() : null;
|
||||
ISymbol sym = (ISymbol) (( objIter != null && objIter.hasNext() ) ? objIter.next() : obj);
|
||||
List objList = ( obj instanceof List ) ? (List)obj : null;
|
||||
int objListSize = ( objList != null ) ? objList.size() : 0, idx = 1;
|
||||
ISymbol sym = (ISymbol) (( objList != null && objListSize > 0 ) ? objList.get(0) : obj);
|
||||
while( sym != null ){
|
||||
if( !checkAmbiguity( sym, temp.get( key ) ) ){
|
||||
if( data.mode == LookupMode.PREFIX ){
|
||||
|
@ -720,8 +715,8 @@ public class ParserSymbolTable {
|
|||
}
|
||||
}
|
||||
|
||||
if( objIter != null && objIter.hasNext() ){
|
||||
sym = (ISymbol) objIter.next();
|
||||
if( objList != null && idx < objListSize ){
|
||||
sym = (ISymbol) objList.get( idx++ );
|
||||
} else {
|
||||
sym = null;
|
||||
}
|
||||
|
@ -744,17 +739,18 @@ public class ParserSymbolTable {
|
|||
private static boolean checkAmbiguity( Object obj1, Object obj2 ){
|
||||
//it is not ambiguous if they are the same thing and it is static or an enumerator
|
||||
if( obj1 == obj2 ){
|
||||
|
||||
Iterator iter = ( obj1 instanceof List ) ? ((List) obj1).iterator() : null;
|
||||
ISymbol symbol = ( iter != null ) ? (ISymbol) iter.next() : ( ISymbol )obj1;
|
||||
List objList = ( obj1 instanceof List ) ? (List) obj1 : null;
|
||||
int objListSize = ( objList != null ) ? objList.size() : 0;
|
||||
ISymbol symbol = ( objList != null ) ? (ISymbol) objList.get(0) : ( ISymbol )obj1;
|
||||
int idx = 1;
|
||||
while( symbol != null ) {
|
||||
TypeInfo type = ((ISymbol)obj1).getTypeInfo();
|
||||
if( !type.checkBit( TypeInfo.isStatic ) && !type.isType( TypeInfo.t_enumerator ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( iter != null && iter.hasNext() ){
|
||||
symbol = (ISymbol) iter.next();
|
||||
if( objList != null && idx < objListSize ){
|
||||
symbol = (ISymbol) objList.get( idx++ );
|
||||
} else {
|
||||
symbol = null;
|
||||
}
|
||||
|
@ -942,16 +938,16 @@ public class ParserSymbolTable {
|
|||
|
||||
Object object = data.foundItems.get( data.name );
|
||||
|
||||
LinkedList functionList = null;
|
||||
ArrayList functionList = null;
|
||||
|
||||
if( object instanceof List ){
|
||||
//if we got this far with a list, they must all be functions
|
||||
functionList = new LinkedList();
|
||||
functionList = new ArrayList( ((List)object).size() );
|
||||
functionList.addAll( (List) object );
|
||||
} else {
|
||||
ISymbol symbol = (ISymbol) object;
|
||||
if( symbol.isType( TypeInfo.t_function ) ){
|
||||
functionList = new LinkedList();
|
||||
functionList = new ArrayList(1);
|
||||
functionList.add( symbol );
|
||||
} else {
|
||||
if( symbol.isTemplateMember() && !symbol.isTemplateInstance() &&
|
||||
|
@ -969,7 +965,7 @@ public class ParserSymbolTable {
|
|||
//we have no parameter information, if we only have one function, return
|
||||
//that, otherwise we can't decide between them
|
||||
if( functionList.size() == 1){
|
||||
resolvedSymbol = (ISymbol) functionList.getFirst();
|
||||
resolvedSymbol = (ISymbol) functionList.get(0);
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_UnableToResolveFunction );
|
||||
}
|
||||
|
@ -1009,9 +1005,8 @@ public class ParserSymbolTable {
|
|||
} else if ( numFns == 1 ){
|
||||
return (IParameterizedSymbol)functions.iterator().next();
|
||||
} else if ( numFns == 2 ){
|
||||
Iterator iter = functions.iterator();
|
||||
while( iter.hasNext() ){
|
||||
IParameterizedSymbol fn = (IParameterizedSymbol) iter.next();
|
||||
for (int i = 0; i < numFns; i++) {
|
||||
IParameterizedSymbol fn = (IParameterizedSymbol) functions.get(i);
|
||||
if( fn.getTypeInfo().isForwardDeclaration() && fn.getTypeSymbol() != null ){
|
||||
if( functions.contains( fn.getTypeSymbol() ) ){
|
||||
return (IParameterizedSymbol) fn.getTypeSymbol();
|
||||
|
@ -1029,10 +1024,6 @@ public class ParserSymbolTable {
|
|||
Cost [] bestFnCost = null; //the cost of the best function
|
||||
Cost [] currFnCost = null; //the cost for the current function
|
||||
|
||||
Iterator iterFns = functions.iterator();
|
||||
Iterator sourceParams = null; //the parameters the function is being called with
|
||||
Iterator targetParams = null; //the current function's parameters
|
||||
|
||||
TypeInfo source = null; //parameter we are called with
|
||||
TypeInfo target = null; //function's parameter
|
||||
|
||||
|
@ -1046,19 +1037,20 @@ public class ParserSymbolTable {
|
|||
boolean currHasAmbiguousParam = false; //currFn has an ambiguous parameter conversion (ok if not bestFn)
|
||||
boolean bestHasAmbiguousParam = false; //bestFn has an ambiguous parameter conversion (not ok, ambiguous)
|
||||
|
||||
List parameters = null;
|
||||
List sourceParameters = null; //the parameters the function is being called with
|
||||
List targetParameters = null; //the current function's parameters
|
||||
|
||||
if( numSourceParams == 0 ){
|
||||
//f() is the same as f( void )
|
||||
parameters = new LinkedList();
|
||||
parameters.add( new TypeInfo( TypeInfo.t_void, 0, null ) );
|
||||
sourceParameters = new ArrayList(1);
|
||||
sourceParameters.add( new TypeInfo( TypeInfo.t_void, 0, null ) );
|
||||
numSourceParams = 1;
|
||||
} else {
|
||||
parameters = data.parameters;
|
||||
sourceParameters = data.parameters;
|
||||
}
|
||||
|
||||
for( int i = numFns; i > 0; i-- ){
|
||||
currFn = (IParameterizedSymbol) iterFns.next();
|
||||
for( int fnIdx = 0; fnIdx < numFns; fnIdx++ ){
|
||||
currFn = (IParameterizedSymbol) functions.get( fnIdx );
|
||||
|
||||
if( bestFn != null ){
|
||||
if( bestFn.isForwardDeclaration() && bestFn.getTypeSymbol() == currFn ){
|
||||
|
@ -1069,19 +1061,17 @@ public class ParserSymbolTable {
|
|||
}
|
||||
}
|
||||
|
||||
sourceParams = parameters.iterator();
|
||||
|
||||
List parameterList = null;
|
||||
if( currFn.getParameterList().isEmpty() && !currFn.hasVariableArgs() ){
|
||||
//the only way we get here and have no parameters, is if we are looking
|
||||
//for a function that takes void parameters ie f( void )
|
||||
parameterList = new LinkedList();
|
||||
parameterList.add( currFn.getSymbolTable().newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$
|
||||
targetParameters = new ArrayList(1);
|
||||
targetParameters.add( currFn.getSymbolTable().newSymbol( "", TypeInfo.t_void ) ); //$NON-NLS-1$
|
||||
} else {
|
||||
parameterList = currFn.getParameterList();
|
||||
targetParameters = currFn.getParameterList();
|
||||
}
|
||||
|
||||
targetParams = parameterList.iterator();
|
||||
int numTargetParams = targetParameters.size();
|
||||
if( currFnCost == null ){
|
||||
currFnCost = new Cost [ numSourceParams ];
|
||||
}
|
||||
|
@ -1090,10 +1080,10 @@ public class ParserSymbolTable {
|
|||
boolean varArgs = false;
|
||||
|
||||
for( int j = 0; j < numSourceParams; j++ ){
|
||||
source = (TypeInfo) sourceParams.next();
|
||||
source = (TypeInfo) sourceParameters.get(j);
|
||||
|
||||
if( targetParams.hasNext() )
|
||||
target = ((ISymbol)targetParams.next()).getTypeInfo();
|
||||
if( j < numTargetParams )
|
||||
target = ((ISymbol)targetParameters.get(j)).getTypeInfo();
|
||||
else
|
||||
varArgs = true;
|
||||
|
||||
|
@ -1138,7 +1128,8 @@ public class ParserSymbolTable {
|
|||
if( data.mode == LookupMode.PREFIX ){
|
||||
//for prefix lookup, just remove from the function list those functions
|
||||
//that don't fit the parameters
|
||||
iterFns.remove();
|
||||
functions.remove( fnIdx-- );
|
||||
numFns--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1219,10 +1210,10 @@ public class ParserSymbolTable {
|
|||
//create a new function that has params as its parameters, then use IParameterizedSymbol.hasSameParameters
|
||||
IParameterizedSymbol tempFn = function.getSymbolTable().newParameterizedSymbol( EMPTY_NAME, TypeInfo.t_function );
|
||||
|
||||
Iterator i = params.iterator();
|
||||
while( i.hasNext() ){
|
||||
int size = params.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol param = function.getSymbolTable().newSymbol( EMPTY_NAME );
|
||||
param.setTypeInfo( (TypeInfo) i.next() );
|
||||
param.setTypeInfo( (TypeInfo) params.get(i) );
|
||||
tempFn.addParameter( param );
|
||||
}
|
||||
|
||||
|
@ -1241,19 +1232,21 @@ public class ParserSymbolTable {
|
|||
|
||||
//Trim the list down to the set of viable functions
|
||||
IParameterizedSymbol function;
|
||||
Iterator iter = functions.iterator();
|
||||
Object obj = null;
|
||||
while( iter.hasNext() ){
|
||||
obj = iter.next();
|
||||
int size = functions.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
obj = functions.get(i);
|
||||
//sanity check
|
||||
if( obj instanceof IParameterizedSymbol ){
|
||||
function = (IParameterizedSymbol) obj;
|
||||
if( !function.isType( TypeInfo.t_function) && !function.isType( TypeInfo.t_constructor ) ){
|
||||
iter.remove();
|
||||
functions.remove( i-- );
|
||||
size--;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
iter.remove();
|
||||
functions.remove( i-- );
|
||||
size--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1256,8 @@ public class ParserSymbolTable {
|
|||
//are viable
|
||||
if( num == numParameters ){
|
||||
if( data.exactFunctionsOnly && !functionHasParameters( function, data.parameters ) ){
|
||||
iter.remove();
|
||||
functions.remove( i-- );
|
||||
size--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -1286,7 +1280,8 @@ public class ParserSymbolTable {
|
|||
continue;
|
||||
}
|
||||
//not enough parameters, remove it
|
||||
iter.remove();
|
||||
functions.remove( i-- );
|
||||
size--;
|
||||
}
|
||||
//a candidate function having more than m parameters is viable only if the (m+1)-st
|
||||
//parameter has a default argument
|
||||
|
@ -1295,12 +1290,13 @@ public class ParserSymbolTable {
|
|||
//during prefix lookup, having more parameters than what is provided is ok
|
||||
continue;
|
||||
}
|
||||
ListIterator listIter = function.getParameterList().listIterator( num );
|
||||
List params = function.getParameterList();
|
||||
TypeInfo param;
|
||||
for( int i = num; i > ( numParameters - num + 1); i-- ){
|
||||
param = ((ISymbol)listIter.previous()).getTypeInfo();
|
||||
for( int j = num - 1; j > ( numParameters - num); j-- ){
|
||||
param = ((ISymbol)params.get(j)).getTypeInfo();
|
||||
if( !param.getHasDefault() ){
|
||||
iter.remove();
|
||||
functions.remove( i-- );
|
||||
size--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1327,10 +1323,8 @@ public class ParserSymbolTable {
|
|||
return;
|
||||
|
||||
int size = directives.size();
|
||||
Iterator iter = directives.iterator();
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
temp = ((IUsingDirectiveSymbol) iter.next()).getNamespace();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
temp = ((IUsingDirectiveSymbol) directives.get(i)).getNamespace();
|
||||
|
||||
//namespaces are searched at most once
|
||||
if( !data.visited.contains( temp ) ){
|
||||
|
@ -1339,11 +1333,11 @@ public class ParserSymbolTable {
|
|||
//the data.usingDirectives is a map from enclosing declaration to
|
||||
//a list of namespaces to consider when we reach that enclosing
|
||||
//declaration
|
||||
LinkedList list = (data.usingDirectives == null )
|
||||
ArrayList list = (data.usingDirectives == null )
|
||||
? null
|
||||
: (LinkedList) data.usingDirectives.get( enclosing );
|
||||
: (ArrayList) data.usingDirectives.get( enclosing );
|
||||
if ( list == null ){
|
||||
list = new LinkedList();
|
||||
list = new ArrayList(4);
|
||||
list.add( temp );
|
||||
if( data.usingDirectives == null ){
|
||||
data.usingDirectives = new HashMap();
|
||||
|
@ -1471,13 +1465,13 @@ public class ParserSymbolTable {
|
|||
return;
|
||||
}
|
||||
|
||||
Iterator iter = obj.getParents().iterator();
|
||||
int size = obj.getParents().size();
|
||||
List parents = obj.getParents();
|
||||
int size = parents.size();
|
||||
IDerivableContainerSymbol.IParentSymbol wrapper;
|
||||
ISymbol base;
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
wrapper = (IDerivableContainerSymbol.IParentSymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
wrapper = (IDerivableContainerSymbol.IParentSymbol) parents.get(i);
|
||||
base = wrapper.getParent();
|
||||
//TODO: what about IDeferredTemplateInstance parents?
|
||||
if( base instanceof IDerivableContainerSymbol ){
|
||||
|
@ -1561,16 +1555,13 @@ public class ParserSymbolTable {
|
|||
|
||||
if( cost.source.hasPtrOperators() ){
|
||||
List sourcePtrs = cost.source.getPtrOperators();
|
||||
Iterator iterator = sourcePtrs.iterator();
|
||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)iterator.next();
|
||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)sourcePtrs.get( 0 );
|
||||
if( ptr.getType() == TypeInfo.PtrOp.t_reference ){
|
||||
iterator.remove();
|
||||
sourcePtrs.remove( 0 );
|
||||
}
|
||||
int size = sourcePtrs.size();
|
||||
Iterator iter = sourcePtrs.iterator();
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
op = (TypeInfo.PtrOp) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
op = (TypeInfo.PtrOp) sourcePtrs.get( 0 );
|
||||
if( op.getType() == TypeInfo.PtrOp.t_array ){
|
||||
op.setType( TypeInfo.PtrOp.t_pointer );
|
||||
}
|
||||
|
@ -1579,18 +1570,16 @@ public class ParserSymbolTable {
|
|||
|
||||
if( cost.target.hasPtrOperators() ){
|
||||
List targetPtrs = cost.target.getPtrOperators();
|
||||
ListIterator iterator = targetPtrs.listIterator();
|
||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)iterator.next();
|
||||
//ListIterator iterator = targetPtrs.listIterator();
|
||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)targetPtrs.get(0);
|
||||
|
||||
if( ptr.getType() == TypeInfo.PtrOp.t_reference ){
|
||||
iterator.remove();
|
||||
targetPtrs.remove(0);
|
||||
cost.targetHadReference = true;
|
||||
}
|
||||
int size = targetPtrs.size();
|
||||
Iterator iter = targetPtrs.iterator();
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
op = (TypeInfo.PtrOp) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
op = (TypeInfo.PtrOp) targetPtrs.get(0);
|
||||
if( op.getType() == TypeInfo.PtrOp.t_array ){
|
||||
op.setType( TypeInfo.PtrOp.t_pointer );
|
||||
}
|
||||
|
@ -1607,26 +1596,25 @@ public class ParserSymbolTable {
|
|||
* see spec section 4.4 regarding qualification conversions
|
||||
*/
|
||||
static private void qualificationConversion( Cost cost ){
|
||||
int size = cost.source.getPtrOperators().size();
|
||||
int size2 = cost.target.getPtrOperators().size();
|
||||
List sourcePtrs = cost.source.getPtrOperators();
|
||||
List targetPtrs = cost.target.getPtrOperators();
|
||||
int size = sourcePtrs.size();
|
||||
int size2 = targetPtrs.size();
|
||||
|
||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
||||
boolean canConvert = true;
|
||||
|
||||
Iterator iter1 = cost.source.getPtrOperators().iterator();
|
||||
Iterator iter2 = cost.target.getPtrOperators().iterator();
|
||||
|
||||
if( size != size2 ){
|
||||
canConvert = false;
|
||||
} else if( size > 0 ){
|
||||
op1 = (TypeInfo.PtrOp) iter1.next();
|
||||
op2 = (TypeInfo.PtrOp) iter2.next();
|
||||
op1 = (TypeInfo.PtrOp) sourcePtrs.get(0);
|
||||
op2 = (TypeInfo.PtrOp) targetPtrs.get(0);
|
||||
|
||||
boolean constInEveryCV2k = true;
|
||||
|
||||
for( int j= 1; j < size; j++ ){
|
||||
op1 = (TypeInfo.PtrOp) iter1.next();
|
||||
op2 = (TypeInfo.PtrOp) iter2.next();
|
||||
op1 = (TypeInfo.PtrOp) sourcePtrs.get(j);
|
||||
op2 = (TypeInfo.PtrOp) targetPtrs.get(j);
|
||||
|
||||
//pointer types must be similar
|
||||
if( op1.getType() != op2.getType() ){
|
||||
|
@ -1726,7 +1714,7 @@ public class ParserSymbolTable {
|
|||
return;
|
||||
}
|
||||
if( src.hasPtrOperators() && src.getPtrOperators().size() == 1 ){
|
||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)src.getPtrOperators().iterator().next();
|
||||
TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)src.getPtrOperators().get(0);
|
||||
ISymbol srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeSymbol() : null;
|
||||
ISymbol trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeSymbol() : null;
|
||||
if( ptr.getType() == TypeInfo.PtrOp.t_pointer ){
|
||||
|
@ -1766,7 +1754,7 @@ public class ParserSymbolTable {
|
|||
return;
|
||||
}
|
||||
|
||||
TypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (TypeInfo.PtrOp)trg.getPtrOperators().iterator().next() : null;
|
||||
TypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (TypeInfo.PtrOp)trg.getPtrOperators().get(0) : null;
|
||||
if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == TypeInfo.PtrOp.t_memberPointer ){
|
||||
try {
|
||||
temp = hasBaseClass( ptr.getMemberOf(), srcPtr.getMemberOf() );
|
||||
|
@ -1884,7 +1872,7 @@ public class ParserSymbolTable {
|
|||
}
|
||||
if( targetDecl.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
|
||||
LookupData data = new LookupData( EMPTY_NAME, TypeInfo.t_constructor);
|
||||
data.parameters = new LinkedList();
|
||||
data.parameters = new ArrayList(1);
|
||||
data.parameters.add( source );
|
||||
data.forUserDefinedConversion = true;
|
||||
|
||||
|
@ -1894,7 +1882,7 @@ public class ParserSymbolTable {
|
|||
IDerivableContainerSymbol container = (IDerivableContainerSymbol) targetDecl;
|
||||
|
||||
if( !container.getConstructors().isEmpty() ){
|
||||
LinkedList constructors = new LinkedList( container.getConstructors() );
|
||||
ArrayList constructors = new ArrayList( container.getConstructors() );
|
||||
constructor = resolveFunction( data, constructors );
|
||||
}
|
||||
if( constructor != null && constructor.getTypeInfo().checkBit( TypeInfo.isExplicit ) ){
|
||||
|
@ -1914,7 +1902,7 @@ public class ParserSymbolTable {
|
|||
|
||||
if( !name.equals(EMPTY_NAME) ){
|
||||
LookupData data = new LookupData( "operator " + name, TypeInfo.t_function ); //$NON-NLS-1$
|
||||
data.parameters = ParserSymbolTable.EMPTY_LIST;
|
||||
data.parameters = Collections.EMPTY_LIST;
|
||||
data.forUserDefinedConversion = true;
|
||||
|
||||
data.foundItems = lookupInContained( data, (IContainerSymbol) sourceDecl );
|
||||
|
@ -2047,7 +2035,7 @@ public class ParserSymbolTable {
|
|||
returnInfo.applyOperatorExpressions( topInfo.getOperatorExpressions() );
|
||||
|
||||
if( topInfo.hasPtrOperators() ){
|
||||
TypeInfo.PtrOp topPtr = (PtrOp) topInfo.getPtrOperators().iterator().next();
|
||||
TypeInfo.PtrOp topPtr = (PtrOp) topInfo.getPtrOperators().get(0);
|
||||
TypeInfo.PtrOp ptr = new PtrOp( topPtr.getType(), topPtr.isConst(), topPtr.isVolatile() );
|
||||
returnInfo.addPtrOperator( ptr );
|
||||
}
|
||||
|
@ -2061,7 +2049,7 @@ public class ParserSymbolTable {
|
|||
private IContainerSymbol _compilationUnit;
|
||||
private ParserLanguage _language;
|
||||
private ParserMode _mode;
|
||||
private LinkedList undoList = new LinkedList();
|
||||
// private ArrayList undoList = new ArrayList();
|
||||
private HashSet markSet = new HashSet();
|
||||
|
||||
public void setLanguage( ParserLanguage language ){
|
||||
|
@ -2076,52 +2064,52 @@ public class ParserSymbolTable {
|
|||
return _mode;
|
||||
}
|
||||
|
||||
protected void pushCommand( Command command ){
|
||||
undoList.addFirst( command );
|
||||
}
|
||||
// protected void pushCommand( Command command ){
|
||||
// undoList.addFirst( command );
|
||||
// }
|
||||
|
||||
public Mark setMark(){
|
||||
Mark mark = new Mark();
|
||||
undoList.addFirst( mark );
|
||||
markSet.add( mark );
|
||||
return mark;
|
||||
}
|
||||
// public Mark setMark(){
|
||||
// Mark mark = new Mark();
|
||||
// undoList.addFirst( mark );
|
||||
// markSet.add( mark );
|
||||
// return mark;
|
||||
// }
|
||||
|
||||
public boolean rollBack( Mark toMark ){
|
||||
if( markSet.contains( toMark ) ){
|
||||
markSet.remove( toMark );
|
||||
Command command = ( Command )undoList.removeFirst();
|
||||
while( command != toMark ){
|
||||
command.undoIt();
|
||||
command = ( Command ) undoList.removeFirst();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// public boolean rollBack( Mark toMark ){
|
||||
// if( markSet.contains( toMark ) ){
|
||||
// markSet.remove( toMark );
|
||||
// Command command = ( Command )undoList.removeFirst();
|
||||
// while( command != toMark ){
|
||||
// command.undoIt();
|
||||
// command = ( Command ) undoList.removeFirst();
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public boolean commit( Mark toMark ){
|
||||
if( markSet.contains( toMark ) ){
|
||||
markSet.remove( toMark );
|
||||
Command command = ( Command )undoList.removeLast();
|
||||
while( command != toMark ){
|
||||
command = (Command) undoList.removeLast();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// public boolean commit( Mark toMark ){
|
||||
// if( markSet.contains( toMark ) ){
|
||||
// markSet.remove( toMark );
|
||||
// Command command = ( Command )undoList.removeLast();
|
||||
// while( command != toMark ){
|
||||
// command = (Command) undoList.removeLast();
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
static abstract protected class Command{
|
||||
abstract public void undoIt();
|
||||
}
|
||||
|
||||
static public class Mark extends Command{
|
||||
public void undoIt(){ }
|
||||
}
|
||||
// static abstract protected class Command{
|
||||
// abstract public void undoIt();
|
||||
// }
|
||||
//
|
||||
// static public class Mark extends Command{
|
||||
// public void undoIt(){ }
|
||||
// }
|
||||
|
||||
|
||||
static public class LookupMode extends Enum{
|
||||
|
|
|
@ -13,14 +13,13 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Command;
|
||||
|
||||
/**
|
||||
* @author aniefe
|
||||
*/
|
||||
|
@ -37,7 +36,7 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
|||
public Object clone(){
|
||||
SpecializedSymbol copy = (SpecializedSymbol)super.clone();
|
||||
|
||||
copy._argumentList = ( _argumentList != ParserSymbolTable.EMPTY_LIST ) ? (LinkedList) _argumentList.clone() : _argumentList;
|
||||
copy._argumentList = ( _argumentList != Collections.EMPTY_LIST ) ? (List)((ArrayList) _argumentList).clone() : _argumentList;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -59,7 +58,7 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
|||
return null;
|
||||
}
|
||||
|
||||
List actualArgs = new LinkedList();
|
||||
List actualArgs = new ArrayList( specArgs.size() );
|
||||
|
||||
Iterator iter1 = specArgs.iterator();
|
||||
Iterator iter2 = arguments.iterator();
|
||||
|
@ -126,34 +125,41 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
|||
return _argumentList;
|
||||
}
|
||||
|
||||
public void prepareArguments( int size ){
|
||||
if( _argumentList == Collections.EMPTY_LIST )
|
||||
_argumentList = new ArrayList( size );
|
||||
else
|
||||
((ArrayList)_argumentList).ensureCapacity( size );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addArgument(org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||
*/
|
||||
public void addArgument(TypeInfo arg) {
|
||||
if( _argumentList == ParserSymbolTable.EMPTY_LIST )
|
||||
_argumentList = new LinkedList();
|
||||
if( _argumentList == Collections.EMPTY_LIST )
|
||||
_argumentList = new ArrayList(4);
|
||||
|
||||
_argumentList.add( arg );
|
||||
|
||||
//arg.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
|
||||
Command command = new AddArgumentCommand( this, arg );
|
||||
getSymbolTable().pushCommand( command );
|
||||
// Command command = new AddArgumentCommand( this, arg );
|
||||
// getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
||||
static private class AddArgumentCommand extends Command{
|
||||
public AddArgumentCommand( ISpecializedSymbol container, TypeInfo arg ){
|
||||
_decl = container;
|
||||
_arg = arg;
|
||||
}
|
||||
public void undoIt(){
|
||||
_decl.getArgumentList().remove( _arg );
|
||||
}
|
||||
|
||||
private ISpecializedSymbol _decl;
|
||||
private TypeInfo _arg;
|
||||
}
|
||||
// static private class AddArgumentCommand extends Command{
|
||||
// public AddArgumentCommand( ISpecializedSymbol container, TypeInfo arg ){
|
||||
// _decl = container;
|
||||
// _arg = arg;
|
||||
// }
|
||||
// public void undoIt(){
|
||||
// _decl.getArgumentList().remove( _arg );
|
||||
// }
|
||||
//
|
||||
// private ISpecializedSymbol _decl;
|
||||
// private TypeInfo _arg;
|
||||
// }
|
||||
|
||||
private LinkedList _argumentList = ParserSymbolTable.EMPTY_LIST; //template specialization arguments
|
||||
private List _argumentList = Collections.EMPTY_LIST; //template specialization arguments
|
||||
private ITemplateSymbol _primaryTemplate; //our primary template
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -46,8 +46,7 @@ public final class TemplateEngine {
|
|||
{
|
||||
TypeInfo targetInfo = new TypeInfo( (TypeInfo) argMap.get( info.getTypeSymbol() ) );
|
||||
if( info.hasPtrOperators() ){
|
||||
List infoOperators = new LinkedList( info.getPtrOperators() );
|
||||
targetInfo.addPtrOperator( infoOperators );
|
||||
targetInfo.addPtrOperator( info.getPtrOperators() );
|
||||
}
|
||||
|
||||
if( info.checkBit( TypeInfo.isConst ) )
|
||||
|
@ -316,16 +315,16 @@ public final class TemplateEngine {
|
|||
TypeInfo a = ParserSymbolTable.getFlatTypeInfo( aInfo );
|
||||
|
||||
if( !pIsAReferenceType ){
|
||||
List aPtrs = a.getPtrOperators();
|
||||
ISymbol aSymbol = a.getTypeSymbol();
|
||||
|
||||
if( a.getType() == TypeInfo.t_type ){
|
||||
if( aSymbol == null ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
||||
} else if( aSymbol.isType( TypeInfo.t_function ) && aPtrs.size() == 0 ){
|
||||
aPtrs.add( new PtrOp( PtrOp.t_pointer ) );
|
||||
} else if( aSymbol.isType( TypeInfo.t_function ) && a.getPtrOperators().size() == 0 ){
|
||||
a.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
|
||||
}
|
||||
}
|
||||
List aPtrs = a.getPtrOperators();
|
||||
if( aPtrs.size() > 0 ){
|
||||
PtrOp pOp = (PtrOp) aPtrs.get( 0 );
|
||||
|
||||
|
@ -392,9 +391,10 @@ public final class TemplateEngine {
|
|||
if( pTemplate instanceof ISpecializedSymbol ){
|
||||
pTemplate = ((ISpecializedSymbol)pTemplate).getPrimaryTemplate();
|
||||
}
|
||||
Iterator iter = a.getParents().iterator();
|
||||
while( iter.hasNext() ){
|
||||
IParentSymbol wrapper = (IParentSymbol) iter.next();
|
||||
List parents = a.getParents();
|
||||
int size = parents.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
IParentSymbol wrapper = (IParentSymbol) parents.get(i);
|
||||
ISymbol parent = wrapper.getParent();
|
||||
if( parent instanceof IDeferredTemplateInstance ){
|
||||
IDeferredTemplateInstance parentInstance = (IDeferredTemplateInstance) parent;
|
||||
|
@ -430,8 +430,8 @@ public final class TemplateEngine {
|
|||
|
||||
boolean pIsAReferenceType = false;
|
||||
|
||||
Iterator i = pSymbol.getPtrOperators().iterator();
|
||||
if( i.hasNext() && ((PtrOp)i.next()).getType() == TypeInfo.PtrOp.t_reference ){
|
||||
List ptrOps = pSymbol.getPtrOperators();
|
||||
if( ptrOps.size() > 0 && ((PtrOp)ptrOps.get(0)).getType() == TypeInfo.PtrOp.t_reference ){
|
||||
pIsAReferenceType = true;
|
||||
}
|
||||
|
||||
|
@ -457,21 +457,23 @@ public final class TemplateEngine {
|
|||
if( aPtrs == null ){
|
||||
return false;
|
||||
}
|
||||
|
||||
int pSize = pPtrs.size();
|
||||
int aSize = aPtrs.size();
|
||||
if( pSize != aSize )
|
||||
return false;
|
||||
|
||||
Iterator pIter = pPtrs.iterator();
|
||||
ListIterator aIter = aPtrs.listIterator();
|
||||
PtrOp pOp = null;
|
||||
PtrOp aOp = null;
|
||||
while( pIter.hasNext() ){
|
||||
pOp = (PtrOp) pIter.next();
|
||||
if( !aIter.hasNext() ){
|
||||
return false;
|
||||
}
|
||||
aOp = (PtrOp) aIter.next();
|
||||
|
||||
int aIdx = 0;
|
||||
for( int i = 0; i < pSize; i++ ){
|
||||
pOp = (PtrOp) pPtrs.get(i);
|
||||
aOp = (PtrOp) aPtrs.get(aIdx++);
|
||||
if( pOp.getType() == aOp.getType() ){
|
||||
if( !pOp.equals( aOp ) )
|
||||
return false;
|
||||
aIter.remove();
|
||||
aPtrs.remove( --aIdx );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -533,11 +535,10 @@ public final class TemplateEngine {
|
|||
if( pParams.size() != aParams.size() ){
|
||||
return false;
|
||||
}
|
||||
Iterator pIter = pParams.iterator();
|
||||
Iterator aIter = aParams.iterator();
|
||||
while( pIter.hasNext() ){
|
||||
TypeInfo info = ((ISymbol)aIter.next()).getTypeInfo();
|
||||
if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), info ) ){
|
||||
int size = pParams.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
TypeInfo info = ((ISymbol)aParams.get( i )).getTypeInfo();
|
||||
if( !deduceTemplateArgument( map, (ISymbol)pParams.get(i), info ) ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -599,10 +600,10 @@ public final class TemplateEngine {
|
|||
if( pList == null || aList == null || pList.size() != aList.size()){
|
||||
return false;
|
||||
}
|
||||
Iterator pIter = pList.iterator();
|
||||
Iterator aIter = aList.iterator();
|
||||
while( pIter.hasNext() ){
|
||||
Object obj = pIter.next();
|
||||
|
||||
int size = pList.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
Object obj = pList.get( i );
|
||||
ISymbol sym = null;
|
||||
if( obj instanceof ISymbol ){
|
||||
sym = (ISymbol) obj;
|
||||
|
@ -611,7 +612,7 @@ public final class TemplateEngine {
|
|||
sym.setTypeInfo( (TypeInfo) obj );
|
||||
}
|
||||
|
||||
TypeInfo arg = transformTypeInfo( aIter.next(), null );
|
||||
TypeInfo arg = transformTypeInfo( aList.get( i ), null );
|
||||
|
||||
try {
|
||||
if( !deduceTemplateArgument( map, sym, arg ) ){
|
||||
|
@ -637,11 +638,11 @@ public final class TemplateEngine {
|
|||
static private Map deduceTemplateArgumentsUsingParameterList( ITemplateSymbol template, IParameterizedSymbol function ){
|
||||
|
||||
List aList = function.getParameterList();
|
||||
LinkedList args = new LinkedList();
|
||||
int size = aList.size();
|
||||
ArrayList args = new ArrayList( size );
|
||||
|
||||
Iterator iter = aList.iterator();
|
||||
while( iter.hasNext() ){
|
||||
ISymbol symbol = (ISymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol symbol = (ISymbol) aList.get(i);
|
||||
args.add( symbol.getTypeInfo() );
|
||||
}
|
||||
|
||||
|
@ -658,7 +659,7 @@ public final class TemplateEngine {
|
|||
* after substitution of the deduced values, compatible with A.
|
||||
*/
|
||||
static private Map deduceTemplateArguments( ITemplateSymbol template, List arguments ){
|
||||
if( template.getContainedSymbols() == ParserSymbolTable.EMPTY_MAP || template.getContainedSymbols().size() != 1 ){
|
||||
if( template.getContainedSymbols() == Collections.EMPTY_MAP || template.getContainedSymbols().size() != 1 ){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -677,12 +678,10 @@ public final class TemplateEngine {
|
|||
|
||||
HashMap map = new HashMap();
|
||||
|
||||
Iterator pIter = pList.iterator();
|
||||
Iterator aIter = arguments.iterator();
|
||||
|
||||
while( pIter.hasNext() ){
|
||||
int size = pList.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
try {
|
||||
if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), (TypeInfo) aIter.next() ) ){
|
||||
if( !deduceTemplateArgument( map, (ISymbol) pList.get(i), (TypeInfo) arguments.get(i) ) ){
|
||||
return null;
|
||||
}
|
||||
} catch (ParserSymbolTableException e) {
|
||||
|
@ -796,8 +795,9 @@ public final class TemplateEngine {
|
|||
HashMap map = new HashMap();
|
||||
TypeInfo val = null;
|
||||
List paramList = template.getParameterList();
|
||||
for( Iterator iterator = paramList.iterator(); iterator.hasNext(); ) {
|
||||
ISymbol param = (ISymbol) iterator.next();
|
||||
int size = paramList.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol param = (ISymbol) paramList.get( i );
|
||||
//template type parameter
|
||||
if( param.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
||||
val = new TypeInfo( TypeInfo.t_type, 0, template.getSymbolTable().newSymbol( "", TypeInfo.t_class ) ); //$NON-NLS-1$
|
||||
|
@ -891,7 +891,7 @@ public final class TemplateEngine {
|
|||
|
||||
Iterator paramIter = template.getParameterList().iterator();
|
||||
Iterator argsIter = (templateArguments != null ) ? templateArguments.iterator() : null;
|
||||
List instanceArgs = new LinkedList();
|
||||
List instanceArgs = new ArrayList( template.getParameterList().size() );
|
||||
while( paramIter.hasNext() ){
|
||||
ISymbol param = (ISymbol) paramIter.next();
|
||||
TypeInfo arg = (TypeInfo) (( argsIter != null && argsIter.hasNext() )? argsIter.next() : null);
|
||||
|
@ -912,7 +912,7 @@ public final class TemplateEngine {
|
|||
|
||||
if( instance != null ){
|
||||
if( instances == null )
|
||||
instances = new LinkedList();
|
||||
instances = new ArrayList(4);
|
||||
instances.add( instance );
|
||||
}
|
||||
}
|
||||
|
@ -981,11 +981,10 @@ public final class TemplateEngine {
|
|||
return false;
|
||||
}
|
||||
|
||||
Iterator iter1 = p1.iterator();
|
||||
Iterator iter2 = p2.iterator();
|
||||
while( iter1.hasNext() ){
|
||||
ISymbol param1 = (ISymbol) iter1.next();
|
||||
ISymbol param2 = (ISymbol) iter2.next();
|
||||
int size = p1.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol param1 = (ISymbol) p1.get( i );
|
||||
ISymbol param2 = (ISymbol) p2.get( i );
|
||||
if( param1.getTypeInfo().getTemplateParameterType() != param2.getTypeInfo().getTemplateParameterType() ){
|
||||
return false;
|
||||
}
|
||||
|
@ -1001,10 +1000,10 @@ public final class TemplateEngine {
|
|||
Map m [] = { new HashMap(), new HashMap() };
|
||||
|
||||
for( List list = p1; list != null; list = p2 ){
|
||||
Iterator i = list.iterator();
|
||||
int size = list.size();
|
||||
int index = 0;
|
||||
while( i.hasNext() ){
|
||||
m[ ( list == p2 )? 1 : 0 ].put( i.next(), new Integer( index++ ) );
|
||||
for( int i = 0; i < size; i++ ) {
|
||||
m[ ( list == p2 )? 1 : 0 ].put( list.get( i ), new Integer( index++ ) );
|
||||
}
|
||||
|
||||
if( list == p2 ){
|
||||
|
@ -1012,11 +1011,10 @@ public final class TemplateEngine {
|
|||
}
|
||||
}
|
||||
|
||||
Iterator i1 = a1.iterator();
|
||||
Iterator i2 = a2.iterator();
|
||||
while( i1.hasNext() ){
|
||||
TypeInfo t1 = (TypeInfo) i1.next();
|
||||
TypeInfo t2 = (TypeInfo) i2.next();
|
||||
int a1Size = a1.size();
|
||||
for( int i = 0; i < a1Size; i++ ){
|
||||
TypeInfo t1 = (TypeInfo) a1.get( i );
|
||||
TypeInfo t2 = (TypeInfo) a2.get( i );
|
||||
|
||||
if( t1.equals( t2 ) ){
|
||||
continue;
|
||||
|
@ -1032,11 +1030,11 @@ public final class TemplateEngine {
|
|||
}
|
||||
|
||||
static private ISpecializedSymbol findPartialSpecialization( ITemplateSymbol template, List parameters, List arguments ){
|
||||
|
||||
Iterator iter = template.getSpecializations().iterator();
|
||||
List specs = template.getSpecializations();
|
||||
int size = specs.size();
|
||||
ISpecializedSymbol spec = null;
|
||||
while( iter.hasNext() ){
|
||||
spec = (ISpecializedSymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
spec = (ISpecializedSymbol) specs.get(i);
|
||||
|
||||
if( ! checkTemplateParameterListsAreEquivalent( spec.getParameterList(), parameters ) ){
|
||||
continue;
|
||||
|
@ -1052,7 +1050,7 @@ public final class TemplateEngine {
|
|||
}
|
||||
|
||||
static protected ISymbol translateParameterForDefinition ( ISymbol templatedSymbol, ISymbol param, Map defnMap ){
|
||||
if( defnMap == ParserSymbolTable.EMPTY_MAP ){
|
||||
if( defnMap == Collections.EMPTY_MAP ){
|
||||
return param;
|
||||
}
|
||||
|
||||
|
@ -1112,10 +1110,11 @@ public final class TemplateEngine {
|
|||
instance = spec.deferredInstance( spec.getArgumentList() );
|
||||
} else {
|
||||
ITemplateSymbol template = symbol;
|
||||
Iterator iter = template.getParameterList().iterator();
|
||||
List args = new LinkedList();
|
||||
while( iter.hasNext() ){
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, (ISymbol) iter.next() ) );
|
||||
List params = template.getParameterList();
|
||||
int size = params.size();
|
||||
List args = new ArrayList( size );
|
||||
for( int i = 0; i < size; i++ ){
|
||||
args.add( new TypeInfo( TypeInfo.t_type, 0, (ISymbol) params.get(i) ) );
|
||||
}
|
||||
|
||||
instance = template.deferredInstance( args );
|
||||
|
@ -1156,13 +1155,13 @@ public final class TemplateEngine {
|
|||
}
|
||||
|
||||
static protected List verifyExplicitArguments( ITemplateSymbol template, List arguments, ISymbol symbol ) throws ParserSymbolTableException{
|
||||
List actualArgs = new LinkedList();
|
||||
|
||||
Iterator params = template.getParameterList().iterator();
|
||||
List params = template.getParameterList();
|
||||
Iterator args = arguments.iterator();
|
||||
|
||||
while( params.hasNext() ){
|
||||
ISymbol param = (ISymbol) params.next();
|
||||
int numParams = params.size();
|
||||
List actualArgs = new ArrayList( numParams );
|
||||
for( int i = 0; i < numParams; i++ ){
|
||||
ISymbol param = (ISymbol) params.get(i);
|
||||
if( args.hasNext() ){
|
||||
TypeInfo arg = (TypeInfo) args.next();
|
||||
if( matchTemplateParameterAndArgument( param, arg ) ){
|
||||
|
@ -1226,7 +1225,7 @@ public final class TemplateEngine {
|
|||
|
||||
static protected List resolveTemplateFunctionArguments( List args, ITemplateSymbol template, IParameterizedSymbol fn )
|
||||
{
|
||||
List resultList = new LinkedList();
|
||||
List resultList = new ArrayList();
|
||||
|
||||
List params = template.getParameterList();
|
||||
Map map = null;
|
||||
|
@ -1323,14 +1322,13 @@ public final class TemplateEngine {
|
|||
|
||||
List args = instance.getArguments();
|
||||
List args2 = instance2.getArguments();
|
||||
|
||||
if( args.size() != args2.size() )
|
||||
int size = args.size();
|
||||
if( size != args2.size() )
|
||||
return false;
|
||||
|
||||
Iterator iter1 = args.iterator(), iter2 = args2.iterator();
|
||||
while( iter1.hasNext() ){
|
||||
TypeInfo info1 = (TypeInfo) iter1.next();
|
||||
TypeInfo info2 = (TypeInfo) iter2.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
TypeInfo info1 = (TypeInfo) args.get(i);
|
||||
TypeInfo info2 = (TypeInfo) args2.get(i);
|
||||
|
||||
if( ! info1.equals( info2 ) )
|
||||
return false;
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
@ -31,8 +31,8 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
|
||||
private IContainerSymbol lastSymbol;
|
||||
|
||||
private List templates = new LinkedList();
|
||||
private List symbols = new LinkedList();
|
||||
private ArrayList templates = new ArrayList(4);
|
||||
private ArrayList symbols = new ArrayList(4);
|
||||
private Map argMap = new HashMap();
|
||||
|
||||
protected TemplateFactory( ParserSymbolTable table ){
|
||||
|
@ -49,7 +49,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
|
||||
public void pushTemplateId(ISymbol symbol, List args) {
|
||||
symbols.add( symbol );
|
||||
argMap.put( symbol, new LinkedList( args ) );
|
||||
argMap.put( symbol, new ArrayList( args ) );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -77,13 +77,14 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
} else {
|
||||
//partial speciailization
|
||||
ISpecializedSymbol spec = template.getSymbolTable().newSpecializedSymbol( symbol.getName() );
|
||||
Iterator iter = params.iterator();
|
||||
while( iter.hasNext() ){
|
||||
spec.addTemplateParameter( (ISymbol) iter.next() );
|
||||
int size = params.size();
|
||||
for( int i = 0; i < size; i++){
|
||||
spec.addTemplateParameter( (ISymbol) params.get( i ) );
|
||||
}
|
||||
iter = args.iterator();
|
||||
while( iter.hasNext() ){
|
||||
spec.addArgument( (TypeInfo) iter.next() );
|
||||
size = args.size();
|
||||
spec.prepareArguments( size );
|
||||
for( int i = 0; i < size; i++){
|
||||
spec.addArgument( (TypeInfo) args.get(i) );
|
||||
}
|
||||
|
||||
spec.addSymbol( symbol );
|
||||
|
@ -106,18 +107,18 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
public void addSymbol(ISymbol symbol) throws ParserSymbolTableException {
|
||||
lastSymbol = getLastSymbol();
|
||||
|
||||
Iterator iter = symbols.iterator();
|
||||
ListIterator tIter = templates.listIterator();
|
||||
|
||||
ISymbol sym = null;
|
||||
ISymbol container = null;
|
||||
boolean templateParamState = false;
|
||||
while( iter.hasNext() ){
|
||||
sym = (ISymbol) iter.next();
|
||||
int size = symbols.size();
|
||||
int templatesSize = templates.size(), templatesIdx = 0;
|
||||
for( int i = 0; i < size; i++ ){
|
||||
sym = (ISymbol) symbols.get( i );
|
||||
if( !sym.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
iter.remove();
|
||||
} else if( tIter.hasNext() ) {
|
||||
ITemplateSymbol template = (ITemplateSymbol) tIter.next();
|
||||
symbols.remove( i-- );
|
||||
size--;
|
||||
} else if( templatesIdx < templatesSize ) {
|
||||
ITemplateSymbol template = (ITemplateSymbol) templates.get( templatesIdx-- );
|
||||
if( template.getParameterList().size() == 0 ){
|
||||
templateParamState = true;
|
||||
container = sym;
|
||||
|
@ -155,10 +156,11 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
|
||||
List argList = null;
|
||||
if( symbol instanceof IParameterizedSymbol ){
|
||||
argList = new LinkedList();
|
||||
Iterator i = ((IParameterizedSymbol)symbol).getParameterList().iterator();
|
||||
while( i.hasNext() ){
|
||||
ISymbol param = (ISymbol) i.next();
|
||||
List params = ((IParameterizedSymbol)symbol).getParameterList();
|
||||
int size = params.size();
|
||||
argList = new ArrayList( size );
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol param = (ISymbol) params.get(i);
|
||||
argList.add( param.getTypeInfo() );
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +184,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
|
||||
if( template.getParameterList().size() == 0 ){
|
||||
//explicit specialization, deduce some arguments and use addTemplateId
|
||||
ISymbol previous = findPreviousSymbol( symbol, new LinkedList() );
|
||||
ISymbol previous = findPreviousSymbol( symbol, new ArrayList() );
|
||||
if( previous == null || !(previous.getContainingSymbol() instanceof ITemplateSymbol) )
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
|
||||
|
@ -276,21 +278,21 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
}
|
||||
|
||||
Iterator tempIter = templates.iterator();
|
||||
Iterator symIter = symbols.iterator();
|
||||
|
||||
while( tempIter.hasNext() ){
|
||||
int size = templates.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
Map defnMap = new HashMap();
|
||||
|
||||
ITemplateSymbol template = (ITemplateSymbol) tempIter.next();
|
||||
ITemplateSymbol origTemplate = (ITemplateSymbol) ((ISymbol)symIter.next()).getContainingSymbol();
|
||||
ITemplateSymbol template = (ITemplateSymbol) templates.get(i);
|
||||
ITemplateSymbol origTemplate = (ITemplateSymbol) ((ISymbol)symbols.get(i)).getContainingSymbol();
|
||||
|
||||
Iterator params = template.getParameterList().iterator();
|
||||
Iterator origParams = origTemplate.getParameterList().iterator();
|
||||
|
||||
while( params.hasNext() ){
|
||||
ISymbol param = (ISymbol) params.next();
|
||||
ISymbol origParam = (ISymbol) origParams.next();
|
||||
List tList = template.getParameterList();
|
||||
List oList = origTemplate.getParameterList();
|
||||
int tListSize = tList.size();
|
||||
if( oList.size() < tListSize )
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
for( int j = 0; j < tListSize; j++ ){
|
||||
ISymbol param = (ISymbol) tList.get(j);
|
||||
ISymbol origParam = (ISymbol) oList.get(j);
|
||||
defnMap.put( param, origParam );
|
||||
}
|
||||
|
||||
|
@ -310,9 +312,9 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
private void addExplicitSpecialization( ITemplateSymbol template, ISymbol symbol, List arguments ) throws ParserSymbolTableException {
|
||||
template.addExplicitSpecialization( symbol, arguments );
|
||||
|
||||
Iterator i = symbols.iterator();
|
||||
while( i.hasNext() ){
|
||||
IContainerSymbol sym = (IContainerSymbol) i.next();
|
||||
int size = symbols.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
IContainerSymbol sym = (IContainerSymbol) symbols.get( 0 );
|
||||
ISymbol instantiated = sym.getInstantiatedSymbol();
|
||||
if( instantiated != null ){
|
||||
IContainerSymbol container = instantiated.getContainingSymbol();
|
||||
|
@ -320,7 +322,6 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
((ITemplateSymbol) container ).removeInstantiation( sym );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( getASTExtension() != null ){
|
||||
|
@ -838,4 +839,10 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
public List getFriends() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#preparePtrOperatros(int)
|
||||
*/
|
||||
public void preparePtrOperatros(int numPtrOps) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,10 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -37,8 +38,8 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
public Object clone(){
|
||||
TemplateSymbol copy = (TemplateSymbol)super.clone();
|
||||
|
||||
copy._defnParameterMap = ( _defnParameterMap != ParserSymbolTable.EMPTY_MAP ) ? (HashMap)((HashMap) _defnParameterMap).clone() : _defnParameterMap;
|
||||
copy._instantiations = ( _instantiations != null ) ? (HashMap)((HashMap) _instantiations).clone() : _instantiations;
|
||||
copy._defnParameterMap = ( _defnParameterMap != Collections.EMPTY_MAP ) ? (Map)((HashMap) _defnParameterMap).clone() : _defnParameterMap;
|
||||
copy._instantiations = ( _instantiations != Collections.EMPTY_MAP ) ? (Map)((HashMap) _instantiations).clone() : _instantiations;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
ISymbol param = null;
|
||||
TypeInfo arg = null;
|
||||
|
||||
List actualArgs = new LinkedList();
|
||||
List actualArgs = new ArrayList( numParams );
|
||||
|
||||
ISymbol templatedSymbol = template.getTemplatedSymbol();
|
||||
while( templatedSymbol != null && templatedSymbol.isTemplateInstance() ){
|
||||
|
@ -255,7 +256,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
|
||||
List actualArgs = TemplateEngine.verifyExplicitArguments( this, args, symbol );
|
||||
|
||||
if( _explicitSpecializations == ParserSymbolTable.EMPTY_MAP )
|
||||
if( _explicitSpecializations == Collections.EMPTY_MAP )
|
||||
_explicitSpecializations = new HashMap();
|
||||
|
||||
Map specs = null;
|
||||
|
@ -274,16 +275,17 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
specs = (Map) _explicitSpecializations.get( key );
|
||||
} else {
|
||||
specs = new HashMap();
|
||||
_explicitSpecializations.put( new LinkedList( actualArgs ), specs );
|
||||
_explicitSpecializations.put( new ArrayList( actualArgs ), specs );
|
||||
}
|
||||
|
||||
ISymbol found = null;
|
||||
try{
|
||||
if( symbol.isType( TypeInfo.t_function ) || symbol.isType( TypeInfo.t_constructor ) ){
|
||||
List fnArgs = new LinkedList();
|
||||
iter = ((IParameterizedSymbol)symbol).getParameterList().iterator();
|
||||
while( iter.hasNext() ){
|
||||
fnArgs.add( ((ISymbol)iter.next()).getTypeInfo() );
|
||||
List params = ((IParameterizedSymbol) symbol).getParameterList();
|
||||
int size = params.size();
|
||||
List fnArgs = new ArrayList( size );
|
||||
for( int i = 0; i < size; i++){
|
||||
fnArgs.add( ((ISymbol)params.get(i)).getTypeInfo() );
|
||||
}
|
||||
found = getTemplatedSymbol().lookupMethodForDefinition( symbol.getName(), fnArgs );
|
||||
} else {
|
||||
|
@ -325,8 +327,8 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol#addSpecialization(org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol)
|
||||
*/
|
||||
public void addSpecialization( ISpecializedSymbol spec ){
|
||||
if( _specializations == ParserSymbolTable.EMPTY_LIST )
|
||||
_specializations = new LinkedList();
|
||||
if( _specializations == Collections.EMPTY_LIST )
|
||||
_specializations = new ArrayList(4);
|
||||
|
||||
_specializations.add( spec );
|
||||
|
||||
|
@ -342,15 +344,15 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
}
|
||||
|
||||
public void addInstantiation( IContainerSymbol instance, List args ){
|
||||
List key = new LinkedList( args );
|
||||
if( _instantiations == ParserSymbolTable.EMPTY_MAP ){
|
||||
List key = new ArrayList( args );
|
||||
if( _instantiations == Collections.EMPTY_MAP ){
|
||||
_instantiations = new HashMap();
|
||||
}
|
||||
_instantiations.put( key, instance );
|
||||
}
|
||||
|
||||
public IContainerSymbol findInstantiation( List arguments ){
|
||||
if( _instantiations == ParserSymbolTable.EMPTY_MAP ){
|
||||
if( _instantiations == Collections.EMPTY_MAP ){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -398,7 +400,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
}
|
||||
|
||||
protected void addToDefinitionParameterMap( ISymbol newSymbol, Map defnMap ){
|
||||
if( _defnParameterMap == ParserSymbolTable.EMPTY_MAP )
|
||||
if( _defnParameterMap == Collections.EMPTY_MAP )
|
||||
_defnParameterMap = new HashMap();
|
||||
_defnParameterMap.put( newSymbol, defnMap );
|
||||
}
|
||||
|
@ -415,20 +417,20 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol#registerDeferredInstatiation(org.eclipse.cdt.internal.core.parser.pst.ParameterizedSymbol, org.eclipse.cdt.internal.core.parser.pst.ISymbol, org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol.DeferredKind)
|
||||
*/
|
||||
public void registerDeferredInstatiation( Object obj0, Object obj1, DeferredKind kind, Map argMap ) {
|
||||
if( _deferredInstantiations == ParserSymbolTable.EMPTY_LIST )
|
||||
_deferredInstantiations = new LinkedList();
|
||||
if( _deferredInstantiations == Collections.EMPTY_LIST )
|
||||
_deferredInstantiations = new ArrayList(8);
|
||||
|
||||
_deferredInstantiations.add( new Object [] { obj0, obj1, kind, argMap } );
|
||||
}
|
||||
|
||||
|
||||
protected void processDeferredInstantiations() throws ParserSymbolTableException{
|
||||
if( _deferredInstantiations == ParserSymbolTable.EMPTY_LIST )
|
||||
if( _deferredInstantiations == Collections.EMPTY_LIST )
|
||||
return;
|
||||
|
||||
Iterator iter = _deferredInstantiations.iterator();
|
||||
while( iter.hasNext() ){
|
||||
Object [] objs = (Object [])iter.next();
|
||||
int size = _deferredInstantiations.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
Object [] objs = (Object [])_deferredInstantiations.get(i);
|
||||
|
||||
DeferredKind kind = (DeferredKind) objs[2];
|
||||
|
||||
|
@ -444,11 +446,11 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
}
|
||||
}
|
||||
|
||||
private LinkedList _specializations = ParserSymbolTable.EMPTY_LIST; //template specializations
|
||||
private Map _explicitSpecializations = ParserSymbolTable.EMPTY_MAP; //explicit specializations
|
||||
private Map _defnParameterMap = ParserSymbolTable.EMPTY_MAP; //members could be defined with different template parameter names
|
||||
private Map _instantiations = ParserSymbolTable.EMPTY_MAP;
|
||||
private LinkedList _deferredInstantiations = ParserSymbolTable.EMPTY_LIST; //used to avoid recursive loop
|
||||
private List _specializations = Collections.EMPTY_LIST; //template specializations
|
||||
private Map _explicitSpecializations = Collections.EMPTY_MAP; //explicit specializations
|
||||
private Map _defnParameterMap = Collections.EMPTY_MAP; //members could be defined with different template parameter names
|
||||
private Map _instantiations = Collections.EMPTY_MAP;
|
||||
private List _deferredInstantiations = Collections.EMPTY_LIST; //used to avoid recursive loop
|
||||
|
||||
|
||||
}
|
|
@ -10,8 +10,9 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
|
@ -23,37 +24,37 @@ public class TypeInfo {
|
|||
super();
|
||||
}
|
||||
|
||||
public TypeInfo( TypeInfo.eType type, int info, ISymbol symbol ){
|
||||
public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol ){
|
||||
super();
|
||||
_typeInfo = info;
|
||||
_typeBits = bits;
|
||||
_type = type;
|
||||
_typeDeclaration = symbol;
|
||||
}
|
||||
|
||||
public TypeInfo( TypeInfo.eType type, int info, ISymbol symbol, TypeInfo.PtrOp op, boolean hasDefault ){
|
||||
public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol, TypeInfo.PtrOp op, boolean hasDefault ){
|
||||
super();
|
||||
_typeInfo = info;
|
||||
_typeBits = bits;
|
||||
_type = type;
|
||||
_typeDeclaration = symbol;
|
||||
if( op != null ){
|
||||
_ptrOperators = new LinkedList();
|
||||
_ptrOperators = new ArrayList(2);
|
||||
_ptrOperators.add( op );
|
||||
} else {
|
||||
_ptrOperators = null;
|
||||
_ptrOperators = Collections.EMPTY_LIST;
|
||||
}
|
||||
_hasDefaultValue = hasDefault;
|
||||
}
|
||||
|
||||
public TypeInfo( TypeInfo.eType type, int info, ISymbol symbol, TypeInfo.PtrOp op, Object def ){
|
||||
public TypeInfo( TypeInfo.eType type, int bits, ISymbol symbol, TypeInfo.PtrOp op, Object def ){
|
||||
super();
|
||||
_typeInfo = info;
|
||||
_typeBits = bits;
|
||||
_type = type;
|
||||
_typeDeclaration = symbol;
|
||||
if( op != null ){
|
||||
_ptrOperators = new LinkedList();
|
||||
_ptrOperators = new ArrayList( 1 );
|
||||
_ptrOperators.add( op );
|
||||
} else {
|
||||
_ptrOperators = null;
|
||||
_ptrOperators = Collections.EMPTY_LIST;
|
||||
}
|
||||
_hasDefaultValue = true;
|
||||
setDefault( def );
|
||||
|
@ -62,35 +63,34 @@ public class TypeInfo {
|
|||
public TypeInfo( TypeInfo info ){
|
||||
super();
|
||||
|
||||
_typeInfo = info._typeInfo;
|
||||
_typeBits = info._typeBits;
|
||||
_type = info._type;
|
||||
_typeDeclaration = info._typeDeclaration;
|
||||
_ptrOperators = ( info._ptrOperators == null ) ? null : (LinkedList)info._ptrOperators.clone();
|
||||
_ptrOperators = ( info._ptrOperators == Collections.EMPTY_LIST ) ? info._ptrOperators : (ArrayList)((ArrayList)info._ptrOperators).clone();
|
||||
_hasDefaultValue = info._hasDefaultValue;
|
||||
_defaultValue = info._defaultValue;
|
||||
}
|
||||
|
||||
public static final int typeMask = 0x001f;
|
||||
public static final int isAuto = 0x0020;
|
||||
public static final int isRegister = 0x0040;
|
||||
public static final int isStatic = 0x0080;
|
||||
public static final int isExtern = 0x0100;
|
||||
public static final int isMutable = 0x0200;
|
||||
public static final int isInline = 0x0400;
|
||||
public static final int isVirtual = 0x0800;
|
||||
public static final int isExplicit = 0x1000;
|
||||
public static final int isTypedef = 0x2000;
|
||||
public static final int isFriend = 0x4000;
|
||||
public static final int isConst = 0x8000;
|
||||
public static final int isVolatile = 0x10000;
|
||||
public static final int isUnsigned = 0x20000;
|
||||
public static final int isShort = 0x40000;
|
||||
public static final int isLong = 0x80000;
|
||||
public static final int isForward = 0x100000;
|
||||
public static final int isComplex = 0x200000;
|
||||
public static final int isImaginary= 0x400000;
|
||||
public static final int isLongLong = 0x800000;
|
||||
public static final int isSigned = 0x1000000;
|
||||
public static final int isAuto = 0x00001;
|
||||
public static final int isRegister = 0x00002;
|
||||
public static final int isStatic = 0x00004;
|
||||
public static final int isExtern = 0x00008;
|
||||
public static final int isMutable = 0x00010;
|
||||
public static final int isInline = 0x00020;
|
||||
public static final int isVirtual = 0x00040;
|
||||
public static final int isExplicit = 0x00080;
|
||||
public static final int isTypedef = 0x00100;
|
||||
public static final int isFriend = 0x00200;
|
||||
public static final int isConst = 0x00400;
|
||||
public static final int isVolatile = 0x00800;
|
||||
public static final int isUnsigned = 0x01000;
|
||||
public static final int isShort = 0x02000;
|
||||
public static final int isLong = 0x04000;
|
||||
public static final int isForward = 0x08000;
|
||||
public static final int isComplex = 0x10000;
|
||||
public static final int isImaginary= 0x20000;
|
||||
public static final int isLongLong = 0x40000;
|
||||
public static final int isSigned = 0x80000;
|
||||
|
||||
// Types (maximum type is typeMask
|
||||
// Note that these should be considered ordered and if you change
|
||||
|
@ -248,14 +248,14 @@ public class TypeInfo {
|
|||
// Convenience methods
|
||||
public void setBit(boolean b, int mask){
|
||||
if( b ){
|
||||
_typeInfo = _typeInfo | mask;
|
||||
_typeBits = _typeBits | mask;
|
||||
} else {
|
||||
_typeInfo = _typeInfo & ~mask;
|
||||
_typeBits = _typeBits & ~mask;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkBit(int mask){
|
||||
return (_typeInfo & mask) != 0;
|
||||
return (_typeBits & mask) != 0;
|
||||
}
|
||||
|
||||
public void setType( TypeInfo.eType t){
|
||||
|
@ -271,11 +271,11 @@ public class TypeInfo {
|
|||
}
|
||||
|
||||
public int getTypeInfo(){
|
||||
return _typeInfo;
|
||||
return _typeBits;
|
||||
}
|
||||
|
||||
public void setTypeInfo( int typeInfo ){
|
||||
_typeInfo = typeInfo;
|
||||
_typeBits = typeInfo;
|
||||
}
|
||||
|
||||
public eType getTemplateParameterType(){
|
||||
|
@ -320,13 +320,10 @@ public class TypeInfo {
|
|||
}
|
||||
|
||||
public boolean hasPtrOperators(){
|
||||
return ( _ptrOperators != null && _ptrOperators.size() > 0 );
|
||||
return _ptrOperators.size() > 0;
|
||||
}
|
||||
|
||||
public List getPtrOperators(){
|
||||
if( _ptrOperators == null ){
|
||||
_ptrOperators = new LinkedList();
|
||||
}
|
||||
return _ptrOperators;
|
||||
}
|
||||
|
||||
|
@ -353,9 +350,6 @@ public class TypeInfo {
|
|||
}
|
||||
|
||||
public List getOperatorExpressions(){
|
||||
if( _operatorExpressions == null ){
|
||||
_operatorExpressions = new LinkedList();
|
||||
}
|
||||
return _operatorExpressions;
|
||||
}
|
||||
|
||||
|
@ -365,10 +359,9 @@ public class TypeInfo {
|
|||
return;
|
||||
|
||||
int size = ops.size();
|
||||
Iterator iter = ops.iterator();
|
||||
OperatorExpression op = null;
|
||||
for( int i = size; i > 0; i-- ){
|
||||
op = (OperatorExpression)iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
op = (OperatorExpression)ops.get(i);
|
||||
if( op == OperatorExpression.indirection ||
|
||||
op == OperatorExpression.subscript )
|
||||
{
|
||||
|
@ -393,24 +386,37 @@ public class TypeInfo {
|
|||
}
|
||||
|
||||
public void addPtrOperator( TypeInfo.PtrOp ptr ){
|
||||
if( _ptrOperators == null ){
|
||||
_ptrOperators = new LinkedList();
|
||||
if( _ptrOperators == Collections.EMPTY_LIST ){
|
||||
_ptrOperators = new ArrayList(4);
|
||||
}
|
||||
if( ptr != null )
|
||||
_ptrOperators.add( ptr );
|
||||
}
|
||||
|
||||
public void addPtrOperator( List ptrs ){
|
||||
if( _ptrOperators == null ){
|
||||
_ptrOperators = new LinkedList();
|
||||
if( ptrs == null || ptrs.size() == 0 )
|
||||
return;
|
||||
|
||||
if( _ptrOperators == Collections.EMPTY_LIST ){
|
||||
_ptrOperators = new ArrayList( ptrs.size() );
|
||||
}
|
||||
if( ptrs != null )
|
||||
_ptrOperators.addAll( ptrs );
|
||||
|
||||
int size = ptrs.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
_ptrOperators.add( ptrs.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void preparePtrOperators(int numPtrOps) {
|
||||
if( _ptrOperators == Collections.EMPTY_LIST )
|
||||
_ptrOperators = new ArrayList( numPtrOps );
|
||||
else
|
||||
((ArrayList) _ptrOperators).ensureCapacity( numPtrOps );
|
||||
}
|
||||
|
||||
public void addOperatorExpression( OperatorExpression exp ){
|
||||
if( _operatorExpressions == null ){
|
||||
_operatorExpressions = new LinkedList();
|
||||
if( _operatorExpressions == Collections.EMPTY_LIST ){
|
||||
_operatorExpressions = new ArrayList(4);
|
||||
}
|
||||
_operatorExpressions.add( exp );
|
||||
}
|
||||
|
@ -461,7 +467,7 @@ public class TypeInfo {
|
|||
|
||||
TypeInfo type = (TypeInfo)t;
|
||||
|
||||
boolean result = ( _typeInfo == type._typeInfo );
|
||||
boolean result = ( _typeBits == type._typeBits );
|
||||
result &= ( _type == type._type );
|
||||
|
||||
if( _typeDeclaration != null && type._typeDeclaration != null ){
|
||||
|
@ -499,17 +505,14 @@ public class TypeInfo {
|
|||
result &= ( _typeDeclaration == type._typeDeclaration );
|
||||
}
|
||||
|
||||
int size1 = (_ptrOperators == null) ? 0 : _ptrOperators.size();
|
||||
int size2 = (type._ptrOperators == null) ? 0 : type._ptrOperators.size();
|
||||
int size1 = _ptrOperators.size();
|
||||
int size2 = type._ptrOperators.size();
|
||||
if( size1 == size2 ){
|
||||
if( size1 != 0 ){
|
||||
Iterator iter1 = _ptrOperators.iterator();
|
||||
Iterator iter2 = type._ptrOperators.iterator();
|
||||
|
||||
TypeInfo.PtrOp op1 = null, op2 = null;
|
||||
for( int i = size1; i > 0; i-- ){
|
||||
op1 = (TypeInfo.PtrOp)iter1.next();
|
||||
op2 = (TypeInfo.PtrOp)iter2.next();
|
||||
for( int i = 0; i < size1; i++ ){
|
||||
op1 = (TypeInfo.PtrOp)_ptrOperators.get(i);
|
||||
op2 = (TypeInfo.PtrOp)type._ptrOperators.get(i);
|
||||
|
||||
if( !op1.equals(op2) ){
|
||||
return false;
|
||||
|
@ -530,14 +533,13 @@ public class TypeInfo {
|
|||
return TypeInfo._image[ getType().toInt() ];
|
||||
}
|
||||
|
||||
private int _typeInfo = 0;
|
||||
private int _typeBits = 0;
|
||||
private eType _type = TypeInfo.t_undef;
|
||||
private eType _templateParameterType = t_typeName;
|
||||
private ISymbol _typeDeclaration;
|
||||
|
||||
private boolean _hasDefaultValue = false;
|
||||
private Object _defaultValue = null;
|
||||
private LinkedList _ptrOperators;
|
||||
private LinkedList _operatorExpressions;
|
||||
|
||||
private List _ptrOperators = Collections.EMPTY_LIST;
|
||||
private List _operatorExpressions = Collections.EMPTY_LIST;
|
||||
}
|
Loading…
Add table
Reference in a new issue