[ruby/prism] Add numbered_parameters field to BlockNode and LambdaNode

We are aware at parse time how many numbered parameters we have
on a BlockNode or LambdaNode, but prior to this commit, did not
store that information anywhere in its own right.

The numbered parameters were stored as locals, but this does not
distinguish them from other locals that have been set, for example
in `a { b = 1; _1 }` there is nothing on the AST that distinguishes
b from _1.

Consumers such as the compiler need to know information about how
many numbered parameters exist to set up their own tables around
parameters. Since we have this information at parse time, we should
compute it here, instead of deferring the work later on.

bf4a1e124d
This commit is contained in:
Jemma Issroff 2023-11-28 15:42:33 -05:00 committed by git
parent 6310522a9a
commit 04cbcd37b1
194 changed files with 1357 additions and 869 deletions

View file

@ -468,11 +468,12 @@ typedef struct pm_scope {
bool explicit_params;
/**
* A boolean indicating whether or not this scope has numbered parameters.
* An integer indicating the number of numbered parameters on this scope.
* This is necessary to determine if child blocks are allowed to use
* numbered parameters.
* numbered parameters, and to pass information to consumers of the AST
* about how many numbered parameters exist.
*/
bool numbered_params;
uint32_t numbered_parameters;
/**
* A transparent scope is a scope that cannot have locals set on itself.