Commit Graph

327 Commits

Author SHA1 Message Date
07d16e7454 lang: codegen: fix segfault when serialising selector with unnamed args 2025-04-22 21:31:44 +01:00
833c80534e doc: update mie msg instruction syntax samples 2025-04-22 15:33:53 +01:00
83b05259f8 meta: update clang-format config
some source files are recognised as objc source files due to the use
of array initialiser macros. because of this, the C/C++ formatting settings
defined in .clang-format weren't being used.

now, the correct settings are applied for objc files too.
2025-04-22 15:32:08 +01:00
1942070c4e frontend: repl: disable post-order ast printing 2025-04-22 15:31:51 +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
dc000ae8ef common: implement conversion from b_status to ivy_status 2025-04-22 15:22:49 +01:00
79a818dd8e test: update mie tests 2025-04-22 15:22:28 +01:00
4ffe445572 mie: add strict-naming support to mie_name_map
in strict mode, the hint is taken as the required name. if a value already
exists with the given name, the operation fails.
2025-04-22 15:21:30 +01:00
f8c322ef6c mie: convert: add support for converting more value types 2025-04-22 15:20:43 +01:00
f0869b5ba0 lang: codegen: start implementing lambda generation 2025-04-21 21:11:45 +01:00
8023ea622a mie: func name and args are now specified separately from func creation
func args are added manually using mie_func_add_arg, while the func's name
is specified when the func is added to a module, to allow the module to generate
a unique name.
2025-04-21 21:10:27 +01:00
8febd270ba mie: convert: add spacing between function definitions 2025-04-21 21:10:14 +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
78817b6b8c update: use updated parser api to fix memory leaks 2025-04-17 23:16:16 +01:00
25c1fbd44b lang: fix a bunch of memory leaks 2025-04-17 23:15:48 +01:00
11449b9919 lang: codegen: add support for non-fstrings to expr generator 2025-04-17 22:55:40 +01:00
9cce4bf541 mie: implement caching and emitting string data 2025-04-17 22:55:17 +01:00
abb7cfaf0e mie: move mie_ctx to a separate header 2025-04-17 22:25:36 +01:00
7b8d77a264 lang: codegen: implement message-send code generation and global var references 2025-04-17 21:44:38 +01:00
a4504c0507 lang: ast: fix source formatting 2025-04-17 21:43:51 +01:00
8388dfeb79 mie: implement ir generation for message sending 2025-04-17 21:43:02 +01:00
6d8809d325 mie: implement generating extern global data items 2025-04-17 21:42:41 +01:00
51e07522e8 lang: ast: fix parens not allowing sub-keyword messages
previously, an expression like:

	x arg1:a arg2:(c subArg:d).

were being parsed incorrectly. This expression was parsed
as single -arg1:arg2:subArg: message being sent to x. the
parentheses around the `c subArg:d` sub-expression were
being ignored.

now, this expression is correcly parsed as the value
of `c subArg:d` being passed as a parameter to the message
-arg1:arg2:
2025-04-17 21:38:31 +01:00
635d23d2e1 frontend: update codegen usage to only use pre-order ast traversal 2025-04-16 21:59:32 +01:00
f0e6237473 lang: codegen: redesign again to use purely pre-order ast traversal 2025-04-16 21:58:52 +01:00
95dbedefde mie: builder: add function to get current block 2025-04-16 21:58:22 +01:00
a184ffce6f doc: fix sample file permissions 2025-04-15 11:06:06 +01:00
ccb31ae545 doc: add var syntax samples 2025-04-15 11:05:52 +01:00
ae35c15f78 ivy.vim: add highlighting for var keyword 2025-04-15 11:05:02 +01:00
e430b7b2f1 lang: add var keyword for variable declarations
the var keyword allows greater control over what scope a
particular variable exists in. it clarifies whether a new
variable is being defined or an existing variable is being
assigned to. it will also facilitate the implementation of
global variables.
2025-04-15 11:02:47 +01:00
abebdb595a frontend: add IR generation to compile command 2025-04-15 11:00:48 +01:00
8d462799dd mie: add selector as a mie_value const type 2025-04-15 11:00:10 +01:00
4587416ac9 frontend: repl: generate ir from input 2025-04-14 20:15:41 +01:00
670b7c5a33 lang: codegen: redesign codegen to use a stack-based state machine 2025-04-14 20:15:05 +01:00
5630132a69 mie: add some convenience functions for func, block, and builder 2025-04-14 20:14:44 +01:00
d4e0df0bda mie: implement sub/mul/div instruction generation 2025-04-14 20:14:28 +01:00
1c8f1447e7 mie: fix a nullptr deref in mie_ctx cleanup 2025-04-14 20:13:13 +01:00
bcc0daa2d5 frontend: update ast iterator api usage 2025-04-14 12:25:49 +01:00
f123902215 frontend: add parameters to print_ast_node iterator function
the caller can now specify whether the nodes should be printed
in pre-order or post-order, and whether the output should be indented.
2025-04-14 12:24:56 +01:00
80e001cdc1 lang: add user args to ast iterator; combine pre/post-order traversal modes
the caller can now provide a pointer arg to ivy_ast_node_iterate, which will
be forwarded to the specified callback function each time it is called.

the iterator now behaves similarly to fts, in that it visits each node
in both pre-order and post-order, and indicates to the callback whether
the current iteration is pre- or post-order.
2025-04-14 12:24:42 +01:00
7a9fc1b11c doc: remove class definition from Expressions sample 2025-04-14 09:53:27 +01:00
2cd78a64b0 lang: start implementing code generation (ast to ir) facility 2025-04-14 09:48:16 +01:00
c682cbb15a frontend: update ast traversal api usage 2025-04-14 09:46:36 +01:00
fd91bb71c0 ast: implement postorder ast traversal 2025-04-14 09:46:27 +01:00
ae5e438207 common: add some more status codes 2025-04-14 09:43:31 +01:00
e1d7bebe9f test: mie-ir: cleanup after ir generation 2025-04-13 19:25:41 +01:00
a7233a6cf6 mie: implement value cleanup 2025-04-13 19:25:23 +01:00