visitMapAccess()

in lib/generator.js [1456:1482]


  visitMapAccess(ast, level, env) {
    assert.equal(ast.type, 'map_access');
    var mapName = _name(ast.id);
    if (ast.id.tag === Tag.VID) {
      mapName = _vid(ast.id);
    } else {
      mapName = _name(ast.id);
    }

    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') {
          mapName += `.${_upperFirst(name)}`;
        } else {
          mapName += `["${name}"]`;
        }
        current = ast.propertyPathTypes[i];
      }
    }

    this.emit(`${mapName}.Get(`);

    this.visitExpr(ast.accessKey, level, env);
    this.emit(`)`);
  }