Invert MetadataProperties.withoutSideEffects to sideEffects
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ var JsInvocation.typeCheck: TypeCheck? by MetadataProperty(default = null)
|
||||
|
||||
var HasMetadata.synthetic: Boolean by MetadataProperty(default = false)
|
||||
|
||||
var HasMetadata.withoutSideEffects: Boolean by MetadataProperty(default = false)
|
||||
var HasMetadata.sideEffects: Boolean by MetadataProperty(default = true)
|
||||
|
||||
enum class TypeCheck {
|
||||
TYPEOF,
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.js.inline.clean
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.*
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.synthetic
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.withoutSideEffects
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.sideEffects
|
||||
import org.jetbrains.kotlin.js.inline.util.collectDefinedNames
|
||||
import org.jetbrains.kotlin.js.inline.util.collectFreeVariables
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||
@@ -179,14 +179,14 @@ internal class TemporaryVariableElimination(private val root: JsStatement) {
|
||||
}
|
||||
|
||||
super.visitNameRef(nameRef)
|
||||
if (nameRef.qualifier != null && !nameRef.withoutSideEffects) {
|
||||
if (nameRef.qualifier != null && nameRef.sideEffects) {
|
||||
sideEffectOccurred = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitInvocation(invocation: JsInvocation) {
|
||||
super.visitInvocation(invocation)
|
||||
if (!invocation.withoutSideEffects) {
|
||||
if (invocation.sideEffects) {
|
||||
sideEffectOccurred = true
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ internal class TemporaryVariableElimination(private val root: JsStatement) {
|
||||
|
||||
override fun visitArrayAccess(x: JsArrayAccess) {
|
||||
super.visitArrayAccess(x)
|
||||
if (!x.withoutSideEffects) {
|
||||
if (x.sideEffects) {
|
||||
sideEffectOccurred = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,8 @@ fun collectDefinedNames(scope: JsNode): Set<JsName> {
|
||||
super.visitExpressionStatement(x)
|
||||
}
|
||||
|
||||
// Skip function expression, since it does not introduce name in scope of containing function.
|
||||
// The only exception is function statement, that is handled with the code above.
|
||||
override fun visitFunction(x: JsFunction) { }
|
||||
|
||||
private fun addNameIfNeeded(name: JsName) {
|
||||
|
||||
@@ -304,7 +304,7 @@ public final class Namer {
|
||||
|
||||
isTypeName = kotlinScope.declareName("isType");
|
||||
modulesMap = kotlin("modules");
|
||||
MetadataProperties.setWithoutSideEffects((HasMetadata) modulesMap, true);
|
||||
MetadataProperties.setSideEffects((HasMetadata) modulesMap, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -396,7 +396,7 @@ public final class Namer {
|
||||
public JsExpression isTypeOf(@NotNull JsExpression type) {
|
||||
JsInvocation invocation = new JsInvocation(kotlin("isTypeOf"), type);
|
||||
MetadataProperties.setTypeCheck(invocation, TypeCheck.TYPEOF);
|
||||
MetadataProperties.setWithoutSideEffects(invocation, true);
|
||||
MetadataProperties.setSideEffects(invocation, false);
|
||||
return invocation;
|
||||
}
|
||||
|
||||
@@ -404,14 +404,14 @@ public final class Namer {
|
||||
public JsExpression isInstanceOf(@NotNull JsExpression type) {
|
||||
JsInvocation invocation = new JsInvocation(kotlin("isInstanceOf"), type);
|
||||
MetadataProperties.setTypeCheck(invocation, TypeCheck.INSTANCEOF);
|
||||
MetadataProperties.setWithoutSideEffects(invocation, true);
|
||||
MetadataProperties.setSideEffects(invocation, false);
|
||||
return invocation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsExpression isInstanceOf(@NotNull JsExpression instance, @NotNull JsExpression type) {
|
||||
JsInvocation result = new JsInvocation(kotlin(isTypeName), instance, type);
|
||||
MetadataProperties.setWithoutSideEffects(result, true);
|
||||
MetadataProperties.setSideEffects(result, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ public final class Namer {
|
||||
@NotNull
|
||||
public JsExpression getModuleReference(@NotNull JsStringLiteral moduleName) {
|
||||
JsArrayAccess result = new JsArrayAccess(modulesMap, moduleName);
|
||||
MetadataProperties.setWithoutSideEffects(result, true);
|
||||
MetadataProperties.setSideEffects(result, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public final class ArrayFIF extends CompositeFIF {
|
||||
assert arguments.size() == 1 : "Array get expression must have one argument.";
|
||||
JsExpression indexExpression = arguments.get(0);
|
||||
JsArrayAccess result = new JsArrayAccess(receiver, indexExpression);
|
||||
MetadataProperties.setWithoutSideEffects(result, true);
|
||||
MetadataProperties.setSideEffects(result, false);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -490,14 +490,14 @@ public final class JsAstUtils {
|
||||
@NotNull
|
||||
public static JsNameRef fqn(@NotNull String identifier, @Nullable JsExpression qualifier) {
|
||||
JsNameRef result = new JsNameRef(identifier, qualifier);
|
||||
MetadataProperties.setWithoutSideEffects(result, true);
|
||||
MetadataProperties.setSideEffects(result, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JsNameRef fqn(@NotNull JsName identifier, @Nullable JsExpression qualifier) {
|
||||
JsNameRef result = new JsNameRef(identifier, qualifier);
|
||||
MetadataProperties.setWithoutSideEffects(result, true);
|
||||
MetadataProperties.setSideEffects(result, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user