public class FragmentExtractor extends Object
Liveness as defined here is not an intuitive concept. A type or method (note that constructors are methods) is considered live for the current fragment when that type can only be instantiated or method executed when the current fragment has already been loaded. That does not always mean that it was caused by direct execution of the current fragment. It may instead mean that direction execution of some other fragment has been affected by the loading of the current fragment in a way that results in the instantiation of the type or execution of the method. It is this second case that can lead to seemingly contradictory but valid situations like having a type which is not currently live but which has a currently live constructor. For example it might be possible to instantiate type Foo even with fragment Bar being loaded (i.e. Foo is not live for Bar) but the loading of fragment Bar might be required to reach a particular one of Bar's multiple constructor (i.e. that constructor is live for Bar).
Modifier and Type | Class and Description |
---|---|
static interface |
FragmentExtractor.StatementLogger
A logger for statements that the fragment extractor encounters.
|
Constructor and Description |
---|
FragmentExtractor(JProgram jprogram,
JsProgram jsprogram,
JavaToJavaScriptMap map) |
Modifier and Type | Method and Description |
---|---|
List<JsStatement> |
createOnLoadedCall(int fragmentId)
Create a call to
AsyncFragmentLoader#onLoad . |
List<JsStatement> |
extractStatements(LivenessPredicate livenessPredicate,
LivenessPredicate alreadyLoadedPredicate)
Assume that all code described by
alreadyLoadedPredicate has
been downloaded. |
Set<JMethod> |
findAllMethodsInJavaScript()
Find all Java methods that still exist in the resulting JavaScript, even
after JavaScript inlining and pruning.
|
static JMethod |
methodFor(JsStatement stat,
JavaToJavaScriptMap map)
Return the Java method corresponding to
stat , or
null if there isn't one. |
void |
setStatementLogger(FragmentExtractor.StatementLogger logger) |
public FragmentExtractor(JProgram jprogram, JsProgram jsprogram, JavaToJavaScriptMap map)
public static JMethod methodFor(JsStatement stat, JavaToJavaScriptMap map)
stat
, or
null
if there isn't one. It recognizes JavaScript of the form
function foo(...) { ...}
, where foo
is the name
of the JavaScript translation of a Java method.public List<JsStatement> createOnLoadedCall(int fragmentId)
AsyncFragmentLoader#onLoad
.public List<JsStatement> extractStatements(LivenessPredicate livenessPredicate, LivenessPredicate alreadyLoadedPredicate)
alreadyLoadedPredicate
has
been downloaded. Extract enough JavaScript statements that the code
described by livenessPredicate
can also run. The caller should
ensure that livenessPredicate
includes strictly more live code
than alreadyLoadedPredicate
.public Set<JMethod> findAllMethodsInJavaScript()
public void setStatementLogger(FragmentExtractor.StatementLogger logger)
Copyright © 2018. All rights reserved.