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.
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.
Since the functions and classes will be moved to the constants buffer
rather than having their own (function buffer and class buffer) the
rename is essential, and to make the refactoring process easier all the
intermediate steps are done with its own pr.
It's just the types that were added and only object creation
and garbage collection of that types are implemented, the
reset of the implementation is not part of this commit.
* and / or logic refactored
* and / or opcodes added and stack size bug fixed
- and / or keywords were added.
- class construction function not poping the class instance
from the stack (fixed).
* fixed typos in src/
* fixed typos in docs/
* fixed typos in README and tests/
* rename INITALIZE to INITIALIZE
* rename PRIMITE to PRIMITIVE
* rename moudle to module
Co-authored-by: Alexander Patel <acpatel@andrew.cmu.edu>
This commit addresses issue #54 in an attempt to add more bitwise
operators to pocketlang. Tests have also been written to verify that
the operators indeed works as expected.
To add, I also introduced a macro PK_RIGHT_OP that just aliases the
string "Right operand" which was already getting too hardcoded and
appearing too much in the pk_core.c file.
* Fix#54: Add bitwise OR operator and make it available in PKVM
Like the bitwise AND, this is an implementation for pocketlang to
support the bitwise OR operation. In addition, updated "value" ->
"result" in other operation to correctly reflect the container's
purpose. It's indeed the result after the operation, which is a value
too.
In addition, add tests for bitwise AND (&) and bitwise OR (|). Add a
print statement in test file with message that all tests passed with
no errors.
* Fix typo in comment
* Cleanup fixes
* 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.