diff --git a/testTs/expect/types/rest/objectRestParameter.txt b/testTs/expect/types/rest/objectRestParameter.txt index d3582019b964e156bdf848b782f01074df6386fe..f1d5ac1eb96ca666702c611897bf9ef3ba554b16 100644 --- a/testTs/expect/types/rest/objectRestParameter.txt +++ b/testTs/expect/types/rest/objectRestParameter.txt @@ -3,7 +3,7 @@ {'lb': [{'t': 2, 'v': 1}, {'t': 2, 'v': 0}, {'t': 25, 'v': 0}, {'t': 2, 'v': 0}, {'t': 2, 'v': 0}, {'t': 2, 'v': 2}, {'t': 5, 'v': 'm'}, {'t': 24, 'v': '_4'}, {'t': 5, 'v': 'p'}, {'t': 24, 'v': '_6'}, {'t': 2, 'v': 0}, {'t': 2, 'v': 0}], 'k': '_3'} {'lb': [{'t': 2, 'v': 3}, {'t': 2, 'v': 0}, {'t': 5, 'v': 'm'}, {'t': 2, 'v': 0}, {'t': 2, 'v': 1}, {'t': 24, 'v': '_5'}, {'t': 25, 'v': 3}], 'k': '_4'} {'lb': [{'t': 2, 'v': 6}, {'t': 2, 'v': 2}, {'t': 5, 'v': 'a'}, {'t': 25, 'v': 1}, {'t': 5, 'v': 'b'}, {'t': 25, 'v': 4}], 'k': '_5'} -{'lb': [{'t': 2, 'v': 3}, {'t': 2, 'v': 0}, {'t': 5, 'v': 'p'}, {'t': 2, 'v': 0}, {'t': 2, 'v': 1}, {'t': 24, 'v': '_7'}, {'t': 25, 'v': 0}], 'k': '_6'} +{'lb': [{'t': 2, 'v': 3}, {'t': 2, 'v': 32}, {'t': 5, 'v': 'p'}, {'t': 2, 'v': 0}, {'t': 2, 'v': 1}, {'t': 24, 'v': '_7'}, {'t': 25, 'v': 0}], 'k': '_6'} {'lb': [{'t': 2, 'v': 6}, {'t': 2, 'v': 2}, {'t': 5, 'v': 'a'}, {'t': 25, 'v': 1}, {'t': 5, 'v': 'b'}, {'t': 25, 'v': 4}], 'k': '_7'} {'lb': [{'t': 2, 'v': 2}, {'t': 24, 'v': '_3'}], 'k': '_8'} {'lb': [{'t': 2, 'v': 3}, {'t': 2, 'v': 0}, {'t': 5, 'v': 'foobar'}, {'t': 2, 'v': 0}, {'t': 2, 'v': 1}, {'t': 25, 'v': 0}, {'t': 25, 'v': 0}], 'k': '_9'} diff --git a/ts2panda/src/base/typeSystem.ts b/ts2panda/src/base/typeSystem.ts index cc06969f4910ab7bd2014dca7c8938a0d7e121eb..331e4f9dedbfdcb4dc80e1485bd6c12db4efe9e5 100644 --- a/ts2panda/src/base/typeSystem.ts +++ b/ts2panda/src/base/typeSystem.ts @@ -129,9 +129,9 @@ export enum ModifierAbstract { } export enum Modifier { - STATIC = 4, - ASYNC = 8, - ASTERISK = 16 + STATIC = 1 << 2, + ASYNC = 1 << 3, + ASTERISK = 1 << 4 } export enum ModifierReadonly { @@ -145,6 +145,11 @@ export enum AccessFlag { PROTECTED } +export enum GetOrSetAccessorFlag { + FALSE = 0, // Not GetAccessor and SetAccessor + TRUE = 1 << 5 // GetAccessor or SetAccessor +} + type ClassMemberFunction = ts.MethodDeclaration | ts.ConstructorDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration; @@ -515,12 +520,16 @@ export class FunctionType extends BaseType { returnType: number = PrimitiveType.ANY; typeIndex: number; shiftedTypeIndex: number; + getOrSetAccessorFlag: GetOrSetAccessorFlag = GetOrSetAccessorFlag.FALSE; constructor(funcNode: ts.FunctionLikeDeclaration | ts.MethodSignature, builtinTypeIdx: number = undefined) { super(); let res = this.calculateIndex(builtinTypeIdx); this.typeIndex = res.typeIndex; this.shiftedTypeIndex = res.shiftedTypeIndex; + if (funcNode.kind == ts.SyntaxKind.GetAccessor || funcNode.kind == ts.SyntaxKind.SetAccessor) { + this.getOrSetAccessorFlag = GetOrSetAccessorFlag.TRUE; + } // record type before its initialization, so its index can be recorded // in case there's recursive reference of this type @@ -600,7 +609,7 @@ export class FunctionType extends BaseType { let funcTypeBuf = new LiteralBuffer(); let funcTypeLiterals: Array = new Array(); funcTypeLiterals.push(new Literal(LiteralTag.INTEGER, L2Type.FUNCTION)); - funcTypeLiterals.push(new Literal(LiteralTag.INTEGER, this.accessFlag + this.modifiers)); + funcTypeLiterals.push(new Literal(LiteralTag.INTEGER, this.accessFlag + this.modifiers + this.getOrSetAccessorFlag)); funcTypeLiterals.push(new Literal(LiteralTag.STRING, this.name)); if (this.containThisParam) { funcTypeLiterals.push(new Literal(LiteralTag.INTEGER, 1)); // marker for having 'this' param