Struct pm_options

Source
#[repr(C)]
pub struct pm_options {
Show 14 fields pub shebang_callback: pm_options_shebang_callback_t, pub shebang_callback_data: *mut c_void, pub filepath: pm_string_t, pub line: i32, pub encoding: pm_string_t, pub scopes_count: usize, pub scopes: *mut pm_options_scope_t, pub version: pm_options_version_t, pub command_line: u8, pub frozen_string_literal: i8, pub encoding_locked: bool, pub main_script: bool, pub partial_script: bool, pub freeze: bool,
}
Expand description

Forward declaration needed by the callback typedef.

Fields§

§shebang_callback: pm_options_shebang_callback_t

The callback to call when additional switches are found in a shebang comment.

§shebang_callback_data: *mut c_void

Any additional data that should be passed along to the shebang callback if one was set.

§filepath: pm_string_t

The name of the file that is currently being parsed.

§line: i32

The line within the file that the parse starts on. This value is 1-indexed.

§encoding: pm_string_t

The name of the encoding that the source file is in. Note that this must correspond to a name that can be found with Encoding.find in Ruby.

§scopes_count: usize

The number of scopes surrounding the code that is being parsed.

§scopes: *mut pm_options_scope_t

The scopes surrounding the code that is being parsed. For most parses this will be NULL, but for evals it will be the locals that are in scope surrounding the eval. Scopes are ordered from the outermost scope to the innermost one.

§version: pm_options_version_t

The version of prism that we should be parsing with. This is used to allow consumers to specify which behavior they want in case they need to parse exactly as a specific version of CRuby.

§command_line: u8

A bitset of the various options that were set on the command line.

§frozen_string_literal: i8

Whether or not the frozen string literal option has been set. May be:

  • PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED
  • PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED
  • PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET
§encoding_locked: bool

Whether or not the encoding magic comments should be respected. This is a niche use-case where you want to parse a file with a specific encoding but ignore any encoding magic comments at the top of the file.

§main_script: bool

When the file being parsed is the main script, the shebang will be considered for command-line flags (or for implicit -x). The caller needs to pass this information to the parser so that it can behave correctly.

§partial_script: bool

When the file being parsed is considered a “partial” script, jumps will not be marked as errors if they are not contained within loops/blocks. This is used in the case that you’re parsing a script that you know will be embedded inside another script later, but you do not have that context yet. For example, when parsing an ERB template that will be evaluated inside another script.

§freeze: bool

Whether or not the parser should freeze the nodes that it creates. This makes it possible to have a deeply frozen AST that is safe to share between concurrency primitives.

Trait Implementations§

Source§

impl Clone for pm_options

Source§

fn clone(&self) -> pm_options

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for pm_options

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for pm_options

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for pm_options

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.