mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 02:31:41 +00:00
Support parsing of class expressions, see #161
This commit is contained in:
@ -76,7 +76,8 @@ import {
|
||||
ParameterNode,
|
||||
ParameterKind,
|
||||
ExportMember,
|
||||
SwitchCase
|
||||
SwitchCase,
|
||||
ClassExpression
|
||||
} from "../ast";
|
||||
|
||||
import {
|
||||
@ -147,6 +148,10 @@ export class ASTBuilder {
|
||||
this.visitCallExpression(<CallExpression>node);
|
||||
break;
|
||||
}
|
||||
case NodeKind.CLASS: {
|
||||
this.visitClassExpression(<ClassExpression>node);
|
||||
break;
|
||||
}
|
||||
case NodeKind.COMMA: {
|
||||
this.visitCommaExpression(<CommaExpression>node);
|
||||
break;
|
||||
@ -477,6 +482,11 @@ export class ASTBuilder {
|
||||
sb.push(")");
|
||||
}
|
||||
|
||||
visitClassExpression(node: ClassExpression): void {
|
||||
var declaration = node.declaration;
|
||||
this.visitClassDeclaration(declaration);
|
||||
}
|
||||
|
||||
visitCommaExpression(node: CommaExpression): void {
|
||||
var expressions = node.expressions;
|
||||
var numExpressions = assert(expressions.length);
|
||||
@ -719,9 +729,10 @@ export class ASTBuilder {
|
||||
sb.push(";\n");
|
||||
} else {
|
||||
let last = sb[sb.length - 1];
|
||||
if (last.length && (
|
||||
last.charCodeAt(last.length - 1) == CharCode.CLOSEBRACE ||
|
||||
last.charCodeAt(last.length - 1) == CharCode.SEMICOLON)
|
||||
let lastCharPos = last.length - 1;
|
||||
if (lastCharPos >= 0 && (
|
||||
last.charCodeAt(lastCharPos) == CharCode.CLOSEBRACE ||
|
||||
last.charCodeAt(lastCharPos) == CharCode.SEMICOLON)
|
||||
) {
|
||||
sb.push("\n");
|
||||
} else {
|
||||
@ -778,8 +789,12 @@ export class ASTBuilder {
|
||||
this.serializeExternalModifiers(node);
|
||||
var sb = this.sb;
|
||||
if (node.is(CommonFlags.ABSTRACT)) sb.push("abstract ");
|
||||
sb.push("class ");
|
||||
this.visitIdentifierExpression(node.name);
|
||||
if (node.name.text.length) {
|
||||
sb.push("class ");
|
||||
this.visitIdentifierExpression(node.name);
|
||||
} else {
|
||||
sb.push("class");
|
||||
}
|
||||
var typeParameters = node.typeParameters;
|
||||
var numTypeParameters = typeParameters.length;
|
||||
if (numTypeParameters) {
|
||||
|
Reference in New Issue
Block a user