@@ -82,6 +82,11 @@ static char buf[1 << 20];
82
82
int buf_size ;
83
83
int * buf_ptr = (int * )buf ;
84
84
int * buf_end ;
85
+ #ifndef DISABLE_EXTF
86
+ int skip_only = 0 ;
87
+ #else
88
+ int skip_only = 1 ;
89
+ #endif
85
90
86
91
int verbosity ;
87
92
@@ -872,6 +877,7 @@ void gen_constructor_store (struct tl_combinator *c) {
872
877
sprintf (s , "T" );
873
878
874
879
int * vars = malloc0 (c -> var_num * 4 );;
880
+ assert (c -> var_num <= 10 );
875
881
gen_uni_skip (c -> result , s , vars , 1 , 0 );
876
882
877
883
if (c -> name == NAME_INT ) {
@@ -937,6 +943,7 @@ void gen_constructor_autocomplete (struct tl_combinator *c) {
937
943
sprintf (s , "T" );
938
944
939
945
int * vars = malloc0 (c -> var_num * 4 );;
946
+ assert (c -> var_num <= 10 );
940
947
gen_uni_skip (c -> result , s , vars , 1 , 0 );
941
948
942
949
if (c -> name == NAME_INT ) {
@@ -1145,6 +1152,7 @@ void gen_function_store (struct tl_combinator *f) {
1145
1152
int i ;
1146
1153
1147
1154
int * vars = malloc0 (f -> var_num * 4 );;
1155
+ assert (f -> var_num <= 10 );
1148
1156
1149
1157
for (i = 0 ; i < f -> args_num ; i ++ ) if (!(f -> args [i ]-> flags & FLAG_OPT_VAR )) {
1150
1158
if (f -> args [i ]-> flags & FLAG_EXCL ) {
@@ -1169,6 +1177,7 @@ void gen_function_autocomplete (struct tl_combinator *f) {
1169
1177
int i ;
1170
1178
1171
1179
int * vars = malloc0 (f -> var_num * 4 );;
1180
+ assert (f -> var_num <= 10 );
1172
1181
1173
1182
for (i = 0 ; i < f -> args_num ; i ++ ) if (!(f -> args [i ]-> flags & FLAG_OPT_VAR )) {
1174
1183
if (f -> args [i ]-> flags & FLAG_EXCL ) {
@@ -1561,7 +1570,8 @@ int parse_tlo_file (void) {
1561
1570
}
1562
1571
1563
1572
assert (buf_ptr == buf_end );
1564
-
1573
+
1574
+
1565
1575
int j ;
1566
1576
for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" )) {
1567
1577
tps [i ]-> name = 0 ;
@@ -1579,21 +1589,27 @@ int parse_tlo_file (void) {
1579
1589
for (i = 0 ; i < tn ; i ++ ) {
1580
1590
for (j = 0 ; j < tps [i ]-> constructors_num ; j ++ ) {
1581
1591
gen_constructor_skip (tps [i ]-> constructors [j ]);
1582
- gen_constructor_store (tps [i ]-> constructors [j ]);
1583
- gen_constructor_fetch (tps [i ]-> constructors [j ]);
1584
- gen_constructor_autocomplete (tps [i ]-> constructors [j ]);
1592
+ if (!skip_only ) {
1593
+ gen_constructor_store (tps [i ]-> constructors [j ]);
1594
+ gen_constructor_fetch (tps [i ]-> constructors [j ]);
1595
+ gen_constructor_autocomplete (tps [i ]-> constructors [j ]);
1596
+ }
1585
1597
}
1586
1598
}
1587
1599
for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" )) {
1588
1600
gen_type_skip (tps [i ]);
1589
- gen_type_store (tps [i ]);
1590
- gen_type_fetch (tps [i ]);
1591
- gen_type_autocomplete (tps [i ]);
1592
- gen_type_do_autocomplete (tps [i ]);
1601
+ if (!skip_only ) {
1602
+ gen_type_store (tps [i ]);
1603
+ gen_type_fetch (tps [i ]);
1604
+ gen_type_autocomplete (tps [i ]);
1605
+ gen_type_do_autocomplete (tps [i ]);
1606
+ }
1593
1607
}
1594
- for (i = 0 ; i < fn ; i ++ ) {
1595
- gen_function_store (fns [i ]);
1596
- gen_function_autocomplete (fns [i ]);
1608
+ if (!skip_only ) {
1609
+ for (i = 0 ; i < fn ; i ++ ) {
1610
+ gen_function_store (fns [i ]);
1611
+ gen_function_autocomplete (fns [i ]);
1612
+ }
1597
1613
}
1598
1614
printf ("int skip_type_any (struct paramed_type *T) {\n" );
1599
1615
printf (" switch (T->type->name) {\n" );
@@ -1603,76 +1619,78 @@ int parse_tlo_file (void) {
1603
1619
}
1604
1620
printf (" default: return -1; }\n" );
1605
1621
printf ("}\n" );
1606
- printf ("int store_type_any (struct paramed_type *T) {\n" );
1607
- printf (" switch (T->type->name) {\n" );
1608
- for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" ) && tps [i ]-> name ) {
1609
- printf (" case 0x%08x: return store_type_%s (T);\n" , tps [i ]-> name , tps [i ]-> print_id );
1610
- printf (" case 0x%08x: return store_type_bare_%s (T);\n" , ~tps [i ]-> name , tps [i ]-> print_id );
1611
- }
1612
- printf (" default: return -1; }\n" );
1613
- printf ("}\n" );
1614
- printf ("int fetch_type_any (struct paramed_type *T) {\n" );
1615
- printf (" switch (T->type->name) {\n" );
1616
- for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" ) && tps [i ]-> name ) {
1617
- printf (" case 0x%08x: return fetch_type_%s (T);\n" , tps [i ]-> name , tps [i ]-> print_id );
1618
- printf (" case 0x%08x: return fetch_type_bare_%s (T);\n" , ~tps [i ]-> name , tps [i ]-> print_id );
1619
- }
1620
- printf (" default: return -1; }\n" );
1621
- printf ("}\n" );
1622
- printf ("int autocomplete_type_any (struct paramed_type *T) {\n" );
1623
- printf (" switch (T->type->name) {\n" );
1624
- for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" ) && tps [i ]-> name ) {
1625
- printf (" case 0x%08x: return autocomplete_type_%s (T);\n" , tps [i ]-> name , tps [i ]-> print_id );
1626
- printf (" case 0x%08x: return autocomplete_type_bare_%s (T);\n" , ~tps [i ]-> name , tps [i ]-> print_id );
1627
- }
1628
- printf (" default: return -1; }\n" );
1629
- printf ("}\n" );
1630
- printf ("struct paramed_type *store_function_any (void) {\n" );
1631
- printf (" if (cur_token_len != 1 || *cur_token != '(') { return 0; }\n" );
1632
- printf (" local_next_token ();\n" );
1633
- printf (" if (cur_token_len == 1 || *cur_token == '.') { \n" );
1634
- printf (" local_next_token ();\n" );
1635
- printf (" if (cur_token_len != 1 || *cur_token != '=') { return 0; }\n" );
1636
- printf (" local_next_token ();\n" );
1637
- printf (" };\n" );
1638
- printf (" if (cur_token_len < 0) { return 0; }\n" );
1639
- for (i = 0 ; i < fn ; i ++ ) {
1640
- printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n" , (int )strlen (fns [i ]-> id ), fns [i ]-> id );
1641
- printf (" out_int (0x%08x);\n" , fns [i ]-> name );
1642
- printf (" local_next_token ();\n" );
1643
- printf (" struct paramed_type *P = store_function_%s ();\n" , fns [i ]-> print_id );
1644
- printf (" if (!P) { return 0; }\n" );
1645
- printf (" if (cur_token_len != 1 || *cur_token != ')') { return 0; }\n" );
1622
+ if (!skip_only ) {
1623
+ printf ("int store_type_any (struct paramed_type *T) {\n" );
1624
+ printf (" switch (T->type->name) {\n" );
1625
+ for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" ) && tps [i ]-> name ) {
1626
+ printf (" case 0x%08x: return store_type_%s (T);\n" , tps [i ]-> name , tps [i ]-> print_id );
1627
+ printf (" case 0x%08x: return store_type_bare_%s (T);\n" , ~tps [i ]-> name , tps [i ]-> print_id );
1628
+ }
1629
+ printf (" default: return -1; }\n" );
1630
+ printf ("}\n" );
1631
+ printf ("int fetch_type_any (struct paramed_type *T) {\n" );
1632
+ printf (" switch (T->type->name) {\n" );
1633
+ for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" ) && tps [i ]-> name ) {
1634
+ printf (" case 0x%08x: return fetch_type_%s (T);\n" , tps [i ]-> name , tps [i ]-> print_id );
1635
+ printf (" case 0x%08x: return fetch_type_bare_%s (T);\n" , ~tps [i ]-> name , tps [i ]-> print_id );
1636
+ }
1637
+ printf (" default: return -1; }\n" );
1638
+ printf ("}\n" );
1639
+ printf ("int autocomplete_type_any (struct paramed_type *T) {\n" );
1640
+ printf (" switch (T->type->name) {\n" );
1641
+ for (i = 0 ; i < tn ; i ++ ) if (tps [i ]-> id [0 ] != '#' && strcmp (tps [i ]-> id , "Type" ) && tps [i ]-> name ) {
1642
+ printf (" case 0x%08x: return autocomplete_type_%s (T);\n" , tps [i ]-> name , tps [i ]-> print_id );
1643
+ printf (" case 0x%08x: return autocomplete_type_bare_%s (T);\n" , ~tps [i ]-> name , tps [i ]-> print_id );
1644
+ }
1645
+ printf (" default: return -1; }\n" );
1646
+ printf ("}\n" );
1647
+ printf ("struct paramed_type *store_function_any (void) {\n" );
1648
+ printf (" if (cur_token_len != 1 || *cur_token != '(') { return 0; }\n" );
1649
+ printf (" local_next_token ();\n" );
1650
+ printf (" if (cur_token_len == 1 || *cur_token == '.') { \n" );
1646
1651
printf (" local_next_token ();\n" );
1647
- printf (" return P;\n" );
1648
- printf (" }\n" );
1649
- }
1650
- printf (" return 0;\n" );
1651
- printf ("}\n" );
1652
- printf ("int do_autocomplete_function (const char *text, int text_len, int index, char **R) {\n" );
1653
- printf (" index ++;\n" );
1654
- int i ;
1655
- for (i = 0 ; i < fn ; i ++ ) {
1656
- printf (" if (index == %d) { if (!strncmp (text, \"%s\", text_len)) { *R = tstrdup (\"%s\"); return index; } else { index ++; }}\n" , i , fns [i ]-> id , fns [i ]-> id );
1657
- }
1658
- printf (" *R = 0;\n" );
1659
- printf (" return 0;\n" );
1660
- printf ("}\n" );
1661
- printf ("struct paramed_type *autocomplete_function_any (void) {\n" );
1662
- printf (" expect_token_ptr_autocomplete (\"(\", 1);\n" );
1663
- printf (" if (cur_token_len == -3) { set_autocomplete_type (do_autocomplete_function); }\n" );
1664
- printf (" if (cur_token_len < 0) { return 0; }\n" );
1665
- for (i = 0 ; i < fn ; i ++ ) {
1666
- printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n" , (int )strlen (fns [i ]-> id ), fns [i ]-> id );
1652
+ printf (" if (cur_token_len != 1 || *cur_token != '=') { return 0; }\n" );
1667
1653
printf (" local_next_token ();\n" );
1668
- printf (" struct paramed_type *P = autocomplete_function_%s ();\n" , fns [i ]-> print_id );
1669
- printf (" if (!P) { return 0; }\n" );
1670
- printf (" expect_token_ptr_autocomplete (\")\", 1);\n" );
1671
- printf (" return P;\n" );
1672
- printf (" }\n" );
1654
+ printf (" };\n" );
1655
+ printf (" if (cur_token_len < 0) { return 0; }\n" );
1656
+ for (i = 0 ; i < fn ; i ++ ) {
1657
+ printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n" , (int )strlen (fns [i ]-> id ), fns [i ]-> id );
1658
+ printf (" out_int (0x%08x);\n" , fns [i ]-> name );
1659
+ printf (" local_next_token ();\n" );
1660
+ printf (" struct paramed_type *P = store_function_%s ();\n" , fns [i ]-> print_id );
1661
+ printf (" if (!P) { return 0; }\n" );
1662
+ printf (" if (cur_token_len != 1 || *cur_token != ')') { return 0; }\n" );
1663
+ printf (" local_next_token ();\n" );
1664
+ printf (" return P;\n" );
1665
+ printf (" }\n" );
1666
+ }
1667
+ printf (" return 0;\n" );
1668
+ printf ("}\n" );
1669
+ printf ("int do_autocomplete_function (const char *text, int text_len, int index, char **R) {\n" );
1670
+ printf (" index ++;\n" );
1671
+ int i ;
1672
+ for (i = 0 ; i < fn ; i ++ ) {
1673
+ printf (" if (index == %d) { if (!strncmp (text, \"%s\", text_len)) { *R = tstrdup (\"%s\"); return index; } else { index ++; }}\n" , i , fns [i ]-> id , fns [i ]-> id );
1674
+ }
1675
+ printf (" *R = 0;\n" );
1676
+ printf (" return 0;\n" );
1677
+ printf ("}\n" );
1678
+ printf ("struct paramed_type *autocomplete_function_any (void) {\n" );
1679
+ printf (" expect_token_ptr_autocomplete (\"(\", 1);\n" );
1680
+ printf (" if (cur_token_len == -3) { set_autocomplete_type (do_autocomplete_function); }\n" );
1681
+ printf (" if (cur_token_len < 0) { return 0; }\n" );
1682
+ for (i = 0 ; i < fn ; i ++ ) {
1683
+ printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n" , (int )strlen (fns [i ]-> id ), fns [i ]-> id );
1684
+ printf (" local_next_token ();\n" );
1685
+ printf (" struct paramed_type *P = autocomplete_function_%s ();\n" , fns [i ]-> print_id );
1686
+ printf (" if (!P) { return 0; }\n" );
1687
+ printf (" expect_token_ptr_autocomplete (\")\", 1);\n" );
1688
+ printf (" return P;\n" );
1689
+ printf (" }\n" );
1690
+ }
1691
+ printf (" return 0;\n" );
1692
+ printf ("}\n" );
1673
1693
}
1674
- printf (" return 0;\n" );
1675
- printf ("}\n" );
1676
1694
} else {
1677
1695
for (i = 0 ; i < tn ; i ++ ) {
1678
1696
for (j = 0 ; j < tps [i ]-> constructors_num ; j ++ ) {
@@ -1725,7 +1743,6 @@ int parse_tlo_file (void) {
1725
1743
}
1726
1744
}
1727
1745
1728
-
1729
1746
1730
1747
return 0 ;
1731
1748
}
0 commit comments