Exemplo n.º 1
0
  @NotNull
  @Override
  public CachedAccessTranslator getCached() {
    List<TemporaryVariable> temporaries = new ArrayList<TemporaryVariable>();
    Map<JetExpression, JsExpression> aliases = new HashMap<JetExpression, JsExpression>();

    TemporaryVariable temporaryArrayExpression = context().declareTemporary(getArrayExpression());
    temporaries.add(temporaryArrayExpression);

    for (JetExpression jetExpression : expression.getIndexExpressions()) {
      JsExpression jsExpression = Translation.translateAsExpression(jetExpression, context());
      TemporaryVariable temporaryVariable = context().declareTemporary(jsExpression);
      temporaries.add(temporaryVariable);
      aliases.put(jetExpression, temporaryVariable.reference());
    }
    return new CachedArrayAccessTranslator(
        expression,
        context().innerContextWithAliasesForExpressions(aliases),
        temporaryArrayExpression,
        temporaries);
  }
Exemplo n.º 2
0
 @NotNull
 protected JsExpression getArrayExpression() {
   JetExpression arrayExpression = expression.getArrayExpression();
   assert arrayExpression != null : "Code with parsing errors shouldn't be translated";
   return Translation.translateAsExpression(arrayExpression, context());
 }