visitMapAccess()

in lib/generator.js [1348:1376]


  visitMapAccess(ast, isExpr, level) {
    assert.equal(ast.type, 'map_access');
    let expr = _name(ast.id);
    if (expr.indexOf('@') > -1) {
      expr = `_${_lowerFirst(expr.substr(1))}`;
    }
    if (ast.propertyPath && ast.propertyPath.length) {
      var current = ast.id.inferred;
      for (var i = 0; i < ast.propertyPath.length; i++) {
        var name = _name(ast.propertyPath[i]);
        if (current.type === 'model') {
          expr += `.${name}`;
        } else {
          expr += `.get("${name}")`;
        }
        current = ast.propertyPathTypes[i];
      }
    }

    if (isExpr) {
      this.emit(`${expr}.get(`);
      this.visitExpr(ast.accessKey);
      this.emit(`)`);
    } else {
      this.emit(`${expr}.put(`, level);
      this.visitExpr(ast.accessKey);
      this.emit(`, `);
    }
  }