public class JjsUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addAllSuperTypes(JDeclaredType type,
Set<JDeclaredType> types)
Adds all the supertypes of
type to types . |
static String |
classLiteralFieldNameFromJavahTypeSignatureName(String javahSignatureName)
Returns the class literal field name.
|
static boolean |
closureStyleLiteralsNeeded(boolean incremental,
boolean closureOutputFormat) |
static boolean |
closureStyleLiteralsNeeded(PrecompileTaskOptions options) |
static String |
computeSignature(String name,
List<JType> params,
JType returnType,
boolean isCtor) |
static String |
constructManglingSignature(JMethod x,
String partialSignature) |
static JExpression |
createDefaultConstructorInstantiation(SourceInfo info,
JClassType type)
Returns an instantiation expression for
type using the default constructor,
Returns null if type does not have a default constructor. |
static JMethod |
createForwardingMethod(JDeclaredType type,
JMethod methodToDelegateTo)
Creates a synthetic forwarding stub in
type with the same signature as
superTypeMethod that dispatchs to that method. |
static JExpression |
createOptimizedMultiExpression(boolean ignoringResult,
List<JExpression> expressions)
Creates a multi expression from a list of expressions, removing expressions that do
not have side effects if possible.
|
static JExpression |
createOptimizedMultiExpression(JExpression... expressions)
Creates a multi expression from a list of expressions, removing expressions that do
not have side effects if possible.
|
static JExpression |
createOptimizedNotNullComparison(JProgram program,
SourceInfo info,
JExpression expression)
Returns an ast node representing the expression
expression != null . |
static JMethod |
createSyntheticAbstractStub(JDeclaredType type,
JMethod superTypeMethod)
Creates a synthetic abstract stub in
type with the same signature as
superTypeMethod . |
static JConstructor |
getDelegatedThisOrSuperConstructor(JConstructor constructor)
Returns the constructor which this constructor delegates or null if none.
|
static Iterable<JReferenceType> |
getExpressionTypes(Iterable<? extends HasType> nodes)
Returns types from typed nodes.
|
static String |
getIndexedName(JMember member) |
static JConstructor |
getJsConstructor(JDeclaredType type)
Returns the JsConstructor for a class or null if it does not have any.
|
static JConstructor |
getJsNativeConstructorOrNull(JType type)
Returns a native constructor of a native JsType class.
|
static JClassType |
getNativeSuperClassOrNull(JDeclaredType type)
Returns the nearest native superclass of
type if any, null otherwise. |
static JConstructor |
getPrimaryConstructor(JDeclaredType type)
Returns the constructor which all others delegate to if any, otherwise null.
|
static String |
getReadableDescription(JMember member)
Returns a description for a member suitable for reporting errors to the users.
|
static String |
getReadableDescription(JType type)
Returns a description for a type suitable for reporting errors to the users.
|
static Set<JDeclaredType> |
getSupertypes(JDeclaredType type)
Gets all the supertypes of
type . |
static JMethodCall |
getThisOrSuperConstructorCall(JStatement statement)
Extracts the this(..) or super(..) call from a statement if the statement is of the expected
form.
|
static boolean |
isEmptyBlock(JStatement stmt)
Return true if the statement is an empty block.
|
static boolean |
isJsMemberUnnecessaryAccidentalOverride(JMethod method)
Returns true if the method is a synthetic accidental override that trivially dispatches to its
same name super.
|
static String |
javahSignatureFromName(String name)
Mangles a qualified name into a Javah signature.
|
static JStatement |
makeMethodEndStatement(JType returnType,
JExpression expression)
Returns the ending statement for a method based on an expression.
|
static String |
mangledNameString(HasName hasName)
Returns an valid identifier for a named Java entity.
|
static String |
mangledNameString(String name)
Returns an valid identifier for a named Java entity.
|
static String |
mangleMemberName(String enclosingTypeName,
String fieldName) |
static void |
replaceMethodBody(JMethod method,
JExpression returnValue) |
static boolean |
requiresJsName(JMember member)
Whether or not to use the JsName when implementing this member.
|
static JsLiteral |
translateLiteral(JLiteral literal)
Translates a Java literal into a JavaScript literal.
|
public static boolean closureStyleLiteralsNeeded(PrecompileTaskOptions options)
public static String classLiteralFieldNameFromJavahTypeSignatureName(String javahSignatureName)
public static boolean closureStyleLiteralsNeeded(boolean incremental, boolean closureOutputFormat)
public static String computeSignature(String name, List<JType> params, JType returnType, boolean isCtor)
public static String constructManglingSignature(JMethod x, String partialSignature)
public static JExpression createDefaultConstructorInstantiation(SourceInfo info, JClassType type)
type
using the default constructor,
Returns null
if type
does not have a default constructor.public static JMethod createForwardingMethod(JDeclaredType type, JMethod methodToDelegateTo)
type
with the same signature as
superTypeMethod
that dispatchs to that method.public static JExpression createOptimizedMultiExpression(JExpression... expressions)
public static JExpression createOptimizedMultiExpression(boolean ignoringResult, List<JExpression> expressions)
public static JExpression createOptimizedNotNullComparison(JProgram program, SourceInfo info, JExpression expression)
expression != null
.public static JMethod createSyntheticAbstractStub(JDeclaredType type, JMethod superTypeMethod)
type
with the same signature as
superTypeMethod
.public static JConstructor getJsNativeConstructorOrNull(JType type)
public static String getReadableDescription(JType type)
public static String getReadableDescription(JMember member)
public static void replaceMethodBody(JMethod method, JExpression returnValue)
public static Iterable<JReferenceType> getExpressionTypes(Iterable<? extends HasType> nodes)
public static boolean isJsMemberUnnecessaryAccidentalOverride(JMethod method)
public static String javahSignatureFromName(String name)
public static String mangledNameString(HasName hasName)
public static String mangledNameString(String name)
public static JStatement makeMethodEndStatement(JType returnType, JExpression expression)
public static JsLiteral translateLiteral(JLiteral literal)
public static boolean isEmptyBlock(JStatement stmt)
public static JMethodCall getThisOrSuperConstructorCall(JStatement statement)
public static Set<JDeclaredType> getSupertypes(JDeclaredType type)
type
.public static void addAllSuperTypes(JDeclaredType type, Set<JDeclaredType> types)
type
to types
.public static JConstructor getJsConstructor(JDeclaredType type)
public static JConstructor getDelegatedThisOrSuperConstructor(JConstructor constructor)
public static JConstructor getPrimaryConstructor(JDeclaredType type)
public static JClassType getNativeSuperClassOrNull(JDeclaredType type)
type
if any, null otherwise.public static boolean requiresJsName(JMember member)
A member should only require a JsName when a JsName has been assigned and the compilation has been configured to honor those names.
Copyright © 2018. All rights reserved.