(nameOrPrefix: ValueScopeName | string, value: NameValue)
| 135 | } |
| 136 | |
| 137 | value(nameOrPrefix: ValueScopeName | string, value: NameValue): ValueScopeName { |
| 138 | if (value.ref === undefined) throw new Error("CodeGen: ref must be passed in value") |
| 139 | const name = this.toName(nameOrPrefix) as ValueScopeName |
| 140 | const {prefix} = name |
| 141 | const valueKey = value.key ?? value.ref |
| 142 | let vs = this._values[prefix] |
| 143 | if (vs) { |
| 144 | const _name = vs.get(valueKey) |
| 145 | if (_name) return _name |
| 146 | } else { |
| 147 | vs = this._values[prefix] = new Map() |
| 148 | } |
| 149 | vs.set(valueKey, name) |
| 150 | |
| 151 | const s = this._scope[prefix] || (this._scope[prefix] = []) |
| 152 | const itemIndex = s.length |
| 153 | s[itemIndex] = value.ref |
| 154 | name.setValue(value, {property: prefix, itemIndex}) |
| 155 | return name |
| 156 | } |
| 157 | |
| 158 | getValue(prefix: string, keyOrRef: unknown): ValueScopeName | undefined { |
| 159 | const vs = this._values[prefix] |
no test coverage detected