Commit Graph

311 Commits

Author SHA1 Message Date
Thakee Nathees
22cecf4415 native call api implemented 2022-05-17 23:51:01 +05:30
Thakee Nathees
80896f04aa
Merge pull request #229 from ThakeeNathees/native-api
native instance interface implemented
2022-05-17 08:03:00 +05:30
Thakee Nathees
48089b2a1a native instance interface implemented 2022-05-17 07:08:14 +05:30
Thakee Nathees
2727f010ec
Merge pull request #227 from ThakeeNathees/native-globals
adding globals support in native interface
2022-05-09 23:32:27 +05:30
Thakee Nathees
b5d98ca4c3 adding globals support in native interface
pkSetGlobal function implemented to support adding globals from the
native interface. Also the PKVM slots doesn't need a runtime anymore to
use them (see math.PI global to see how it works).
2022-05-09 22:52:25 +05:30
Thakee Nathees
78b7004de6
Merge pull request #225 from ThakeeNathees/number-from-string
Number constructor from string
2022-05-09 16:04:16 +05:30
Thakee Nathees
b96b18a4d7 Number constructor from string 2022-05-09 15:25:44 +05:30
Thakee Nathees
6e66721b2e
Merge pull request #224 from ThakeeNathees/mini-impl
negative index, range slice and string concat (..)
2022-05-09 10:22:38 +05:30
Thakee Nathees
f5e2f15d23 negative index, range slice and more
... string concat with .. operator
    exponent operator with ** operator
2022-05-08 23:19:33 +05:30
Thakee Nathees
b908f85338
Merge pull request #223 from ThakeeNathees/docs-change
documentations are refactored
2022-05-07 17:54:32 +05:30
Thakee Nathees
a83aa9438e documentations are refactored
function keyword changed back to fn
2022-05-07 17:47:58 +05:30
Thakee Nathees
443bc8f6ac
Merge pull request #222 from ThakeeNathees/import-refactor
import statements are refactored.
2022-05-06 11:25:51 +05:30
Thakee Nathees
168f365cde import statements are refactored.
- all import statement (native or script file) have the same syntax
- allow relative (including parent directory) imports
- cyclic imports are handled by caching the scripts
- `import foo` can potentially import `<searchpath>/foo/_init.pk`
- * import are not supported anymore
2022-05-06 11:16:48 +05:30
Thakee Nathees
9dc2a99c3f
Merge pull request #221 from ThakeeNathees/native-interface
native interface refactored
2022-05-05 15:24:11 +05:30
Thakee Nathees
3c107d4da2 native interface refactored 2022-05-05 12:54:15 +05:30
Thakee Nathees
a9f57d9ec7
Merge pull request #220 from ThakeeNathees/leak-detect
Memory leak detection implemented
2022-05-03 19:25:31 +05:30
Thakee Nathees
1c7ddf07ad memory trace for vmRealloc implemented.
a little python script have written to check for memory leaks
from the trace report. Which is at scripts/leak_detect.py
2022-05-03 16:56:59 +05:30
Thakee Nathees
1d77ec7adf
Merge pull request #218 from ThakeeNathees/stack-realloc-bug
stack overflow, and realloc bug fixed
2022-05-02 14:25:02 +05:30
Thakee Nathees
6ac4e93c9a stack overflow, and realloc bug fixed
stack realloc wasn't update the next callframe's base pointer which
caused a crash which is fixed

infinit recursions are now handled properly. now it'll dump the stack
frames and exit properly
2022-05-02 14:07:01 +05:30
Thakee Nathees
c05c839c0a
Merge pull request #217 from ThakeeNathees/super-calls
super class method call implemented
2022-05-02 05:35:39 +05:30
Thakee Nathees
e47d982883 super class method call implemented 2022-05-01 20:24:07 +05:30
Thakee Nathees
616c48a510
Merge pull request #216 from ThakeeNathees/build-scripts
scripts are moved to scritps/ directory
2022-05-01 14:44:45 +05:30
Thakee Nathees
4e9091b5ec scripts are moved to scritps/ directory 2022-05-01 14:12:27 +05:30
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