JS backend: remove isEcma5() from property initialize
This commit is contained in:
+3
-8
@@ -72,7 +72,7 @@ public final class PropertyTranslator extends AbstractTranslator {
|
|||||||
|
|
||||||
private void translate(@NotNull List<JsPropertyInitializer> result) {
|
private void translate(@NotNull List<JsPropertyInitializer> result) {
|
||||||
List<JsPropertyInitializer> to;
|
List<JsPropertyInitializer> to;
|
||||||
if (context().isEcma5() && !JsDescriptorUtils.isExtension(descriptor)) {
|
if (!JsDescriptorUtils.isExtension(descriptor)) {
|
||||||
to = new SmartList<JsPropertyInitializer>();
|
to = new SmartList<JsPropertyInitializer>();
|
||||||
result.add(new JsPropertyInitializer(context().nameToLiteral(descriptor), new JsObjectLiteral(to, true)));
|
result.add(new JsPropertyInitializer(context().nameToLiteral(descriptor), new JsObjectLiteral(to, true)));
|
||||||
}
|
}
|
||||||
@@ -205,12 +205,7 @@ public final class PropertyTranslator extends AbstractTranslator {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private JsPropertyInitializer generateDefaultAccessor(@NotNull PropertyAccessorDescriptor accessorDescriptor,
|
private JsPropertyInitializer generateDefaultAccessor(@NotNull PropertyAccessorDescriptor accessorDescriptor,
|
||||||
@NotNull JsFunction function) {
|
@NotNull JsFunction function) {
|
||||||
if (context().isEcma5()) {
|
return TranslationUtils.translateFunctionAsEcma5PropertyDescriptor(function, accessorDescriptor, context());
|
||||||
return TranslationUtils.translateFunctionAsEcma5PropertyDescriptor(function, accessorDescriptor, context());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new JsPropertyInitializer(context().getNameForDescriptor(accessorDescriptor).makeRef(), function);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -221,6 +216,6 @@ public final class PropertyTranslator extends AbstractTranslator {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private JsPropertyInitializer translateCustomAccessor(@NotNull JetPropertyAccessor expression) {
|
private JsPropertyInitializer translateCustomAccessor(@NotNull JetPropertyAccessor expression) {
|
||||||
FunctionTranslator translator = Translation.functionTranslator(expression, context());
|
FunctionTranslator translator = Translation.functionTranslator(expression, context());
|
||||||
return context().isEcma5() ? translator.translateAsEcma5PropertyDescriptor() : translator.translateAsMethod();
|
return translator.translateAsEcma5PropertyDescriptor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public final class InitializerUtils {
|
|||||||
JsExpression value = Translation.translateAsExpression(delegate, context);
|
JsExpression value = Translation.translateAsExpression(delegate, context);
|
||||||
String name = property.getName();
|
String name = property.getName();
|
||||||
assert name != null: "Delegate property must have name";
|
assert name != null: "Delegate property must have name";
|
||||||
return JsAstUtils.defineSimpleProperty(Namer.getDelegateName(name), value, context);
|
return JsAstUtils.defineSimpleProperty(Namer.getDelegateName(name), value);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,17 +228,8 @@ public final class JsAstUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JsStatement defineSimpleProperty(@NotNull String name, @NotNull JsExpression value, @NotNull TranslationContext context) {
|
public static JsStatement defineSimpleProperty(@NotNull String name, @NotNull JsExpression value) {
|
||||||
if (context.isEcma5()) {
|
return assignment(new JsNameRef(name, JsLiteral.THIS), value).makeStmt();
|
||||||
return defineProperty(name, createDataDescriptor(value, false, false), context).makeStmt();
|
|
||||||
} else {
|
|
||||||
return assignment(new JsNameRef(name, JsLiteral.THIS), value).makeStmt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static JsObjectLiteral createDataDescriptor(@NotNull JsExpression value) {
|
|
||||||
return createDataDescriptor(value, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user