From fde276a3bf3d20da5346bd302a736101ce440362 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 10 Jan 2017 16:28:49 -0500 Subject: IR: implement error for missing or extra switch prongs --- src/ir_print.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ir_print.cpp') diff --git a/src/ir_print.cpp b/src/ir_print.cpp index 1f4d368afc..c05e51cf1a 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -799,6 +799,20 @@ static void ir_print_int_to_enum(IrPrint *irp, IrInstructionIntToEnum *instructi fprintf(irp->f, ")"); } +static void ir_print_check_switch_prongs(IrPrint *irp, IrInstructionCheckSwitchProngs *instruction) { + fprintf(irp->f, "@checkSwitchProngs("); + ir_print_other_instruction(irp, instruction->target_value); + fprintf(irp->f, ","); + for (size_t i = 0; i < instruction->range_count; i += 1) { + if (i != 0) + fprintf(irp->f, ","); + ir_print_other_instruction(irp, instruction->ranges[i].start); + fprintf(irp->f, "..."); + ir_print_other_instruction(irp, instruction->ranges[i].end); + } + fprintf(irp->f, ")"); +} + static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { ir_print_prefix(irp, instruction); switch (instruction->id) { @@ -1056,6 +1070,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdIntToEnum: ir_print_int_to_enum(irp, (IrInstructionIntToEnum *)instruction); break; + case IrInstructionIdCheckSwitchProngs: + ir_print_check_switch_prongs(irp, (IrInstructionCheckSwitchProngs *)instruction); + break; } fprintf(irp->f, "\n"); } -- cgit v1.2.3