in lib/generator.js [2686:2731]
visitMapAccess(ast, level, env, expected) {
assert.equal(ast.type, 'map_access');
let mapName = _name(ast.id);
if (ast.id.tag === Tag.VID) {
mapName = _vid(mapName);
}
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 += `.${_format(name)}`;
} else {
mapName += `["${name}"]`;
}
current = ast.propertyPathTypes[i];
}
}
let accessKey = ast.accessKey;
if (!DSL.util.isBasicType(ast.accessKey.type) && !ast.accessKey.inferred) {
ast.accessKey.inferred = {
type: 'basic',
name: 'string'
};
}
if ((!expected || !expected.pointer) && (DSL.util.isBasicType(_name(ast.inferred)) &&
!_isFilterType(_name(ast.inferred))) && _name(ast.inferred) !== 'model') {
this.emit(`${_setValueFunc(_name(ast.inferred))}${mapName}[`);
this.visitExpr(accessKey, level, env);
this.emit(`])`);
} else {
this.emit(`${mapName}[`);
if (ast.propertyPathTypes && ast.propertyPathTypes.length) {
if (ast.propertyPathTypes[ast.propertyPathTypes.length - 1].type === 'map') {
accessKey = {
inferred: ast.propertyPathTypes[ast.propertyPathTypes.length - 1].keyType,
...accessKey
};
}
}
this.visitExpr(accessKey, level, env);
this.emit(`]`);
}
}