diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-10 16:28:49 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-10 16:28:49 -0500 |
| commit | fde276a3bf3d20da5346bd302a736101ce440362 (patch) | |
| tree | de395f7e8e8624c99a4af3eea160437b89d4b3ee /src/ir_print.cpp | |
| parent | 430e33b869b004ca24faee2dfa9e51aa4e94093f (diff) | |
| download | zig-fde276a3bf3d20da5346bd302a736101ce440362.tar.gz zig-fde276a3bf3d20da5346bd302a736101ce440362.zip | |
IR: implement error for missing or extra switch prongs
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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"); } |
