array_store_value.ts 861 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { IStoreValue } from "./istore_value";
  2. import { Type } from "../../typeSystem/type";
  3. export class ArrayStoreValue implements IStoreValue {
  4. public type: Type;
  5. public id: String | null;
  6. public isConst: boolean;
  7. public lines: number;
  8. public columns: number;
  9. public values: any[];
  10. constructor(type: Type, values: any[], id: String | null, lines: number, columns: number, isConst = false) {
  11. this.type = type;
  12. this.id = id;
  13. this.isConst = isConst
  14. this.values = values;
  15. this.lines = lines;
  16. this.columns = columns;
  17. }
  18. get (): any[] {
  19. return this.values;
  20. }
  21. getAt (line: number, column = 0): any {
  22. const pos = column * this.lines + line;
  23. return this.values[pos];
  24. }
  25. setAt (value: any, line:number, column = 0): any {
  26. const pos = column * this.lines + line;
  27. this.values[pos] = value;
  28. }
  29. }