mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Debugging helpers.
This commit is contained in:
parent
97b34939ee
commit
237ac325a7
8 changed files with 50 additions and 37 deletions
|
@ -52,9 +52,18 @@ public class DebugUtil {
|
|||
className, caller.getMethodName(), caller.getFileName(), caller.getLineNumber());
|
||||
|
||||
if(extraMessage != null)
|
||||
message += ": " + extraMessage;//$NON-NLS-1$
|
||||
message += ": " + extraMessage; //$NON-NLS-1$
|
||||
|
||||
System.out.println(message);
|
||||
}
|
||||
|
||||
public static String safeClassName(Object obj) {
|
||||
return obj != null ? obj.getClass().getSimpleName() : ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static String toStringWithClass(Object obj) {
|
||||
return obj != null ?
|
||||
String.valueOf(obj) + " " + obj.getClass().getSimpleName() : //$NON-NLS-1$
|
||||
"null"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ public class CPPASTSimpleTypeTemplateParameter extends CPPASTNode implements
|
|||
private IASTName name;
|
||||
private IASTTypeId typeId;
|
||||
|
||||
|
||||
public CPPASTSimpleTypeTemplateParameter() {
|
||||
}
|
||||
|
||||
|
@ -70,22 +69,22 @@ public class CPPASTSimpleTypeTemplateParameter extends CPPASTNode implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) {
|
||||
switch( ((ICPPASTVisitor)action).visit( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
switch (((ICPPASTVisitor) action).visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if( name != null ) if( !name.accept( action ) ) return false;
|
||||
if( typeId != null ) if( !typeId.accept( action ) ) return false;
|
||||
if (name != null) if (!name.accept(action)) return false;
|
||||
if (typeId != null) if (!typeId.accept(action)) return false;
|
||||
|
||||
if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) {
|
||||
switch( ((ICPPASTVisitor)action).leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
switch (((ICPPASTVisitor) action).leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
@ -93,8 +92,13 @@ public class CPPASTSimpleTypeTemplateParameter extends CPPASTNode implements
|
|||
}
|
||||
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == name )
|
||||
if (n == name)
|
||||
return r_declaration;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName().toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternalScope {
|
||||
private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
|
||||
final private ICPPSpecialization specialization;
|
||||
|
||||
|
||||
public CPPClassSpecializationScope(ICPPSpecialization specialization) {
|
||||
this.specialization = specialization;
|
||||
|
@ -131,7 +130,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
|||
|
||||
public IName getScopeName() {
|
||||
if (specialization instanceof ICPPInternalBinding)
|
||||
return (IASTName) ((ICPPInternalBinding)specialization).getDefinition();
|
||||
return (IASTName) ((ICPPInternalBinding) specialization).getDefinition();
|
||||
//TODO: get the scope name for non-internal bindings
|
||||
return null;
|
||||
}
|
||||
|
@ -201,6 +200,6 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
|||
@Override
|
||||
public String toString() {
|
||||
IName name = getScopeName();
|
||||
return name != null ? name.toString() : "<unnamed scope>"; //$NON-NLS-1$
|
||||
return name != null ? name.toString() : String.valueOf(specialization);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class CPPTemplateParameter extends PlatformObject implements ICPPTemplate
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return CPPVisitor.getContainingScope(getPrimaryDeclaration ());
|
||||
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -28,8 +28,7 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
|
|||
*/
|
||||
public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
||||
ICPPTemplateTypeParameter, IType, ICPPInternalUnknown {
|
||||
private ICPPScope unknownScope = null;
|
||||
|
||||
private ICPPScope unknownScope;
|
||||
|
||||
public CPPTemplateTypeParameter(IASTName name) {
|
||||
super(name);
|
||||
|
@ -58,7 +57,6 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if (type == this)
|
||||
return true;
|
||||
|
@ -67,7 +65,6 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public IBinding resolveUnknown(ObjectMap argMap) {
|
||||
// Cannot do resolution here since the result is not necessarily a binding.
|
||||
return null;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPTypedefSpecialization extends CPPSpecialization implements ITypedef, ITypeContainer {
|
||||
private IType type = null;
|
||||
private IType type;
|
||||
|
||||
/**
|
||||
* @param specialized
|
||||
|
|
|
@ -116,6 +116,7 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.DebugUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
@ -153,30 +154,39 @@ public class CPPSemantics {
|
|||
public static final String EMPTY_NAME = ""; //$NON-NLS-1$
|
||||
public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '};
|
||||
public static final IType VOID_TYPE = new CPPBasicType(IBasicType.t_void, 0);
|
||||
|
||||
// Set to true for debugging.
|
||||
public static boolean traceBindingResolution = false;
|
||||
|
||||
static protected IBinding resolveBinding(IASTName name) {
|
||||
//1: get some context info off of the name to figure out what kind of lookup we want
|
||||
static protected IBinding resolveBinding(IASTName name) {
|
||||
if (traceBindingResolution) {
|
||||
System.out.println("Resolving " + name); //$NON-NLS-1$
|
||||
}
|
||||
// 1: get some context info off of the name to figure out what kind of lookup we want
|
||||
LookupData data = createLookupData(name, true);
|
||||
|
||||
try {
|
||||
//2: lookup
|
||||
// 2: lookup
|
||||
lookup(data, name);
|
||||
} catch (DOMException e1) {
|
||||
data.problem = (ProblemBinding) e1.getProblem();
|
||||
} catch (DOMException e) {
|
||||
data.problem = (ProblemBinding) e.getProblem();
|
||||
}
|
||||
|
||||
if (data.problem != null)
|
||||
return data.problem;
|
||||
|
||||
//3: resolve ambiguities
|
||||
// 3: resolve ambiguities
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = resolveAmbiguities(data, name);
|
||||
} catch (DOMException e2) {
|
||||
binding = e2.getProblem();
|
||||
} catch (DOMException e) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
//4: post processing
|
||||
// 4: post processing
|
||||
binding = postResolution(binding, data);
|
||||
if (traceBindingResolution) {
|
||||
System.out.println("Resolved " + name + " to " + DebugUtil.toStringWithClass(binding)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,13 +115,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
|
|||
*/
|
||||
public IType instantiate(ObjectMap argMap) {
|
||||
IType[] arguments = getArguments();
|
||||
|
||||
IType[] newArgs = new IType[arguments.length];
|
||||
int size = arguments.length;
|
||||
for (int i = 0; i < size; i++) {
|
||||
newArgs[i] = CPPTemplates.instantiateType(arguments[i], argMap);
|
||||
}
|
||||
|
||||
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
|
||||
return (IType) ((ICPPInternalTemplateInstantiator) getTemplateDefinition()).instantiate(newArgs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue