nightshade

The nightshade programming language, compiler and tools (WIP)
Log | Files | Refs | README

commit e465c6a9023bf04858c57f80db17a33de60b6c68
parent dd59341772e163a849a363b9cba6311092b586e4
Author: citbl <citbl@citbl.org>
Date:   Mon, 15 Jun 2026 15:59:40 +1000

IR wip

Diffstat:
Msrc/ir.adb | 4++--
Msrc/ir.ads | 46++++++++++++++++++++++++++++++++++++++++++++++
Msrc/nightshade.adb | 1+
3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/ir.adb b/src/ir.adb @@ -1,3 +1,3 @@ -package body IR is +-- package body IR is -end IR; +-- end IR; diff --git a/src/ir.ads b/src/ir.ads @@ -1,3 +1,49 @@ +with Ada.Containers.Vectors; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; + package IR is + type IR_Type is (IR_VOID, IR_STR, IR_I64, IR_BOOL); + + type IR_Value is record + Id : Positive; + Typ : IR_Type; + end record; + + type IR_Inst_Kind is (CONST_STR, RET, CALL); + + package IR_Values_Vector is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => IR_Value); + + type IR_Instruction (Kind : IR_Inst_Kind := CONST_STR) is record + case Kind is + when CONST_STR => + Const_Str_Value : Unbounded_String; + + when RET => + Ret_Value : IR_Value; + Has_Value : Boolean; + + when CALL => + Call_Name : Unbounded_String; + Call_Has_Dest : Boolean; + Call_Dest : IR_Value; + Call_Args : IR_Values_Vector.Vector; + end case; + end record; + + package Instructions_Vector is new + Ada.Containers.Vectors (Index_Type => Natural, Element_Type => IR_Instruction); + + type IR_Function is record + Name : Unbounded_String; + Instructions : Instructions_Vector.Vector; + end record; + + package Functions_Vector is new + Ada.Containers.Vectors (Index_Type => Natural, Element_Type => IR_Function); + + type IR_Module is record + Functions : Functions_Vector.Vector; + end record; + end IR; diff --git a/src/nightshade.adb b/src/nightshade.adb @@ -6,6 +6,7 @@ with Lexer; with Parser; with Scope; with Typing; +with IR; procedure Nightshade is begin