this is a part of the class implementation. In this commit classes
and instances type were completely cleaned and prepared for a new
implementation. Native class registering mechanism were fully refactored
and made it much simpler.
a buffer of classes for primitive types added to PKVM, but they'll
not be initialized in this commit.
names buffer and constant pool of a module are now merged (just like
java's constant pool).
VM's core libraries and scirpt modules are merged into a single
map name modules.
creating a new module doesn't register it automatically anymore,
you need to call pkRegisterModule(...) each time.
newModule() function refactored with a simpler interface, we're not
setting path or registering globals anymore, the caller is
responsible for that.
inorder to support tcc, I need to remove some math functions that
tcc on windows doesn't support (v language is using openlibm).
This is temproarly and the math functions should be moved to it's
own math script module once the import system is refactored.
TCC build tested with the binary downloaded from --
https://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip
(download link from the https://bellard.org/tcc/ website), and this
should be added to the CI workflow.
now it's easier to re-use cli modules into another hosting
application and a little python script have added to generate
native api to support native extension library.
The name script is missleading as it only refering to the scripts
(the files that contain the statements) where as it could also
be the native module objects containing collection of native
functions.
After this commit, native functions can also have set owner module
and it won't be as confusing as before.
There are small typos in:
- README.md
- cli/modules.c
- src/pk_compiler.c
- src/pk_core.c
- src/pk_opcodes.h
- src/pk_vm.h
- tests/benchmarks/benchmarks.py
Fixes:
- Should read `temporary` rather than `temproary`.
- Should read `stdout` rather than `stdour`.
- Should read `sprintf` rather than `spritnf`.
- Should read `splitted` rather than `splited`.
- Should read `script` rather than `scirpt`.
- Should read `reported` rather than `repored`.
- Should read `reduce` rather than `recude`.
- Should read `performance` rather than `preformance`.
- Should read `instead` rather than `insted`.
- Should read `default` rather than `defalt`.
* argparse library added to third parth.
We're using argparse (https://github.com/cofyc/argparse) repo to parse
cli args.
* parsed arguments applied to the cli.
Co-authored-by: Derick Alangi <alangiderick@gmail.com>
Introduced a new function `readLine()` that utilizes the byte buffer
together with `fgetc()` to read input from the STDIN. This enables
the REPL to read characters one at a time for validation & in a
safer manner where the buffer gets to be resized if it's full.
* While reading various files in the repo, just going ahead to
clean up some typos (for clarity of text).
* When calling `realloc()`, let the pointer be returned to the
first byte of the memory block after resize. Compiler warns against
not doing this too.
* In addition, rename the file uitls.c to "utils.c" which seems to
be the correct name in this case.
NOTE: I recompiled and tested the `./pocket` intepreter and it still
works as expected.
- popping operands from the stack was too early -fixed
- some temproary string objects weren't pushed to the vm's temp root
-fixed
- and some minor bug fixed