Search in sources :

Example 1 with JsBlock

use of org.jetbrains.kotlin.js.backend.ast.JsBlock in project kotlin by JetBrains.

the class OverloadedAssignmentTranslator method overloadedMethodInvocation.

@NotNull
private JsExpression overloadedMethodInvocation(AccessTranslator accessTranslator) {
    JsBlock innerBlock = new JsBlock();
    TranslationContext innerContext = context().innerBlock(innerBlock);
    JsExpression oldValue = accessTranslator.translateAsGet();
    JsBlock argumentBlock = new JsBlock();
    TranslationContext argumentContext = innerContext.innerBlock(argumentBlock);
    KtExpression argumentPsi = expression.getRight();
    assert argumentPsi != null;
    JsExpression argument = Translation.translateAsExpression(argumentPsi, argumentContext);
    if (!argumentBlock.isEmpty()) {
        oldValue = innerContext.defineTemporary(oldValue);
        innerContext.addStatementsToCurrentBlockFrom(argumentBlock);
    }
    Map<KtExpression, JsExpression> aliases = new HashMap<KtExpression, JsExpression>();
    aliases.put(argumentPsi, argument);
    innerContext = innerContext.innerContextWithAliasesForExpressions(aliases);
    JsExpression result = CallTranslator.translate(innerContext, resolvedCall, oldValue);
    context().addStatementsToCurrentBlockFrom(innerBlock);
    return result;
}
Also used : JsExpression(org.jetbrains.kotlin.js.backend.ast.JsExpression) HashMap(java.util.HashMap) KtExpression(org.jetbrains.kotlin.psi.KtExpression) JsBlock(org.jetbrains.kotlin.js.backend.ast.JsBlock) TranslationContext(org.jetbrains.kotlin.js.translate.context.TranslationContext) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HashMap (java.util.HashMap)1 NotNull (org.jetbrains.annotations.NotNull)1 JsBlock (org.jetbrains.kotlin.js.backend.ast.JsBlock)1 JsExpression (org.jetbrains.kotlin.js.backend.ast.JsExpression)1 TranslationContext (org.jetbrains.kotlin.js.translate.context.TranslationContext)1 KtExpression (org.jetbrains.kotlin.psi.KtExpression)1