Commit Graph

288 Commits

Author SHA1 Message Date
Thakee Nathees
962f868907
Merge pull request #215 from ThakeeNathees/operator-overload
operator overloading.
2022-05-01 05:39:44 +05:30
Thakee Nathees
2713aaba35 operator overloading implementation.
at this point only binary operators are implemented, unary are yet
to do.

getters and setters for native classes implemented with the names
@getter, and @setter (however the names or arity aren't validated
at the moment TODO:)
2022-04-30 21:35:02 +05:30
Thakee Nathees
895f177211
Merge pull request #212 from ThakeeNathees/fiber-api-change
runFunction() abstraction to hide fiber creation
2022-04-28 15:57:22 +05:30
Thakee Nathees
89056637b9
Merge pull request #214 from ThakeeNathees/ctor-crash
class without constructor crash fix
2022-04-27 20:29:15 +05:30
Thakee Nathees
821874f823 class without constructor crash fix 2022-04-27 20:26:57 +05:30
Thakee Nathees
87fe3b01d6 runFunction() abstraction to hide fiber creation
the function will create a fiber and execute the function, this is
a better abstracion for the host applicaion (createFiber, runFiber
are removed) and this will come in handy when it comes to execute
pocket functions inside a native function (it's required to
implement operator overloading).
2022-04-27 08:46:00 +05:30
Thakee Nathees
590e76b19f
Merge pull request #211 from ThakeeNathees/inheritance
inheritance and 'is' test implemented
2022-04-27 07:05:21 +05:30
Thakee Nathees
acf38a31ca inheritance and 'is' test implemented 2022-04-26 21:57:35 +05:30
Thakee Nathees
745387e307
Merge pull request #210 from ThakeeNathees/globals-init
functions and classes are runtime initialized
2022-04-26 19:23:53 +05:30
Thakee Nathees
b5ec401cf4 functions and classes are runtime initialized
this is necessare to make classes inherit from unknown
identifiers which are resolved at the runtime

and if we were to write the byte code to a file and run it, the globals
should be initialized at the runtime since there isn't any compile
time for them (pre compiled).
2022-04-26 15:53:30 +05:30
Thakee Nathees
cb209eb4d4 Some tiny bugs bug fix
When parsing class and if there is an EOF it's not being marked
as an error which is a regression after the syntax error refactor
which is fixed.

Constructor of boolean class return C boolean instead of VAR_BOOL()
bug fixed
2022-04-25 21:31:51 +05:30
Thakee Nathees
95c318b6f7
Merge pull request #208 from ThakeeNathees/slots
Native interface refactored into slots.
2022-04-24 10:05:53 +05:30
Thakee Nathees
bb588e9470 native interface refactored into slots.
pkVar is removed and slots (like wren) are implemented for accessing or passing pocketlang values to C and vice versa. Yet all the slot related functions are callable at runtime (a fiber is associated with the VM) which needs to be refactored to allocate slots even if it's not runtime, to let users make use of the pocketlang values before or without running a function.
2022-04-24 09:56:27 +05:30
Thakee Nathees
13b70d6512
Merge pull request #207 from ThakeeNathees/pretty-error
error pretty print (print lines) implemented
2022-04-23 06:50:29 +05:30
Thakee Nathees
d431dd7975 error pretty print (print lines) implemented
also support ansi color to highlight the error token.
2022-04-22 17:51:17 +05:30
Thakee Nathees
020f9e2eab
Merge pull request #206 from ThakeeNathees/class2
[WIP] class implementation
2022-04-22 07:58:29 +05:30
Thakee Nathees
2fe579d9cc math module moved to cli/modules 2022-04-22 07:04:09 +05:30
Thakee Nathees
179026294d class compilation implementation 2022-04-21 20:35:12 +05:30
Thakee Nathees
1951b3d5f7 self initialization and constructor calls implemented
fibers are moved to builtin class and the fiber
module has removed.

native docstring support required to move math to cli
modules (TODO)
2022-04-21 15:17:32 +05:30
Thakee Nathees
03bac026ee METHOD_CALL opcode implemented
As of this commit there is only one method in the entier pocketlang
thats List.append() have added (the reset is todo).

