Conversation
…ion calls. * Has InterpreterFunction save a pointer to the frame it's defined in, so that it can implement its own call() and analyze() methods. * Adds a Class.get_attribute() method. For now, it just does a simple lookup in the class's members map. * Uses function calls and attribute lookups to implement a Class.instantiate(). The typing for functions ended up getting much more complicated than I'd like, with a protocol that captures the Frame attributes that InterpreterFunction cares about, another protocol for a function call's return value (to hopefully make the return type generic enough to accommodate a future PyTDFunction), and BaseFunction being generic to give us precise typing. Without the last piece, we get pytype errors about the Frame protocol not matching the concrete Frame class. PiperOrigin-RevId: 614876767
PiperOrigin-RevId: 615151423
PiperOrigin-RevId: 615198171
Still iterating on the design, but the basic idea is - `pretty_printer.PrettyPrinter` contains functions to print types and variables - Other classes in `pretty_printer` contain code to format the contents of structured error objects returned from various modules, e.g. `matcher.MatchError` or `function.FailedFunctionCall`. These classes take a `PrettyPrinter` as an init argument, and delegate to it to print types. - The `ErrorLog` is initialised with a `PrettyPrinter`, which it passes to other `pretty_printer.*` objects it creates to format various errors. Ultimately, all code that cares about the inner details of abstract objects should be confined to the `PrettyPrinter` class, so that it can be swapped out for a printer that works with the rewrite's abstract objects while keeping the rest of the error formatting code unchanged. PiperOrigin-RevId: 615473461
PiperOrigin-RevId: 615502466
PiperOrigin-RevId: 615542228
Also separates error printing into its own module to resolve an import cycle PiperOrigin-RevId: 615548836
* Splits abstract.Instance into FrozenInstance and MutableInstance, so that we can easily distinguish between canonical instances created by BaseClass.instantiate() that should ignore any attribute setting done outside of __new__ and __init__, and instances created in the course of bytecode analysis that should respect all modifications. * Implements opcodes for loading and storing attributes. PiperOrigin-RevId: 615684582
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.
No description provided.