Commit Graph

14 Commits

Author SHA1 Message Date
Michael Schimmel 260669cba1 Perf: Restore core optimizations and stabilize VM execution
This commit restores and enhances several high-performance features that
were
previously lost, while fixing critical bugs in scope management.

Performance Optimizations:
- Zero-Copy TCO: Refactored TailCallRequest to use (Rc, usize), moving
  arguments
  directly on the VM stack via drain/resize instead of heap-allocating
  Vecs.
- Slice-based Calls: Native functions and field accessors now operate
  directly
  on stack slices, significantly reducing memory churn.
- SoA Push Fast-Path: Restored specialized 'push' intrinsic for
  RecordSeries.
  Matches layouts via Arc::ptr_eq to distribute values directly into
  columns
  without keyword lookups.

Architectural Improvements:
- Static Stack Frames (max_slots): The Binder now calculates the maximum

  required slots per lambda. The VM pre-resizes the stack frame,
  preventing
  collisions between local variables and temporary call arguments.
- Macro Hygiene: Fixed a bug where macro-internal variables could
  overwrite
  outer call arguments due to stack overlap.
- Trait Refactoring: Unified series operations via a polymorphic
  'push_value'
  on the Series trait, with a generic implementation for
  ScalarSeries<T>.

Code Quality:
- Resolved all 'cargo clippy' warnings (collapsible ifs, redundant
  borrows, etc).
- Restored 100% test pass rate (64/64 tests).
- Verified stability of all examples and benchmarks.
2026-03-10 13:06:56 +01:00
Michael Schimmel 595bcf09e5 Update examples to use StreamNode and Series with lookback
The `PipelineNode` has been refactored into `StreamNode`. This commit
updates the example files to reflect this change and also updates the
`series` constructor to accept a lookback parameter.

The `PipelineNode` was an artifact of a previous implementation and is
no longer needed. The `StreamNode` is the appropriate type for
representing the output of a pipe operation.

The `series` function now requires a `lookback` argument to specify the
maximum number of items to store. This makes the behavior of series more
explicit and prevents accidental unbounded memory growth.
2026-03-07 23:48:09 +01:00
Michael Schimmel 7b6f6e52bd Fix: Improve series type handling and coercions
This commit enhances the series type handling in `src/ast/rtl/series.rs`
by introducing helper methods `as_float` and `as_int` in
`src/ast/types.rs` to manage type conversions more robustly.

It also updates the function overload resolution in `src/ast/types.rs`
to prioritize exact parameter matches before falling back to implicit
coercions.

Finally, the example `err.myc` has been updated to reflect a more
accurate implementation of a Simple Moving Average (SMA) calculation.
2026-03-06 16:31:50 +01:00
Michael Schimmel 7e3b000d99 Handle Int values in ScalarSeries<f64> push 2026-03-06 16:03:49 +01:00
Michael Schimmel 9ba4f795d1 Change series field type from :msg to :text
Update example to use :text for string fields in series. This aligns
with the new :text type support in the series implementation.
2026-03-05 15:07:31 +01:00
Michael Schimmel 831525b402 Add series, SMA, and WMA indicators
Introduce new indicators for Simple Moving Average (SMA) and Weighted
Moving Average (WMA), along with their Hull Moving Average (HMA)
derivative.

Also refactors series implementation to use `RefCell` for interior
mutability and adds `SeriesMember` trait for better dynamic series
access. Updates `soa_series.myc` example to reflect new series creation
and push syntax.
2026-03-05 14:07:42 +01:00
Michael Schimmel 8c4db9a5ba Refactor function signatures to use slices 2026-03-03 18:13:20 +01:00
Michael Schimmel 2eb7a2e136 Formatting 2026-03-02 23:13:36 +01:00
Michael Schimmel b177aa8854 feat: Add SharedValueSeries and PipelineNode
Introduces `SharedValueSeries` for read-only access to generic `Value`
buffers, and `PipelineNode` which combines an `ObservableStream` with a
`Series` view. This is a foundational step for implementing the `pipe`
operator.
2026-03-01 23:12:09 +01:00
Michael Schimmel a98e51c762 feat: Add streams module for reactive pipeline
Introduces the streams module, defining core reactive primitives like
Signal,
Stream, Observer, RootStream, and PipeStream. This module lays the
groundwork
for building reactive data processing pipelines.

Includes new types for managing reactive data flow and a basic test
suite to
verify the functionality of RootStream and PipeStream.
2026-03-01 21:33:37 +01:00
Michael Schimmel b74ddcfd61 Introduce unified Series trait
This commit introduces the `Series` trait to provide a unified interface
for accessing indexed data across different series types (RecordSeries,
SeriesView, and future SharedSeries). This simplifies the VM's indexer
logic and lays the groundwork for the dual series architecture.
2026-03-01 21:24:42 +01:00
Michael Schimmel 46b546446f Add RecordSeries::get_record and support for (my_ticks 0)
This commit introduces the `get_record` method to `RecordSeries`,
allowing for the dynamic reconstruction of a full record from its
constituent fields at a given index. This enables idiomatic access to
series data using indexing like `(my_ticks 0)`.

The `push-series` function has also been updated to correctly handle the
structure of records when pushing data into a `RecordSeries`.
2026-03-01 18:44:46 +01:00
Michael Schimmel b612df6e10 Add Series RTL and SeriesView
Introduces a new RTL module for handling series data, enabling efficient
storage and retrieval of time-series data in a Struct-of-Arrays (SoA)
format.

Includes `SeriesView`, a zero-copy wrapper that provides a fast,
read-only interface to individual columns within a `RecordSeries`,
optimizing performance for data access in the VM.

Registers new native functions `create-series` and `push-series` for
managing series data.
2026-02-28 21:47:14 +01:00
Michael Schimmel 85d21943dd Add series module for time-series data
Introduce the `series` module to handle time-series data storage and
manipulation. This module includes:

- `RingBuffer`: An efficient ring buffer for storing time-series data
  with a configurable lookback.
- `ScalarSeries`: A type-safe series for primitive scalar values (f64,
  i64, bool) optimized for performance.
- `ValueSeries`: A fallback series for non-scalar or mixed data types.
- `RecordSeries`: A "Struct of Arrays" implementation for records,
  splitting fields into parallel series for efficient access.
2026-02-28 18:30:44 +01:00