Commit Graph

271 Commits

Author SHA1 Message Date
Mattia Giambirtone b903005504 Initial work on fixing calling functions assigned to variables 2022-10-25 11:17:38 +02:00
Mattia Giambirtone dc626a90d9 Improved VM debugger, fixed bugs with fixing CFI offsets, minor docs and code changes 2022-10-24 13:53:27 +02:00
Mattia Giambirtone 6c305d6382 Disabled the GC in the entire VM module and updated config.nim 2022-10-21 19:50:07 +02:00
Mattia Giambirtone 9573769868 Various fixes to module system 2022-10-21 16:10:00 +02:00
Mattia Giambirtone 1c54243d43 Various bug fixes to scopes 2022-10-17 12:03:27 +02:00
Mattia Giambirtone 11f725e176 Added new modular standard library 2022-10-17 11:28:54 +02:00
Mattia Giambirtone d33a597f19 Massive improvements to import system (added export statement, initial work on namespaces, module names can now be paths, added module search paths) 2022-10-17 11:28:00 +02:00
Mattia Giambirtone c7893fb14b Fixed issues with negative numbers and infinity. Variables can now accept function expressions as type arguments. Compiler.infer() now always returns a concrete type, minor bug fix in varDecl 2022-10-13 18:34:11 +02:00
Mattia Giambirtone 8667cbdceb Initial ground work on generics, some stuff is broken :( 2022-10-13 16:52:37 +02:00
Mattia Giambirtone d4d1034cef Return addresses are now 64 bits long, return statements now compile to jumps, initial (broken) work on generics 2022-10-13 13:12:24 +02:00
Mattia Giambirtone 807b48bac9 Renamed compareTypes to compare 2022-10-11 10:01:01 +02:00
Mattia Giambirtone c168d1584b Updated compiler error messages and Generic type object, minor name changes 2022-10-11 09:59:27 +02:00
Mattia Giambirtone 9ef80535f3 Minor fixes to operator system and updated compiler error messages 2022-10-11 09:52:49 +02:00
Mattia Giambirtone 318f09541a Fixed config.nim 2022-10-11 09:36:33 +02:00
Mattia Giambirtone 61dceab9fd Fixed grammatical error in docs 2022-10-11 09:07:50 +02:00
Mattia Giambirtone 15f3143599 Removed makefile + minor fixes 2022-10-11 09:07:25 +02:00
Mattia Giambirtone 3e6e9da475 Fixed a bug where regular functions were mistaken for closures 2022-10-08 15:48:26 +02:00
Mattia Giambirtone ca5a1c1bc9 Updated config.nim 2022-10-08 15:21:32 +02:00
Mattia Giambirtone 66cd6be0be Minor additions/changes 2022-10-08 15:21:13 +02:00
Mattia Giambirtone 11c8c0a5ab Definitive fix for closures 2022-10-08 09:18:35 +02:00
Mattia Giambirtone fc74bab529 Minor fix to the VM and updated closures test 2022-10-07 16:27:08 +02:00
Mattia Giambirtone e759e6cbb2 Various fixes to closures. Fixed chained calls and local scopes 2022-10-07 15:55:41 +02:00
Mattia Giambirtone a4bccba6cd Various fixes to closures and function objects 2022-10-06 09:57:19 +02:00
Mattia Giambirtone 9c878e5b9e Fix some stuff? 2022-10-06 00:21:25 +02:00
Mattia Giambirtone c230142378 Broken work with closures and chained calls 2022-08-30 12:55:14 +02:00
Mattia Giambirtone 85de75a50a It is now possible to close over function arguments 2022-08-19 12:16:40 +02:00
Mattia Giambirtone 885d6e3ea8 Fixed a bug in the type system with consecutive calls 2022-08-19 09:08:49 +02:00
Mattia Giambirtone 66b409bbd4 Updated config.nim 2022-08-19 08:53:49 +02:00
Mattia Giambirtone 058b021493 Fixed some bugs with void functions in the compiler 2022-08-18 23:49:20 +02:00
Mattia Giambirtone 8e53b19233 Various parser adjustments and compiler fixes 2022-08-18 22:07:46 +02:00
Mattia Giambirtone 4fdd90614a Various fixes to the GC, added a few more tests 2022-08-18 19:18:29 +02:00
Mattia Giambirtone 95315a0094 Minor changes and fixes 2022-08-18 11:15:55 +02:00
Mattia Giambirtone ae6da275fa Implement a M&S collector 2022-08-18 03:17:52 +02:00
Mattia Giambirtone 36970e493b Slotted in JAPL's old memory manager and fixed strings. Preliminary work for GC 2022-08-17 22:35:32 +02:00
Mattia Giambirtone 47a6f16664 Even more cleanup. Added pretty colors to the VM's debugger 2022-08-17 20:40:34 +02:00
Mattia Giambirtone 77fd5931fa Further clean up 2022-08-17 19:31:27 +02:00
Mattia Giambirtone f7733d925f Cleaned up and renamed some things 2022-08-17 19:23:11 +02:00
Mattia Giambirtone 19a089f4a2 Move towards unboxed types in the Peon VM 2022-08-17 17:31:15 +02:00
Mattia Giambirtone fc14cfec2d Added chained imports test 2022-08-16 14:23:58 +02:00
Mattia Giambirtone 9a19fad1ad More fixes to the import system and incremental compilation 2022-08-16 13:37:09 +02:00
Mattia Giambirtone 3636c74a6a WIP for importing the same module multiple times and other failed fixes 2022-08-16 13:11:09 +02:00
Mattia Giambirtone 13b432b2d2 Basic support for actual incremental compilation 2022-08-16 12:20:17 +02:00
Mattia Giambirtone 26c55c403e Removed debugging echo 2022-08-15 22:34:08 +02:00
Mattia Giambirtone 626375bc1f Added all missing comparison operators and fixed error reporting system 2022-08-15 22:15:06 +02:00
Mattia Giambirtone 5dc8ce437c Expanded comparison test and fixed some typos/mistakes 2022-08-15 20:09:54 +02:00
Mattia Giambirtone 70a5f9dcd3 Fixed issues with '>', thanks Nim... 2022-08-15 19:52:06 +02:00
Mattia Giambirtone 0861135e7f Initial work on a stdlib of sorts, added comparison operators and refactored tests 2022-08-15 19:07:37 +02:00
Mattia Giambirtone 7ef5b4dfbf Fixed some issues with strings and added debug print to fibonacci test 2022-08-15 17:20:09 +02:00
Mattia Giambirtone edef50deca Made exception handling in main.nim module-aware and did some minor refactoring 2022-08-15 11:46:24 +02:00
Mattia Giambirtone 39a84182b0 Fixed name resolution error in findByName 2022-08-14 19:51:12 +02:00
Mattia Giambirtone c85fff8f67 Initial tests for an import system 2022-08-14 18:37:17 +02:00
Mattia Giambirtone f50dd66741 Minor documentation additions 2022-08-04 17:48:56 +02:00
Mattia Giambirtone da651355b9 Added a few more tests 2022-08-01 13:16:07 +02:00
Mattia Giambirtone a370961218 Removed debug print 2022-08-01 11:36:23 +02:00
Mattia Giambirtone 0fdddbfda4 Fixed fib to work again 2022-08-01 11:36:00 +02:00
Mattia Giambirtone 3fba30b8ac Fixed inference of unary and binary operators 2022-08-01 11:30:44 +02:00
Mattia Giambirtone cc49cb98a6 Updated the manual and changed the syntax for foreach loops 2022-08-01 11:03:49 +02:00
Mattia Giambirtone 67b44dbfc9 Added support for GenericPrint opcode 2022-08-01 10:44:38 +02:00
Mattia Giambirtone ff0ae8fcba Various fixes to frames, recursion, and more. Removed stack bottom from CFI data. Added comparison opcode for fib test as well as a clock opcode 2022-08-01 10:38:51 +02:00
Mattia Giambirtone b4628109ce Fixed a bug with nested scopes 2022-07-31 16:40:47 +02:00
Mattia Giambirtone 33066d3b9b Fixed bug with calling a call 2022-07-31 16:09:22 +02:00
Mattia Giambirtone da2cfefe75 Removed the need for parentheses around control flow and looping statements, enforced braces instead. Got rid of the old C-style for loop 2022-07-16 13:21:40 +02:00
Mattia Giambirtone b40275b52f Added Compiler.check(), made type constraints mandatory in generics, reverted '\n' being converted to a semicolon, minor refactoring 2022-07-16 13:04:00 +02:00
Mattia Giambirtone 2072f34d4c BYE BYE SEMICOLONS! 2022-07-15 19:48:32 +02:00
Mattia Giambirtone 60028ed664 Fixed issues when debugSerializer == true 2022-07-10 16:31:30 +02:00
Mattia Giambirtone 9cedc72f68 Fixed error message when returning values from void functions 2022-07-10 15:10:01 +02:00
Mattia Giambirtone 39d1eab234 Temporary fix for not closing over function arguments 2022-07-10 15:07:44 +02:00
Mattia Giambirtone 13cc641e7b Initial work on closures. Seems to be working 2022-07-10 14:50:08 +02:00
Mattia Giambirtone 6116c127c6 Moved for peon types to its own module, added support for negating primitives in the compiler and for floats in the VM, added some more docs to the VM and restored the old empty-jump mechanism for closure declaration. Minor changes to endScope 2022-07-10 13:19:57 +02:00
Mattia Giambirtone e38610fdbd Updated Makefile 2022-07-09 16:25:19 +02:00
Mattia Giambirtone 3f5f514259 Fixed some issued with scoping and globals 2022-07-09 13:36:29 +02:00
Mattia Giambirtone cc0aab850e Simplified calling convention, added for PeonObject, added some comments, fixed bug with StoreVar in stack frames, fixed issues with functions assigned to variables, changed the way closures are emitted so that empty jumps are no longer needed 2022-07-09 12:47:53 +02:00
Mattia Giambirtone 2c6325d33b Initial broken work on generics 2022-06-21 20:18:53 +02:00
Mattia Giambirtone 985ceed075 Initial unfinished work on generic functions 2022-06-20 09:39:54 +02:00
Mattia Giambirtone 95880b7ba2 Updated .gitignore, slightly edited README and added some more tests 2022-06-19 14:45:38 +02:00
Mattia Giambirtone 6f60f76270 More fixes for assigning builtin functions to variables 2022-06-14 23:34:42 +02:00
Mattia Giambirtone d3b9418fea Added some missing files 2022-06-14 22:45:41 +02:00
Mattia Giambirtone e32b8e258f Initial work on generics and fixed bugs in the parser with stropped operator names 2022-06-14 22:45:32 +02:00
Mattia Giambirtone 4591e5ca0e Added built-in operators as a single instruction (src/peon/stdlib/arithmetics.pn is now fully functional) 2022-06-14 18:10:13 +02:00
Mattia Giambirtone 73381513f9 Minor fixes 2022-06-14 12:14:58 +02:00
Mattia Giambirtone 5d572386a3 Initial work on pragma handling (+ some parser fixes). Changed the way the lexer handles indentation and made tabs illegal. Added instructions for some operations on primitive types, removed file argument from serializer 2022-06-14 12:12:56 +02:00
Mattia Giambirtone d241333047 Initial work on closures (again?) 2022-06-13 17:28:05 +02:00
Mattia Giambirtone e3ab2fbdb6 Fixed issues with returning/calling function objects 2022-06-13 15:44:53 +02:00
Mattia Giambirtone 02f1f8a54d Various style fixes with nil checks, added PushC opcode, added support for calling function objects 2022-06-13 15:04:53 +02:00
Mattia Giambirtone 11b15abc01 More work on pragmas, returning functions now works 2022-06-08 16:07:08 +02:00
Mattia Giambirtone dac0cca1bc Initial experimental support for parsing pragmas 2022-06-07 11:23:08 +02:00
Mattia Giambirtone aed0f6e8f2 Initial work on type declarations 2022-06-02 14:23:05 +02:00
Mattia Giambirtone 1d228c6310 Fixed logic bug within if/else construct 2022-06-02 12:19:18 +02:00
Mattia Giambirtone dfa42d994b Fixed if/else 2022-06-02 12:05:22 +02:00
Mattia Giambirtone 72ba5c7528 Updated config.nim 2022-06-02 11:48:17 +02:00
Mattia Giambirtone e9cb3fca89 Fixed local variables 2022-06-02 11:45:27 +02:00
Mattia Giambirtone 6b314f2882 Fixed nested calls 2022-06-02 10:19:34 +02:00
Mattia Giambirtone f2f0fae36f Fixed inverse parameter ordering (whoops) 2022-06-02 01:50:06 +02:00
Mattia Giambirtone 099f733db6 Initial work on a two-stack design 2022-06-02 01:33:56 +02:00
Mattia Giambirtone f8ab292c27 Fixed peon calling convention and various errors with function calls 2022-05-30 22:06:15 +02:00
Mattia Giambirtone 369dff7da2 Removed debugging print (oops) 2022-05-30 12:33:30 +02:00
Mattia Giambirtone df105125c4 Various fixes to stack frame alignment and added incremental compilation to REPL 2022-05-30 12:32:24 +02:00
Mattia Giambirtone 0887dab246 Added lastPop field to VM 2022-05-30 09:32:15 +02:00
Mattia Giambirtone 9f126845fc Initial work on function calls 2022-05-30 09:29:03 +02:00
Mattia Giambirtone 50b7b56feb Fixed some segfaults 2022-05-29 23:01:36 +02:00
Mattia Giambirtone 9dacda4009 Various fixes and stack frame changes 2022-05-29 17:04:19 +02:00
Mattia Giambirtone b0515d3573 Refactored the type system which no longer relies on AST node objects. Added types for ref, ptr and mutable types 2022-05-29 15:54:01 +02:00
Mattia Giambirtone bf9b9389ce Some work for heap vars, wip fixes for higher-order functions 2022-05-27 14:01:57 +02:00
Mattia Giambirtone 71c05ec1bf Fixed closure variables and debugger output with nested CFI data (also removed unneeded peon files) 2022-05-26 18:32:02 +02:00
Mattia Giambirtone 0f0a442578 Fixed issues with stack frames when returning from functions 2022-05-25 14:38:40 +02:00
Mattia Giambirtone e15b6a4915 Fixed recursion error inside inferType 2022-05-25 14:17:58 +02:00
Mattia Giambirtone 5bf5c6d3fd Fixed variable declarations not compiling in some cases 2022-05-25 12:15:45 +02:00
Mattia Giambirtone 990b54fa3e Made main.nim a bit nicer with command-line options 2022-05-25 11:49:21 +02:00
Mattia Giambirtone be4c2500ac Added info about CFI section and made minor changes to README 2022-05-25 11:36:12 +02:00
Mattia Giambirtone 48d1c3fc8c Initial work on CFI-like functionality for better debugging 2022-05-24 22:26:45 +02:00
Mattia Giambirtone dbeae16dc4 Various fixes to matchImpl. Variables can now shadow functions, but not other variables 2022-05-24 10:23:34 +02:00
Mattia Giambirtone 15f412bcac Updated config.nim and changed mechanism for finding operators (also added binary operator lookup) 2022-05-24 09:56:11 +02:00
Mattia Giambirtone 396f40d3d6 Added some docs, LoadVar to the VM and readInt32 2022-05-23 14:03:17 +02:00
Mattia Giambirtone 9c14bfae91 Initial work on generics, fixed StoreVar. declareName no longer emits any bytecode (as it doesn't need to) 2022-05-23 11:53:34 +02:00
Mattia Giambirtone 8d1699ff9e Refactored calling convention and added stack frame support to the VM as well as StoreVar 2022-05-23 10:49:38 +02:00
Mattia Giambirtone 5f43ea9490 Initial work on calls (with runtime support too) 2022-05-22 17:23:52 +02:00
Mattia Giambirtone 50b0f98f6a Removed raise in main.nim 2022-05-22 15:31:13 +02:00
Mattia Giambirtone 21a9689f6c Functions can now return functions which return functions... recursively. Initial work on forward declarations and function call resolution 2022-05-22 15:27:28 +02:00
Mattia Giambirtone 9f1769ab71 Added LoadVar support to the VM and fixed a minor mistake in the debugger output 2022-05-22 13:09:46 +02:00
Mattia Giambirtone 42ab1d4c6e Initial work on call resolution, added support for running files 2022-05-22 13:02:57 +02:00
Mattia Giambirtone 6d6ae3ee7a Fixed and improved error reporting and made the parser ignore whitespace/tab (again) 2022-05-22 11:49:38 +02:00
Mattia Giambirtone 7cf69cf0cf Added hasExplicitReturn field to function and lambda declarations to fix some errors with compiling them. Fixed minor issues with function and lambda parsing, the parser is now able to skip whitespace/tab tokens trasparently, made parser.done() inline, removed invalid state error from funDecl 2022-05-21 12:20:12 +02:00
Mattia Giambirtone e4c2ba2ce2 Got rid of serializedRaw in main module and prettyfied the output 2022-05-20 18:34:14 +02:00
Mattia Giambirtone 751cf644dc Removed unneded flags 2022-05-20 16:01:34 +02:00
Mattia Giambirtone beb853837a Added skeleton for future expansion 2022-05-20 15:55:28 +02:00
Mattia Giambirtone 1a0587d08b Minor style changes, removed findImpl from compiler, made the VM use the multibyte utilities, bytecode chunks now no longer store AST node objects and use a stream of bytes instead, fixed issues with endScope() in the compiler which would not pop properly from self.names, fixed issues with blockStmt in parser, added more multibyte utilities 2022-05-20 15:47:04 +02:00
Mattia Giambirtone 77bd0c8b6f Minor changes to bytecode file 2022-05-18 13:47:07 +02:00
Mattia Giambirtone cb21af4aa3 Added Makefile, prettyfied code, initial work on pragmas 2022-05-18 13:32:32 +02:00
Mattia Giambirtone e8cbec94bd Minor bug fixes 2022-05-16 19:40:13 +02:00
Mattia Giambirtone ffee77b6fc Made function jumps absolute 2022-05-16 19:31:17 +02:00
Mattia Giambirtone 620c56237a Fixed an issue with jump offsets and with functions return types 2022-05-16 19:23:38 +02:00
Mattia Giambirtone e823a459c8 Implemented jump opcodes and LoadUInt64 in the VM, some style and proc changes in the compiler, chunk constants are now type-aware, fixed various inheritance mistakes in the AST node, refined type inference system, moved types back to the compiler and completely redesigned operator parsing to be more modular 2022-05-07 10:48:42 +02:00
Mattia Giambirtone 6ec5619d04 Added missing typing module 2022-05-04 14:28:36 +02:00
Mattia Giambirtone c7500f610e Renamed all infer* functions to inferType, minor changes to signatures of declaration() and statement() 2022-05-04 14:27:15 +02:00
Mattia Giambirtone a1c5430773 Collections are no longer a compiler intrinsic. Added parser support for ptr/ref arguments 2022-05-04 14:01:38 +02:00
Mattia Giambirtone f189b0214e Initial work on simplifying the type system and added more VM utility functions 2022-05-02 23:19:31 +02:00
Mattia Giambirtone b4fffe18aa Completely reworked the type inference system. Initial work on specializing the constants table in the bytecode chunk 2022-05-02 17:26:38 +02:00
Mattia Giambirtone 0493181262 Removed broken optimizer module 2022-05-02 12:38:43 +02:00
Mattia Giambirtone 8d31b79302 The parser can now correctly recognize returning functions from other functions 2022-05-02 11:13:04 +02:00
Mattia Giambirtone f2b60bd9c4 Experimental support for multiple arguments of the same type using only one type declaration + various compiler fixes 2022-05-01 13:08:02 +02:00
Mattia Giambirtone 776968bffc Name stropping, added NoOp, minor AST fixes, removed builtin opcodes for most operations 2022-04-29 23:04:53 +02:00
Mattia Giambirtone 299b359344 Name stropping now is generic to identifiers 2022-04-29 17:15:57 +02:00
Mattia Giambirtone d81ceb6760 Added types module 2022-04-29 16:57:14 +02:00
Mattia Giambirtone 223ba603a7 Removed old JAPL type system. Initial dummy VM for testing purposes 2022-04-28 18:06:53 +02:00
Mattia Giambirtone 0e4eb82554 Fixed AST inheritance issues and got back to a working state 2022-04-28 11:50:10 +02:00
Mattia Giambirtone f26541d4ae BROKEN: Initial work on closed-over variables and attempt to cleanup the AST type structure 2022-04-27 16:03:48 +02:00
Mattia Giambirtone d7cb6eaae0 Bytecode is now serialized to a file 2022-04-26 16:22:23 +02:00
Mattia Giambirtone c1152b8859 Updated commit hash in config.nim 2022-04-26 13:05:17 +02:00
Mattia Giambirtone 76d2b4e59d Fixed various bugs with parsing and compiling functions as well as with jumping 2022-04-26 13:04:40 +02:00
Mattia Giambirtone 4839c9a341 Turned off optimizer (breaks compiler) further work on closures and scope resolution 2022-04-26 09:29:59 +02:00