Skip to content

Google sync#1599

Merged
rchen152 merged 10 commits intomainfrom
google_sync
Mar 14, 2024
Merged

Google sync#1599
rchen152 merged 10 commits intomainfrom
google_sync

Conversation

@rchen152
Copy link
Copy Markdown
Contributor

No description provided.

rchen152 and others added 10 commits March 14, 2024 13:08
…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
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
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
@rchen152 rchen152 merged commit b899682 into main Mar 14, 2024
@rchen152 rchen152 deleted the google_sync branch March 14, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants