Minor in JS backend:
- use constants from Namer in JsAstUtils#createPackage; - dropped extra JsInvoke node when create IIF; - create new JsName for Kotlin object in IIF scope.
This commit is contained in:
@@ -32,6 +32,7 @@ import static org.jetbrains.jet.lang.descriptors.ClassKind.TRAIT;
|
||||
public final class Namer {
|
||||
public static final String KOTLIN_NAME = JetLanguage.NAME;
|
||||
public static final String KOTLIN_LOWER_NAME = KOTLIN_NAME.toLowerCase();
|
||||
public static final JsNameRef KOTLIN_OBJECT_REF = new JsNameRef(KOTLIN_NAME);
|
||||
|
||||
public static final String CALLEE_NAME = "$fun";
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.List;
|
||||
public final class JsAstUtils {
|
||||
private static final JsNameRef DEFINE_PROPERTY = new JsNameRef("defineProperty");
|
||||
public static final JsNameRef CREATE_OBJECT = new JsNameRef("create");
|
||||
private static final JsNameRef EMPTY_REF = new JsNameRef("");
|
||||
|
||||
private static final JsNameRef VALUE = new JsNameRef("value");
|
||||
private static final JsPropertyInitializer WRITABLE = new JsPropertyInitializer(new JsNameRef("writable"), JsLiteral.TRUE);
|
||||
@@ -232,8 +231,12 @@ public final class JsAstUtils {
|
||||
@NotNull
|
||||
public static JsFunction createPackage(@NotNull List<JsStatement> to, @NotNull JsScope scope) {
|
||||
JsFunction packageBlockFunction = createFunctionWithEmptyBody(scope);
|
||||
packageBlockFunction.getParameters().add(new JsParameter(scope.findName("Kotlin")));
|
||||
to.add(new JsInvocation(EMPTY_REF, new JsInvocation(packageBlockFunction, new JsNameRef("Kotlin"))).makeStmt());
|
||||
|
||||
JsName kotlinObjectAsParameter = packageBlockFunction.getScope().declareName(Namer.KOTLIN_NAME);
|
||||
packageBlockFunction.getParameters().add(new JsParameter(kotlinObjectAsParameter));
|
||||
|
||||
to.add(new JsInvocation(packageBlockFunction, Namer.KOTLIN_OBJECT_REF).makeStmt());
|
||||
|
||||
return packageBlockFunction;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user