Commit Graph

178 Commits

Author SHA1 Message Date
7ee2e9dd81 lang: codegen: fix block code generator using unit_codegen_state 2025-09-08 16:10:47 +01:00
e5ea7b1134 lang: codegen: remove old var declaration generator 2025-09-08 16:10:11 +01:00
ee402fb437 lang: move IVY_OP_ASSIGN operator id to be with the other assignment operators 2025-09-08 16:03:45 +01:00
3b5f08b1ea lang: ast: add new ast node type ids 2025-09-08 16:03:39 +01:00
7d1b7c5d68 lang: lex: add new lex token type ids 2025-09-08 16:03:26 +01:00
6e65349d70 lang: ast: fix some source formatting 2025-09-08 16:01:02 +01:00
d95a544ff2 lang: ast: fix parsing of tuple iterator declaration in for-loops 2025-09-08 16:00:42 +01:00
59a85e9c47 lang: ast: fix parsing of unlabelled complex msg args 2025-09-08 16:00:07 +01:00
6dfa0c7e17 lang: ast: add function to signal the end of token input to the parser 2025-09-08 15:58:14 +01:00
3c72527204 lang: ast: fix parsing of inline-if expressions that immediately precede an end keyword 2025-09-08 15:57:04 +01:00
8ab377b3ab lang: ast: implement parsing of true/false/null keyword constants 2025-09-08 15:56:03 +01:00
bf250179da lang: ast: implement parsing of break/continue loop-control statements 2025-09-08 15:55:12 +01:00
84e52b1649 lang: ast: replace var keyword with global
local variables are now created automatically when they are first assigned to.

the global keyword can be used to declare that a name refers to a global variable instead,
at which point, assigning to the name results in the assignment referencing the global variable
instead of allocating a new global variable.
2025-09-08 15:52:29 +01:00
5ea544692b lang: diag: add some new diag codes and messages 2025-09-08 15:48:38 +01:00
d532d9cff3 lang: codegen: fix free of mie_ctx that isn't allocated by ivy_codegen 2025-08-16 21:11:46 +01:00
adb326c795 lang: codegen: fix instr gen duplicating left operand 2025-08-16 21:00:50 +01:00
bda10b1166 lang: codegen: update mie_ctx include path 2025-08-16 21:00:22 +01:00
9f83929600 lang: update mie ir api usage 2025-06-02 11:31:35 +01:00
d746ea5234 lang: ast: fix nullptr deref in expr_finalise_arith when calculating ast node bounds 2025-05-12 15:53:06 +01:00
661014f49f lang: adjust for-loop diagnostic wording 2025-05-09 13:39:02 +01:00
1d4661f7a4 lang: ast: fix parser_push_diag not setting diag location 2025-05-09 13:38:38 +01:00
b89c3bedc5 lang: ast: add diag for do keyword in inline for-loop 2025-05-08 22:32:23 +01:00
5f560d28a7 lang: ast: update arith parser to set ast node bounds 2025-05-08 22:31:37 +01:00
c12371f0ec lang: ast: add diag support to parser 2025-05-08 22:30:23 +01:00
a0f1931c00 lang: lex: update ivy_token to use ivy_char_cell 2025-05-08 22:27:13 +01:00
a28874145c lang: lex: add diagnostic support 2025-05-08 20:31:55 +01:00
cc99e7440e lang: add diagnostic definitions 2025-05-08 20:31:40 +01:00
475575f76f lang: codegen: add for-loop generator 2025-05-08 10:53:00 +01:00
1c3aff9ad3 lang: add start/end coordinates to lexer tokens 2025-04-28 22:53:21 +01:00
de7d5c44cd lang: codegen: add missing ctx parameter to ivy_codegen_create prototype 2025-04-28 15:50:54 +01:00
64d1015a3c lang: codegen: implement cond-group code generation 2025-04-28 15:44:44 +01:00
cbec21b90f lang: implement elif keyword for more complex if-statements 2025-04-24 09:45:26 +01:00
d37c07e5e4 lang: codegen: implement return generation 2025-04-24 09:25:36 +01:00
da4aa7df78 lang: codegen: function load now uses func type instead of id 2025-04-24 09:25:21 +01:00
614329091c lang: codegen: implement unit-package and unit-import generation 2025-04-23 15:44:01 +01:00
4ea9683880 lang: codegen: lambda s_outer_block is now only initialised once 2025-04-23 11:02:47 +01:00
2062ee631c lang: codegen: fix pop_generator_recurse only popping generators with a value_received callback defined 2025-04-23 11:01:12 +01:00
2eb358457c lang: codegen: fix serialisation of selectors with unnamed args 2025-04-23 11:00:57 +01:00
857d99ea34 lang: codegen: codegen_load_variable now supports loading non-ptr variables 2025-04-23 11:00:16 +01:00
3af786b32c lang: ast: fix selector, unit-package, and unit-import string conversion
stringifying selectors with unnamed args no longer causes a segfault,
and unit-package and unit-import node strings are now formatted correctly.
2025-04-23 10:58:22 +01:00
c7aa3b422d lang: ast: fix lambdas starting with var declaration not being parsed correctly
IVY_KW_VAR is not treated as an expression start token (as variable declarations are not
strictly expressions). so the lambda parser did not create a block parser context
when it encountered this keyword.
2025-04-23 10:57:17 +01:00
279b387b69 lang: ast: complex-msg args are now separated by commas
additionally, unnamed complex-msg args no longer need to be prefixed
with a colon. this allows complex-msgs to more closely emulate
traditional function calls. this also applies to the call-operator.

for example, take the following lambda:

	var f = [ :x :y | ^x * 2 + y ].

before, this lambda would be invoked using the following syntax:

	f(:2 :4).

now, this syntax is used instead:

	f(2, 4).
2025-04-23 10:53:34 +01:00
07d16e7454 lang: codegen: fix segfault when serialising selector with unnamed args 2025-04-22 21:31:44 +01:00
b8459f9390 lang: codegen: implement lambda variable capture 2025-04-22 15:31:23 +01:00
7483b32c25 lang: codegen: redesign variable definition/resolution system to support capturing
the codegen scope system has been removed. instead, each generator state in the stack,
from the current state backwards, is informed when a variable is defined, resolved, or
captured.

when a variable is defined, the state stack is traversed back-to-front (current generator
first). each state has a chance to record the variable definition. once one state has
signalled that it has recorded the variable definition, the traversal ends.

when a variable is resolved, the state stack is traversed back-to-front (current generator
first). each state is asked whether or not it recognises the variable identifier being resolved.
if a state has the variable in question defined, it returns information about the variable
definition, and the traversal stops.

once a variable has been resolved, the state stack is traversed front-to-back (current generator
last), starting from the generator /after/ the one that provided the variable definition. each
generator in the iteration is given the chance to adjust the variable information, or generate
IR in response to the variable being accessed. this is used to implement variable capture,
where the state of a variable in the enclosing context is captured for later use.
2025-04-22 15:23:42 +01:00
f0869b5ba0 lang: codegen: start implementing lambda generation 2025-04-21 21:11:45 +01:00
f220fc2f4b lang: ast: fix nested lambdas not parsing correctly 2025-04-20 21:25:28 +01:00
4a258e2580 lang: codegen: implement fstring generation 2025-04-18 23:17:39 +01:00
2ddb065243 lang: codegen: disable CODEGEN_F_IGNORE_RESULT in expression generation
this flag caused some issues where the result of a message would
be ignored if it was the first operand in a larger expression.
2025-04-18 23:15:28 +01:00
25c1fbd44b lang: fix a bunch of memory leaks 2025-04-17 23:15:48 +01:00