| 51 | } |
| 52 | |
| 53 | class IndexReference implements Reference { |
| 54 | constructor(private target: Value[], private index: number) { |
| 55 | this.type = 'reference'; |
| 56 | } |
| 57 | |
| 58 | type: 'reference'; |
| 59 | |
| 60 | get(): Value { |
| 61 | this.assertIndexInRange(); |
| 62 | return this.target[this.index]!; |
| 63 | } |
| 64 | |
| 65 | set(value: Value): void { |
| 66 | this.assertIndexInRange(); |
| 67 | this.target[this.index] = value; |
| 68 | } |
| 69 | |
| 70 | private assertIndexInRange(): void { |
| 71 | const index = this.index; |
| 72 | if (index < 0 || this.target.length <= index) { |
| 73 | throw new AiScriptIndexOutOfRangeError(`Index out of range. index: ${this.index} max: ${this.target.length - 1}`); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | class PropReference implements Reference { |
| 79 | constructor(private target: Map<string, Value>, private index: string) { |
nothing calls this directly
no outgoing calls
no test coverage detected