Skip to main content

Interpreter

Struct Interpreter 

Source
pub struct Interpreter {
Show 71 fields pub scope: Scope, pub ofs: String, pub ors: String, pub irs: Option<String>, pub errno: String, pub errno_code: i32, pub eval_error: String, pub eval_error_code: i32, pub eval_error_value: Option<PerlValue>, pub argv: Vec<String>, pub env: IndexMap<String, PerlValue>, pub env_materialized: bool, pub program_name: String, pub line_number: i64, pub last_readline_handle: String, pub handle_line_numbers: HashMap<String, i64>, pub sigint_pending_caret: Cell<bool>, pub auto_split: bool, pub field_separator: Option<String>, pub warnings: bool, pub output_autoflush: bool, pub default_print_handle: String, pub suppress_stdout: bool, pub child_exit_status: i64, pub last_match: String, pub prematch: String, pub postmatch: String, pub last_paren_match: String, pub list_separator: String, pub script_start_time: i64, pub compile_hints: i64, pub warning_bits: i64, pub global_phase: String, pub subscript_sep: String, pub inplace_edit: String, pub debug_flags: i64, pub perl_debug_flags: i64, pub eval_nesting: u32, pub argv_current_file: String, pub strict_refs: bool, pub strict_subs: bool, pub strict_vars: bool, pub utf8_pragma: bool, pub open_pragma_utf8: bool, pub feature_bits: u64, pub num_threads: usize, pub struct_defs: HashMap<String, Arc<StructDef>>, pub enum_defs: HashMap<String, Arc<EnumDef>>, pub class_defs: HashMap<String, Arc<ClassDef>>, pub trait_defs: HashMap<String, Arc<TraitDef>>, pub profiler: Option<Profiler>, pub format_page_number: i64, pub format_lines_per_page: i64, pub format_lines_left: i64, pub format_line_break_chars: String, pub format_top_name: String, pub accumulator_format: String, pub max_system_fd: i64, pub emergency_memory: String, pub last_subpattern_name: String, pub inc_hook_index: i64, pub multiline_match: bool, pub executable_path: String, pub formfeed_string: String, pub vm_jit_enabled: bool, pub disasm_bytecode: bool, pub pec_precompiled_chunk: Option<Chunk>, pub pec_cache_fingerprint: Option<[u8; 32]>, pub line_mode_skip_main: bool, pub line_mode_stdin_pending: VecDeque<String>, pub debugger: Option<Debugger>, /* private fields */
}

Fields§

§scope: Scope§ofs: String

Output separator ($,)

§ors: String

Output record separator ($)

§irs: Option<String>

Input record separator ($/). None represents undef (slurp mode in <>). Default at startup: Some("\n"). local $/ (no init) sets None.

§errno: String

$! — last OS error

§errno_code: i32

Numeric errno for $! dualvar (raw_os_error()), 0 when unset.

§eval_error: String

$@ — last eval error (string)

§eval_error_code: i32

Numeric side of $@ dualvar (0 when cleared; 1 for typical exception strings; or explicit code from assignment / dualvar).

§eval_error_value: Option<PerlValue>

When die is called with a ref argument, the ref value is preserved here.

§argv: Vec<String>

@ARGV

§env: IndexMap<String, PerlValue>

%ENV (mirrors scope hash "ENV" after Self::materialize_env_if_needed)

§env_materialized: bool

False until first Self::materialize_env_if_needed (defers std::env::vars() cost).

§program_name: String

$0

§line_number: i64

Current line number $. (global increment; see handle_line_numbers for per-handle)

§last_readline_handle: String

Last handle key used for $. (e.g. STDIN, FH, ARGV:path).

§handle_line_numbers: HashMap<String, i64>

Line count per handle for $. when keyed (Perl-style last-read handle).

§sigint_pending_caret: Cell<bool>

$^C — set when SIGINT is pending before handler runs (cleared on read).

§auto_split: bool

Auto-split mode (-a)

§field_separator: Option<String>

Field separator for -F

§warnings: bool

-w warnings / use warnings / $^W

§output_autoflush: bool

Output autoflush ($|).

§default_print_handle: String

Default handle for print / say / printf with no explicit handle (select FH sets this).

§suppress_stdout: bool

Suppress stdout output (fan workers with progress bars).

§child_exit_status: i64

Child wait status ($?) — POSIX-style (exit code in high byte, etc.).

§last_match: String

Last successful match ($&, ${^MATCH}).

§prematch: String

Before match ($`, ${^PREMATCH}).

§postmatch: String

After match ($', ${^POSTMATCH}).

§last_paren_match: String

Last bracket match ($+, ${^LAST_SUBMATCH_RESULT}).

§list_separator: String

List separator for array stringification in concatenation / interpolation ($").

§script_start_time: i64

Script start time ($^T) — seconds since Unix epoch.

§compile_hints: i64

$^H — compile-time hints (bit flags; pragma / BEGIN may update).

§warning_bits: i64

${^WARNING_BITS} — warnings bitmask (Perl internal; surfaced for compatibility).

§global_phase: String

${^GLOBAL_PHASE} — interpreter phase (RUN, …).

§subscript_sep: String

$; — hash subscript separator (multi-key join); Perl default \034.

§inplace_edit: String

$^I — in-place edit backup suffix (empty when no backup; also unset when -i was not passed). The stryke driver sets this from -i / -i.ext.

§debug_flags: i64

$^D — debugging flags (integer; mostly ignored).

§perl_debug_flags: i64

$^P — debugging / profiling flags (integer; mostly ignored).

§eval_nesting: u32

Nesting depth for eval / evalblock ($^S is non-zero while inside eval).

§argv_current_file: String

$ARGV — name of the file last opened by <> (empty for stdin or before first file).

§strict_refs: bool

use strict / use strict 'refs' / qw(refs subs vars) (Perl names).

§strict_subs: bool§strict_vars: bool§utf8_pragma: bool

use utf8 — source is UTF-8 (reserved for future lexer/string semantics).

§open_pragma_utf8: bool

use open ':encoding(UTF-8)' / qw(:std :encoding(UTF-8)) / :utf8 — readline uses UTF-8 lossy decode.

§feature_bits: u64

use feature — bit flags (FEAT_*).

§num_threads: usize

Number of parallel threads

§struct_defs: HashMap<String, Arc<StructDef>>

struct Name { ... } definitions (merged from VM chunks and tree-walker).

§enum_defs: HashMap<String, Arc<EnumDef>>

enum Name { ... } definitions (merged from VM chunks and tree-walker).

§class_defs: HashMap<String, Arc<ClassDef>>

class Name extends ... impl ... { ... } definitions.

§trait_defs: HashMap<String, Arc<TraitDef>>

trait Name { ... } definitions.

§profiler: Option<Profiler>

When set, stryke --profile records timings: VM path uses per-opcode line samples and sub call/return (JIT disabled); tree-walker fallback uses per-statement lines and subs.

§format_page_number: i64

$% — format output page number.

§format_lines_per_page: i64

$= — format lines per page.

§format_lines_left: i64

$- — lines remaining on format page.

§format_line_break_chars: String

$: — characters to break format lines (Perl default \n).

§format_top_name: String

$^ — top-of-form format name.

§accumulator_format: String

$^A — format write accumulator.

§max_system_fd: i64

$^F — max system file descriptor (Perl default 2).

§emergency_memory: String

$^M — emergency memory buffer (no-op pool in stryke).

§last_subpattern_name: String

$^N — last opened named regexp capture name.

§inc_hook_index: i64

$INC@INC hook iterator (Perl 5.37+).

§multiline_match: bool

$* — multiline matching (deprecated in Perl); when true, compile_regex prepends (?s).

§executable_path: String

$^X — path to this executable (cached).

§formfeed_string: String

$^L — formfeed string for formats (Perl default \f).

§vm_jit_enabled: bool

When false, the bytecode VM runs without Cranelift (see crate::try_vm_execute). Disabled by STRYKE_NO_JIT=1 / true / yes, or stryke --no-jit after Self::new.

§disasm_bytecode: bool

When true, crate::try_vm_execute prints bytecode disassembly to stderr before running the VM.

§pec_precompiled_chunk: Option<Chunk>

Sideband: precompiled crate::bytecode::Chunk loaded from a .pec cache hit. When Some, crate::try_vm_execute uses it directly and skips compile_program. Consumed (.take()) on first read so re-entry compiles normally.

§pec_cache_fingerprint: Option<[u8; 32]>

Sideband: fingerprint to save the compiled chunk under after a cache miss (pairs with crate::pec::try_save). None when the cache is disabled or the caller does not want the compiled chunk persisted.

§line_mode_skip_main: bool

-n/-p driver: prelude only in Self::execute_tree; body runs in Self::process_line.

§line_mode_stdin_pending: VecDeque<String>

-n/-p stdin driver: lines peek-read to compute eof / is_last are pushed here so <> / readline in the body reads them before the real stdin stream (Perl shares one fd).

§debugger: Option<Debugger>

Interactive debugger state (-d flag).

Implementations§

Source§

impl Interpreter

Source

pub fn new() -> Self

Source

pub fn line_mode_worker_clone(&self) -> Interpreter

Fork interpreter state for -n/-p over multiple @ARGV files in parallel (rayon). Clears file descriptors and I/O handles (each worker only runs the line loop).

Source

pub fn materialize_env_if_needed(&mut self)

Populate Self::env and the %ENV hash from std::env::vars once. Deferred from Self::new to reduce interpreter startup when %ENV is unused.

Source

pub fn install_data_handle(&mut self, data: Vec<u8>)

Install the DATA handle from a script __DATA__ section (bytes after the marker line).

Source

pub fn set_file(&mut self, file: &str)

Source

pub fn repl_completion_names(&self) -> Vec<String>

Keywords, builtins, lexical names, and subroutine names for REPL tab-completion.

Source

pub fn repl_completion_snapshot(&self) -> ReplCompletionSnapshot

Subroutine keys, blessed scalar classes, and @ISA edges for REPL $obj-> completion.

Source

pub fn execute(&mut self, program: &Program) -> PerlResult<PerlValue>

Source

pub fn run_end_blocks(&mut self) -> PerlResult<()>

Run END blocks (after -n/-p line loop when prelude used Self::line_mode_skip_main).

Source

pub fn run_global_teardown(&mut self) -> PerlResult<()>

After a top-level program finishes (post-END), set ${^GLOBAL_PHASE} to DESTRUCT and drain remaining DESTROY callbacks.

Source

pub fn execute_tree(&mut self, program: &Program) -> PerlResult<PerlValue>

Tree-walking execution (fallback when bytecode compilation fails).

Source

pub fn process_line( &mut self, line_str: &str, program: &Program, is_last_input_line: bool, ) -> PerlResult<Option<String>>

Process a line in -n/-p mode.

is_last_input_line is true when this line is the last from the current stdin or @ARGV file so eof with no arguments matches Perl behavior on that line.

Trait Implementations§

Source§

impl Default for Interpreter

Source§

fn default() -> Self

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

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V