nightshade

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

ir.ads (1352B)



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;