feat(vm): Complete object model; inheritance, dunder protocol, properties and IC.#7
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the
NotImplementedsingleton, a non-throwingresolve_attr_silent, and the centraltry_call_dunderhelper in a newvm/handlers/dunder.rs. Centralizes the protocol so every later phase is a two-line insertion instead of reimplementing it per operator.Adds a
basesfield toHeapObj::Class, walks the chain inresolve_attr, and threads the current class throughCallFrame. Comes before dunders because dunder lookup itself needs to find methods on base classes.Wires every operator and protocol handler to the dunder dispatch — arithmetic with subclass-first reflected ops, comparisons,
__bool__/__len__, indexing,__call__, iteration with StopIteration,__hash__with the eq-hash invariant, repr/str/format, getattr fallback, and full context-manager semantics via a new WithCleanup opcode.Recognizes
@propertyand@x.setterat class construction and routes attribute access through them. Earns its own phase because properties are attribute access that executes code — they don't fit the dunder protocol shape.Adds
FastOp::InstanceDunderwith class-identity guards so monomorphic dunder calls promote like primitive ops. Without this, hot loops likeSeries.__getitem__pay full resolution cost every iteration.Updates the markdown documentation to reflect the new supported surface. Lands after the implementation phases so the published reference always matches the shipped behavior, never ahead of it.
Adds JSON coverage of the protocol matrix to catch ordering rules (subclass-first dispatch, exit suppression, IC invalidation) that fail silently when implemented naively.
CI / CD / Build Demo / GitHub Pages since it only promotes the mainline branch to production.