12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { IType } from "./itype";
- import { Type } from "./type";
- export class ArrayType implements IType {
- public innerType: IType;
- constructor (type: Type, public dimensions: number) {
- this.innerType = type;
- }
- get isVector () {
- return this.dimensions == 1;
- }
- isCompatible (another: IType): boolean {
- 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;
- }
- get value () {
- return null;
- }
- get ord () {
- return null;
- }
- canAccept (another: IType) {
- 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);
- }
- }
- }
|