2828 */
2929
3030/*
31- */
3231#define DEBUG_RESOLVE
32+ */
3333
3434/* regular (and very slow) sanity checks on symbols ... needs DEBUG in
3535 * symbol.c as well
36- */
3736#define DEBUG_SANITY
37+ */
3838
3939/* count how many nodes we find with common sub-expression removal.
40- */
4140#define DEBUG_COMMON
41+ */
4242
4343/* show what everything compiled to
44- */
4544#define DEBUG_RESULT
45+ */
4646
4747/* trace list comp compile
48- */
4948#define DEBUG_LCOMP
49+ */
5050
5151/* trace pattern LHS generation
52- */
5352#define DEBUG_PATTERN
53+ */
5454
5555/*
5656#define DEBUG
@@ -1468,29 +1468,6 @@ compile_remove_subexpr(Compile *compile, PElement *root)
14681468 return TRUE;
14691469}
14701470
1471- /* This is a def with multiple RHS. Check that:
1472- *
1473- * - all defs hjave the same number of args
1474- * - no more then def RHS has no pattern matching args
1475- * - if there is a no-pattern def, it must be the last one
1476- */
1477- static gboolean
1478- compile_check_rhs (Compile * compile )
1479- {
1480- g_assert (!compile -> sym -> generated );
1481- g_assert (compile -> sym -> next_rhs );
1482-
1483- int nargs = -1 ;
1484- for (Symbol * p = compile -> sym ; p ; p = p -> next_rhs )
1485- if (nargs == -1 )
1486- nargs = p -> nargs ;
1487- else if (nargs != p -> nargs ) {
1488- error ...
1489- }
1490-
1491- return TRUE;
1492- }
1493-
14941471/* Top-level compiler driver.
14951472 */
14961473
@@ -1506,14 +1483,6 @@ compile_heap(Compile *compile)
15061483 if (compile -> sym -> placeholder )
15071484 return NULL ;
15081485
1509- /* There could be multiple RHS ... if this is the first RHS, check the
1510- * rules around parameters and patterns.
1511- */
1512- if (!compile -> sym -> generated &&
1513- compile -> sym -> next_rhs &&
1514- !compile_check_rhs (compile ))
1515- return compile -> sym ;
1516-
15171486 PEPOINTE (& base , & compile -> base );
15181487
15191488 /* Is there an existing function base? GC it away.
@@ -1601,8 +1570,7 @@ compile_symbol_sub(Symbol *sym)
16011570{
16021571 Compile * compile ;
16031572
1604- if (sym -> expr &&
1605- (compile = sym -> expr -> compile ))
1573+ if (sym -> expr && (compile = sym -> expr -> compile ))
16061574 if (compile_object_sub (compile ))
16071575 return sym ;
16081576
@@ -1684,12 +1652,14 @@ compile_check_i18n(Compile *compile, ParseNode *pn)
16841652 static GHashTable * msgid = NULL ;
16851653
16861654 if (!msgid )
1687- msgid = g_hash_table_new (g_str_hash , g_str_equal );
1655+ msgid = g_hash_table_new (
1656+ g_str_hash , g_str_equal );
16881657
16891658 if (!g_hash_table_lookup (msgid , text )) {
16901659 char buf [MAX_STRSIZE ];
16911660
1692- g_hash_table_insert (msgid , (void * ) text , NULL );
1661+ g_hash_table_insert (msgid ,
1662+ (void * ) text , NULL );
16931663 my_strecpy (buf , text , TRUE);
16941664 printf ("msgid \"%s\"\n" , buf );
16951665 printf ("msgstr \"\"\n\n" );
@@ -2488,9 +2458,11 @@ compile_pattern_access(Compile *compile,
24882458 * item in the trail in the list of elements.
24892459 */
24902460 c .type = PARSE_CONST_NUM ;
2491- c .val .num = g_slist_index (trail [i ]-> elist , trail [i + 1 ]);
2461+ c .val .num = g_slist_index (trail [i ]-> elist ,
2462+ trail [i + 1 ]);
24922463 right = tree_const_new (compile , c );
2493- node = tree_binop_new (compile , BI_SELECT , node , right );
2464+ node = tree_binop_new (compile ,
2465+ BI_SELECT , node , right );
24942466 break ;
24952467
24962468 default :
@@ -2529,27 +2501,34 @@ compile_pattern_condition(Compile *compile,
25292501 /* Generate is_complex x.
25302502 */
25312503 left = tree_leaf_new (compile , "is_complex" );
2532- right = compile_pattern_access (compile , leaf , trail , i );
2504+ right = compile_pattern_access (compile ,
2505+ leaf , trail , i );
25332506 node2 = tree_appl_new (compile , left , right );
25342507
2535- node = tree_binop_new (compile , BI_LAND , node2 , node );
2508+ node = tree_binop_new (compile ,
2509+ BI_LAND , node2 , node );
25362510 break ;
25372511
25382512 case BI_CONS :
25392513 /* Generate is_list x && x != [].
25402514 */
25412515 left = tree_leaf_new (compile , "is_list" );
2542- right = compile_pattern_access (compile , leaf , trail , i );
2516+ right = compile_pattern_access (compile ,
2517+ leaf , trail , i );
25432518 node2 = tree_appl_new (compile , left , right );
25442519
2545- node = tree_binop_new (compile , BI_LAND , node2 , node );
2520+ node = tree_binop_new (compile ,
2521+ BI_LAND , node2 , node );
25462522
2547- left = compile_pattern_access (compile , leaf , trail , i );
2523+ left = compile_pattern_access (compile ,
2524+ leaf , trail , i );
25482525 n .type = PARSE_CONST_ELIST ;
25492526 right = tree_const_new (compile , n );
2550- node2 = tree_binop_new (compile , BI_NOTEQ , left , right );
2527+ node2 = tree_binop_new (compile ,
2528+ BI_NOTEQ , left , right );
25512529
2552- node = tree_binop_new (compile , BI_LAND , node , node2 );
2530+ node = tree_binop_new (compile ,
2531+ BI_LAND , node , node2 );
25532532 break ;
25542533
25552534 default :
@@ -2561,7 +2540,8 @@ compile_pattern_condition(Compile *compile,
25612540 /* Generate is_list x && is_list_len n x.
25622541 */
25632542 left = tree_leaf_new (compile , "is_list" );
2564- right = compile_pattern_access (compile , leaf , trail , i );
2543+ right = compile_pattern_access (compile ,
2544+ leaf , trail , i );
25652545 node2 = tree_appl_new (compile , left , right );
25662546
25672547 node = tree_binop_new (compile , BI_LAND , node2 , node );
@@ -2571,7 +2551,8 @@ compile_pattern_condition(Compile *compile,
25712551 n .val .num = g_slist_length (trail [i ]-> elist );
25722552 right = tree_const_new (compile , n );
25732553 left = tree_appl_new (compile , left , right );
2574- right = compile_pattern_access (compile , leaf , trail , i );
2554+ right = compile_pattern_access (compile ,
2555+ leaf , trail , i );
25752556 node2 = tree_appl_new (compile , left , right );
25762557
25772558 node = tree_binop_new (compile , BI_LAND , node , node2 );
@@ -2580,7 +2561,8 @@ compile_pattern_condition(Compile *compile,
25802561 case NODE_CONST :
25812562 /* Generate x == n.
25822563 */
2583- left = compile_pattern_access (compile , leaf , trail , i );
2564+ left = compile_pattern_access (compile ,
2565+ leaf , trail , i );
25842566 right = tree_const_new (compile , trail [i ]-> con );
25852567 node2 = tree_binop_new (compile , BI_EQ , left , right );
25862568
@@ -2595,7 +2577,8 @@ compile_pattern_condition(Compile *compile,
25952577 n .val .str = g_strdup (trail [i ]-> tag );
25962578 right = tree_const_new (compile , n );
25972579 node2 = tree_appl_new (compile , left , right );
2598- right = compile_pattern_access (compile , leaf , trail , i );
2580+ right = compile_pattern_access (compile ,
2581+ leaf , trail , i );
25992582 node2 = tree_appl_new (compile , node2 , right );
26002583
26012584 node = tree_binop_new (compile , BI_LAND , node2 , node );
0 commit comments