AST: add Self class

This commit is contained in:
Arthur Baars
2021-02-12 13:15:49 +01:00
parent ce824f4adb
commit 64cba18c41
5 changed files with 23 additions and 5 deletions

View File

@@ -12,6 +12,18 @@ class Expr extends Stmt {
Expr() { this = range }
}
/**
* A reference to the current object. For example:
* - `self == other`
* - `self.method_name`
* - `def self.method_name ... end`
*/
class Self extends Expr, @token_self {
override Self::Range range;
final override string getAPrimaryQlClass() { result = "Self" }
}
/**
* A literal.
*

View File

@@ -47,8 +47,6 @@ module AstNode {
or
this instanceof Generated::BareString
or
this instanceof Generated::Self
or
this instanceof Generated::Float
or
this instanceof Generated::Superclass

View File

@@ -6,6 +6,14 @@ module Expr {
abstract class Range extends Stmt::Range { }
}
module Self {
class Range extends Expr::Range, @token_self {
final override Generated::Self generated;
final override string toString() { result = "self" }
}
}
module Literal {
abstract class Range extends Expr::Range {
abstract string getValueText();