Designing High-Level Interpreter Memory Systems

High-level interpreters store values according to variable names, not memory addresses (like low-level interpreters and CPUs do). That means we’ve got to represent memory with a dictionary mapping names to values.

There are three kinds of memory spaces to worry about for most programming languages: global memory, function spaces (for parameters and locals), and data aggregate instances (structs or objects). For simplicity, we can normalize all these spaces by treating them as dictionaries. Even fields are really just variables stored within an instance’s memory space. To store a value into a space, we map a name to that value. A memory space is the run-time analog of a scope from static analysis. ...

Get Language Implementation Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.