1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Switch PST templates to use ObjectMap instead of HashMap

Remove use of Stack in the parser (replaced where necessary with custom
implementation)
This commit is contained in:
Andrew Niefer 2004-08-03 21:21:11 +00:00
parent c6c90a1e95
commit d4261f7fc8
15 changed files with 205 additions and 193 deletions

View file

@ -11,9 +11,7 @@
package org.eclipse.cdt.internal.core.parser;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
import org.eclipse.cdt.core.parser.BacktrackException;
import org.eclipse.cdt.core.parser.EndOfFileException;
@ -81,9 +79,42 @@ public class ExpressionParser implements IExpressionParser, IParserData {
protected IToken currToken;
protected IToken lastToken;
private boolean limitReached = false;
private Stack templateIdScopes = null;
private ScopeStack templateIdScopes = new ScopeStack();
private TypeId typeIdInstance = new TypeId();
private static class ScopeStack {
private int [] stack;
private int index = -1;
public ScopeStack(){
stack = new int [8];
}
private void grow(){
int [] newStack = new int[ stack.length << 1 ];
System.arraycopy( stack, 0, newStack, 0, stack.length );
stack = newStack;
}
final public void push( int i ){
if( ++index == stack.length )
grow();
stack[index] = i;
}
final public int pop(){
if( index >= 0 )
return stack[index--];
return -1;
}
final public int peek(){
if( index >= 0 )
return stack[index];
return -1;
}
final public int size(){
return index + 1;
}
}
/**
* @return Returns the astFactory.
*/
@ -252,23 +283,23 @@ public class ExpressionParser implements IExpressionParser, IParserData {
if (LT(1) == IToken.tLT) {
last = consume(IToken.tLT);
// until we get all the names sorted out
Stack scopes = new Stack();
scopes.push(new Integer(IToken.tLT));
ScopeStack scopes = new ScopeStack();
scopes.push(IToken.tLT);
while (!scopes.empty()) {
while (scopes.size() > 0) {
int top;
last = consume();
switch (last.getType()) {
case IToken.tGT :
if (((Integer) scopes.peek()).intValue() == IToken.tLT) {
if (scopes.peek() == IToken.tLT) {
scopes.pop();
}
break;
case IToken.tRBRACKET :
do {
top = ((Integer) scopes.pop()).intValue();
} while (!scopes.empty()
top = scopes.pop();
} while (scopes.size() > 0
&& (top == IToken.tGT || top == IToken.tLT));
if (top != IToken.tLBRACKET)
throwBacktrack(startingOffset, last.getEndOffset(), last.getLineNumber(), last.getFilename());
@ -276,8 +307,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
break;
case IToken.tRPAREN :
do {
top = ((Integer) scopes.pop()).intValue();
} while (!scopes.empty()
top = scopes.pop();
} while (scopes.size() > 0
&& (top == IToken.tGT || top == IToken.tLT));
if (top != IToken.tLPAREN)
throwBacktrack(startingOffset, last.getEndOffset(), last.getLineNumber(), last.getFilename());
@ -286,7 +317,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
case IToken.tLT :
case IToken.tLBRACKET :
case IToken.tLPAREN :
scopes.push(new Integer(last.getType()));
scopes.push(last.getType());
break;
}
}
@ -308,10 +339,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
boolean completedArg = false;
boolean failed = false;
if (templateIdScopes == null) {
templateIdScopes = new Stack();
}
templateIdScopes.push(new Integer(IToken.tLT));
templateIdScopes.push( IToken.tLT );
while (LT(1) != IToken.tGT) {
completedArg = false;
@ -381,9 +409,6 @@ public class ExpressionParser implements IExpressionParser, IParserData {
}
templateIdScopes.pop();
if (templateIdScopes.size() == 0) {
templateIdScopes = null;
}
if (failed) {
if (expression != null)
@ -1214,8 +1239,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
for (;;) {
switch (LT(1)) {
case IToken.tGT :
if (templateIdScopes != null
&& ((Integer) templateIdScopes.peek()).intValue() == IToken.tLT) {
if (templateIdScopes.size() > 0 && templateIdScopes.peek() == IToken.tLT) {
return firstExpression;
}
case IToken.tLT :
@ -1465,8 +1489,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
char [] fn = la.getFilename();
IToken mark = mark();
consume();
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push( IToken.tLPAREN );
}
boolean popped = false;
IASTTypeId typeId = null;
@ -1482,7 +1506,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
throw bte;
}
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
popped = true;
}
@ -1507,7 +1531,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
throwBacktrack(startingOffset, endOffset, line, fn);
}
} catch (BacktrackException b) {
if (templateIdScopes != null && !popped) {
if (templateIdScopes.size() > 0 && !popped) {
templateIdScopes.pop();
}
}
@ -1818,8 +1842,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
if (LT(1) == IToken.tLPAREN) {
consume(IToken.tLPAREN);
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
}
try {
// Try to consume placement list
@ -1828,15 +1852,15 @@ public class ExpressionParser implements IExpressionParser, IParserData {
newPlacementExpressions.add(expression(scope,
CompletionKind.SINGLE_NAME_REFERENCE, key));
consume(IToken.tRPAREN);
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
} //pop 1st Parent
placementParseFailure = false;
if (LT(1) == IToken.tLPAREN) {
beforeSecondParen = mark();
consume(IToken.tLPAREN);
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
} //push 2nd Paren
typeIdInParen = true;
}
@ -1849,7 +1873,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
// - then it has to be typeId
typeId = typeId(scope, true, CompletionKind.NEW_TYPE_REFERENCE);
consume(IToken.tRPAREN);
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
} //pop 1st Paren
} else {
@ -1885,7 +1909,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
typeId = typeId(scope, true,
CompletionKind.NEW_TYPE_REFERENCE);
consume(IToken.tRPAREN);
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
} //popping the 2nd Paren
@ -1925,7 +1949,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
// CASE: new (typeid-looking-as-placement)(initializer-not-looking-as-typeid)
// Fallback to initializer processing
backup(beforeSecondParen);
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}//pop that 2nd paren
}
@ -1941,15 +1965,15 @@ public class ExpressionParser implements IExpressionParser, IParserData {
// array new
consume();
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLBRACKET));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLBRACKET);
}
newTypeIdExpressions.add(assignmentExpression(scope,
CompletionKind.SINGLE_NAME_REFERENCE, key));
consume(IToken.tRBRACKET);
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
}
@ -1959,8 +1983,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
setCurrentFunctionName(((typeId != null) ? typeId
.getFullSignatureCharArray() : EMPTY_STRING));
setCompletionValues(scope, CompletionKind.CONSTRUCTOR_REFERENCE);
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
}
//we want to know the difference between no newInitializer and an empty new Initializer
@ -1970,7 +1994,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
setCurrentFunctionName(EMPTY_STRING);
consume(IToken.tRPAREN);
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
}
@ -2142,13 +2166,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
CompletionKind.TYPE_REFERENCE, KeywordSetKey.EMPTY);
consume(IToken.tLPAREN);
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
}
IASTExpression expressionList = expression(scope,
CompletionKind.TYPE_REFERENCE, key);
int endOffset = consume(IToken.tRPAREN).getEndOffset();
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
@ -2228,8 +2252,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
case IToken.t_typeid :
consume();
consume(IToken.tLPAREN);
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
}
boolean isTypeId = true;
IASTExpression lhs = null;
@ -2241,7 +2265,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
lhs = expression(scope, CompletionKind.TYPE_REFERENCE, key);
}
endOffset = consume(IToken.tRPAREN).getEndOffset();
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
try {
@ -2269,13 +2293,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
case IToken.tLBRACKET :
// array access
consume(IToken.tLBRACKET);
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLBRACKET));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLBRACKET);
}
secondExpression = expression(scope,
CompletionKind.SINGLE_NAME_REFERENCE, key);
int endOffset = consume(IToken.tRBRACKET).getEndOffset();
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
try {
@ -2310,8 +2334,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
}
}
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
}
setCompletionValues(scope,
CompletionKind.FUNCTION_REFERENCE, context);
@ -2319,7 +2343,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
CompletionKind.FUNCTION_REFERENCE, key);
setCurrentFunctionName(EMPTY_STRING);
endOffset = consume(IToken.tRPAREN).getEndOffset();
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
try {
@ -2589,12 +2613,12 @@ public class ExpressionParser implements IExpressionParser, IParserData {
}
case IToken.tLPAREN :
t = consume();
if (templateIdScopes != null) {
templateIdScopes.push(new Integer(IToken.tLPAREN));
if (templateIdScopes.size() > 0) {
templateIdScopes.push(IToken.tLPAREN);
}
IASTExpression lhs = expression(scope, kind, key);
int endOffset = consume(IToken.tRPAREN).getEndOffset();
if (templateIdScopes != null) {
if (templateIdScopes.size() > 0) {
templateIdScopes.pop();
}
try {

View file

@ -10,7 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast;
import java.util.Stack;
import java.util.ArrayList;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
@ -31,16 +31,16 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
*/
public ASTQualifiedNamedElement(IASTScope scope, char[] name )
{
Stack names = new Stack();
ArrayList names = new ArrayList(4);
IASTScope parent = scope;
names.push( name ); // push on our own name
names.add( name ); // push on our own name
while (parent != null)
{
if (parent instanceof IASTNamespaceDefinition
|| parent instanceof IASTClassSpecifier )
{
names.push(((IASTOffsetableNamedElement)parent).getNameCharArray());
names.add( ((IASTOffsetableNamedElement)parent).getNameCharArray() );
if( parent instanceof IASTScopedElement )
parent = ((IASTScopedElement)parent).getOwnerScope();
}
@ -57,8 +57,8 @@ public class ASTQualifiedNamedElement implements IASTQualifiedNameElement
{
qualifiedNames = new char[names.size()][];
int counter = 0;
while (!names.empty())
qualifiedNames[counter++] = (char[])names.pop();
for( int i = names.size() - 1; i >= 0; i-- )
qualifiedNames[counter++] = (char[])names.get(i);
}
else
qualifiedNames = null;

View file

@ -14,7 +14,8 @@
package org.eclipse.cdt.internal.core.parser.pst;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
public class BasicSymbol extends ExtensibleSymbol implements ISymbol
{
@ -31,7 +32,7 @@ public class BasicSymbol extends ExtensibleSymbol implements ISymbol
_typeInfo = TypeInfoProvider.newTypeInfo( typeInfo );
}
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
if( !isTemplateMember() && !getContainingSymbol().isTemplateMember() ){
return null;
}

View file

@ -18,10 +18,8 @@ import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.eclipse.cdt.core.parser.ParserLanguage;
@ -29,10 +27,11 @@ 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.LookupData;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArraySet;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
/**
* @author aniefer
@ -60,7 +59,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
return copy;
}
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
if( !isTemplateMember() || template == null ){
return null;
}
@ -107,15 +106,14 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
}
}
Map instanceMap = argMap;
ObjectMap instanceMap = argMap;
if( !template.getDefinitionParameterMap().isEmpty() &&
template.getDefinitionParameterMap().containsKey( containedSymbol ) )
{
Map defMap = (Map) template.getDefinitionParameterMap().get( containedSymbol );
instanceMap = new HashMap();
Iterator i = defMap.keySet().iterator();
while( i.hasNext() ){
ISymbol p = (ISymbol) i.next();
ObjectMap defMap = (ObjectMap) template.getDefinitionParameterMap().get( containedSymbol );
instanceMap = new ObjectMap(defMap.size());
for( int i = 0; i < defMap.size(); i++ ){
ISymbol p = (ISymbol) defMap.keyAt(i);
instanceMap.put( p, argMap.get( defMap.get( p ) ) );
}
}

View file

@ -12,7 +12,8 @@ package org.eclipse.cdt.internal.core.parser.pst;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefer
@ -47,7 +48,7 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
return _arguments;
}
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
List args = getArguments();
List newArgs = new ArrayList( args.size() );
int size = args.size();

View file

@ -17,12 +17,12 @@ package org.eclipse.cdt.internal.core.parser.pst;
import java.util.ArrayList;
import java.util.Collections;
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.LookupData;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefer
@ -51,7 +51,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
return copy;
}
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
if( !isTemplateMember() ){
return null;
}
@ -82,7 +82,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
return newSymbol;
}
public void instantiateDeferredParent( ISymbol parent, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public void instantiateDeferredParent( ISymbol parent, ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
List parents = getParents();
int size = parents.size();
ParentWrapper w = null;
@ -99,7 +99,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
* @param symbol2
* @param map
*/
public void discardDeferredParent(IDeferredTemplateInstance parent, ITemplateSymbol template, Map map) {
public void discardDeferredParent(IDeferredTemplateInstance parent, ITemplateSymbol template, ObjectMap map) {
List parents = getParents();
int size = parents.size();
ParentWrapper w = null;

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.internal.core.parser.pst;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author jcamelon
@ -31,7 +32,7 @@ public interface ISymbol extends Cloneable, IExtensibleSymbol {
* r_BadTemplateArgument if an argument does not match the corresponding parameter type
* r_Ambiguous if more than one specialization can be used but none is more specialized than all the others
*/
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException;
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException;
public void setName(char[] name);
public char[] getName();

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.internal.core.parser.pst;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefer
@ -36,7 +37,7 @@ public interface ITemplateSymbol extends IParameterizedSymbol {
public IContainerSymbol getTemplatedSymbol();
public Map getDefinitionParameterMap();
public ObjectMap getDefinitionParameterMap();
public IContainerSymbol findInstantiation( List arguments );
public List findArgumentsFor( IContainerSymbol instance );
@ -59,14 +60,14 @@ public interface ITemplateSymbol extends IParameterizedSymbol {
public IDeferredTemplateInstance deferredInstance( List args );
public Map getExplicitSpecializations();
public ObjectMap getExplicitSpecializations();
/**
* @param symbol
* @param type
* @param kind
*/
public void registerDeferredInstatiation( Object obj0, Object obj1, DeferredKind kind, Map argMap );
public void registerDeferredInstatiation( Object obj0, Object obj1, DeferredKind kind, ObjectMap argMap );
public int getNumberDeferredInstantiations();
public static class DeferredKind{

View file

@ -16,9 +16,9 @@ package org.eclipse.cdt.internal.core.parser.pst;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefer
@ -45,7 +45,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
return copy;
}
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
if( !isTemplateMember() ){
return null;
}
@ -88,7 +88,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
return newParameterized;
}
public void instantiateDeferredReturnType( ISymbol returnType, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public void instantiateDeferredReturnType( ISymbol returnType, ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
setReturnType( returnType.instantiate( template, argMap ) );
}
@ -97,7 +97,7 @@ public class ParameterizedSymbol extends ContainerSymbol implements IParameteriz
* @param symbol2
* @param map
*/
public void discardDeferredReturnType(ISymbol oldReturnType, TemplateSymbol template, Map map) {
public void discardDeferredReturnType(ISymbol oldReturnType, TemplateSymbol template, ObjectMap map) {
ISymbol returnType = getReturnType();
setReturnType( null );
template.removeInstantiation( (IContainerSymbol) returnType );

View file

@ -15,10 +15,8 @@ package org.eclipse.cdt.internal.core.parser.pst;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
@ -26,11 +24,11 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.IASTMember;
import org.eclipse.cdt.core.parser.ast.IASTNode;
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArraySet;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
/**
* @author aniefer
@ -382,16 +380,14 @@ public class ParserSymbolTable {
*/
private static CharArrayObjectMap lookupInParameters(LookupData data, IContainerSymbol lookIn, CharArrayObjectMap found) throws ParserSymbolTableException {
Object obj;
Iterator iterator;
char[] name;
if( lookIn instanceof ITemplateSymbol && !((ITemplateSymbol)lookIn).getDefinitionParameterMap().isEmpty() ){
ITemplateSymbol template = (ITemplateSymbol) lookIn;
if( data.templateMember != null && template.getDefinitionParameterMap().containsKey( data.templateMember ) ){
Map map = (Map) template.getDefinitionParameterMap().get( data.templateMember );
iterator = map.keySet().iterator();
while( iterator.hasNext() ){
ISymbol symbol = (ISymbol) iterator.next();
ObjectMap map = (ObjectMap) template.getDefinitionParameterMap().get( data.templateMember );
for( int i = 0; i < map.size(); i++ ){
ISymbol symbol = (ISymbol) map.keyAt(i);
if( nameMatches( data, symbol.getName() ) ){
obj = collectSymbol( data, symbol );
if( obj != null ){

View file

@ -15,9 +15,9 @@ package org.eclipse.cdt.internal.core.parser.pst;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefe
@ -46,14 +46,13 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
}
public ISymbol instantiate( List arguments ) throws ParserSymbolTableException{
Map argMap = new HashMap();
List specArgs = getArgumentList();
if( specArgs.size() != arguments.size() ){
return null;
}
List actualArgs = new ArrayList( specArgs.size() );
ObjectMap argMap = new ObjectMap( specArgs.size() );
ISymbol templatedSymbol = getTemplatedSymbol();
while( templatedSymbol.isTemplateInstance() ){

View file

@ -11,16 +11,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.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Cost;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
/**
@ -28,7 +25,7 @@ import org.eclipse.cdt.internal.core.parser.scanner2.ObjectSet;
*/
public final class TemplateEngine {
static protected ITypeInfo instantiateTypeInfo( ITypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
static protected ITypeInfo instantiateTypeInfo( ITypeInfo info, ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
if( argMap == null )
return info;
@ -66,7 +63,7 @@ public final class TemplateEngine {
}
static protected void instantiateDeferredTypeInfo( ITypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException {
static protected void instantiateDeferredTypeInfo( ITypeInfo info, ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException {
info.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
}
@ -75,7 +72,7 @@ public final class TemplateEngine {
* @param symbol
* @param map
*/
public static void discardDeferredTypeInfo(ITypeInfo info, TemplateSymbol template, Map map) {
public static void discardDeferredTypeInfo(ITypeInfo info, TemplateSymbol template, ObjectMap map) {
ISymbol instance = info.getTypeSymbol();
if( !(instance instanceof IDeferredTemplateInstance ) )
template.removeInstantiation( (IContainerSymbol) instance );
@ -105,7 +102,7 @@ public final class TemplateEngine {
}
int specArgsSize = specArgs.size();
HashMap map = new HashMap();
ObjectMap map = new ObjectMap(specArgsSize);
ITypeInfo info1 = null, info2 = null;
boolean match = true;
@ -444,7 +441,7 @@ public final class TemplateEngine {
return aSymbol;
}
static private boolean deduceTemplateArgument( Map map, ISymbol pSymbol, ITypeInfo a ) throws ParserSymbolTableException{
static private boolean deduceTemplateArgument( ObjectMap map, ISymbol pSymbol, ITypeInfo a ) throws ParserSymbolTableException{
ISymbol symbol;
boolean pIsAReferenceType = false;
@ -590,7 +587,7 @@ public final class TemplateEngine {
* @param aSymbol
* @return
*/
private static boolean deduceFromTemplateTemplateArguments(Map map, ISymbol pSymbol, ISymbol aSymbol) {
private static boolean deduceFromTemplateTemplateArguments(ObjectMap map, ISymbol pSymbol, ISymbol aSymbol) {
//template-name<T> or template-name<i>, where template-name is a class template
ITemplateSymbol p = ( pSymbol instanceof IDeferredTemplateInstance ) ?
(ITemplateSymbol) ((IDeferredTemplateInstance) pSymbol ).getTemplate() :
@ -658,7 +655,7 @@ public final class TemplateEngine {
* type (A), and an attempt is made to find template argument vaules that will make P,
* after substitution of the deduced values, compatible with A.
*/
static private Map deduceTemplateArgumentsUsingParameterList( ITemplateSymbol template, IParameterizedSymbol function ){
static private ObjectMap deduceTemplateArgumentsUsingParameterList( ITemplateSymbol template, IParameterizedSymbol function ){
List aList = function.getParameterList();
int size = aList.size();
@ -681,8 +678,8 @@ public final class TemplateEngine {
* type (A), and an attempt is made to find template argument vaules that will make P,
* after substitution of the deduced values, compatible with A.
*/
static private Map deduceTemplateArguments( ITemplateSymbol template, List arguments ){
if( template.getContainedSymbols() == Collections.EMPTY_MAP || template.getContainedSymbols().size() != 1 ){
static private ObjectMap deduceTemplateArguments( ITemplateSymbol template, List arguments ){
if( template.getContainedSymbols() == CharArrayObjectMap.EMPTY_MAP || template.getContainedSymbols().size() != 1 ){
return null;
}
@ -699,9 +696,8 @@ public final class TemplateEngine {
return null;
}
HashMap map = new HashMap();
int size = pList.size();
ObjectMap map = new ObjectMap(size);
for( int i = 0; i < size; i++ ){
try {
if( !deduceTemplateArgument( map, (ISymbol) pList.get(i), (ITypeInfo) arguments.get(i) ) ){
@ -715,7 +711,7 @@ public final class TemplateEngine {
return map;
}
static private boolean deduceArgument( Map map, ISymbol p, ITypeInfo a ){
static private boolean deduceArgument( ObjectMap map, ISymbol p, ITypeInfo a ){
a = ParserSymbolTable.getFlatTypeInfo( a, null );
@ -762,7 +758,7 @@ public final class TemplateEngine {
static protected int orderTemplateFunctions( ITemplateSymbol spec1, ITemplateSymbol spec2 ) throws ParserSymbolTableException{
//Using the transformed parameter list, perform argument deduction against the other
//function template
Map map = createMapForFunctionTemplateOrdering( spec1 );
ObjectMap map = createMapForFunctionTemplateOrdering( spec1 );
IContainerSymbol templatedSymbol = spec1.getTemplatedSymbol();
if( !( templatedSymbol instanceof IParameterizedSymbol ) )
@ -772,7 +768,7 @@ public final class TemplateEngine {
function = (IParameterizedSymbol) function.instantiate( spec1, map );
((TemplateSymbol)spec1).processDeferredInstantiations();
Map m1 = deduceTemplateArgumentsUsingParameterList( spec2, function);
ObjectMap m1 = deduceTemplateArgumentsUsingParameterList( spec2, function);
map = createMapForFunctionTemplateOrdering( spec2 );
@ -784,7 +780,7 @@ public final class TemplateEngine {
function = (IParameterizedSymbol) function.instantiate( spec2, map );
((TemplateSymbol)spec2).processDeferredInstantiations();
Map m2 = deduceTemplateArgumentsUsingParameterList( spec1, function );
ObjectMap m2 = deduceTemplateArgumentsUsingParameterList( spec1, function );
//The transformed template is at least as specialized as the other iff the deduction
//succeeds and the deduced parameter types are an exact match
@ -814,11 +810,11 @@ public final class TemplateEngine {
* for each occurence of that parameter in the function parameter list
*/
static private Map createMapForFunctionTemplateOrdering( ITemplateSymbol template ){
HashMap map = new HashMap();
static private ObjectMap createMapForFunctionTemplateOrdering( ITemplateSymbol template ){
ITypeInfo val = null;
List paramList = template.getParameterList();
int size = paramList.size();
ObjectMap map = new ObjectMap(size);
for( int i = 0; i < size; i++ ){
ISymbol param = (ISymbol) paramList.get( i );
//template type parameter
@ -870,7 +866,7 @@ public final class TemplateEngine {
return transformed;
}
static private ITypeInfo transformTypeInfo( Object obj, Map argumentMap ){
static private ITypeInfo transformTypeInfo( Object obj, ObjectMap argumentMap ){
ITypeInfo info = null;
if( obj instanceof ISymbol ){
info = TypeInfoProvider.newTypeInfo( ITypeInfo.t_type, 0, (ISymbol) obj );
@ -908,7 +904,7 @@ public final class TemplateEngine {
IParameterizedSymbol fn = (IParameterizedSymbol) templates.keyAt( idx );
ITemplateSymbol template = (ITemplateSymbol) fn.getContainingSymbol();
Map map = deduceTemplateArguments( template, functionArguments );
ObjectMap map = deduceTemplateArguments( template, functionArguments );
if( map == null )
continue;
@ -1021,7 +1017,7 @@ public final class TemplateEngine {
return false;
}
Map m [] = { new HashMap(), new HashMap() };
ObjectMap m [] = { new ObjectMap(p1.size()), new ObjectMap(p1.size()) };
for( List list = p1; list != null; list = p2 ){
int size = list.size();
@ -1073,8 +1069,8 @@ public final class TemplateEngine {
return null;
}
static protected ISymbol translateParameterForDefinition ( ISymbol templatedSymbol, ISymbol param, Map defnMap ){
if( defnMap == Collections.EMPTY_MAP ){
static protected ISymbol translateParameterForDefinition ( ISymbol templatedSymbol, ISymbol param, ObjectMap defnMap ){
if( defnMap == ObjectMap.EMPTY_MAP || templatedSymbol == null ){
return param;
}
@ -1084,11 +1080,10 @@ public final class TemplateEngine {
}
if( defnMap.containsKey( templatedSymbol ) ){
Map map = (Map) defnMap.get( templatedSymbol );
ObjectMap map = (ObjectMap) defnMap.get( templatedSymbol );
Iterator i = map.keySet().iterator();
while( i.hasNext() ){
ISymbol key = (ISymbol) i.next();
for( int i = 0; i < map.size(); i++){
ISymbol key = (ISymbol) map.keyAt(i);
if( map.get( key ) == mappedParam ){
return key;
}
@ -1202,7 +1197,7 @@ public final class TemplateEngine {
if( template.getTemplatedSymbol() instanceof IParameterizedSymbol &&
symbol instanceof IParameterizedSymbol && CharArrayUtils.equals( template.getTemplatedSymbol().getName(), symbol.getName() ) )
{
Map map = deduceTemplateArgumentsUsingParameterList( template, (IParameterizedSymbol) symbol );
ObjectMap map = deduceTemplateArgumentsUsingParameterList( template, (IParameterizedSymbol) symbol );
if( map != null && map.containsKey( param ) ){
actualArgs.add( map.get( param ) );
} else {
@ -1214,25 +1209,23 @@ public final class TemplateEngine {
return actualArgs;
}
static protected ITemplateSymbol resolveTemplateFunctions( Set functions, List args, ISymbol symbol ) throws ParserSymbolTableException{
static protected ITemplateSymbol resolveTemplateFunctions( ObjectSet functions, List args, ISymbol symbol ) throws ParserSymbolTableException{
ITemplateSymbol template = null;
Iterator iter = functions.iterator();
outer: while( iter.hasNext() ){
IParameterizedSymbol fn = (IParameterizedSymbol) iter.next();
outer: for( int i = 0; i < functions.size(); i++ ){
IParameterizedSymbol fn = (IParameterizedSymbol) functions.keyAt(i);
ITemplateSymbol tmpl = (ITemplateSymbol) fn.getContainingSymbol();
Map map = deduceTemplateArgumentsUsingParameterList( tmpl, (IParameterizedSymbol) symbol );
ObjectMap map = deduceTemplateArgumentsUsingParameterList( tmpl, (IParameterizedSymbol) symbol );
if( map == null )
continue;
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);
ITypeInfo arg = (ITypeInfo) args.get(i);
for( int j = 0; j < numParams && j < numArgs; j++ ){
ISymbol param = (ISymbol) params.get(j);
ITypeInfo arg = (ITypeInfo) args.get(j);
if( map.containsKey( param ) ) {
if( !map.get( param ).equals( arg )){
continue outer;
@ -1256,7 +1249,7 @@ public final class TemplateEngine {
List resultList = new ArrayList();
List params = template.getParameterList();
Map map = null;
ObjectMap map = null;
int numParams = params.size();
int numArgs = ( args != null ) ? args.size() : 0;
@ -1288,13 +1281,13 @@ public final class TemplateEngine {
static protected ISymbol checkForTemplateExplicitSpecialization( ITemplateSymbol template, ISymbol symbol, List arguments ){
if( !template.getExplicitSpecializations().isEmpty() ){
//TODO: could optimize this if we had a TypeInfo.hashCode()
Iterator iter = template.getExplicitSpecializations().keySet().iterator();
ObjectMap specs = template.getExplicitSpecializations();
List args = null;
while( iter.hasNext() ){
args = (List) iter.next();
for( int i = 0; i < specs.size(); i++ ){
args = (List) specs.keyAt(i);
if( args.equals( arguments ) ){
Map explicitMap = (Map) template.getExplicitSpecializations().get( args );
ObjectMap explicitMap = (ObjectMap) template.getExplicitSpecializations().get( args );
if( explicitMap.containsKey( symbol ) ){
return (ISymbol) explicitMap.get( symbol );
}

View file

@ -11,16 +11,15 @@
package org.eclipse.cdt.internal.core.parser.pst;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateDeclaration;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateInstantiation;
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTemplateSpecialization;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefer
@ -31,7 +30,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
private ArrayList templates = new ArrayList(4);
private ArrayList symbols = new ArrayList(4);
private Map argMap = new HashMap();
private ObjectMap argMap = new ObjectMap(2);
protected TemplateFactory( ParserSymbolTable table ){
super( table );
@ -278,8 +277,6 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
int size = templates.size();
for( int i = 0; i < size; i++ ){
Map defnMap = new HashMap();
ITemplateSymbol template = (ITemplateSymbol) templates.get(i);
ITemplateSymbol origTemplate = (ITemplateSymbol) ((ISymbol)symbols.get(i)).getContainingSymbol();
@ -288,6 +285,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
int tListSize = tList.size();
if( oList.size() < tListSize )
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
ObjectMap defnMap = new ObjectMap(tListSize);
for( int j = 0; j < tListSize; j++ ){
ISymbol param = (ISymbol) tList.get(j);
ISymbol origParam = (ISymbol) oList.get(j);
@ -609,7 +607,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbol#instantiate(org.eclipse.cdt.internal.core.parser.pst.ITemplateSymbol, java.util.Map)
*/
public ISymbol instantiate(ITemplateSymbol template, Map argMapParm) {
public ISymbol instantiate(ITemplateSymbol template, ObjectMap argMapParm) {
return null;
}

View file

@ -12,12 +12,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.List;
import java.util.Map;
import org.eclipse.cdt.internal.core.parser.scanner2.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectMap;
/**
* @author aniefer
@ -34,8 +33,8 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
public Object clone(){
TemplateSymbol copy = (TemplateSymbol)super.clone();
copy._defnParameterMap = ( _defnParameterMap != Collections.EMPTY_MAP ) ? (Map)((HashMap) _defnParameterMap).clone() : _defnParameterMap;
copy._instantiations = ( _instantiations != Collections.EMPTY_MAP ) ? (Map)((HashMap) _instantiations).clone() : _instantiations;
copy._defnParameterMap = ( _defnParameterMap != ObjectMap.EMPTY_MAP ) ? (ObjectMap)_defnParameterMap.clone() : _defnParameterMap;
copy._instantiations = ( _instantiations != ObjectMap.EMPTY_MAP ) ? (ObjectMap)_instantiations.clone() : _instantiations;
return copy;
}
@ -78,7 +77,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
return null;
}
HashMap map = new HashMap();
ObjectMap map = new ObjectMap( numParams );
ISymbol param = null;
ITypeInfo arg = null;
List actualArgs = new ArrayList( numParams );
@ -159,7 +158,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
return instance;
}
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
public ISymbol instantiate( ITemplateSymbol template, ObjectMap argMap ) throws ParserSymbolTableException{
if( !isTemplateMember() ){
return null;
}
@ -260,15 +259,14 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
List actualArgs = TemplateEngine.verifyExplicitArguments( this, args, symbol );
if( _explicitSpecializations == Collections.EMPTY_MAP )
_explicitSpecializations = new HashMap();
if( _explicitSpecializations == ObjectMap.EMPTY_MAP )
_explicitSpecializations = new ObjectMap(2);
Map specs = null;
ObjectMap specs = null;
List key = null;
Iterator iter = _explicitSpecializations.keySet().iterator();
while( iter.hasNext() ){
List list = (List) iter.next();
for( int i = 0; i < _explicitSpecializations.size(); i++ ){
List list = (List) _explicitSpecializations.keyAt( i );
if( list.equals( args ) ){
key = list;
break;
@ -276,9 +274,9 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
}
if( key != null ){
specs = (Map) _explicitSpecializations.get( key );
specs = (ObjectMap) _explicitSpecializations.get( key );
} else {
specs = new HashMap();
specs = new ObjectMap(2);
_explicitSpecializations.put( new ArrayList( actualArgs ), specs );
}
@ -350,22 +348,22 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
public void addInstantiation( IContainerSymbol instance, List args ){
List key = new ArrayList( args );
if( _instantiations == Collections.EMPTY_MAP ){
_instantiations = new HashMap();
if( _instantiations == ObjectMap.EMPTY_MAP ){
_instantiations = new ObjectMap(2);
}
_instantiations.put( key, instance );
}
public IContainerSymbol findInstantiation( List arguments ){
if( _instantiations == Collections.EMPTY_MAP ){
if( _instantiations == ObjectMap.EMPTY_MAP ){
return null;
}
//TODO: we could optimize this by doing something other than a linear search.
Iterator iter = _instantiations.keySet().iterator();
int size = _instantiations.size();
List args = null;
while( iter.hasNext() ){
args = (List) iter.next();
for( int i = 0; i < size; i++ ){
args = (List) _instantiations.keyAt(i);
if( args.equals( arguments ) ){
return (IContainerSymbol) _instantiations.get( args );
@ -378,13 +376,13 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
if( instance == null || !instance.isTemplateInstance() )
return null;
ITemplateSymbol template = (ITemplateSymbol) instance.getInstantiatedSymbol().getContainingSymbol();
if( template != this )
return null;
// ITemplateSymbol template = (ITemplateSymbol) instance.getInstantiatedSymbol().getContainingSymbol();
// if( template != this )
// return null;
Iterator iter = _instantiations.keySet().iterator();
while( iter.hasNext() ){
List args = (List) iter.next();
int size = _instantiations.size();
for( int i = 0; i < size; i++){
List args = (List) _instantiations.keyAt( i );
if( _instantiations.get( args ) == instance ){
return args;
}
@ -400,13 +398,13 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
}
}
public Map getDefinitionParameterMap(){
public ObjectMap getDefinitionParameterMap(){
return _defnParameterMap;
}
protected void addToDefinitionParameterMap( ISymbol newSymbol, Map defnMap ){
if( _defnParameterMap == Collections.EMPTY_MAP )
_defnParameterMap = new HashMap();
protected void addToDefinitionParameterMap( ISymbol newSymbol, ObjectMap defnMap ){
if( _defnParameterMap == ObjectMap.EMPTY_MAP )
_defnParameterMap = new ObjectMap(2);
_defnParameterMap.put( newSymbol, defnMap );
}
@ -414,14 +412,14 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
return new DeferredTemplateInstance( getSymbolTable(), this, args );
}
public Map getExplicitSpecializations() {
public ObjectMap getExplicitSpecializations() {
return _explicitSpecializations;
}
/* (non-Javadoc)
* @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 ) {
public void registerDeferredInstatiation( Object obj0, Object obj1, DeferredKind kind, ObjectMap argMap ) {
if( _deferredInstantiations == Collections.EMPTY_LIST )
_deferredInstantiations = new ArrayList(8);
@ -451,12 +449,12 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
if( kind == DeferredKind.PARENT ){
DerivableContainerSymbol d = (DerivableContainerSymbol) objs[0];
d.instantiateDeferredParent( (ISymbol) objs[ 1 ], this, (Map) objs[3] );
d.instantiateDeferredParent( (ISymbol) objs[ 1 ], this, (ObjectMap) objs[3] );
} else if( kind == DeferredKind.RETURN_TYPE ){
ParameterizedSymbol p = (ParameterizedSymbol) objs[0];
p.instantiateDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] );
p.instantiateDeferredReturnType( (ISymbol) objs[1], this, (ObjectMap) objs[3] );
} else if( kind == DeferredKind.TYPE_SYMBOL ){
TemplateEngine.instantiateDeferredTypeInfo( (ITypeInfo) objs[0], this, (Map) objs[3] );
TemplateEngine.instantiateDeferredTypeInfo( (ITypeInfo) objs[0], this, (ObjectMap) objs[3] );
}
numProcessed++;
}
@ -479,21 +477,21 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
if( kind == DeferredKind.PARENT ){
DerivableContainerSymbol d = (DerivableContainerSymbol) objs[0];
d.discardDeferredParent( (IDeferredTemplateInstance) objs[1], this, (Map) objs[3] );
d.discardDeferredParent( (IDeferredTemplateInstance) objs[1], this, (ObjectMap) objs[3] );
} else if( kind == DeferredKind.RETURN_TYPE ){
ParameterizedSymbol p = (ParameterizedSymbol) objs[0];
p.discardDeferredReturnType( (ISymbol) objs[1], this, (Map) objs[3] );
p.discardDeferredReturnType( (ISymbol) objs[1], this, (ObjectMap) objs[3] );
} else if( kind == DeferredKind.TYPE_SYMBOL ){
TemplateEngine.discardDeferredTypeInfo( (ITypeInfo) objs[0], this, (Map) objs[3] );
TemplateEngine.discardDeferredTypeInfo( (ITypeInfo) objs[0], this, (ObjectMap) objs[3] );
}
}
_deferredInstantiations.clear();
}
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 ObjectMap _explicitSpecializations = ObjectMap.EMPTY_MAP; //explicit specializations
private ObjectMap _defnParameterMap = ObjectMap.EMPTY_MAP; //members could be defined with different template parameter names
private ObjectMap _instantiations = ObjectMap.EMPTY_MAP;
private List _deferredInstantiations = Collections.EMPTY_LIST; //used to avoid recursive loop
private boolean _processingDeferred = false;

View file

@ -84,6 +84,8 @@ public class ObjectMap extends HashTable{
}
final public Object remove( Object key ) {
if( key == null )
return null;
int i = lookup(key);
if (i < 0)
return null;