mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 02:31:41 +00:00
Initial implementation of 'instanceof'
Works like an assignability check for now / does not yet honor nullables.
This commit is contained in:
@ -52,6 +52,7 @@ import {
|
||||
ForStatement,
|
||||
IfStatement,
|
||||
ImportStatement,
|
||||
InstanceOfExpression,
|
||||
ReturnStatement,
|
||||
SwitchStatement,
|
||||
ThrowStatement,
|
||||
@ -160,6 +161,10 @@ export class ASTBuilder {
|
||||
this.visitFunctionExpression(<FunctionExpression>node);
|
||||
break;
|
||||
}
|
||||
case NodeKind.INSTANCEOF: {
|
||||
this.visitInstanceOfExpression(<InstanceOfExpression>node);
|
||||
break;
|
||||
}
|
||||
case NodeKind.LITERAL: {
|
||||
this.visitLiteralExpression(<LiteralExpression>node);
|
||||
break;
|
||||
@ -544,6 +549,12 @@ export class ASTBuilder {
|
||||
this.sb.push(node.value.toString(10));
|
||||
}
|
||||
|
||||
visitInstanceOfExpression(node: InstanceOfExpression): void {
|
||||
this.visitNode(node.expression);
|
||||
this.sb.push(" instanceof ");
|
||||
this.visitTypeNode(node.isType);
|
||||
}
|
||||
|
||||
visitIntegerLiteralExpression(node: IntegerLiteralExpression): void {
|
||||
this.sb.push(i64_to_string(node.value));
|
||||
}
|
||||
|
Reference in New Issue
Block a user