JS backend minor: made undefined expression static field
This commit is contained in:
committed by
Zalim Bashorov
parent
fb475775c9
commit
d6f8aa6f03
@@ -79,6 +79,19 @@ public final class Namer {
|
|||||||
private static final String PROTOTYPE_NAME = "prototype";
|
private static final String PROTOTYPE_NAME = "prototype";
|
||||||
public static final String CAPTURED_VAR_FIELD = "v";
|
public static final String CAPTURED_VAR_FIELD = "v";
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static final JsExpression UNDEFINED_EXPRESSION = new JsPrefixOperation(JsUnaryOperator.VOID, JsNumberLiteral.ZERO);
|
||||||
|
|
||||||
|
public static boolean isUndefined(@NotNull JsExpression expr) {
|
||||||
|
if (expr instanceof JsPrefixOperation) {
|
||||||
|
JsUnaryOperator op = ((JsPrefixOperation) expr).getOperator();
|
||||||
|
|
||||||
|
return op == JsUnaryOperator.VOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String getReceiverParameterName() {
|
public static String getReceiverParameterName() {
|
||||||
return RECEIVER_PARAMETER_NAME;
|
return RECEIVER_PARAMETER_NAME;
|
||||||
@@ -212,8 +225,6 @@ public final class Namer {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final JsName callableRefForExtensionProperty;
|
private final JsName callableRefForExtensionProperty;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final JsExpression undefinedExpression;
|
|
||||||
@NotNull
|
|
||||||
private final JsExpression callGetProperty;
|
private final JsExpression callGetProperty;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final JsExpression callSetProperty;
|
private final JsExpression callSetProperty;
|
||||||
@@ -243,8 +254,6 @@ public final class Namer {
|
|||||||
callableRefForExtensionProperty = kotlinScope.declareName(CALLABLE_REF_FOR_EXTENSION_PROPERTY);
|
callableRefForExtensionProperty = kotlinScope.declareName(CALLABLE_REF_FOR_EXTENSION_PROPERTY);
|
||||||
|
|
||||||
isTypeName = kotlinScope.declareName("isType");
|
isTypeName = kotlinScope.declareName("isType");
|
||||||
|
|
||||||
undefinedExpression = new JsPrefixOperation(JsUnaryOperator.VOID, rootScope.getProgram().getNumberLiteral(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -365,7 +374,7 @@ public final class Namer {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JsExpression getUndefinedExpression() {
|
public JsExpression getUndefinedExpression() {
|
||||||
return undefinedExpression;
|
return UNDEFINED_EXPRESSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user