mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 10:41:42 +00:00
Rename lib prefix to '~lib' (parens aren't valid); Add built-in alignof<T>; Prepare for ArrayBufferView
This commit is contained in:
bin
dist
src
ast.tsbuiltins.tscompiler.tsdiagnosticMessages.generated.tsdiagnosticMessages.json
extra
parser.tsprogram.tsstd
tests
binaryen
compiler
binary.optimized.watbinary.untouched.watshowcase.optimized.watshowcase.untouched.wat
std
allocator_arena.optimized.watallocator_arena.untouched.watarray.optimized.watarray.untouched.watarraybuffer.optimized.watarraybuffer.untouched.watcarray.optimized.watcarray.untouched.watconstructor.optimized.watconstructor.untouched.watlibm.optimized.watlibm.untouched.watmath.optimized.watmath.untouched.watmod.optimized.watmod.untouched.watnew.optimized.watnew.untouched.watoperator-overloading.optimized.watoperator-overloading.untouched.watpolyfills.optimized.watpolyfills.untouched.watset.optimized.watset.untouched.watstatic-array.optimized.watstatic-array.untouched.watstring.optimized.watstring.untouched.wat
@ -262,9 +262,10 @@ export class Parser extends DiagnosticEmitter {
|
||||
}
|
||||
// fall through
|
||||
}
|
||||
case Token.CLASS: {
|
||||
case Token.CLASS:
|
||||
case Token.INTERFACE: {
|
||||
tn.next();
|
||||
statement = this.parseClass(tn, flags, decorators, startPos);
|
||||
statement = this.parseClassOrInterface(tn, flags, decorators, startPos);
|
||||
decorators = null;
|
||||
break;
|
||||
}
|
||||
@ -1381,20 +1382,22 @@ export class Parser extends DiagnosticEmitter {
|
||||
return Node.createFunctionExpression(declaration);
|
||||
}
|
||||
|
||||
parseClass(
|
||||
parseClassOrInterface(
|
||||
tn: Tokenizer,
|
||||
flags: CommonFlags,
|
||||
decorators: DecoratorNode[] | null,
|
||||
startPos: i32
|
||||
): ClassDeclaration | null {
|
||||
|
||||
// at 'class':
|
||||
// at ('class' | 'interface'):
|
||||
// Identifier
|
||||
// ('<' TypeParameters)?
|
||||
// ('extends' Type)?
|
||||
// ('implements' Type (',' Type)*)?
|
||||
// '{' ClassMember* '}'
|
||||
|
||||
var isInterface = tn.token == Token.INTERFACE;
|
||||
|
||||
if (!tn.skip(Token.IDENTIFIER)) {
|
||||
this.error(
|
||||
DiagnosticCode.Identifier_expected,
|
||||
@ -1431,12 +1434,21 @@ export class Parser extends DiagnosticEmitter {
|
||||
extendsType = <TypeNode>t;
|
||||
}
|
||||
|
||||
var implementsTypes = new Array<TypeNode>();
|
||||
var implementsTypes: TypeNode[] | null = null;
|
||||
if (tn.skip(Token.IMPLEMENTS)) {
|
||||
if (isInterface) {
|
||||
this.error(
|
||||
DiagnosticCode.Interface_declaration_cannot_have_implements_clause,
|
||||
tn.range()
|
||||
); // recoverable
|
||||
}
|
||||
do {
|
||||
let type = this.parseType(tn);
|
||||
if (!type) return null;
|
||||
implementsTypes.push(<TypeNode>type);
|
||||
if (!isInterface) {
|
||||
if (!implementsTypes) implementsTypes = [];
|
||||
implementsTypes.push(<TypeNode>type);
|
||||
}
|
||||
} while (tn.skip(Token.COMMA));
|
||||
}
|
||||
|
||||
@ -1449,16 +1461,30 @@ export class Parser extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
var members = new Array<DeclarationStatement>();
|
||||
var declaration = Node.createClassDeclaration(
|
||||
identifier,
|
||||
typeParameters,
|
||||
extendsType,
|
||||
implementsTypes,
|
||||
members,
|
||||
decorators,
|
||||
flags,
|
||||
tn.range(startPos, tn.pos)
|
||||
);
|
||||
var declaration: ClassDeclaration;
|
||||
if (isInterface) {
|
||||
assert(!implementsTypes);
|
||||
declaration = Node.createInterfaceDeclaration(
|
||||
identifier,
|
||||
typeParameters,
|
||||
extendsType,
|
||||
members,
|
||||
decorators,
|
||||
flags,
|
||||
tn.range(startPos, tn.pos)
|
||||
);
|
||||
} else {
|
||||
declaration = Node.createClassDeclaration(
|
||||
identifier,
|
||||
typeParameters,
|
||||
extendsType,
|
||||
implementsTypes,
|
||||
members,
|
||||
decorators,
|
||||
flags,
|
||||
tn.range(startPos, tn.pos)
|
||||
);
|
||||
}
|
||||
if (!tn.skip(Token.CLOSEBRACE)) {
|
||||
do {
|
||||
let member = this.parseClassMember(tn, declaration);
|
||||
|
Reference in New Issue
Block a user