Search in sources :

Example 26 with JsExpression

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

the class OverloadedAssignmentTranslator method reassignment.

@NotNull
private JsExpression reassignment() {
    KtExpression left = expression.getLeft();
    assert left != null;
    AccessTranslator accessTranslator = AccessTranslationUtils.getAccessTranslator(left, context()).getCached();
    JsExpression newValue = overloadedMethodInvocation(accessTranslator);
    return accessTranslator.translateAsSet(newValue);
}
Also used : JsExpression(org.jetbrains.kotlin.js.backend.ast.JsExpression) KtExpression(org.jetbrains.kotlin.psi.KtExpression) AccessTranslator(org.jetbrains.kotlin.js.translate.reference.AccessTranslator) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with JsExpression

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

the class AccessTranslationUtils method getArrayAccessTranslator.

@NotNull
private static AccessTranslator getArrayAccessTranslator(@NotNull KtArrayAccessExpression expression, @NotNull TranslationContext context, boolean forceOrderOfEvaluation) {
    TranslationContext accessArrayContext;
    if (forceOrderOfEvaluation) {
        Map<KtExpression, JsExpression> indexesMap = new LinkedHashMap<KtExpression, JsExpression>();
        for (KtExpression indexExpression : expression.getIndexExpressions()) {
            JsExpression jsIndexExpression = context.cacheExpressionIfNeeded(Translation.translateAsExpression(indexExpression, context));
            indexesMap.put(indexExpression, jsIndexExpression);
        }
        accessArrayContext = context.innerContextWithAliasesForExpressions(indexesMap);
    } else {
        accessArrayContext = context;
    }
    return ArrayAccessTranslator.newInstance(expression, accessArrayContext);
}
Also used : JsExpression(org.jetbrains.kotlin.js.backend.ast.JsExpression) TranslationContext(org.jetbrains.kotlin.js.translate.context.TranslationContext) LinkedHashMap(java.util.LinkedHashMap) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JsExpression (org.jetbrains.kotlin.js.backend.ast.JsExpression)27 NotNull (org.jetbrains.annotations.NotNull)21 KotlinType (org.jetbrains.kotlin.types.KotlinType)7 KtExpression (org.jetbrains.kotlin.psi.KtExpression)6 JsNameRef (org.jetbrains.kotlin.js.backend.ast.JsNameRef)5 JsBinaryOperation (org.jetbrains.kotlin.js.backend.ast.JsBinaryOperation)4 JsInvocation (org.jetbrains.kotlin.js.backend.ast.JsInvocation)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Nullable (org.jetbrains.annotations.Nullable)2 JsBinaryOperator (org.jetbrains.kotlin.js.backend.ast.JsBinaryOperator)2 JsName (org.jetbrains.kotlin.js.backend.ast.JsName)2 TemporaryVariable (org.jetbrains.kotlin.js.translate.context.TemporaryVariable)2 TranslationContext (org.jetbrains.kotlin.js.translate.context.TranslationContext)2 KtTypeReference (org.jetbrains.kotlin.psi.KtTypeReference)2 IElementType (com.intellij.psi.tree.IElementType)1 LinkedHashMap (java.util.LinkedHashMap)1 FunctionDescriptor (org.jetbrains.kotlin.descriptors.FunctionDescriptor)1 PropertyDescriptor (org.jetbrains.kotlin.descriptors.PropertyDescriptor)1 VariableDescriptor (org.jetbrains.kotlin.descriptors.VariableDescriptor)1