Skip to main content

Interpreter

Struct Interpreter 

Source
pub struct Interpreter {
    pub debug_breakpoint_check: Option<DebugBreakpointCheck>,
    pub debug_breakpoint_handler: Option<DebugBreakpointHandler>,
    /* private fields */
}
Expand description

Pascal interpreter using modular architecture

Fields§

§debug_breakpoint_check: Option<DebugBreakpointCheck>§debug_breakpoint_handler: Option<DebugBreakpointHandler>

Implementations§

Source§

impl Interpreter

Source

pub fn new(verbose: bool) -> Self

Create a new interpreter

Source

pub fn current_scope(&self) -> &Scope

Get the current scope for testing purposes

Source

pub fn get_variable_value(&self, name: &str) -> Option<Value>

Get a variable value for testing purposes

Source

pub fn scope_count(&self) -> usize

Number of active scopes (for leak analysis)

Source

pub fn all_scope_variables(&self) -> Vec<(String, Value)>

All variables across all scopes

Source

pub fn load_uses_clause(&mut self, uses: &[String]) -> Result<()>

Load uses clause units (simplified implementation)

Source

pub fn declare_block_vars(&mut self, block: &Block) -> Result<()>

Declare variables in a block

Source

pub fn register_block_types(&mut self, block: &Block) -> Result<()>

Register type declarations (enum constants and generic types) in a block

Source

pub fn register_block_classes(&mut self, block: &Block) -> Result<()>

Register classes in a block

Source

pub fn register_class(&mut self, class_decl: &ClassDecl) -> Result<()>

Register a single class (validates interfaces when registry knows them)

Source

pub fn register_interface(&mut self, iface: InterfaceDecl)

Register an interface declaration

Source

pub fn register_operator_overload(&mut self, overload: OperatorOverload)

Register a user-defined operator overload (the implementation is a function with the given name, already registered in the function table).

Source

pub fn register_block_functions(&mut self, block: &Block) -> Result<()>

Register functions and procedures in a block

Source

pub fn run_program(&mut self, program: &Program) -> Result<()>

Execute a program

Source

pub fn execute_stmt(&mut self, stmt: &Stmt) -> Result<()>

Execute a statement

Source

pub fn eval_expr(&mut self, expr: &Expr) -> Result<Value>

Evaluate an expression

Source

pub fn eval_literal(&mut self, literal: &Literal) -> Result<Value>

Evaluate a literal value

Source

pub fn call_function(&mut self, name: &str, args: &[Value]) -> Result<Value>

Call a built-in or user function

Source

pub fn call_procedure(&mut self, name: &str, args: &[Value]) -> Result<()>

Call a procedure (function that returns Nil)

Source

pub fn execute_block_stmts(&mut self, statements: &[Stmt]) -> Result<()>

Execute multiple statements (for blocks)

Source

pub fn set_debug_mode(&mut self, debug: bool)

Enable debug mode

Source

pub fn set_debug_breakpoint_check(&mut self, callback: DebugBreakpointCheck)

Set debug breakpoint callback

Source

pub fn set_debug_breakpoint_handler(&mut self, handler: DebugBreakpointHandler)

Set debug breakpoint handler

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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