1
0

arrayAccess.js 563 B

123456789101112131415161718192021222324252627282930
  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. let text = null;
  16. if(strColumn) {
  17. text = `${this.id}[${strLine}][${strColumn}]`;
  18. } else {
  19. text = `${this.id}[${strLine}]`;
  20. }
  21. if(this.parenthesis ){
  22. return `(${text})`
  23. } else {
  24. return text;
  25. }
  26. }
  27. }