Skip to content

Commit

Permalink
chore(ast-generic): Add Cls variant (#329)
Browse files Browse the repository at this point in the history
- [X] I ran `make setup && make` to update the generated code after
editing a `.atd` file (TODO: have a CI check)
- [X] I made sure we're still backward compatible with old versions of
the CLI.
For example, the Semgrep backend need to still be able to *consume* data
	  generated by Semgrep 1.50.0.
See
https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
	  Note that the types related to the semgrep-core JSON output or the
	  semgrep-core RPC do not need to be backward compatible!
  • Loading branch information
brandonspark authored Dec 12, 2024
1 parent f71d99f commit 1c82453
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ast_generic_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ type field_name = [
type special = [
(* special vars *)
| This | Super (* called 'base' in C# *)
| Cls (* similar to `self`, but indicating the type of the class, not the instance *)
| Self | Parent (* different from This/Super? *)

(* special calls *)
Expand Down
7 changes: 7 additions & 0 deletions ast_generic_v1_j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ let write_special = (
match x with
| `This -> Buffer.add_string ob "\"This\""
| `Super -> Buffer.add_string ob "\"Super\""
| `Cls -> Buffer.add_string ob "\"Cls\""
| `Self -> Buffer.add_string ob "\"Self\""
| `Parent -> Buffer.add_string ob "\"Parent\""
| `Eval -> Buffer.add_string ob "\"Eval\""
Expand Down Expand Up @@ -1435,6 +1436,10 @@ let read_special = (
Yojson.Safe.read_space p lb;
Yojson.Safe.read_gt p lb;
`Super
| "Cls" ->
Yojson.Safe.read_space p lb;
Yojson.Safe.read_gt p lb;
`Cls
| "Self" ->
Yojson.Safe.read_space p lb;
Yojson.Safe.read_gt p lb;
Expand Down Expand Up @@ -1578,6 +1583,8 @@ let read_special = (
`This
| "Super" ->
`Super
| "Cls" ->
`Cls
| "Self" ->
`Self
| "Parent" ->
Expand Down

0 comments on commit 1c82453

Please sign in to comment.