JS: fix inlining in a new flat JS generator
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@ import com.google.dart.compiler.backend.js.ast.JsName;
|
||||
import com.google.dart.compiler.backend.js.ast.JsNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.js.inline.util.CollectUtilsKt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -43,6 +44,13 @@ public class AstSearchUtil {
|
||||
return property;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JsExpression getMetadataOrFunction(@NotNull JsNode searchRoot, @NotNull String name) {
|
||||
JsExpression property = findByIdent(CollectUtilsKt.collectNamedFunctionsOrMetadata(searchRoot), name);
|
||||
assert property != null: "Property `" + name + "` was not found";
|
||||
return property;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static <T extends JsExpression> T findByIdent(@NotNull Map<JsName, T> properties, @NotNull String name) {
|
||||
for (Map.Entry<JsName, T> entry : properties.entrySet()) {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class DirectiveTestUtils {
|
||||
@NotNull
|
||||
String getFunctionCode(@NotNull JsNode ast, @NotNull String functionName) {
|
||||
JsFunction function = AstSearchUtil.getFunction(ast, functionName);
|
||||
return function.toString();
|
||||
return function.getBody().toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -213,7 +213,7 @@ public class DirectiveTestUtils {
|
||||
@Override
|
||||
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
|
||||
String functionName = arguments.getPositionalArgument(0);
|
||||
JsExpression property = AstSearchUtil.getProperty(ast, functionName);
|
||||
JsExpression property = AstSearchUtil.getMetadataOrFunction(ast, functionName);
|
||||
String message = "Inline metadata has not been generated for function " + functionName;
|
||||
assertNotNull(message, InlineMetadata.decompose(property));
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public class DirectiveTestUtils {
|
||||
@Override
|
||||
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
|
||||
String functionName = arguments.getPositionalArgument(0);
|
||||
JsExpression property = AstSearchUtil.getProperty(ast, functionName);
|
||||
JsExpression property = AstSearchUtil.getMetadataOrFunction(ast, functionName);
|
||||
String message = "Inline metadata has been generated for not effectively public function " + functionName;
|
||||
assertTrue(message, property instanceof JsFunction);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user