Vim9script internals, how to read the source code and in what order #13543
Answered
by
vim-ml
stefanos82
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi,
On Sat, Nov 18, 2023 at 3:14 AM stefanos ***@***.***> wrote:
I'm fascinated by programming languages and I always find myself digging
deep in their internals to learn how each creator implements specific
language features they may find interesting.
In case of Vim's scripting language, how do I read the source code to
familiarize myself with it?
For Vim9 script support, you can go through the following source files:
https://github.com/vim/vim/blob/master/src/vim9compile.c
https://github.com/vim/vim/blob/master/src/vim9expr.c
https://github.com/vim/vim/blob/master/src/vim9execute.c
https://github.com/vim/vim/blob/master/src/vim9instr.c
https://github.com/vim/vim/blob/master/src/vim9script.c
https://github.com/vim/vim/blob/master/src/vim9cmds.c
https://github.com/vim/vim/blob/master/src/vim9class.c
For Vim9 def function compilation, you can start with the
compile_def_function() function.
For Vim9 script execution, you can start with the exec_instructions()
function.
With the implementation of vim9script, I can see we have added "primitive"
types and class objects and I would like to see how they have improve the
whole performance and / or what type of bytecode or native code they
generate behind the scenes.
Only code in def functions are compiled and converted to bytecode. You can
use the 'defcompile'
and 'disassemble <def function name>' command to see the generated
bytecode. Example:
vim9script
def Foo()
var i = 10
i = i + 20
enddef
defcompile
disassemble Foo
Are there any plans to write in the near future anything like PHP's internals
book <https://www.phpinternalsbook.com/>?
There are currently no plans to write an internal book.
Regards,
Yegappan
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stefanos82
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm fascinated by programming languages and I always find myself digging deep in their internals to learn how each creator implements specific language features they may find interesting.
In case of Vim's scripting language, how do I read the source code to familiarize myself with it?
With the implementation of
vim9script
, I can see we have added "primitive" types and class objects and I would like to see how they have improve the whole performance and / or what type of bytecode or native code they generate behind the scenes.Are there any plans to write in the near future anything like PHP's internals book?
Beta Was this translation helpful? Give feedback.
All reactions