arrayAccess.js 466 B

123456789101112131415161718192021222324
  1. import { Expression } from './expression';
  2. export class ArrayAccess extends Expression {
  3. constructor (id, line, column) {
  4. super();
  5. this.id = id;
  6. this.line = line;
  7. this.column = column;
  8. }
  9. toString () {
  10. const strLine = this.line.toString();
  11. let strColumn = null;
  12. if(this.column) {
  13. strColumn = this.column.toString();
  14. }
  15. if(strColumn) {
  16. return `${this.id}[${strLine}][${strColumn}]`;
  17. } else {
  18. return `${this.id}[${strLine}]`;
  19. }
  20. }
  21. }