1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

52120 - Document ParserSymbolTableException

Comments added to the ISymbol interfaces to indicate which
exception reasons are thrown by which function
This commit is contained in:
Andrew Niefer 2004-02-16 20:58:22 +00:00
parent c1a246da20
commit 8cf9302004
8 changed files with 1265 additions and 1126 deletions

File diff suppressed because it is too large Load diff

View file

@ -29,7 +29,6 @@ import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
@ -2622,12 +2621,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
throw new ASTSemanticException();
}
} else if( isFriend ){
try {
((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
} catch (ParserSymbolTableException e1) {
throw new ASTSemanticException();
}
((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
}
}

View file

@ -173,7 +173,12 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
TypeInfo param = new TypeInfo( TypeInfo.t_type, TypeInfo.isConst, this, new TypeInfo.PtrOp( TypeInfo.PtrOp.t_reference, false, false ), false );
parameters.add( param );
IParameterizedSymbol constructor = lookupConstructor( parameters );
IParameterizedSymbol constructor = null;
try{
constructor = lookupConstructor( parameters );
} catch ( ParserSymbolTableException e ){
}
if( constructor == null ){
constructor = getSymbolTable().newParameterizedSymbol( getName(), TypeInfo.t_constructor );
@ -280,7 +285,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
* TODO: if/when the parser symbol table starts caring about visibility
* (public/protected/private) we will need to do more to record friendship.
*/
public void addFriend( ISymbol friend ) throws ParserSymbolTableException{
public void addFriend( ISymbol friend ){
//is this symbol already in the table?
IContainerSymbol containing = friend.getContainingSymbol();
if( containing == null ){
@ -292,7 +297,10 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
friend.setIsInvisible( true );
friend.setIsForwardDeclaration( true );
enclosing.addSymbol( friend );
try {
enclosing.addSymbol( friend );
} catch (ParserSymbolTableException e) {
}
}
getFriends().add( friend );

View file

@ -26,19 +26,73 @@ import java.util.Map;
*/
public interface IContainerSymbol extends ISymbol {
/**
* Add a symbol to this container
* @param symbol
* @throws ParserSymbolTableException
* Reason : r_BadTemplate if (14-2) the symbol is a template declaration is outside a namespace or class scope
* or if (14.5.2-3) the symbol is a member function template and is virtual
* r_RedeclaredTemplateParam if (14.6.1-4) a template parameter is redeclared in its scope
* r_InvalidOverload if there already exists a symbol with the same name and the new symbol does not
* hide the first symbol (3.3.7) or is not a valid function overload (3.4-1)
*/
public void addSymbol( ISymbol symbol ) throws ParserSymbolTableException;
public boolean hasUsingDirectives();
public List getUsingDirectives();
/**
* Add a using directive to this symbol
* @param namespace
* @return
* @throws ParserSymbolTableException
* Reason: r_InvalidUsing if (7.3.4) the using directive appears in class scope
* or if the symbol being added is not a namespace
*/
public IUsingDirectiveSymbol addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException;
/**
* Add a using declaration to this symbol
* @param name
* @return
* @throws ParserSymbolTableException
* Reason: r_InvalidUsing if (7.3.3-5) the name is a template-id
* or if (7.3.3-4) this using declaration is a member declaration and the name is not a
* member of a base class, or an anonymous union that is a member of a base class, or
* an enumerator for an enumeration which is a member of a base class
* or if the name specified can not be found
* r_Ambiguous if more than one symbol with the given name is found and we can't resolve which one to use
* r_BadTypeInfo if during lookup of the name, we come across a class inheriting from a symbol which is not an
* IDerivableContainerSymbol
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
*/
public ISymbol addUsingDeclaration( String name ) throws ParserSymbolTableException;
public ISymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException;
public Map getContainedSymbols();
/**
* Lookup symbols matching the given prefix
* @param filter
* @param prefix
* @param qualified
* @return
* @throws ParserSymbolTableException
* Reason: r_BadTypeInfo if during lookup, we come across a class inheriting from a symbol which is not an
* IDerivableContainerSymbol
* r_CircularInheritance if during lookup, we come across a class with a circular inheritance tree
*/
public List prefixLookup( TypeFilter filter, String prefix, boolean qualified ) throws ParserSymbolTableException;
/**
* Lookups
* @throws ParserSymbolTableException
* Reason: r_Ambiguous if more than one symbol with the given name is found and we can't resolve which one to use
* r_UnableToResolveFunction if an overloaded function is found and no parameter information has been provided
* r_BadTypeInfo if during lookup of the name, we come across a class inheriting from a symbol which is not an
* IDerivableContainerSymbol
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
*/
public ISymbol elaboratedLookup( TypeInfo.eType type, String name ) throws ParserSymbolTableException;
public ISymbol lookup( String name ) throws ParserSymbolTableException;
public ISymbol lookupMemberForDefinition( String name ) throws ParserSymbolTableException;
@ -50,8 +104,29 @@ public interface IContainerSymbol extends ISymbol {
public IParameterizedSymbol memberFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
public IParameterizedSymbol qualifiedFunctionLookup( String name, List parameters ) throws ParserSymbolTableException;
/**
*
* @param name
* @param arguments
* @return
* @throws ParserSymbolTableException
* In addition to the above lookup reasons, the following also can happen in lookupTemplate
* r_Ambiguous if (14.5.4.1) more than one specialization can be used and none is more specializaed than all the others
* r_BadTemplateArgument if (14.3.1, 14.3.2) a template argument is invalid
*/
public ISymbol lookupTemplate( String name, List arguments ) throws ParserSymbolTableException;
/**
*
* @param name
* @param templateParameters
* @param templateArguments
* @return
* @throws ParserSymbolTableException
* In addition to the Exception thrown in lookup functions, and lookupTemplate, lookupTemplateForMemberDefinition can also throw:
* r_BadTemplateParameter if (14.5.1-3) the parameters provided can't be matched up to a template declaration
* r_BadTemplate if the parameter and argument list can't be resolved to either the template or a specialization
*/
public ITemplateFactory lookupTemplateForMemberDefinition( String name, List templateParameters,
List templateArguments ) throws ParserSymbolTableException;

View file

@ -33,12 +33,40 @@ public interface IDerivableContainerSymbol extends IContainerSymbol {
public List getParents();
public boolean hasParents();
/**
*
* @param constructor
* @throws ParserSymbolTableException
* Reason:
* r_BadTypeInfo if the symbol being added is not of type TypeInfo.t_constructor
* r_InvalidOverload if the constructor being added is not a valid overload of existing constructors
*/
public void addConstructor( IParameterizedSymbol constructor ) throws ParserSymbolTableException;
public void addCopyConstructor() throws ParserSymbolTableException;
/**
*
* @param parameters
* @return
* @throws ParserSymbolTableException
* Reason:
* r_Ambiguous if more than one constructor can be used with the given parameters
*/
public IParameterizedSymbol lookupConstructor( List parameters ) throws ParserSymbolTableException;
public List getConstructors();
public void addFriend( ISymbol friend ) throws ParserSymbolTableException;
public void addFriend( ISymbol friend );
/**
* Lookups
* @throws ParserSymbolTableException
* Reason: r_Ambiguous if more than one symbol with the given name is found and we can't resolve which one to use
* r_UnableToResolveFunction if an overloaded function is found and no parameter information has been provided
* r_BadTypeInfo if during lookup of the name, we come across a class inheriting from a symbol which is not an
* IDerivableContainerSymbol
* r_CircularInheritance if during lookup of the name, we come across a class with a circular inheritance tree
*/
public ISymbol lookupForFriendship( String name ) throws ParserSymbolTableException;
public IParameterizedSymbol lookupFunctionForFriendship( String name, List parameters ) throws ParserSymbolTableException;

View file

@ -20,7 +20,17 @@ import java.util.Map;
public interface ISymbol extends Cloneable, IExtensibleSymbol {
public Object clone();
/**
*
* @param args
* @return
* @throws ParserSymbolTableException
* Exceptions can be thrown when a IDeferredTemplateInstance must be instantiated
* Reason:
* 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 void setName(String name);

View file

@ -19,6 +19,15 @@ import java.util.Map;
public interface ITemplateSymbol extends IParameterizedSymbol {
/**
*
* @param param
* @throws ParserSymbolTableException
* Reason:
* r_BadTemplateParameter if the Parameter does not have type TypeInfo.t_templateParameter
* or if the parameter has the same name as the template
* or if the parameter is a non-type parameter and does not have a valid type (14.1-4, 14.1-7)
*/
public void addTemplateParameter( ISymbol param ) throws ParserSymbolTableException;
public boolean hasSpecializations();
@ -34,7 +43,18 @@ public interface ITemplateSymbol extends IParameterizedSymbol {
public List findArgumentsFor( IContainerSymbol instance );
public void addInstantiation( IContainerSymbol instance, List args );
public ISymbol instantiate( List args ) throws ParserSymbolTableException;
/**
*
* @param args
* @return
* @throws ParserSymbolTableException
* Reason:
* 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( List args ) throws ParserSymbolTableException;
public IDeferredTemplateInstance deferredInstance( List args );
}

View file

@ -731,7 +731,7 @@ public final class TemplateEngine {
IContainerSymbol templatedSymbol = spec1.getTemplatedSymbol();
if( !( templatedSymbol instanceof IParameterizedSymbol ) )
throw new ParserSymbolTableException( ParserSymbolTableException.r_InternalError );
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
IParameterizedSymbol function = (IParameterizedSymbol)templatedSymbol;
function = (IParameterizedSymbol) function.instantiate( spec1, map );
@ -742,7 +742,7 @@ public final class TemplateEngine {
templatedSymbol = spec2.getTemplatedSymbol();
if( !( templatedSymbol instanceof IParameterizedSymbol ) )
throw new ParserSymbolTableException( ParserSymbolTableException.r_InternalError );
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
function = (IParameterizedSymbol)templatedSymbol;
function = (IParameterizedSymbol) function.instantiate( spec2, map );