Commit Graph

14 Commits

Author SHA1 Message Date
haxala1r 947d2274bb vm: modified StoreLocal and StoreGlobal logic to be more consistent with the rest of the VM,
ci/woodpecker/push/nix Pipeline was successful
ci/woodpecker/push/fedora Pipeline was successful
ci/woodpecker/push/debian Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful
and modified the emit module to emit a Pop instruction after every top-level expression.

This change was required because the semantics of the language are pretty clear.
Every expression evaluates to something - meaning that, in the corresponding bytecode,
every expression must have exactly a +1 effect on the data stack. I.e. every expression,
when its corresponding bytecode is evaluated, has the effect of pushing something
to the stack. For values that are not used by another expression, this value
must be immediately popped.

Some optimizations could target this area. For example, for top-level expressions,
it is obvious to the compiler that their values will not be used - hence the compiler
can use optimized versions of some instructions (like StoreLocal and StoreGlobal)
to simply never leave the value on the stack, thus saving an extra Pop instruction
(good for performance and code size).

Same thing applies in function bodies, letrec/let/begin bodies, where expressions
whose values are never used may appear.

It may also make sense to introduce registers to the VM, for the purposes of
parameter passing (such that up to a predetermined number of parameters are
progressively passed through registers instead of pushed to the stack).
This would pair well with eliminating unnecessary currying in the byte code.
2026-04-26 01:20:05 +03:00
haxala1r d846046c4a Big changes:
ci/woodpecker/push/debian Pipeline was successful
ci/woodpecker/push/nix Pipeline was successful
ci/woodpecker/push/fedora Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful
Compiler and VM are now working well enough to support larger programs.
A test program is included and executed immediately upon running
the executable.

A more feature complete read-eval-print loop is planned.
2026-04-26 00:55:43 +03:00
haxala1r 5edcc974b6 binary: modify binary to make use of the new compilation pipeline 2026-04-25 22:47:34 +03:00
haxala1r 4792a296d3 interpreter: minor fixes, changes to the main binary to actually interpret some source code
ci/woodpecker/push/debian Pipeline was successful
ci/woodpecker/push/nix Pipeline was successful
ci/woodpecker/push/fedora Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful
ci/woodpecker/cron/debian Pipeline was canceled
ci/woodpecker/cron/nix Pipeline was canceled
ci/woodpecker/cron/fedora Pipeline was canceled
ci/woodpecker/cron/publish Pipeline was canceled
2026-03-22 17:23:49 +03:00
haxala1r 3a3bf2c674 core_ast: removed letrec. we now treat it as let + set.
ci/woodpecker/push/debian Pipeline was successful
ci/woodpecker/push/nix Pipeline was successful
ci/woodpecker/push/fedora Pipeline was successful
ci/woodpecker/cron/fedora Pipeline was successful
ci/woodpecker/cron/debian Pipeline was successful
ci/woodpecker/cron/nix Pipeline was successful
2026-02-02 22:36:55 +03:00
haxala1r be81061895 syntactic_ast: fix issue in set! parsing, add set! to the test case.
ci/woodpecker/push/build Pipeline was successful
2026-01-07 18:18:38 +03:00
haxala1r 54c48ddf0e syntactic_ast: add node for if expressions
ci/woodpecker/push/build Pipeline was successful
2026-01-07 18:03:28 +03:00
haxala1r edc9d8b9e6 syntactic_ast: added parsing and pretty printing for cond expressions
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/cron/build Pipeline was successful
2026-01-04 21:38:04 +03:00
haxala1r e95a115acf syntactic_ast: Added proper handling for Let and Letrec
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/cron/build Pipeline was successful
2026-01-03 21:35:27 +03:00
haxala1r 6d95977324 ast: improved the implementation of syntactic_ast
ci/woodpecker/push/build Pipeline was successful
debug: added debug functions for the syntactic_ast module
Modified the compiler executable to test a little bit.

todo: Some nodes of the syntactic ast are not yet emitted,
2026-01-03 18:30:47 +03:00
haxala1r 9981c222eb Added desugar phase for converting cond into a chain of if's 2025-12-28 21:04:45 +03:00
haxala1r d80caadc85 Added gensym, and phases in the desugar module for logical and & or 2025-12-28 21:04:45 +03:00
haxala1r be0d479665 Added desugar steps to add (begin) wrappers around long lambda bodies, and rewrite internal (define) forms into letrec forms 2025-12-28 21:04:45 +03:00
haxala1r 4f1ad54596 Started work on the compiler, with a desugar phase 2025-12-28 21:04:45 +03:00