rrthomas / mit

A simple stack-based VM
Other
10 stars 3 forks source link

Separate code generation from specification #376

Closed rrthomas closed 4 years ago

rrthomas commented 4 years ago

stack.StackEffect, action.ActionEnum.dispatch and action.AbstractAction contain methods for code generation. It would make more sense to separate the description of the VM from code generation, by extracting the code generation methods (see below), and making them top-level functions in run_fn.py.

Specification:

StackEffect: args, results, by_name, of, __str__, __repr__ StackItem: everything but load and store StackPicture Action: everything but gen_case ActionEnum: everything but dispatch Instruction: everything but gen_case and (arguably) opcode

Code generation:

StackEffect: declare_vars, load_args, store_results StackItem: load and store The top-level functions in stack.py AbstractAction: gen_case Action: gen_case ActionEnum: dispatch Instruction: gen_case and (arguably) opcode