11/*
2- * Copyright (c) 2010-2011 Stephen Williams (steve@icarus.com)
2+ * Copyright (c) 2010-2026 Stephen Williams (steve@icarus.com)
33 *
44 * This source code is free software; you can redistribute it
55 * and/or modify it in source code form under the terms of the GNU
2424# include <assert.h>
2525# include <inttypes.h>
2626
27- // HERE: This still needs work! Fall back to <width>'b format for
28- // very large constants. We also should pass the file and
27+ // HERE: This still needs work! We should pass the file and
2928// line number information for the enum type and the MSB and
3029// LSB should be used instead of the width.
30+
31+ static void draw_enum4_value (ivl_enumtype_t enumtype , unsigned idx );
32+
3133/*
3234 * If it fits we always print this as a uint64_t the run time will turn
33- * it back into a signed value when needed.
35+ * it back into a signed value when needed. Wider values are printed in
36+ * the <width>'b format.
3437 */
3538static void draw_enum2_value (ivl_enumtype_t enumtype , unsigned idx )
3639{
@@ -39,9 +42,11 @@ static void draw_enum2_value(ivl_enumtype_t enumtype, unsigned idx)
3942 const char * bit ;
4043 unsigned len = strlen (bits );
4144
42- // HERE: If this doesn't fit then write it as a enum4 and modify the run
43- // time to deal with the conversion.
44- assert (len <= sizeof (uint64_t )* 8 );
45+ if (len > sizeof (uint64_t )* 8 ) {
46+ draw_enum4_value (enumtype , idx );
47+ return ;
48+ }
49+
4550 val = 0 ;
4651 for (bit = bits , mask = 1 ; * bit != 0 ; bit += 1 , mask <<= 1 ) {
4752 if (* bit == '1' )
0 commit comments