-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the interpreter definition DSL to be legal C syntax #477
Comments
Looks good, although I'd prefer to come up with a solution where the stack effect (both what it takes from the stack and what it leaves behind) are arguments to the macro. Maybe this would work?
When preceded by e.g.
VS Code has no problem with that. |
Maybe use a two argument macro, that way we can keep the stack comment format #define inst(x, y) void inst_ ## x(void)
inst (LOAD_FAST, -- value)
{
value = frame->localsplus[oparg];
Py_INCREF(value);
} |
Sure, that'll work, assuming the DSL lives in a separate file. I'll try to update the definition file. |
For streams, I propose |
switch from ``` inst NAME (inputs -- outputs) { C-code } ``` to ``` inst(NAME, (inputs -- outputs)) { C-code } ``` Also from ``` inst NAME = op1 op2; ``` to ``` inst(NAME) = op1 + op2; ``` Change stream syntax from ``` #NAME ##NAME ####NAME ``` to ``` NAME/1 NAME/2 NAME/4 ``` Finally change ``` family NAME = OP1, OP2, ..., OPN; ``` to ``` family(NAME) = OP1, OP2, ..., OPN; ```
The proposed DSL for defining the interpreter has sound semantics, but the syntax is problematic due to lack of tooling.
We want to be able to edit and view the code in standard tools.
The 3.11 (and earlier) instructions definitions are understood by tools that understand C, we want to retain that.
To do that we need to change the DSL to be a subset of C, as follows:
kind NAME ...
tokind "(" NAME ")" ...
( -- value)
becomes/* -- value */
CHECK_OBJECT_TYPE LOAD_SLOT
becomesCHECK_OBJECT_TYPE + LOAD_SLOT
#index
becomesindex*1
and##version
becomesversion*2
.From the examples,
becomes
Alternatively we could define
S1
,S2
andS4
for values in the instruction stream:The definition of
LOAD_FAST
changes from:to:
The text was updated successfully, but these errors were encountered: