Skip to content

Commit

Permalink
Rename Method.isNative and MethodBody.isNative to .isJsniMethod and .…
Browse files Browse the repository at this point in the history
…isJsniMethodBody.

The purpose of this rename is to avoid confusion with isJsNative.

Change-Id: I62e7ad3af1487d27414aeef354a9cac00a247938
  • Loading branch information
rluble authored and Gerrit Code Review committed Oct 12, 2015
1 parent be1f83b commit 3744185
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 50 deletions.
23 changes: 0 additions & 23 deletions dev/core/src/com/google/gwt/dev/jjs/ast/CanBeNative.java

This file was deleted.

Expand Up @@ -31,7 +31,7 @@ public JMethod getMethod() {
return method; return method;
} }


public abstract boolean isNative(); public abstract boolean isJsniMethodBody();


public void setMethod(JMethod method) { public void setMethod(JMethod method) {
this.method = method; this.method = method;
Expand Down
9 changes: 4 additions & 5 deletions dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
Expand Up @@ -38,7 +38,7 @@
/** /**
* A Java method implementation. * A Java method implementation.
*/ */
public class JMethod extends JNode implements JMember, CanBeAbstract, CanBeNative { public class JMethod extends JNode implements JMember, CanBeAbstract {


/** /**
* Indicates whether a method is a JsProperty accessor. * Indicates whether a method is a JsProperty accessor.
Expand Down Expand Up @@ -610,12 +610,11 @@ public boolean isForwarding() {
return isForwarding; return isForwarding;
} }


@Override public boolean isJsniMethod() {
public boolean isNative() {
if (body == null) { if (body == null) {
return false; return false;
} else { } else {
return body.isNative(); return body.isJsniMethodBody();
} }
} }


Expand Down Expand Up @@ -651,7 +650,7 @@ public boolean needsDynamicDispatch() {
*/ */
public void removeParam(int index) { public void removeParam(int index) {
params = Lists.remove(params, index); params = Lists.remove(params, index);
if (isNative()) { if (isJsniMethod()) {
((JsniMethodBody) getBody()).getFunc().getParameters().remove(index); ((JsniMethodBody) getBody()).getFunc().getParameters().remove(index);
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion dev/core/src/com/google/gwt/dev/jjs/ast/JMethodBody.java
Expand Up @@ -58,7 +58,7 @@ public List<JStatement> getStatements() {
} }


@Override @Override
public boolean isNative() { public boolean isJsniMethodBody() {
return false; return false;
} }


Expand Down
Expand Up @@ -110,7 +110,7 @@ public Set<String> getUsedStrings() {
} }


@Override @Override
public boolean isNative() { public boolean isJsniMethodBody() {
return true; return true;
} }


Expand Down
Expand Up @@ -346,7 +346,7 @@ public boolean visit(final JMethod x, Context ctx) {
rescue(enclosingType, false); rescue(enclosingType, false);
} }


if (x.isNative()) { if (x.isJsniMethod()) {
// Manually rescue native parameter references // Manually rescue native parameter references
final JsniMethodBody body = (JsniMethodBody) x.getBody(); final JsniMethodBody body = (JsniMethodBody) x.getBody();
final JsFunction func = body.getFunc(); final JsFunction func = body.getFunc();
Expand Down Expand Up @@ -614,7 +614,7 @@ private void rescue(JMethod method) {
if (dependencyRecorder != null) { if (dependencyRecorder != null) {
curMethodStack.remove(curMethodStack.size() - 1); curMethodStack.remove(curMethodStack.size() - 1);
} }
if (method.isNative()) { if (method.isJsniMethod()) {
// Returning from this method passes a value from JavaScript into Java. // Returning from this method passes a value from JavaScript into Java.
maybeRescueJavaScriptObjectPassingIntoJava(method.getType()); maybeRescueJavaScriptObjectPassingIntoJava(method.getType());
} }
Expand Down
Expand Up @@ -377,7 +377,7 @@ public void endVisit(JMethodCall x, Context ctx) {
maybeBlackListDueToStaticCall(x.getSourceInfo(), target); maybeBlackListDueToStaticCall(x.getSourceInfo(), target);
} }


if (x.getTarget().isNative()) { if (x.getTarget().isJsniMethod()) {
// Black list enum types declared in parameters of native functions. // Black list enum types declared in parameters of native functions.
for (JParameter parameter :x.getTarget().getParams()) { for (JParameter parameter :x.getTarget().getParams()) {
blackListIfEnum(parameter.getType(), x.getSourceInfo()); blackListIfEnum(parameter.getType(), x.getSourceInfo());
Expand Down
Expand Up @@ -395,14 +395,14 @@ public boolean visit(JMethod x, Context ctx) {
* Only allocate a name for a function if it is native, not polymorphic, * Only allocate a name for a function if it is native, not polymorphic,
* is a JNameOf target or stack-stripping is disabled. * is a JNameOf target or stack-stripping is disabled.
*/ */
if (!stripStack || !polymorphicNames.containsKey(x) || x.isNative() if (!stripStack || !polymorphicNames.containsKey(x) || x.isJsniMethod()
|| nameOfTargets.contains(x)) { || nameOfTargets.contains(x)) {
globalName = topScope.declareName(mangleName, name); globalName = topScope.declareName(mangleName, name);
names.put(x, globalName); names.put(x, globalName);
recordSymbol(x, globalName); recordSymbol(x, globalName);
} }
JsFunction function; JsFunction function;
if (x.isNative()) { if (x.isJsniMethod()) {
// set the global name of the JSNI peer // set the global name of the JSNI peer
JsniMethodBody body = (JsniMethodBody) x.getBody(); JsniMethodBody body = (JsniMethodBody) x.getBody();
function = body.getFunc(); function = body.getFunc();
Expand Down Expand Up @@ -796,7 +796,7 @@ public JsNode transformMethod(JMethod method) {
JsFunction function = transform(method.getBody()); JsFunction function = transform(method.getBody());
function.setInliningMode(method.getInliningMode()); function.setInliningMode(method.getInliningMode());


if (!method.isNative()) { if (!method.isJsniMethod()) {
// Setup params on the generated function. A native method already got // Setup params on the generated function. A native method already got
// its jsParams set when parsed from JSNI. // its jsParams set when parsed from JSNI.
transformInto(method.getParams(), function.getParameters()); transformInto(method.getParams(), function.getParameters());
Expand Down Expand Up @@ -2615,7 +2615,7 @@ private class CollectJsFunctionsForInlining extends JVisitor {


@Override @Override
public void endVisit(JMethod x, Context ctx) { public void endVisit(JMethod x, Context ctx) {
if (x.isNative()) { if (x.isJsniMethod()) {
// These are methods whose bodies where not traversed by the Java method inliner. // These are methods whose bodies where not traversed by the Java method inliner.
JsFunction function = jsFunctionsByJavaMethodBody.get(x.getBody()); JsFunction function = jsFunctionsByJavaMethodBody.get(x.getBody());
if (function != null && function.getBody() != null) { if (function != null && function.getBody() != null) {
Expand All @@ -2637,7 +2637,7 @@ public void endVisit(JsFunction x, JsContext ctx) {
@Override @Override
public void endVisit(JMethodCall x, Context ctx) { public void endVisit(JMethodCall x, Context ctx) {
JMethod target = x.getTarget(); JMethod target = x.getTarget();
if (target.isInliningAllowed() && (target.isNative() if (target.isInliningAllowed() && (target.isJsniMethod()
|| program.getIndexedTypes().contains(target.getEnclosingType()) || program.getIndexedTypes().contains(target.getEnclosingType())
|| target.getInliningMode() == InliningMode.FORCE_INLINE)) { || target.getInliningMode() == InliningMode.FORCE_INLINE)) {
// These are either: 1) callsites to JSNI functions, in which case MethodInliner did not // These are either: 1) callsites to JSNI functions, in which case MethodInliner did not
Expand Down
Expand Up @@ -2452,7 +2452,7 @@ public boolean visit(MethodDeclaration x, ClassScope scope) {
JMethod method = typeMap.get(x.binding); JMethod method = typeMap.get(x.binding);
assert !method.isExternal(); assert !method.isExternal();
JMethodBody body = null; JMethodBody body = null;
if (!method.isNative()) { if (!method.isJsniMethod()) {
body = new JMethodBody(method.getSourceInfo()); body = new JMethodBody(method.getSourceInfo());
method.setBody(body); method.setBody(body);
} }
Expand Down
Expand Up @@ -108,7 +108,7 @@ public void endVisit(JMethod x, Context ctx) {
processIfTypesNotEqual(x.getType(), overridden.getType(), x.getSourceInfo()); processIfTypesNotEqual(x.getType(), overridden.getType(), x.getSourceInfo());
} }


if (x.getBody() != null && x.getBody().isNative()) { if (x.getBody() != null && x.getBody().isJsniMethodBody()) {
/* /*
* Check if this method has a native (jsni) method body, in which case all * Check if this method has a native (jsni) method body, in which case all
* arguments passed in are implicitly cast to JavaScriptObject * arguments passed in are implicitly cast to JavaScriptObject
Expand Down
Expand Up @@ -62,7 +62,7 @@ public final boolean visit(JStatement x, Context ctx) {
} }


protected JLocal createTempLocal(SourceInfo info, JType type) { protected JLocal createTempLocal(SourceInfo info, JType type) {
assert !getCurrentMethod().isNative(); assert !getCurrentMethod().isJsniMethod();
JMethodBody currentMethodBody = (JMethodBody) getCurrentMethod().getBody(); JMethodBody currentMethodBody = (JMethodBody) getCurrentMethod().getBody();
String temporaryLocalName = newTemporaryLocalName(info, type, currentMethodBody); String temporaryLocalName = newTemporaryLocalName(info, type, currentMethodBody);
JLocal local = JProgram.createLocal(info, temporaryLocalName, type, false, currentMethodBody); JLocal local = JProgram.createLocal(info, temporaryLocalName, type, false, currentMethodBody);
Expand Down
Expand Up @@ -210,7 +210,7 @@ public boolean visit(JMethod x, Context ctx) {
* Rewrite the method body. Update all thisRefs to paramRefs. Update * Rewrite the method body. Update all thisRefs to paramRefs. Update
* paramRefs and localRefs to target the params/locals in the new method. * paramRefs and localRefs to target the params/locals in the new method.
*/ */
if (newMethod.isNative()) { if (newMethod.isJsniMethod()) {
// For natives, we also need to create the JsParameter for this$static, // For natives, we also need to create the JsParameter for this$static,
// because the jsFunc already has parameters. // because the jsFunc already has parameters.
// TODO: Do we really need to do that in BuildTypeMap? // TODO: Do we really need to do that in BuildTypeMap?
Expand Down
4 changes: 2 additions & 2 deletions dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
Expand Up @@ -124,7 +124,7 @@ public void endVisit(JMultiExpression x, Context ctx) {
private InlineResult tryInlineMethodCall(JMethodCall x, Context ctx) { private InlineResult tryInlineMethodCall(JMethodCall x, Context ctx) {
JMethod method = x.getTarget(); JMethod method = x.getTarget();


if (!method.isStatic() || method.isNative() || method.canBeImplementedExternally()) { if (!method.isStatic() || method.isJsniMethod() || method.canBeImplementedExternally()) {
// Only inline static methods that are not native. // Only inline static methods that are not native.
return InlineResult.BLACKLIST; return InlineResult.BLACKLIST;
} }
Expand Down Expand Up @@ -210,7 +210,7 @@ private JMethodCall createClinitCall(JMethodCall x) {
JMethod clinit = targetType.getClinitMethod(); JMethod clinit = targetType.getClinitMethod();


// If the clinit is a non-native, empty body we can optimize it out here // If the clinit is a non-native, empty body we can optimize it out here
if (!clinit.isNative() && (((JMethodBody) clinit.getBody())).getStatements().size() == 0) { if (!clinit.isJsniMethod() && (((JMethodBody) clinit.getBody())).getStatements().size() == 0) {
return null; return null;
} }


Expand Down
Expand Up @@ -17,7 +17,6 @@


import com.google.gwt.dev.jjs.ast.CanBeAbstract; import com.google.gwt.dev.jjs.ast.CanBeAbstract;
import com.google.gwt.dev.jjs.ast.CanBeFinal; import com.google.gwt.dev.jjs.ast.CanBeFinal;
import com.google.gwt.dev.jjs.ast.CanBeNative;
import com.google.gwt.dev.jjs.ast.CanBeStatic; import com.google.gwt.dev.jjs.ast.CanBeStatic;
import com.google.gwt.dev.jjs.ast.Context; import com.google.gwt.dev.jjs.ast.Context;
import com.google.gwt.dev.jjs.ast.HasName; import com.google.gwt.dev.jjs.ast.HasName;
Expand Down Expand Up @@ -1082,8 +1081,8 @@ protected void printName(HasName x) {
print(x.getName()); print(x.getName());
} }


protected void printNativeFlag(CanBeNative x) { protected void printNativeFlag(JMethod x) {
if (x.isNative()) { if (x.isJsniMethod()) {
print(CHARS_NATIVE); print(CHARS_NATIVE);
} }
} }
Expand Down
4 changes: 2 additions & 2 deletions dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
Expand Up @@ -523,7 +523,7 @@ public void exit(JMethod x, Context ctx) {
* The only information that we can infer about native methods is if they * The only information that we can infer about native methods is if they
* are declared to return a leaf type. * are declared to return a leaf type.
*/ */
if (x.isNative() || x.canBeImplementedExternally()) { if (x.isJsniMethod() || x.canBeImplementedExternally()) {
return; return;
} }


Expand Down Expand Up @@ -616,7 +616,7 @@ public boolean enter(JMethod x, Context ctx) {
* Explicitly NOT visiting native methods since we can't infer further * Explicitly NOT visiting native methods since we can't infer further
* type information. * type information.
*/ */
return !x.isNative(); return !x.isJsniMethod();
} }


/** /**
Expand Down

0 comments on commit 3744185

Please sign in to comment.