Minor in JS backend: added useful message to assert(for EA-48931) and drop unnecessary code.

This commit is contained in:
Zalim Bashorov
2014-05-07 22:10:21 +04:00
parent 814b558bcf
commit 235b03c407
@@ -20,7 +20,6 @@ import com.google.dart.compiler.backend.js.ast.*;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
@@ -72,18 +71,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
private static JsNode translateConstantExpression(@NotNull JetConstantExpression expression, @NotNull TranslationContext context) {
CompileTimeConstant<?> compileTimeValue = context.bindingContext().get(BindingContext.COMPILE_TIME_VALUE, expression);
// TODO: workaround for default parameters translation. Will be fixed later.
// public fun parseInt(s: String, radix:Int = 10): Int = js.noImpl
if (compileTimeValue == null) {
if (expression.getNode().getElementType() == JetNodeTypes.BOOLEAN_CONSTANT) {
return JsLiteral.getBoolean(Boolean.valueOf(expression.getText()));
}
else if (expression.getNode().getElementType() == JetNodeTypes.INTEGER_CONSTANT) {
return context.program().getNumberLiteral(Integer.parseInt(expression.getText()));
}
}
assert compileTimeValue != null;
assert compileTimeValue != null : message(expression, "Expression is not compile time value: " + expression.getText() + " ");
if (compileTimeValue instanceof NullValue) {
return JsLiteral.NULL;