12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import { Literal } from './literal';
- export class ArrayLiteral extends Literal {
-
- constructor(type, value) {
- super(type);
- this.value = value;
- }
- get subtype () {
- let element = this.value[0];
- if (element instanceof ArrayLiteral) {
- return element.value[0].type;
- } else {
- return element.type;
- }
- }
- get lines () {
- return this.value.length;
- }
- get columns () {
- let element = this.value[0];
- if (!(element instanceof ArrayLiteral)){
- return null;
- } else {
- return element.value[0].value.length;
- }
- }
- get isVector () {
- return this.columns === null;
- }
- get isValid () {
- return true;
- }
- validateType () {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return true;
- }
- validateSize () {
- let valid = true;
- if(this.columns !== null) {
- const equalityTest = data.value.map(v => v.length)
- .reduce((old, next) => {
- if (old === null) {
- return next;
- } else if (old === next) {
- return old
- } else {
- return -1;
- }
- }, null);
- valid = equalityTest !== -1;
- }
- return valid;
- }
- }
|