[ruby/prism] Expose main_script in serialization API

https://github.com/ruby/prism/commit/0b527ca93f
This commit is contained in:
Kevin Newton 2024-09-13 15:00:03 -04:00 коммит произвёл git
Родитель 77521afac1
Коммит f85efc9748
3 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -448,6 +448,9 @@ module Prism
template << "C"
values << (options[:encoding] == false ? 1 : 0)
template << "C"
values << (options.fetch(:main_script, false) ? 1 : 0)
template << "L"
if (scopes = options[:scopes])
values << scopes.length

Просмотреть файл

@ -756,6 +756,11 @@ parse_input(pm_string_t *input, const pm_options_t *options) {
* has been set. This should be a boolean or nil.
* * `line` - the line number that the parse starts on. This should be an
* integer or nil. Note that this is 1-indexed.
* * `main_script` - a boolean indicating whether or not the source being parsed
* is the main script being run by the interpreter. This controls whether
* or not shebangs are parsed for additional flags and whether or not the
* parser will attempt to find a matching shebang if the first one does
* not contain the word "ruby".
* * `scopes` - the locals that are in scope surrounding the code that is being
* parsed. This should be an array of arrays of symbols or nil. Scopes are
* ordered from the outermost scope to the innermost one.

Просмотреть файл

@ -241,6 +241,7 @@ pm_options_read(pm_options_t *options, const char *data) {
options->command_line = (uint8_t) *data++;
options->version = (pm_options_version_t) *data++;
options->encoding_locked = ((uint8_t) *data++) > 0;
options->main_script = ((uint8_t) *data++) > 0;
uint32_t scopes_count = pm_options_read_u32(data);
data += 4;