mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
reduce the use of iterators in the symbol table
This commit is contained in:
parent
1b8740f2d3
commit
495d77744b
10 changed files with 112 additions and 123 deletions
|
@ -686,12 +686,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
//collect associated namespaces & classes.
|
||||
int size = ( parameters == null ) ? 0 : parameters.size();
|
||||
Iterator iter = ( parameters == null ) ? null : parameters.iterator();
|
||||
|
||||
|
||||
TypeInfo param = null;
|
||||
ISymbol paramType = null;
|
||||
for( int i = size; i > 0; i-- ){
|
||||
param = (TypeInfo) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
param = (TypeInfo) parameters.get(i);
|
||||
paramType = ParserSymbolTable.getFlatTypeInfo( param ).getTypeSymbol();
|
||||
|
||||
if( paramType == null ){
|
||||
|
@ -703,7 +702,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
//if T is a pointer to a data member of class X, its associated namespaces and classes
|
||||
//are those associated with the member type together with those associated with X
|
||||
if( param.hasPtrOperators() && param.getPtrOperators().size() == 1 ){
|
||||
TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().iterator().next();
|
||||
TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().get(0);
|
||||
if( op.getType() == TypeInfo.PtrOp.t_pointer &&
|
||||
paramType.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) )
|
||||
{
|
||||
|
@ -994,9 +993,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
IDerivableContainerSymbol derivable = (IDerivableContainerSymbol) symbol;
|
||||
|
||||
Iterator iter = derivable.getFriends().iterator();
|
||||
while( iter.hasNext() ){
|
||||
ISymbol friend = (ISymbol) iter.next();
|
||||
List friends = derivable.getFriends();
|
||||
int size = friends.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol friend = (ISymbol) friends.get(i);
|
||||
ISymbol typeSymbol = friend.getTypeSymbol();
|
||||
if( friend == this || typeSymbol == this ||
|
||||
friend == container || ( container != null && typeSymbol == container ) )
|
||||
|
|
|
@ -51,10 +51,9 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
|||
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||
List args = getArguments();
|
||||
List newArgs = new ArrayList( args.size() );
|
||||
Iterator iter = args.iterator();
|
||||
|
||||
while( iter.hasNext() ){
|
||||
TypeInfo arg = (TypeInfo) iter.next();
|
||||
int size = args.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
TypeInfo arg = (TypeInfo) args.get(i);
|
||||
newArgs.add( TemplateEngine.instantiateTypeInfo( arg, template, argMap ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -62,12 +62,12 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
|
||||
DerivableContainerSymbol newSymbol = (DerivableContainerSymbol) super.instantiate( template, argMap );
|
||||
|
||||
Iterator parents = getParents().iterator();
|
||||
|
||||
List parents = getParents();
|
||||
int size = parents.size();
|
||||
newSymbol.getParents().clear();
|
||||
ParentWrapper wrapper = null;
|
||||
while( parents.hasNext() ){
|
||||
wrapper = (ParentWrapper) parents.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
wrapper = (ParentWrapper) parents.get(i);
|
||||
ISymbol parent = wrapper.getParent();
|
||||
if( parent == null )
|
||||
continue;
|
||||
|
@ -87,10 +87,11 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
}
|
||||
|
||||
public void instantiateDeferredParent( ISymbol parent, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||
Iterator parents = getParents().iterator();
|
||||
List parents = getParents();
|
||||
int size = parents.size();
|
||||
ParentWrapper w = null;
|
||||
while( parents.hasNext() ) {
|
||||
w = (ParentWrapper) parents.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
w = (ParentWrapper) parents.get(i);
|
||||
if( w.getParent() == parent ){
|
||||
w.setParent( parent.instantiate( template, argMap ) );
|
||||
}
|
||||
|
|
|
@ -82,15 +82,16 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
|
||||
//handle template parameter lists in TemplateSymbol, only do function parameter lists here.
|
||||
if( !isType( TypeInfo.t_template ) ){
|
||||
Iterator iter = getParameterList().iterator();
|
||||
List params = getParameterList();
|
||||
int size = params.size();
|
||||
|
||||
newParameterized.getParameterList().clear();
|
||||
newParameterized.getParameterMap().clear();
|
||||
|
||||
ISymbol param = null, newParam = null;
|
||||
|
||||
while( iter.hasNext() ){
|
||||
param = (ISymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
param = (ISymbol) params.get(i);
|
||||
newParam = param.instantiate( template, argMap );
|
||||
|
||||
newParameterized.addParameter( newParam );
|
||||
|
@ -211,15 +212,15 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
|
|||
if( fsize == 0 )
|
||||
return true;
|
||||
|
||||
Iterator iter = getParameterList().iterator();
|
||||
Iterator fIter = function.getParameterList().iterator();
|
||||
List params = getParameterList();
|
||||
List functionParams = function.getParameterList();
|
||||
|
||||
TypeInfo info = null;
|
||||
TypeInfo fInfo = null;
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
ISymbol p = (ISymbol) iter.next();
|
||||
ISymbol pf = (ISymbol) fIter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ISymbol p = (ISymbol) params.get(i);
|
||||
ISymbol pf = (ISymbol) functionParams.get(i);
|
||||
|
||||
info = p.getTypeInfo();
|
||||
fInfo = pf.getTypeInfo();
|
||||
|
|
|
@ -826,7 +826,7 @@ public class ParserSymbolTable {
|
|||
|
||||
protected static boolean isValidOverload( List origList, ISymbol newSymbol ){
|
||||
if( origList.size() == 1 ){
|
||||
return isValidOverload( (ISymbol)origList.iterator().next(), newSymbol );
|
||||
return isValidOverload( (ISymbol)origList.get(0), newSymbol );
|
||||
} else if ( origList.size() > 1 ){
|
||||
if( newSymbol.isType( TypeInfo.t_template ) ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
||||
|
@ -840,18 +840,18 @@ public class ParserSymbolTable {
|
|||
return false;
|
||||
}
|
||||
|
||||
Iterator iter = origList.iterator();
|
||||
ISymbol symbol = (ISymbol) iter.next();
|
||||
|
||||
//Iterator iter = origList.iterator();
|
||||
ISymbol symbol = (ISymbol) origList.get(0);
|
||||
int numSymbols = origList.size();
|
||||
if( symbol.isType( TypeInfo.t_template ) ){
|
||||
IParameterizedSymbol template = (IParameterizedSymbol) symbol;
|
||||
symbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
||||
}
|
||||
|
||||
boolean valid = isValidOverload( symbol, newSymbol );
|
||||
|
||||
while( valid && iter.hasNext() ){
|
||||
symbol = (ISymbol) iter.next();
|
||||
int idx = 1;
|
||||
while( valid && idx < numSymbols ){
|
||||
symbol = (ISymbol) origList.get(idx++);
|
||||
if( symbol.isType( TypeInfo.t_template ) ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) symbol;
|
||||
symbol = template.getTemplatedSymbol();
|
||||
|
@ -990,7 +990,7 @@ public class ParserSymbolTable {
|
|||
if( numFns == 0 ){
|
||||
return null;
|
||||
} else if ( numFns == 1 ){
|
||||
return (IParameterizedSymbol)functions.iterator().next();
|
||||
return (IParameterizedSymbol)functions.get(0);
|
||||
} else if ( numFns == 2 ){
|
||||
for (int i = 0; i < numFns; i++) {
|
||||
IParameterizedSymbol fn = (IParameterizedSymbol) functions.get(i);
|
||||
|
@ -1250,12 +1250,12 @@ public class ParserSymbolTable {
|
|||
}
|
||||
//check for void
|
||||
else if( numParameters == 0 && num == 1 ){
|
||||
ISymbol param = (ISymbol)function.getParameterList().iterator().next();
|
||||
ISymbol param = (ISymbol)function.getParameterList().get(0);
|
||||
if( param.isType( TypeInfo.t_void ) )
|
||||
continue;
|
||||
}
|
||||
else if( numParameters == 1 && num == 0 ){
|
||||
TypeInfo paramType = (TypeInfo) data.getParameters().iterator().next();
|
||||
TypeInfo paramType = (TypeInfo) data.getParameters().get(0);
|
||||
if( paramType.isType( TypeInfo.t_void ) )
|
||||
continue;
|
||||
}
|
||||
|
@ -1399,11 +1399,11 @@ public class ParserSymbolTable {
|
|||
IDerivableContainerSymbol parent = null;
|
||||
IDerivableContainerSymbol.IParentSymbol wrapper;
|
||||
|
||||
Iterator iter = symbol.getParents().iterator();
|
||||
int size = symbol.getParents().size();
|
||||
List parents = symbol.getParents();
|
||||
int size = parents.size();
|
||||
|
||||
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);
|
||||
temp = wrapper.getParent();
|
||||
boolean isVisible = ( wrapper.getAccess() == ASTAccessVisibility.PUBLIC );
|
||||
if ( temp instanceof IDerivableContainerSymbol ){
|
||||
|
@ -2271,13 +2271,13 @@ public void setLanguage( ParserLanguage language ){
|
|||
}
|
||||
|
||||
List parents = ((IDerivableContainerSymbol) qualifyingSymbol).getParents();
|
||||
Iterator iter = parents.iterator();
|
||||
int numParents = parents.size();
|
||||
IParentSymbol parent = null;
|
||||
ASTAccessVisibility symbolAccess = null;
|
||||
ASTAccessVisibility parentAccess = null;
|
||||
|
||||
while( iter.hasNext() ){
|
||||
parent = (IParentSymbol) iter.next();
|
||||
for( int i = 0; i < numParents; i++ ){
|
||||
parent = (IParentSymbol) parents.get(i);
|
||||
|
||||
if( container == parent.getParent() ){
|
||||
parentAccess = parent.getAccess();
|
||||
|
@ -2287,14 +2287,12 @@ public void setLanguage( ParserLanguage language ){
|
|||
}
|
||||
}
|
||||
|
||||
iter = parents.iterator();
|
||||
|
||||
//if static or an enumerator, the symbol could be visible through more than one path through the heirarchy,
|
||||
//so we need to check all paths
|
||||
boolean checkAllPaths = ( symbol.isType( TypeInfo.t_enumerator ) || symbol.getTypeInfo().checkBit( TypeInfo.isStatic ) );
|
||||
ASTAccessVisibility resultingAccess = null;
|
||||
while( iter.hasNext() ){
|
||||
parent = (IParentSymbol) iter.next();
|
||||
for( int i = 0; i < numParents; i++ ){
|
||||
parent = (IParentSymbol) parents.get(i);
|
||||
parentAccess = parent.getAccess();
|
||||
|
||||
ISymbol tmp = parent.getParent();
|
||||
|
|
|
@ -60,17 +60,15 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
|||
|
||||
List actualArgs = new ArrayList( specArgs.size() );
|
||||
|
||||
Iterator iter1 = specArgs.iterator();
|
||||
Iterator iter2 = arguments.iterator();
|
||||
|
||||
ISymbol templatedSymbol = getTemplatedSymbol();
|
||||
while( templatedSymbol.isTemplateInstance() ){
|
||||
templatedSymbol = templatedSymbol.getInstantiatedSymbol();
|
||||
}
|
||||
|
||||
while( iter1.hasNext() ){
|
||||
TypeInfo info = (TypeInfo) iter1.next();
|
||||
TypeInfo mappedInfo = (TypeInfo) iter2.next();
|
||||
int numSpecArgs = specArgs.size();
|
||||
for( int i = 0; i < numSpecArgs; i++ ){
|
||||
TypeInfo info = (TypeInfo) specArgs.get(i);
|
||||
TypeInfo mappedInfo = (TypeInfo) arguments.get(i);
|
||||
|
||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||
if( mappedInfo.isType( TypeInfo.t_type ) && mappedInfo.getTypeSymbol().isType( TypeInfo.t_templateParameter ) ){
|
||||
|
@ -93,9 +91,10 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
|||
if( getParameterList().size() != argMap.size() )
|
||||
return null;
|
||||
|
||||
Iterator params = getParameterList().iterator();
|
||||
while( params.hasNext() ){
|
||||
if( !argMap.containsKey( params.next() ) )
|
||||
List params = getParameterList();
|
||||
int numParams = params.size();
|
||||
for( int i = 0; i < numParams; i++ ){
|
||||
if( !argMap.containsKey( params.get(i) ) )
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,26 +82,23 @@ public final class TemplateEngine {
|
|||
|
||||
ISpecializedSymbol bestMatch = null;
|
||||
boolean bestMatchIsBest = true;
|
||||
Iterator iter = specs.iterator();
|
||||
ISpecializedSymbol spec = null;
|
||||
List specArgs = null;
|
||||
for( int i = size; i > 0; i-- ){
|
||||
spec = (ISpecializedSymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
spec = (ISpecializedSymbol) specs.get(i);
|
||||
specArgs = spec.getArgumentList();
|
||||
if( specArgs == null || specArgs.size() != args.size() ){
|
||||
continue;
|
||||
}
|
||||
|
||||
Iterator iter1 = specArgs.iterator();
|
||||
Iterator iter2 = args.iterator();
|
||||
|
||||
int specArgsSize = specArgs.size();
|
||||
HashMap map = new HashMap();
|
||||
TypeInfo info1 = null, info2 = null;
|
||||
|
||||
boolean match = true;
|
||||
for( int j = specArgs.size(); j > 0; j-- ){
|
||||
info1 = (TypeInfo) iter1.next();
|
||||
info2 = (TypeInfo) iter2.next();
|
||||
for( int j = 0; j < specArgsSize; j++ ){
|
||||
info1 = (TypeInfo) specArgs.get(j);
|
||||
info2 = (TypeInfo) args.get(j);
|
||||
|
||||
ISymbol sym1 = template.getSymbolTable().newSymbol( ParserSymbolTable.EMPTY_NAME );
|
||||
sym1.setTypeInfo( info1 );
|
||||
|
@ -150,16 +147,14 @@ public final class TemplateEngine {
|
|||
|
||||
List pList = p.getParameterList();
|
||||
List aList = a.getParameterList();
|
||||
|
||||
if( pList.size() != aList.size() ){
|
||||
int size = pList.size();
|
||||
if( aList.size() != size){
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator pIter = pList.iterator();
|
||||
Iterator aIter = aList.iterator();
|
||||
while( pIter.hasNext() ){
|
||||
ISymbol pParam = (ISymbol) pIter.next();
|
||||
ISymbol aParam = (ISymbol) aIter.next();
|
||||
for( int i = 0; i < size; i++){
|
||||
ISymbol pParam = (ISymbol) pList.get(i);
|
||||
ISymbol aParam = (ISymbol) aList.get(i);
|
||||
|
||||
if( pParam.getType() != aParam.getType() ||
|
||||
pParam.getTypeInfo().getTemplateParameterType() != aParam.getTypeInfo().getTemplateParameterType() )
|
||||
|
@ -521,7 +516,7 @@ public final class TemplateEngine {
|
|||
|
||||
List pPtrs = p.getPtrOperators();
|
||||
if( pPtrs.size() != 0 ){
|
||||
PtrOp op = (PtrOp) pPtrs.iterator().next();
|
||||
PtrOp op = (PtrOp) pPtrs.get(0);
|
||||
if( op.getType() == PtrOp.t_memberPointer ){
|
||||
TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() );
|
||||
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
|
||||
|
@ -889,12 +884,13 @@ public final class TemplateEngine {
|
|||
if( map == null )
|
||||
continue;
|
||||
|
||||
Iterator paramIter = template.getParameterList().iterator();
|
||||
Iterator argsIter = (templateArguments != null ) ? templateArguments.iterator() : null;
|
||||
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);
|
||||
List templateParams = template.getParameterList();
|
||||
int numTemplateParams = templateParams.size();
|
||||
int numTemplateArgs = ( templateArguments != null ) ? templateArguments.size() : 0;
|
||||
List instanceArgs = new ArrayList( templateParams.size() );
|
||||
for( int i = 0; i < numTemplateParams; i++ ){
|
||||
ISymbol param = (ISymbol) templateParams.get(i);
|
||||
TypeInfo arg = (TypeInfo) ( i < numTemplateArgs ? templateArguments.get(i) : null);
|
||||
TypeInfo mapped = (TypeInfo) map.get( param );
|
||||
|
||||
if( arg != null && mapped != null )
|
||||
|
@ -937,10 +933,9 @@ public final class TemplateEngine {
|
|||
if( arguments.size() != parameters.size() ){
|
||||
forPrimary = false;
|
||||
} else if( !parameters.isEmpty() ){
|
||||
Iterator pIter = parameters.iterator();
|
||||
Iterator aIter = arguments.iterator();
|
||||
while( pIter.hasNext() ){
|
||||
if( pIter.next() != ((TypeInfo) aIter.next()).getTypeSymbol() ){
|
||||
int size = parameters.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
if( parameters.get(i) != ((TypeInfo) arguments.get(i)).getTypeSymbol() ){
|
||||
forPrimary = false;
|
||||
break;
|
||||
}
|
||||
|
@ -1156,14 +1151,14 @@ public final class TemplateEngine {
|
|||
|
||||
static protected List verifyExplicitArguments( ITemplateSymbol template, List arguments, ISymbol symbol ) throws ParserSymbolTableException{
|
||||
List params = template.getParameterList();
|
||||
Iterator args = arguments.iterator();
|
||||
|
||||
int numParams = params.size();
|
||||
int numArgs = arguments.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( i < numArgs ){
|
||||
TypeInfo arg = (TypeInfo) arguments.get(i);
|
||||
if( matchTemplateParameterAndArgument( param, arg ) ){
|
||||
actualArgs.add( arg );
|
||||
} else {
|
||||
|
@ -1200,11 +1195,12 @@ public final class TemplateEngine {
|
|||
|
||||
if( map == null )
|
||||
continue;
|
||||
Iterator pIter = tmpl.getParameterList().iterator();
|
||||
Iterator aIter = args.iterator();
|
||||
while( pIter.hasNext() && aIter.hasNext() ){
|
||||
ISymbol param = (ISymbol) pIter.next();
|
||||
TypeInfo arg = (TypeInfo) aIter.next();
|
||||
List params = tmpl.getParameterList();
|
||||
int numParams = params.size();
|
||||
int numArgs = args.size();
|
||||
for( int i = 0; i < numParams && i < numArgs; i++ ){
|
||||
ISymbol param = (ISymbol) params.get(i);
|
||||
TypeInfo arg = (TypeInfo) args.get(i);
|
||||
if( map.containsKey( param ) ) {
|
||||
if( !map.get( param ).equals( arg )){
|
||||
continue outer;
|
||||
|
@ -1230,13 +1226,13 @@ public final class TemplateEngine {
|
|||
List params = template.getParameterList();
|
||||
Map map = null;
|
||||
|
||||
Iterator pIter = params.iterator();
|
||||
Iterator aIter = ( args != null ) ? args.iterator() : null;
|
||||
while( pIter.hasNext() ){
|
||||
ISymbol param = (ISymbol) pIter.next();
|
||||
int numParams = params.size();
|
||||
int numArgs = ( args != null ) ? args.size() : 0;
|
||||
for( int i = 0; i < numParams; i++ ){
|
||||
ISymbol param = (ISymbol) params.get(i);
|
||||
TypeInfo arg = null;
|
||||
if( aIter != null && aIter.hasNext() ){
|
||||
arg = (TypeInfo) aIter.next();
|
||||
if( i < numArgs ){
|
||||
arg = (TypeInfo) args.get(i);
|
||||
} else {
|
||||
if( map == null ){
|
||||
map = deduceTemplateArgumentsUsingParameterList( template, fn );
|
||||
|
|
|
@ -512,23 +512,22 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
}
|
||||
|
||||
private ITemplateSymbol getNextAvailableTemplate() throws ParserSymbolTableException{
|
||||
Iterator tIter = templates.iterator();
|
||||
Iterator sIter = symbols.iterator();
|
||||
|
||||
while( sIter.hasNext() ){
|
||||
ISymbol symbol = (ISymbol) sIter.next();
|
||||
int numSymbols = symbols.size();
|
||||
int numTemplates = templates.size();
|
||||
int templateIdx = 0;
|
||||
for( int i = 0; i < numSymbols; i++ ){
|
||||
ISymbol symbol = (ISymbol) symbols.get(i);
|
||||
if( symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
|
||||
if( tIter.hasNext() )
|
||||
tIter.next();
|
||||
if( templateIdx < numTemplates )
|
||||
templateIdx++;
|
||||
else
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( !tIter.hasNext() )
|
||||
if( templateIdx >= numTemplates )
|
||||
return null;
|
||||
return (ITemplateSymbol) tIter.next();
|
||||
return (ITemplateSymbol) templates.get( templateIdx );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -76,18 +76,15 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
|
||||
List paramList = template.getParameterList();
|
||||
int numParams = ( paramList != null ) ? paramList.size() : 0;
|
||||
int numArgs = arguments.size();
|
||||
|
||||
if( numParams == 0 ){
|
||||
return null;
|
||||
}
|
||||
|
||||
HashMap map = new HashMap();
|
||||
Iterator paramIter = paramList.iterator();
|
||||
Iterator argIter = arguments.iterator();
|
||||
|
||||
ISymbol param = null;
|
||||
TypeInfo arg = null;
|
||||
|
||||
List actualArgs = new ArrayList( numParams );
|
||||
|
||||
ISymbol templatedSymbol = template.getTemplatedSymbol();
|
||||
|
@ -96,12 +93,12 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
}
|
||||
|
||||
for( int i = 0; i < numParams; i++ ){
|
||||
param = (ISymbol) paramIter.next();
|
||||
param = (ISymbol) paramList.get(i);
|
||||
|
||||
param = TemplateEngine.translateParameterForDefinition ( templatedSymbol, param, getDefinitionParameterMap() );
|
||||
|
||||
if( argIter.hasNext() ){
|
||||
arg = (TypeInfo) argIter.next();
|
||||
if( i < numArgs ){
|
||||
arg = (TypeInfo) arguments.get(i);
|
||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||
if( arg.isType( TypeInfo.t_type ) ){
|
||||
if( arg.getTypeSymbol() == null )
|
||||
|
@ -166,10 +163,11 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
|||
TemplateSymbol newTemplate = (TemplateSymbol) super.instantiate( template, argMap );
|
||||
|
||||
//we don't want to instantiate the template parameters, just the defaults if there are any
|
||||
Iterator iter = newTemplate.getParameterList().iterator();
|
||||
List parameters = newTemplate.getParameterList();
|
||||
int size = parameters.size();
|
||||
ISymbol param = null;
|
||||
while( iter.hasNext() ){
|
||||
param = (ISymbol) iter.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
param = (ISymbol) parameters.get(i);
|
||||
Object obj = param.getTypeInfo().getDefault();
|
||||
if( obj instanceof TypeInfo ){
|
||||
param.getTypeInfo().setDefault( TemplateEngine.instantiateTypeInfo( (TypeInfo) obj, template, argMap ) );
|
||||
|
|
|
@ -330,15 +330,13 @@ public class TypeInfo {
|
|||
public boolean hasSamePtrs( TypeInfo type ){
|
||||
int size = getPtrOperators().size();
|
||||
int size2 = type.getPtrOperators().size();
|
||||
Iterator iter1 = getPtrOperators().iterator();
|
||||
Iterator iter2 = type.getPtrOperators().iterator();
|
||||
TypeInfo.PtrOp ptr1 = null, ptr2 = null;
|
||||
|
||||
if( size == size2 ){
|
||||
if( size > 0 ){
|
||||
for( int i = size; i > 0; i-- ){
|
||||
ptr1 = (TypeInfo.PtrOp)iter1.next();
|
||||
ptr2 = (TypeInfo.PtrOp)iter2.next();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
ptr1 = (TypeInfo.PtrOp)getPtrOperators().get(i);
|
||||
ptr2 = (TypeInfo.PtrOp)type.getPtrOperators().get(i);
|
||||
if( ptr1.getType() != ptr2.getType() ){
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue