Commit Graph

330 Commits

Author SHA1 Message Date
Thakee Nathees
b020e249aa isVarType falsly returning VAR_NULL fix 2022-05-27 01:01:48 +05:30
Thakee Nathees
fb1e1099c7
Merge pull request #238 from ThakeeNathees/register-builtin
Register builtin function implementation
2022-05-26 11:20:22 +05:30
Thakee Nathees
9686b1fb75 Register builtin function implementation 2022-05-26 11:13:27 +05:30
Thakee Nathees
e458682486
Merge pull request #237 from ThakeeNathees/term
new Fiber objects falsely garbage collected -- fixed
2022-05-26 08:22:58 +05:30
Thakee Nathees
82919a690e Garbage collection bugs fixed
- Objects that weren't pushed to PKVM's temp reference were fixed
- vm->bytes_allocated was modified after the re-calculation of garbage
  collection fixed.
2022-05-25 16:44:58 +05:30
Thakee Nathees
0cfdfa7415 New fibers are not added to temp list -- fixed 2022-05-25 00:06:44 +05:30
Thakee Nathees
156a4e9203
Merge pull request #236 from ThakeeNathees/elif
else if change to elif
2022-05-24 15:43:47 +05:30
Thakee Nathees
6e91b66e69 else if change to elif again.
The primary purpose of this change is to disambiguate between
`else if` and `else \n if`.

Even though it's a breaking change, since it's at the very early
state we're allowed to make such breaking syntax change.

lang.write function moved to io and io.stdin, io.stdout, io.stderr
added for future streamed io operations

io.File read, write, open, close, getline, seek, tell implemented

str * int multiplication implemented
2022-05-24 15:31:36 +05:30
Thakee Nathees
e16debcff0
Merge pull request #235 from ThakeeNathees/more-methods
Some builtin class methods were added
2022-05-24 00:04:51 +05:30
Thakee Nathees
8e04748f86 some builtin class methods were added
- check a string contains another with `in` keyword
- Number: isint, isbyte
- String: find, replace, split, startswith, endswith, strip
- Map: clear, has, get, pop
- list: insert, clear, find, pop
- removed str_sub builtin function as its redunent since we have
  range slice over strings.
- moved lower, upper attributes of strings as methods
2022-05-23 23:47:28 +05:30
Thakee Nathees
b2c68d6064
Merge pull request #234 from ThakeeNathees/bytebuffer
More code enhancements (read bellow)
2022-05-23 04:23:06 +05:30
Thakee Nathees
2fd7b1f6e4 More code enhancements (read bellow)
- ByteBuffer, and Vector classes were created. However thier methods are
  limited, and to do.
- Strings supports new line escape "\\n".
- typename will return class name of an instance (was just 'Inst' fixed)
- _repr() method added. if _str method doesn' exists on an instance,
  it'll try to call _repr() to make a string.
- number.isint(), number.isbyte() method added
- [], []= operator were added.
2022-05-23 03:48:35 +05:30
Thakee Nathees
4072a06bd7
Merge pull request #233 from ThakeeNathees/warnings-fix
Minor code enhancements
2022-05-21 13:18:32 +05:30
Thakee Nathees
6a22653263 Minor code enhancements (read bellow)
- Warnings were fixed
- Libraries are registered internally when PKVM created
  and cleanedup when PKVM freed (if PK_NO_LIBS not defined)
- Lang.clock() moved to time module and sleep, epoch time
  were added.
- Support both upper case and lower case hex literals
- Support hex excaped characters inside strings (ex: "\x41")
- Native api for import modules added `pkImportModule(...)`
- pkAllocString, pkDeallocString are changed to pkRealloc.
- NewInstance, DeleteInstance functions now take PKVM however
  delete function should not allocate any memory since it's
  invoked at the GC execution.
2022-05-21 04:15:30 +05:30
Thakee Nathees
710d0c47f3
Merge pull request #232 from ThakeeNathees/amalgam
Amalgamation implemented
2022-05-20 13:41:11 +05:30
Thakee Nathees
e3cab82978 amalgamation added and libs moved to src/libs/ 2022-05-20 04:49:50 +05:30
Thakee Nathees
f613153dcb
Merge pull request #231 from ThakeeNathees/try-online
try online page added to docs
2022-05-19 00:40:07 +05:30
Thakee Nathees
97f9a364f3 try online page added to docs 2022-05-19 00:13:53 +05:30
Thakee Nathees
ade5d9ee44
Merge pull request #230 from ThakeeNathees/native-call-api
native call api implemented
2022-05-18 15:27:15 +05:30
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