Drop extra fields which covered by metadata: isLocal from JsFunction.
This commit is contained in:
@@ -19,7 +19,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final JsFunctionScope scope;
|
private final JsFunctionScope scope;
|
||||||
private JsName name;
|
private JsName name;
|
||||||
private boolean isLocal = false;
|
|
||||||
|
|
||||||
public JsFunction(@NotNull JsScope parentScope, @NotNull String description) {
|
public JsFunction(@NotNull JsScope parentScope, @NotNull String description) {
|
||||||
this(parentScope, description, null);
|
this(parentScope, description, null);
|
||||||
@@ -63,10 +62,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocal() {
|
|
||||||
return isLocal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBody(@NotNull JsBlock body) {
|
public void setBody(@NotNull JsBlock body) {
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
@@ -75,10 +70,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAsLocal() {
|
|
||||||
isLocal = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(JsVisitor v) {
|
public void accept(JsVisitor v) {
|
||||||
v.visitFunction(this);
|
v.visitFunction(this);
|
||||||
@@ -106,7 +97,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
functionCopy.getScope().copyOwnNames(scope);
|
functionCopy.getScope().copyOwnNames(scope);
|
||||||
functionCopy.setBody(body.deepCopy());
|
functionCopy.setBody(body.deepCopy());
|
||||||
functionCopy.params = AstUtil.deepCopy(params);
|
functionCopy.params = AstUtil.deepCopy(params);
|
||||||
functionCopy.isLocal = isLocal;
|
|
||||||
|
|
||||||
return functionCopy.withMetadataFrom(this);
|
return functionCopy.withMetadataFrom(this);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.k2js.inline.clean
|
|||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.*
|
import com.google.dart.compiler.backend.js.ast.*
|
||||||
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
|
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
|
||||||
|
import com.google.dart.compiler.backend.js.ast.metadata.isLocal
|
||||||
|
|
||||||
import com.intellij.util.containers.Stack
|
import com.intellij.util.containers.Stack
|
||||||
import java.util.IdentityHashMap
|
import java.util.IdentityHashMap
|
||||||
@@ -54,11 +55,11 @@ private class UnusedLocalFunctionsCollector(functions: Map<JsName, JsFunction>)
|
|||||||
get() = tracker.removable
|
get() = tracker.removable
|
||||||
|
|
||||||
public fun process() {
|
public fun process() {
|
||||||
functions.filter { it.value.isLocal() }
|
functions.filter { it.value.isLocal }
|
||||||
.forEach { tracker.addCandidateForRemoval(it.key, it.value) }
|
.forEach { tracker.addCandidateForRemoval(it.key, it.value) }
|
||||||
|
|
||||||
for ((name, function) in functions) {
|
for ((name, function) in functions) {
|
||||||
if (function.isLocal()) {
|
if (function.isLocal) {
|
||||||
processLocalFunction(name, function)
|
processLocalFunction(name, function)
|
||||||
} else {
|
} else {
|
||||||
processNonLocalFunction(name, function)
|
processNonLocalFunction(name, function)
|
||||||
|
|||||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.k2js.translate.expression
|
|||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.*
|
import com.google.dart.compiler.backend.js.ast.*
|
||||||
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
|
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
|
||||||
|
import com.google.dart.compiler.backend.js.ast.metadata.isLocal
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||||
@@ -60,11 +61,11 @@ class LiteralFunctionTranslator(context: TranslationContext) : AbstractTranslato
|
|||||||
|
|
||||||
if (tracker.hasCapturedExceptContaining()) {
|
if (tracker.hasCapturedExceptContaining()) {
|
||||||
val lambdaCreator = simpleReturnFunction(invokingContext.scope(), lambda)
|
val lambdaCreator = simpleReturnFunction(invokingContext.scope(), lambda)
|
||||||
lambdaCreator.markAsLocal()
|
lambdaCreator.isLocal = true
|
||||||
return lambdaCreator.withCapturedParameters(functionContext, invokingContext, descriptor)
|
return lambdaCreator.withCapturedParameters(functionContext, invokingContext, descriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
lambda.markAsLocal()
|
lambda.isLocal = true
|
||||||
return invokingContext.define(descriptor, lambda)
|
return invokingContext.define(descriptor, lambda)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user