method searching algorithm should be optimized in the future by
sorting the methods according to their names and do a binary search
2022-04-21 07:11:21 +05:30
Thakee Nathees
167355be59 getMethod and preConstructSelf functions impl 2022-04-20 20:38:23 +05:30
Thakee Nathees
67ab2057c0 method buffer added to classes
and also allocation/de-allocation callbacks were added to newClass
function and yet registering attribute getters and setters is to do.
2022-04-20 16:41:57 +05:30
Thakee Nathees
776ea0ab87 builtin types added.
This commit adds the builtin types to the VM's builtin classes
buffer (however no methods were added to those classes) and a super
class parameter introduced while creating a new class.
2022-04-20 15:35:33 +05:30
Thakee Nathees
4d46930d1b instance and class type cleaned
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.
2022-04-20 14:40:08 +05:30
Thakee Nathees
29be68fc86 classes were removed temproarly
to implement classes properly and support methods I had to remove
the older class syntax temproarly.
2022-04-20 13:54:45 +05:30
Thakee Nathees
48102123af
Merge pull request #205 from ThakeeNathees/cleanups
dlfcn removed and minor code cleanups
2022-04-20 13:28:05 +05:30
Thakee Nathees
1f8a71fe0a dlfcn removed and minor code cleanups 2022-04-20 13:08:14 +05:30
Thakee Nathees
2262089948
Merge pull request #203 from ThakeeNathees/syntax-change
function and else if keywords are changed.
2022-04-17 07:49:52 +05:30
Thakee Nathees
88c45cccac function and else if keywords are changed.
- `func` keyword has change to `function`.
- `elsif` changed to `else if`
2022-04-17 07:33:40 +05:30
Thakee Nathees
c67572d552
names buffer merged with constant pool (#202)
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.
2022-04-17 06:47:27 +05:30
andrea321123
f980e91b60
Handle Ctrl+D, Ctrl+Z properly
* Fix #105

* Check if last char is EOF
2022-04-16 15:24:55 +05:30
Thakee Nathees
925ba3504d
Merge pull request #201 from ThakeeNathees/tcc-build
tcc build supported.
2022-04-16 09:56:19 +05:30
Thakee Nathees
d8d229b0fb tcc build supported.
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.
2022-04-16 09:37:38 +05:30
Thakee Nathees
34622afc0b
Merge pull request #199 from ThakeeNathees/modules
modules were moved to cli/modules
2022-04-16 07:35:28 +05:30
Thakee Nathees
5aee9616c1 modules were moved to cli/modules
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.
2022-04-15 19:30:26 +05:30
Thakee Nathees
ec569aba74
Merge pull request #198 from ThakeeNathees/minor-refactor
Yet another refactor.
2022-04-15 10:11:36 +05:30
Thakee Nathees
ddc8bd8197 yet another refactor.
This commit doesn't change any behavior, just moving the code
around cleaning things.
2022-04-15 09:58:02 +05:30
Thakee Nathees
6083af6dbe
Merge pull request #197 from ThakeeNathees/minor-changes
fiber pointer stored as register variable
2022-04-14 16:30:21 +05:30
Thakee Nathees
b285336895 fiber stored as register variable
and the benchmark script refactored, and now it will generate an
html report
2022-04-14 08:01:16 +05:30
Thakee Nathees
9d6d37fa09
Merge pull request #196 from ThakeeNathees/upvalue
Closures implemented
2022-04-14 05:07:50 +05:30
Thakee Nathees
8d062e38b8 closures were completely added. 2022-04-13 14:31:57 +05:30
Thakee Nathees
2e1d8d89dd lexical scoping support using upvalues 2022-04-13 09:20:56 +05:30
Thakee Nathees
9a8f3365ad
Merge pull request #195 from ThakeeNathees/expr-name
exprName re-defined
2022-04-13 09:04:58 +05:30
Thakee Nathees
e0852139b9 exprName re-defined
The exprName function re-defined into a cleanner way, and now it's
possible to override builtin functions, this will come in handy
to introduce upvalues.
2022-04-13 08:40:37 +05:30
Thakee Nathees
e5d881fc40
Merge pull request #194 from ThakeeNathees/upvalue
local variable index miss-calculation bug fix
2022-04-13 03:20:37 +05:30
Thakee Nathees
227be9aab5 local variable miss-calculation bug fix
for nested functions the count of locals and the required stack size
are miss-calculated, ie. No new count wasn't started for inner functions
it makes the required stack size greater than or equal to it's enclosing
functions stack size.
2022-04-12 16:29:20 +05:30
Thakee Nathees
db9fad35a9
Merge pull request #193 from ThakeeNathees/fn-closure-replace
functions are replaced with closures
2022-04-12 13:45:27 +05:30
Thakee Nathees
3feb9ac723 functions are replaced with clsoures
Every occurrence of function as first classes citizen is replaced
with closures yet upvalues are still to do.
2022-04-12 07:28:33 +05:30
Thakee Nathees
3b5da9cad3
Merge pull request #192 from ThakeeNathees/script-type-rename
Scripts renamed to Modules
2022-04-12 01:26:39 +05:30
Thakee Nathees
20b99c60b3 script renamed to modules
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.
2022-04-11 14:08:00 +05:30