Writing a compiler. Bytecode basics

preview_player
Показать описание
Continuing the implementation of a compiler for a functional language in F#. Now the time has come to work on the bytecode. Compared to a tree-walking interpreter, the setup for bytecode compilation is more involved, so the actual implementation is split into several videos.

In this video we'll lay the groundwork: define types and basic components required to generate and execute Fang bytecode.

00:00 - Intro
02:03 - Compilation: native and bytecode
04:03 - Stack VM
06:55 - Module scaffolding
10:57 - BytecodeBuilder scaffolding
13:19 - Start working on the bytecode gen
16:53 - Bytecode for arithmetic
22:27 - More BytecodeBuilder infrastructure
23:10 - Fleshing out the VM
29:31 - Final touches
31:42 - Running the bytecode
32:35 - Bytecode in the debugger
34:54 - Outro
Рекомендации по теме
Комментарии
Автор

Artem I fully support you in such dire times. I pray for the day this terror will end🙏

andygyakobo
Автор

I was also playing around with a toy interpreter/compiler in F# a couple of years ago. I have found a sloghtly different approach at code structure slightly more manageable. Instead of having operations enumeration, actual logic and implementation (also an opcode decode/encode logic in my case), i have decided to make it an array where all these pieces where together. The pros of such approach is that I didnot need to jump accross different parts of code when added new operation, the cons is that code was less readablec because i had lookups to this “master-specification” array’s fields everywhere.

Eugensson