mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 09:21:35 +00:00
Initial implementation of 'instanceof'
Works like an assignability check for now / does not yet honor nullables.
This commit is contained in:
23
src/ast.ts
23
src/ast.ts
@ -45,6 +45,7 @@ export enum NodeKind {
|
||||
ELEMENTACCESS,
|
||||
FALSE,
|
||||
FUNCTION,
|
||||
INSTANCEOF,
|
||||
LITERAL,
|
||||
NEW,
|
||||
NULL,
|
||||
@ -346,6 +347,18 @@ export abstract class Node {
|
||||
return expr;
|
||||
}
|
||||
|
||||
static createInstanceOfExpression(
|
||||
expression: Expression,
|
||||
isType: CommonTypeNode,
|
||||
range: Range
|
||||
): InstanceOfExpression {
|
||||
var expr = new InstanceOfExpression();
|
||||
expr.range = range;
|
||||
expr.expression = expression; expression.parent = expr;
|
||||
expr.isType = isType; isType.parent = expr;
|
||||
return expr;
|
||||
}
|
||||
|
||||
static createIntegerLiteralExpression(
|
||||
value: I64,
|
||||
range: Range
|
||||
@ -1267,6 +1280,16 @@ export class FunctionExpression extends Expression {
|
||||
declaration: FunctionDeclaration;
|
||||
}
|
||||
|
||||
/** Represents an `instanceof` expression. */
|
||||
export class InstanceOfExpression extends Expression {
|
||||
kind = NodeKind.INSTANCEOF;
|
||||
|
||||
/** Expression being asserted. */
|
||||
expression: Expression;
|
||||
/** Type to test for. */
|
||||
isType: CommonTypeNode;
|
||||
}
|
||||
|
||||
/** Represents an integer literal expression. */
|
||||
export class IntegerLiteralExpression extends LiteralExpression {
|
||||
literalKind = LiteralKind.INTEGER;
|
||||
|
Reference in New Issue
Block a user