2007-06-12 13:43:16 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright (c) 2002 - 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*****************************************************************************/
|
2007-06-01 03:31:35 +00:00
|
|
|
package com.ibm.wala.cast.ipa.callgraph;
|
|
|
|
|
2007-06-15 14:01:44 +00:00
|
|
|
import java.util.Map;
|
2007-06-01 03:31:35 +00:00
|
|
|
|
2007-06-15 14:01:44 +00:00
|
|
|
import com.ibm.wala.classLoader.IClass;
|
|
|
|
import com.ibm.wala.classLoader.NewSiteReference;
|
|
|
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
|
|
|
import com.ibm.wala.ipa.callgraph.ClassTargetSelector;
|
2008-01-24 22:05:51 +00:00
|
|
|
import com.ibm.wala.util.strings.Atom;
|
2007-06-01 03:31:35 +00:00
|
|
|
|
2007-06-12 13:43:16 +00:00
|
|
|
/**
|
|
|
|
* A ClassTargetSelector implementation that delegates to one of several
|
|
|
|
* child selectors based on the language of the type being allocated. This
|
|
|
|
* selector uses the language associated with the TypeReference of the
|
|
|
|
* allocated type to delagate t =o the appropriate language-specific
|
|
|
|
* selector.
|
|
|
|
*
|
|
|
|
* @author Julian Dolby (dolby@us.ibm.com)
|
|
|
|
*/
|
2007-06-01 03:31:35 +00:00
|
|
|
public class CrossLanguageClassTargetSelector implements ClassTargetSelector {
|
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<Atom, ClassTargetSelector> languageSelectors;
|
2007-06-01 03:31:35 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
public CrossLanguageClassTargetSelector(Map<Atom, ClassTargetSelector> languageSelectors) {
|
2007-06-01 03:31:35 +00:00
|
|
|
this.languageSelectors = languageSelectors;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Atom getLanguage(NewSiteReference target) {
|
|
|
|
return target
|
|
|
|
.getDeclaredType()
|
|
|
|
.getClassLoader()
|
|
|
|
.getLanguage();
|
|
|
|
}
|
|
|
|
|
|
|
|
private ClassTargetSelector getSelector(NewSiteReference site) {
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
return languageSelectors.get(getLanguage(site));
|
2007-06-01 03:31:35 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-06-01 03:31:35 +00:00
|
|
|
public IClass getAllocatedTarget(CGNode caller, NewSiteReference site) {
|
|
|
|
return getSelector(site).getAllocatedTarget(caller, site);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|