INTERPRETER #104
Replies: 23 comments 58 replies
-
I have opened this section so as not to mix such specific topics in other discussions |
Beta Was this translation helpful? Give feedback.
-
I have created a spreadsheet to be able to describe and discuss opcodes and how they work. |
Beta Was this translation helpful? Give feedback.
-
I have added a stupid print OP in compiler. I don't know some functionalities then print value and possible opcode |
Beta Was this translation helpful? Give feedback.
-
Starting the disassembler. There are still things that I don't quite understand. |
Beta Was this translation helpful? Give feedback.
-
@hiperiondev
Finally, function bytecode is recursive - that is to say, a function has it's own literal cache, function section and runnable code section. In addition, I think the first two bytes of the runnable code section are ACTUALLY specifying the literal within the function's cache containing the parameter list, and the next two bytes specify the literal in the cache which is the returns array. (sticking those indexes within the runnable section was another ugly hack - sorry!) I should note that the final parameter might actually signal a rest parameter with |
Beta Was this translation helpful? Give feedback.
-
Good. In any case, a disassembler only takes into account the bytecode, not the execution time. In the case of FN_CALL there is no argument in the code, therefore it is an opcode without arguments.
Could you give me a concrete example of how that would be interpreted? I guess that's why the first test (fib-memo) works but the second fails (function-within-function-bugfix), clearly I can't apply toy_read_interpreter_sections directly to the function body. If it is exactly the same as the rest of the code, the two bytes that you say are consumed here: Is there a recursion limit for functions?
|
Beta Was this translation helpful? Give feedback.
-
I have solved the recursion problem in the function code and now it seems to work correctly. And every FN_RETURN continue with: That's right? |
Beta Was this translation helpful? Give feedback.
-
Just making a note here: while the args & rets literal indexes are technically stored within the program section, they are extracted BEFORE the function proceeds to (I fixed how these are read in the disassembler, btw - check the pull requests) |
Beta Was this translation helpful? Give feedback.
-
Good!!! |
Beta Was this translation helpful? Give feedback.
-
After: Is that a bug or does it have some functionality? |
Beta Was this translation helpful? Give feedback.
-
That looks much nicer without the extra SCOPE operations. |
Beta Was this translation helpful? Give feedback.
-
I was thinking that maybe FN_RETURN is not the proper name for the OPCODE, since it doesn't really perform a RETURN but rather a data manipulation for the return. Perhaps FN_DATA_RETURN would be more appropriate. |
Beta Was this translation helpful? Give feedback.
-
I'm going to start separating the code from the functions. |
Beta Was this translation helpful? Give feedback.
-
In generator.toy, function 0 (generateTilemapData) I understand that this would indicate the number of values returned, but currently it cannot be more than 1. |
Beta Was this translation helpful? Give feedback.
-
At the beginning of the file are the calls to import: Why is there a NULL in the middle? |
Beta Was this translation helpful? Give feedback.
-
In generator.tb Why does it nest two SCOPEs? |
Beta Was this translation helpful? Give feedback.
-
here's a thought - arrays generally don't shrink their capacities... but the interpreter's stack could do that to free up memory, perhaps? |
Beta Was this translation helpful? Give feedback.
-
Concerning #107 - I've made a few tweaks (will push and close in a moment) to remove an excess scope creation when using a.toy
a.tb
b.toy
b.tb
|
Beta Was this translation helpful? Give feedback.
-
I just pushed a change to the disassembler. Now you can choose a linear presentation according to a conventional assembler. |
Beta Was this translation helpful? Give feedback.
-
Question about JUMPs:
|
Beta Was this translation helpful? Give feedback.
-
In LITERAL_ARRAY and LITERAL_DICTIONARY what is SUBTYPE? |
Beta Was this translation helpful? Give feedback.
-
Now, with the last commit, disassembler show all the program relative to labels. |
Beta Was this translation helpful? Give feedback.
-
I'm back! Although, for now a little slow because I am moving to a new house, when I am completely settled I will resume the project with more vigor. I've been working on a new interpreter, based on the JVM handles frames for local variables. You can see the first implementation is: https://github.com/hiperiondev/stack_vm |
Beta Was this translation helpful? Give feedback.
-
Here we will only discuss issues related to the internal functioning of the interpreter/VM (opcodes, data types, address types, memory management, etc).
Beta Was this translation helpful? Give feedback.
All reactions