pub struct VMHelper {Show 76 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 test_pass_count: AtomicUsize,
pub test_fail_count: AtomicUsize,
pub test_skip_count: AtomicUsize,
pub test_run_failed: AtomicBool,
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 cached_chunk: Option<Chunk>,
pub cache_script_path: Option<PathBuf>,
pub line_mode_skip_main: bool,
pub line_mode_chunk: Option<Chunk>,
pub line_mode_stdin_pending: VecDeque<String>,
pub debugger: Option<Debugger>,
/* private fields */
}Expand description
There is no Tree walking Interpreter, this is Just a Virtual Machine helper struct
Fields§
§scope: Scope§ofs: StringOutput separator ($,)
ors: StringOutput 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: i32Numeric errno for $! dualvar (raw_os_error()), 0 when unset.
eval_error: String$@ — last eval error (string)
eval_error_code: i32Numeric 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: boolFalse until first Self::materialize_env_if_needed (defers std::env::vars() cost).
program_name: String$0
line_number: i64Current line number $. (global increment; see handle_line_numbers for per-handle)
last_readline_handle: StringLast 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: boolAuto-split mode (-a)
field_separator: Option<String>Field separator for -F
warnings: bool-w warnings / use warnings / $^W
output_autoflush: boolOutput autoflush ($|).
default_print_handle: StringDefault handle for print / say / printf with no explicit handle (select FH sets this).
suppress_stdout: boolSuppress stdout output (fan workers with progress bars).
test_pass_count: AtomicUsizePer-instance test counters for assert_* / test_run / test_skip (stryke
.stk test framework). Atomics so the immutable-ref builtin signature
(fn(&VMHelper, ...)) can mutate without changing every call site. Replaces
the previous AtomicUsize process-globals which leaked counts across runs
in a single process — embedders running multiple .stk programs in one
VMHelper would see the previous run’s counts contaminate the next.
test_fail_count: AtomicUsize§test_skip_count: AtomicUsize§test_run_failed: AtomicBoolSet to true by test_run when any assertion failed during the run.
CLI driver (main.rs) reads this after execute returns and exits with
code 1. Replaces the previous in-VM std::process::exit(1) which made
embedding (running a .stk program from a Rust harness) impossible —
any failing test would kill the host process.
child_exit_status: i64Child wait status ($?) — POSIX-style (exit code in high byte, etc.).
last_match: StringLast successful match ($&, ${^MATCH}).
prematch: StringBefore match ($`, ${^PREMATCH}).
postmatch: StringAfter match ($', ${^POSTMATCH}).
last_paren_match: StringLast bracket match ($+, ${^LAST_SUBMATCH_RESULT}).
list_separator: StringList separator for array stringification in concatenation / interpolation ($").
script_start_time: i64Script 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: u32Nesting 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: booluse strict / use strict 'refs' / qw(refs subs vars) (Perl names).
strict_subs: bool§strict_vars: bool§utf8_pragma: booluse utf8 — source is UTF-8 (reserved for future lexer/string semantics).
open_pragma_utf8: booluse open ':encoding(UTF-8)' / qw(:std :encoding(UTF-8)) / :utf8 — readline uses UTF-8 lossy decode.
feature_bits: u64use feature — bit flags (FEAT_*).
num_threads: usizeNumber of parallel threads
struct_defs: HashMap<String, Arc<StructDef>>struct Name { ... } definitions (merged from VM chunks).
enum_defs: HashMap<String, Arc<EnumDef>>enum Name { ... } definitions (merged from VM chunks).
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); 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: boolWhen 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: boolWhen true, crate::try_vm_execute prints bytecode disassembly to stderr before running the VM.
cached_chunk: Option<Chunk>Sideband: precompiled crate::bytecode::Chunk loaded from a bytecode 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.
cache_script_path: Option<PathBuf>Sideband: script path for bytecode cache save after compilation (mtime-based).
line_mode_skip_main: bool-n/-p driver: prelude only; body runs per line in [Self::process_line_vm].
line_mode_chunk: Option<Chunk>Pre-compiled chunk for -n/-p line mode. Stored after the prelude execute() call
so process_line_vm can re-execute the body portion per input 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 VMHelper
impl VMHelper
pub fn new() -> Self
Sourcepub fn refresh_parameters_hash(&mut self)
pub fn refresh_parameters_hash(&mut self)
Rebuild %parameters (zsh-$parameters analogue) from the current
scope. Maps every live sigil-prefixed name ($x, @a, %h, …) to its
kind string ("scalar", "array", "hash", "atomic_array",
"atomic_hash", "shared_array", "shared_hash"). Installed as a
frozen global hash so user code can read it but not assign into it
(parallel to %all / %b / %stryke::*). Refreshed automatically on
every %parameters read via the touch_env_hash hook, so the snapshot
is always current — the user never needs to call this directly.
Sourcepub fn refresh_package_stashes(&mut self)
pub fn refresh_package_stashes(&mut self)
Populate %main:: / %Foo:: package stashes with current symbol-table
state so keys %main:: and keys %Foo:: enumerate live names. Maps
each unqualified name → its kind string ("scalar", "array",
"hash", "sub"). Stryke has no real Perl typeglob layer; the kind
string is the most useful per-symbol value we can offer.
Callable repeatedly — overwrites prior stashes — so the REPL refreshes
after every line and scripts can call it explicitly via the
refresh_stashes() builtin if they want post-eval visibility.
Sourcepub fn line_mode_worker_clone(&self) -> VMHelper
pub fn line_mode_worker_clone(&self) -> VMHelper
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).
Sourcepub fn materialize_env_if_needed(&mut self)
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.
Sourcepub fn register_virtual_module(&mut self, path: String, source: String)
pub fn register_virtual_module(&mut self, path: String, source: String)
Register a virtual module (for AOT bundles). Path should be relative like “lib/foo.stk”.
Sourcepub fn install_data_handle(&mut self, data: Vec<u8>)
pub fn install_data_handle(&mut self, data: Vec<u8>)
Install the DATA handle from a script __DATA__ section (bytes after the marker line).
pub fn set_file(&mut self, file: &str)
Sourcepub fn repl_completion_names(&self) -> Vec<String>
pub fn repl_completion_names(&self) -> Vec<String>
Keywords, builtins, lexical names, and subroutine names for REPL tab-completion.
Sourcepub fn repl_completion_snapshot(&self) -> ReplCompletionSnapshot
pub fn repl_completion_snapshot(&self) -> ReplCompletionSnapshot
Subroutine keys, blessed scalar classes, and @ISA edges for REPL $obj-> completion.
pub fn execute(&mut self, program: &Program) -> PerlResult<PerlValue>
Sourcepub fn run_end_blocks(&mut self) -> PerlResult<()>
pub fn run_end_blocks(&mut self) -> PerlResult<()>
Run END blocks (after -n/-p line loop when prelude used Self::line_mode_skip_main).
Sourcepub fn run_global_teardown(&mut self) -> PerlResult<()>
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.
Sourcepub fn process_line(
&mut self,
line_str: &str,
_program: &Program,
is_last_input_line: bool,
) -> PerlResult<Option<String>>
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 via the VM.
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§
Auto Trait Implementations§
impl !Freeze for VMHelper
impl !RefUnwindSafe for VMHelper
impl Send for VMHelper
impl !Sync for VMHelper
impl Unpin for VMHelper
impl UnsafeUnpin for VMHelper
impl !UnwindSafe for VMHelper
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.