use of org.jetbrains.kotlin.psi.KtUnaryExpression in project kotlin by JetBrains.
the class Translation method translateExpression.
@NotNull
public static JsNode translateExpression(@NotNull KtExpression expression, @NotNull TranslationContext context, @NotNull JsBlock block) {
JsExpression aliasForExpression = context.aliasingContext().getAliasForExpression(expression);
if (aliasForExpression != null) {
return aliasForExpression;
}
CompileTimeConstant<?> compileTimeValue = ConstantExpressionEvaluator.getConstant(expression, context.bindingContext());
if (compileTimeValue != null) {
KotlinType type = context.bindingContext().getType(expression);
if (type != null) {
if (KotlinBuiltIns.isLong(type) || (KotlinBuiltIns.isInt(type) && expression instanceof KtUnaryExpression)) {
JsExpression constantResult = translateConstant(compileTimeValue, expression, context);
if (constantResult != null)
return constantResult;
}
}
}
TranslationContext innerContext = context.innerBlock();
JsNode result = doTranslateExpression(expression, innerContext);
context.moveVarsFrom(innerContext);
block.getStatements().addAll(innerContext.dynamicContext().jsBlock().getStatements());
return result;
}
Aggregations