import { Type } from "./type"; export class ArrayType extends Type { constructor (type, dimensions) { super(null); this.innerType = type; this.dimensions = dimensions; } get isVector () { return this.dimensions == 1; } isCompatible (another) { if(another instanceof ArrayType){ if(this.dimensions !== another.dimensions) { return false; } return this.innerType.isCompatible(another.innerType); } return false; } stringInfo () { const list = this.innerType.stringInfo(); list.forEach(v => { v.dim = this.dimensions; }); return list; } canAccept (another) { if(another instanceof ArrayType) { return false;// return this.dimensions > another.dimensions && this.innerType.isCompatible(another.innerType); } else { return this.dimensions == 1 && this.innerType.isCompatible(another); } } }