From 38dc40652773da9ea3f34752f0f7dcf9c218f963 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 16 Feb 2022 22:55:02 -0600 Subject: [PATCH] Replace all direct pointers in rules with typedef. Moving towards true C++ type safety by retyping all raw pointers. The typedefs will eventually be replaced with managed pointers. --- src/engine/command.h | 10 +- src/engine/compile.cpp | 7 +- src/engine/function.h | 4 + src/engine/hash.h | 19 +++ src/engine/jamgram.cpp | 341 ++++++++++++++++++++--------------------- src/engine/jamgram.hpp | 4 +- src/engine/lists.h | 8 +- src/engine/make.cpp | 25 +-- src/engine/make1.cpp | 31 ++-- src/engine/modules.h | 4 + src/engine/object.h | 3 + src/engine/rules.cpp | 161 ++++++++++--------- src/engine/rules.h | 310 +++++++++++++++++++------------------ 13 files changed, 477 insertions(+), 450 deletions(-) diff --git a/src/engine/command.h b/src/engine/command.h index 0b968de58..23ab775a1 100644 --- a/src/engine/command.h +++ b/src/engine/command.h @@ -4,6 +4,12 @@ * This file is part of Jam - see jam.c for Copyright information. */ +/* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) + */ + /* * command.h - the CMD structure and routines to manipulate them * @@ -79,8 +85,8 @@ struct _cmd string buf[ 1 ]; /* actual commands */ int noop; /* no-op commands should be faked instead of executed */ int asynccnt; /* number of outstanding dependencies */ - TARGETS * lock; /* semaphores that are required by this cmd. */ - TARGETS * unlock; /* semaphores that are released when this cmd finishes. */ + targets_ptr lock; /* semaphores that are required by this cmd. */ + targets_ptr unlock; /* semaphores that are released when this cmd finishes. */ char status; /* the command status */ }; diff --git a/src/engine/compile.cpp b/src/engine/compile.cpp index 4730a5513..e1c4564fd 100644 --- a/src/engine/compile.cpp +++ b/src/engine/compile.cpp @@ -5,6 +5,7 @@ */ /* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -106,15 +107,15 @@ LIST * evaluate_rule( RULE * rule, OBJECT * rulename, FRAME * frame ) */ if ( rule->actions ) { - TARGETS * t; + targets_ptr t; /* The action is associated with this instance of this rule. */ ACTION * const action = (ACTION *)BJAM_MALLOC( sizeof( ACTION ) ); memset( (char *)action, '\0', sizeof( *action ) ); action->rule = rule; - action->targets = targetlist( (TARGETS *)0, lol_get( frame->args, 0 ) ); - action->sources = targetlist( (TARGETS *)0, lol_get( frame->args, 1 ) ); + action->targets = targetlist( (targets_ptr)0, lol_get( frame->args, 0 ) ); + action->sources = targetlist( (targets_ptr)0, lol_get( frame->args, 1 ) ); action->refs = 1; /* If we have a group of targets all being built using the same action diff --git a/src/engine/function.h b/src/engine/function.h index 3c9c129a5..afa0277bb 100644 --- a/src/engine/function.h +++ b/src/engine/function.h @@ -1,4 +1,5 @@ /* + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2011 Steven Watanabe * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -17,6 +18,9 @@ typedef struct _function FUNCTION; typedef struct _stack STACK; +typedef FUNCTION* function_ptr; +typedef STACK* stack_ptr; + STACK * stack_global( void ); void stack_push( STACK * s, LIST * l ); LIST * stack_pop( STACK * s ); diff --git a/src/engine/hash.h b/src/engine/hash.h index 5f69f97cb..4088894e3 100644 --- a/src/engine/hash.h +++ b/src/engine/hash.h @@ -4,6 +4,12 @@ * This file is part of Jam - see jam.c for Copyright information. */ +/* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) + */ + /* * hash.h - simple in-memory hashing routines */ @@ -36,12 +42,25 @@ struct hash * hashinit( int32_t datalen, char const * name ); void hash_free( struct hash * ); void hashdone( struct hash * ); +typedef void (* hashenumerate_f)( void *, void * ); + /* * hashenumerate() - call f(i, data) on each item, i in the hash table. The * enumeration order is unspecified. */ void hashenumerate( struct hash *, void (* f)( void *, void * ), void * data ); +template +void hash_enumerate( struct hash * h, void (* f)(T *, D *), D * data) +{ + hashenumerate(h, reinterpret_cast(f), data); +} +template +void hash_enumerate( struct hash * h, void (* f)(T *, D *)) +{ + hashenumerate(h, reinterpret_cast(f), nullptr); +} + /* * hash_insert() - insert a new item in a hash table, or return an existing one. * diff --git a/src/engine/jamgram.cpp b/src/engine/jamgram.cpp index edba219f2..0cda88047 100644 --- a/src/engine/jamgram.cpp +++ b/src/engine/jamgram.cpp @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.7.6. */ +/* A Bison parser, made by GNU Bison 3.8.2. */ /* Bison implementation for Yacc-like parsers in C @@ -46,10 +46,10 @@ USER NAME SPACE" below. */ /* Identify Bison output, and Bison version. */ -#define YYBISON 30706 +#define YYBISON 30802 /* Bison version string. */ -#define YYBISON_VERSION "3.7.6" +#define YYBISON_VERSION "3.8.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -416,12 +416,18 @@ typedef int yy_state_fast_t; # define YY_USE(E) /* empty */ #endif -#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ +#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") +# else +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# endif # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else @@ -640,7 +646,7 @@ static const yytype_int8 yytranslate[] = }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { 0, 145, 145, 147, 158, 160, 164, 166, 168, 168, @@ -698,20 +704,6 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const yytype_int16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305 -}; -#endif - #define YYPACT_NINF (-119) #define yypact_value_is_default(Yyn) \ @@ -722,8 +714,8 @@ static const yytype_int16 yytoknum[] = #define yytable_value_is_error(Yyn) \ 0 - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int16 yypact[] = { 140, -119, -119, 1, -119, 2, -18, -119, -119, -23, @@ -749,9 +741,9 @@ static const yytype_int16 yypact[] = -119, 115, -119, -119, -119, 140, -119 }; - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ +/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ static const yytype_int8 yydefact[] = { 2, 103, 111, 0, 47, 0, 18, 41, 22, 8, @@ -777,7 +769,7 @@ static const yytype_int8 yydefact[] = 60, 0, 19, 95, 37, 11, 96 }; - /* YYPGOTO[NTERM-NUM]. */ +/* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -119, -119, -118, 25, -119, -119, 96, -119, -119, -119, @@ -789,7 +781,7 @@ static const yytype_int16 yypgoto[] = -119, -119, -119, -119, -119, -119, -119, -119 }; - /* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_uint8 yydefgoto[] = { 0, 17, 38, 39, 31, 168, 40, 109, 140, 175, @@ -801,9 +793,9 @@ static const yytype_uint8 yydefgoto[] = 53, 84, 149, 148, 23, 61, 87, 121 }; - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ +/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { 21, 73, 70, 71, 72, 152, 66, 74, 75, 1, @@ -862,8 +854,8 @@ static const yytype_int16 yycheck[] = 14, 15, 16 }; - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ +/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of + state STATE-NUM. */ static const yytype_int8 yystos[] = { 0, 18, 20, 22, 24, 25, 29, 30, 33, 34, @@ -889,7 +881,7 @@ static const yytype_int8 yystos[] = 48, 53, 63, 10, 48, 105, 53 }; - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ static const yytype_int8 yyr1[] = { 0, 51, 52, 52, 53, 53, 54, 54, 55, 56, @@ -907,7 +899,7 @@ static const yytype_int8 yyr1[] = 118, 117 }; - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ static const yytype_int8 yyr2[] = { 0, 2, 0, 1, 1, 1, 1, 2, 0, 0, @@ -934,6 +926,7 @@ enum { YYENOMEM = -2 }; #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab +#define YYNOMEM goto yyexhaustedlab #define YYRECOVERING() (!!yyerrstatus) @@ -974,10 +967,7 @@ do { \ YYFPRINTF Args; \ } while (0) -/* This macro is provided for backward compatibility. */ -# ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif + # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ @@ -1004,10 +994,6 @@ yy_symbol_value_print (FILE *yyo, YY_USE (yyoutput); if (!yyvaluep) return; -# ifdef YYPRINT - if (yykind < YYNTOKENS) - YYPRINT (yyo, yytoknum[yykind], *yyvaluep); -# endif YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YY_USE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END @@ -1192,6 +1178,7 @@ yyparse (void) YYDPRINTF ((stderr, "Starting parse\n")); yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; @@ -1217,7 +1204,7 @@ yysetstate: if (yyss + yystacksize - 1 <= yyssp) #if !defined yyoverflow && !defined YYSTACK_RELOCATE - goto yyexhaustedlab; + YYNOMEM; #else { /* Get the current used size of the three stacks, in elements. */ @@ -1245,7 +1232,7 @@ yysetstate: # else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + YYNOMEM; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; @@ -1256,7 +1243,7 @@ yysetstate: YY_CAST (union yyalloc *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) - goto yyexhaustedlab; + YYNOMEM; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE @@ -1278,6 +1265,7 @@ yysetstate: } #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + if (yystate == YYFINAL) YYACCEPT; @@ -1392,719 +1380,719 @@ yyreduce: case 3: /* run: rules */ #line 148 "src/engine/jamgram.y" { parse_save( yyvsp[0].parse ); } -#line 1396 "src/engine/jamgram.cpp" +#line 1384 "src/engine/jamgram.cpp" break; case 4: /* block: null */ #line 159 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; } -#line 1402 "src/engine/jamgram.cpp" +#line 1390 "src/engine/jamgram.cpp" break; case 5: /* block: rules */ #line 161 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; } -#line 1408 "src/engine/jamgram.cpp" +#line 1396 "src/engine/jamgram.cpp" break; case 6: /* rules: rule */ #line 165 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; } -#line 1414 "src/engine/jamgram.cpp" +#line 1402 "src/engine/jamgram.cpp" break; case 7: /* rules: rule rules */ #line 167 "src/engine/jamgram.y" { yyval.parse = prules( yyvsp[-1].parse, yyvsp[0].parse ); } -#line 1420 "src/engine/jamgram.cpp" +#line 1408 "src/engine/jamgram.cpp" break; case 8: /* $@1: %empty */ #line 168 "src/engine/jamgram.y" { yymode( SCAN_ASSIGN ); } -#line 1426 "src/engine/jamgram.cpp" +#line 1414 "src/engine/jamgram.cpp" break; case 9: /* $@2: %empty */ #line 168 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1432 "src/engine/jamgram.cpp" +#line 1420 "src/engine/jamgram.cpp" break; case 10: /* rules: LOCAL_t $@1 list assign_list_opt _SEMIC_t $@2 block */ #line 169 "src/engine/jamgram.y" { yyval.parse = plocal( yyvsp[-4].parse, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1438 "src/engine/jamgram.cpp" +#line 1426 "src/engine/jamgram.cpp" break; case 11: /* null: %empty */ #line 173 "src/engine/jamgram.y" { yyval.parse = pnull(); } -#line 1444 "src/engine/jamgram.cpp" +#line 1432 "src/engine/jamgram.cpp" break; case 12: /* $@3: %empty */ #line 176 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1450 "src/engine/jamgram.cpp" +#line 1438 "src/engine/jamgram.cpp" break; case 13: /* assign_list_opt: _EQUALS_t $@3 list */ #line 177 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; yyval.number = ASSIGN_SET; } -#line 1456 "src/engine/jamgram.cpp" +#line 1444 "src/engine/jamgram.cpp" break; case 14: /* assign_list_opt: null */ #line 179 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; yyval.number = ASSIGN_APPEND; } -#line 1462 "src/engine/jamgram.cpp" +#line 1450 "src/engine/jamgram.cpp" break; case 15: /* arglist_opt: _LPAREN_t lol _RPAREN_t */ #line 183 "src/engine/jamgram.y" { yyval.parse = yyvsp[-1].parse; } -#line 1468 "src/engine/jamgram.cpp" +#line 1456 "src/engine/jamgram.cpp" break; case 16: /* arglist_opt: %empty */ #line 185 "src/engine/jamgram.y" { yyval.parse = P0; } -#line 1474 "src/engine/jamgram.cpp" +#line 1462 "src/engine/jamgram.cpp" break; case 17: /* local_opt: LOCAL_t */ #line 189 "src/engine/jamgram.y" { yyval.number = 1; } -#line 1480 "src/engine/jamgram.cpp" +#line 1468 "src/engine/jamgram.cpp" break; case 18: /* local_opt: %empty */ #line 191 "src/engine/jamgram.y" { yyval.number = 0; } -#line 1486 "src/engine/jamgram.cpp" +#line 1474 "src/engine/jamgram.cpp" break; case 19: /* else_opt: ELSE_t rule */ #line 195 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; } -#line 1492 "src/engine/jamgram.cpp" +#line 1480 "src/engine/jamgram.cpp" break; case 20: /* else_opt: %empty */ #line 197 "src/engine/jamgram.y" { yyval.parse = pnull(); } -#line 1498 "src/engine/jamgram.cpp" +#line 1486 "src/engine/jamgram.cpp" break; case 21: /* rule: _LBRACE_t block _RBRACE_t */ #line 200 "src/engine/jamgram.y" { yyval.parse = yyvsp[-1].parse; } -#line 1504 "src/engine/jamgram.cpp" +#line 1492 "src/engine/jamgram.cpp" break; case 22: /* $@4: %empty */ #line 201 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1510 "src/engine/jamgram.cpp" +#line 1498 "src/engine/jamgram.cpp" break; case 23: /* rule: INCLUDE_t $@4 list _SEMIC_t */ #line 202 "src/engine/jamgram.y" { yyval.parse = pincl( yyvsp[-1].parse ); yymode( SCAN_NORMAL ); } -#line 1516 "src/engine/jamgram.cpp" +#line 1504 "src/engine/jamgram.cpp" break; case 24: /* $@5: %empty */ #line 203 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1522 "src/engine/jamgram.cpp" +#line 1510 "src/engine/jamgram.cpp" break; case 25: /* rule: ARG $@5 lol _SEMIC_t */ #line 204 "src/engine/jamgram.y" { yyval.parse = prule( yyvsp[-3].string, yyvsp[-1].parse ); yymode( SCAN_NORMAL ); } -#line 1528 "src/engine/jamgram.cpp" +#line 1516 "src/engine/jamgram.cpp" break; case 26: /* $@6: %empty */ #line 205 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1534 "src/engine/jamgram.cpp" +#line 1522 "src/engine/jamgram.cpp" break; case 27: /* rule: arg assign $@6 list _SEMIC_t */ #line 206 "src/engine/jamgram.y" { yyval.parse = pset( yyvsp[-4].parse, yyvsp[-1].parse, yyvsp[-3].number ); yymode( SCAN_NORMAL ); } -#line 1540 "src/engine/jamgram.cpp" +#line 1528 "src/engine/jamgram.cpp" break; case 28: /* $@7: %empty */ #line 207 "src/engine/jamgram.y" { yymode( SCAN_ASSIGN ); } -#line 1546 "src/engine/jamgram.cpp" +#line 1534 "src/engine/jamgram.cpp" break; case 29: /* $@8: %empty */ #line 207 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1552 "src/engine/jamgram.cpp" +#line 1540 "src/engine/jamgram.cpp" break; case 30: /* rule: arg ON_t $@7 list assign $@8 list _SEMIC_t */ #line 208 "src/engine/jamgram.y" { yyval.parse = pset1( yyvsp[-7].parse, yyvsp[-4].parse, yyvsp[-1].parse, yyvsp[-3].number ); yymode( SCAN_NORMAL ); } -#line 1558 "src/engine/jamgram.cpp" +#line 1546 "src/engine/jamgram.cpp" break; case 31: /* $@9: %empty */ #line 209 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1564 "src/engine/jamgram.cpp" +#line 1552 "src/engine/jamgram.cpp" break; case 32: /* rule: RETURN_t $@9 list _SEMIC_t */ #line 210 "src/engine/jamgram.y" { yyval.parse = preturn( yyvsp[-1].parse ); yymode( SCAN_NORMAL ); } -#line 1570 "src/engine/jamgram.cpp" +#line 1558 "src/engine/jamgram.cpp" break; case 33: /* rule: BREAK_t _SEMIC_t */ #line 212 "src/engine/jamgram.y" { yyval.parse = pbreak(); } -#line 1576 "src/engine/jamgram.cpp" +#line 1564 "src/engine/jamgram.cpp" break; case 34: /* rule: CONTINUE_t _SEMIC_t */ #line 214 "src/engine/jamgram.y" { yyval.parse = pcontinue(); } -#line 1582 "src/engine/jamgram.cpp" +#line 1570 "src/engine/jamgram.cpp" break; case 35: /* $@10: %empty */ #line 215 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1588 "src/engine/jamgram.cpp" +#line 1576 "src/engine/jamgram.cpp" break; case 36: /* $@11: %empty */ #line 215 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1594 "src/engine/jamgram.cpp" +#line 1582 "src/engine/jamgram.cpp" break; case 37: /* rule: FOR_t local_opt ARG IN_t $@10 list _LBRACE_t $@11 block _RBRACE_t */ #line 216 "src/engine/jamgram.y" { yyval.parse = pfor( yyvsp[-7].string, yyvsp[-4].parse, yyvsp[-1].parse, yyvsp[-8].number ); } -#line 1600 "src/engine/jamgram.cpp" +#line 1588 "src/engine/jamgram.cpp" break; case 38: /* $@12: %empty */ #line 217 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1606 "src/engine/jamgram.cpp" +#line 1594 "src/engine/jamgram.cpp" break; case 39: /* $@13: %empty */ #line 217 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1612 "src/engine/jamgram.cpp" +#line 1600 "src/engine/jamgram.cpp" break; case 40: /* rule: SWITCH_t $@12 list _LBRACE_t $@13 cases _RBRACE_t */ #line 218 "src/engine/jamgram.y" { yyval.parse = pswitch( yyvsp[-4].parse, yyvsp[-1].parse ); } -#line 1618 "src/engine/jamgram.cpp" +#line 1606 "src/engine/jamgram.cpp" break; case 41: /* $@14: %empty */ #line 219 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1624 "src/engine/jamgram.cpp" +#line 1612 "src/engine/jamgram.cpp" break; case 42: /* $@15: %empty */ #line 219 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1630 "src/engine/jamgram.cpp" +#line 1618 "src/engine/jamgram.cpp" break; case 43: /* rule: IF_t $@14 expr _LBRACE_t $@15 block _RBRACE_t else_opt */ #line 220 "src/engine/jamgram.y" { yyval.parse = pif( yyvsp[-5].parse, yyvsp[-2].parse, yyvsp[0].parse ); } -#line 1636 "src/engine/jamgram.cpp" +#line 1624 "src/engine/jamgram.cpp" break; case 44: /* $@16: %empty */ #line 221 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1642 "src/engine/jamgram.cpp" +#line 1630 "src/engine/jamgram.cpp" break; case 45: /* $@17: %empty */ #line 221 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1648 "src/engine/jamgram.cpp" +#line 1636 "src/engine/jamgram.cpp" break; case 46: /* rule: MODULE_t $@16 list _LBRACE_t $@17 block _RBRACE_t */ #line 222 "src/engine/jamgram.y" { yyval.parse = pmodule( yyvsp[-4].parse, yyvsp[-1].parse ); } -#line 1654 "src/engine/jamgram.cpp" +#line 1642 "src/engine/jamgram.cpp" break; case 47: /* $@18: %empty */ #line 223 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1660 "src/engine/jamgram.cpp" +#line 1648 "src/engine/jamgram.cpp" break; case 48: /* $@19: %empty */ #line 223 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1666 "src/engine/jamgram.cpp" +#line 1654 "src/engine/jamgram.cpp" break; case 49: /* rule: CLASS_t $@18 lol _LBRACE_t $@19 block _RBRACE_t */ #line 224 "src/engine/jamgram.y" { yyval.parse = pclass( yyvsp[-4].parse, yyvsp[-1].parse ); } -#line 1672 "src/engine/jamgram.cpp" +#line 1660 "src/engine/jamgram.cpp" break; case 50: /* $@20: %empty */ #line 225 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1678 "src/engine/jamgram.cpp" +#line 1666 "src/engine/jamgram.cpp" break; case 51: /* $@21: %empty */ #line 225 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1684 "src/engine/jamgram.cpp" +#line 1672 "src/engine/jamgram.cpp" break; case 52: /* rule: WHILE_t $@20 expr $@21 _LBRACE_t block _RBRACE_t */ #line 226 "src/engine/jamgram.y" { yyval.parse = pwhile( yyvsp[-4].parse, yyvsp[-1].parse ); } -#line 1690 "src/engine/jamgram.cpp" +#line 1678 "src/engine/jamgram.cpp" break; case 53: /* $@22: %empty */ #line 227 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1696 "src/engine/jamgram.cpp" +#line 1684 "src/engine/jamgram.cpp" break; case 54: /* $@23: %empty */ #line 227 "src/engine/jamgram.y" { yymode( SCAN_PARAMS ); } -#line 1702 "src/engine/jamgram.cpp" +#line 1690 "src/engine/jamgram.cpp" break; case 55: /* $@24: %empty */ #line 227 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1708 "src/engine/jamgram.cpp" +#line 1696 "src/engine/jamgram.cpp" break; case 56: /* rule: local_opt RULE_t $@22 ARG $@23 arglist_opt $@24 rule */ #line 228 "src/engine/jamgram.y" { yyval.parse = psetc( yyvsp[-4].string, yyvsp[0].parse, yyvsp[-2].parse, yyvsp[-7].number ); } -#line 1714 "src/engine/jamgram.cpp" +#line 1702 "src/engine/jamgram.cpp" break; case 57: /* rule: ON_t arg rule */ #line 230 "src/engine/jamgram.y" { yyval.parse = pon( yyvsp[-1].parse, yyvsp[0].parse ); } -#line 1720 "src/engine/jamgram.cpp" +#line 1708 "src/engine/jamgram.cpp" break; case 58: /* $@25: %empty */ #line 232 "src/engine/jamgram.y" { yymode( SCAN_STRING ); } -#line 1726 "src/engine/jamgram.cpp" +#line 1714 "src/engine/jamgram.cpp" break; case 59: /* $@26: %empty */ #line 234 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1732 "src/engine/jamgram.cpp" +#line 1720 "src/engine/jamgram.cpp" break; case 60: /* rule: ACTIONS_t eflags ARG bindlist _LBRACE_t $@25 STRING $@26 _RBRACE_t */ #line 236 "src/engine/jamgram.y" { yyval.parse = psete( yyvsp[-6].string,yyvsp[-5].parse,yyvsp[-2].string,yyvsp[-7].number ); } -#line 1738 "src/engine/jamgram.cpp" +#line 1726 "src/engine/jamgram.cpp" break; case 61: /* assign: _EQUALS_t */ #line 244 "src/engine/jamgram.y" { yyval.number = ASSIGN_SET; } -#line 1744 "src/engine/jamgram.cpp" +#line 1732 "src/engine/jamgram.cpp" break; case 62: /* assign: _PLUS_EQUALS_t */ #line 246 "src/engine/jamgram.y" { yyval.number = ASSIGN_APPEND; } -#line 1750 "src/engine/jamgram.cpp" +#line 1738 "src/engine/jamgram.cpp" break; case 63: /* assign: _QUESTION_EQUALS_t */ #line 248 "src/engine/jamgram.y" { yyval.number = ASSIGN_DEFAULT; } -#line 1756 "src/engine/jamgram.cpp" +#line 1744 "src/engine/jamgram.cpp" break; case 64: /* assign: DEFAULT_t _EQUALS_t */ #line 250 "src/engine/jamgram.y" { yyval.number = ASSIGN_DEFAULT; } -#line 1762 "src/engine/jamgram.cpp" +#line 1750 "src/engine/jamgram.cpp" break; case 65: /* expr: arg */ #line 257 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_EXISTS, yyvsp[0].parse, pnull() ); yymode( SCAN_COND ); } -#line 1768 "src/engine/jamgram.cpp" +#line 1756 "src/engine/jamgram.cpp" break; case 66: /* $@27: %empty */ #line 258 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1774 "src/engine/jamgram.cpp" +#line 1762 "src/engine/jamgram.cpp" break; case 67: /* expr: expr _EQUALS_t $@27 expr */ #line 259 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_EQUALS, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1780 "src/engine/jamgram.cpp" +#line 1768 "src/engine/jamgram.cpp" break; case 68: /* $@28: %empty */ #line 260 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1786 "src/engine/jamgram.cpp" +#line 1774 "src/engine/jamgram.cpp" break; case 69: /* expr: expr _BANG_EQUALS_t $@28 expr */ #line 261 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_NOTEQ, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1792 "src/engine/jamgram.cpp" +#line 1780 "src/engine/jamgram.cpp" break; case 70: /* $@29: %empty */ #line 262 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1798 "src/engine/jamgram.cpp" +#line 1786 "src/engine/jamgram.cpp" break; case 71: /* expr: expr _LANGLE_t $@29 expr */ #line 263 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_LESS, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1804 "src/engine/jamgram.cpp" +#line 1792 "src/engine/jamgram.cpp" break; case 72: /* $@30: %empty */ #line 264 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1810 "src/engine/jamgram.cpp" +#line 1798 "src/engine/jamgram.cpp" break; case 73: /* expr: expr _LANGLE_EQUALS_t $@30 expr */ #line 265 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_LESSEQ, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1816 "src/engine/jamgram.cpp" +#line 1804 "src/engine/jamgram.cpp" break; case 74: /* $@31: %empty */ #line 266 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1822 "src/engine/jamgram.cpp" +#line 1810 "src/engine/jamgram.cpp" break; case 75: /* expr: expr _RANGLE_t $@31 expr */ #line 267 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_MORE, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1828 "src/engine/jamgram.cpp" +#line 1816 "src/engine/jamgram.cpp" break; case 76: /* $@32: %empty */ #line 268 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1834 "src/engine/jamgram.cpp" +#line 1822 "src/engine/jamgram.cpp" break; case 77: /* expr: expr _RANGLE_EQUALS_t $@32 expr */ #line 269 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_MOREEQ, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1840 "src/engine/jamgram.cpp" +#line 1828 "src/engine/jamgram.cpp" break; case 78: /* $@33: %empty */ #line 270 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1846 "src/engine/jamgram.cpp" +#line 1834 "src/engine/jamgram.cpp" break; case 79: /* expr: expr _AMPER_t $@33 expr */ #line 271 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_AND, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1852 "src/engine/jamgram.cpp" +#line 1840 "src/engine/jamgram.cpp" break; case 80: /* $@34: %empty */ #line 272 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1858 "src/engine/jamgram.cpp" +#line 1846 "src/engine/jamgram.cpp" break; case 81: /* expr: expr _AMPERAMPER_t $@34 expr */ #line 273 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_AND, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1864 "src/engine/jamgram.cpp" +#line 1852 "src/engine/jamgram.cpp" break; case 82: /* $@35: %empty */ #line 274 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1870 "src/engine/jamgram.cpp" +#line 1858 "src/engine/jamgram.cpp" break; case 83: /* expr: expr _BAR_t $@35 expr */ #line 275 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_OR, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1876 "src/engine/jamgram.cpp" +#line 1864 "src/engine/jamgram.cpp" break; case 84: /* $@36: %empty */ #line 276 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1882 "src/engine/jamgram.cpp" +#line 1870 "src/engine/jamgram.cpp" break; case 85: /* expr: expr _BARBAR_t $@36 expr */ #line 277 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_OR, yyvsp[-3].parse, yyvsp[0].parse ); } -#line 1888 "src/engine/jamgram.cpp" +#line 1876 "src/engine/jamgram.cpp" break; case 86: /* $@37: %empty */ #line 278 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 1894 "src/engine/jamgram.cpp" +#line 1882 "src/engine/jamgram.cpp" break; case 87: /* expr: arg IN_t $@37 list */ #line 279 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_IN, yyvsp[-3].parse, yyvsp[0].parse ); yymode( SCAN_COND ); } -#line 1900 "src/engine/jamgram.cpp" +#line 1888 "src/engine/jamgram.cpp" break; case 88: /* $@38: %empty */ #line 280 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1906 "src/engine/jamgram.cpp" +#line 1894 "src/engine/jamgram.cpp" break; case 89: /* expr: _BANG_t $@38 expr */ #line 281 "src/engine/jamgram.y" { yyval.parse = peval( EXPR_NOT, yyvsp[0].parse, pnull() ); } -#line 1912 "src/engine/jamgram.cpp" +#line 1900 "src/engine/jamgram.cpp" break; case 90: /* $@39: %empty */ #line 282 "src/engine/jamgram.y" { yymode( SCAN_CONDB ); } -#line 1918 "src/engine/jamgram.cpp" +#line 1906 "src/engine/jamgram.cpp" break; case 91: /* expr: _LPAREN_t $@39 expr _RPAREN_t */ #line 283 "src/engine/jamgram.y" { yyval.parse = yyvsp[-1].parse; } -#line 1924 "src/engine/jamgram.cpp" +#line 1912 "src/engine/jamgram.cpp" break; case 92: /* cases: %empty */ #line 294 "src/engine/jamgram.y" { yyval.parse = P0; } -#line 1930 "src/engine/jamgram.cpp" +#line 1918 "src/engine/jamgram.cpp" break; case 93: /* cases: case cases */ #line 296 "src/engine/jamgram.y" { yyval.parse = pnode( yyvsp[-1].parse, yyvsp[0].parse ); } -#line 1936 "src/engine/jamgram.cpp" +#line 1924 "src/engine/jamgram.cpp" break; case 94: /* $@40: %empty */ #line 299 "src/engine/jamgram.y" { yymode( SCAN_CASE ); } -#line 1942 "src/engine/jamgram.cpp" +#line 1930 "src/engine/jamgram.cpp" break; case 95: /* $@41: %empty */ #line 299 "src/engine/jamgram.y" { yymode( SCAN_NORMAL ); } -#line 1948 "src/engine/jamgram.cpp" +#line 1936 "src/engine/jamgram.cpp" break; case 96: /* case: CASE_t $@40 ARG _COLON_t $@41 block */ #line 300 "src/engine/jamgram.y" { yyval.parse = psnode( yyvsp[-3].string, yyvsp[0].parse ); } -#line 1954 "src/engine/jamgram.cpp" +#line 1942 "src/engine/jamgram.cpp" break; case 97: /* lol: list */ #line 309 "src/engine/jamgram.y" { yyval.parse = pnode( P0, yyvsp[0].parse ); } -#line 1960 "src/engine/jamgram.cpp" +#line 1948 "src/engine/jamgram.cpp" break; case 98: /* lol: list _COLON_t lol */ #line 311 "src/engine/jamgram.y" { yyval.parse = pnode( yyvsp[0].parse, yyvsp[-2].parse ); } -#line 1966 "src/engine/jamgram.cpp" +#line 1954 "src/engine/jamgram.cpp" break; case 99: /* list: listp */ #line 321 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; } -#line 1972 "src/engine/jamgram.cpp" +#line 1960 "src/engine/jamgram.cpp" break; case 100: /* listp: %empty */ #line 325 "src/engine/jamgram.y" { yyval.parse = pnull(); } -#line 1978 "src/engine/jamgram.cpp" +#line 1966 "src/engine/jamgram.cpp" break; case 101: /* listp: listp arg */ #line 327 "src/engine/jamgram.y" { yyval.parse = pappend( yyvsp[-1].parse, yyvsp[0].parse ); } -#line 1984 "src/engine/jamgram.cpp" +#line 1972 "src/engine/jamgram.cpp" break; case 102: /* arg: ARG */ #line 331 "src/engine/jamgram.y" { yyval.parse = plist( yyvsp[0].string ); } -#line 1990 "src/engine/jamgram.cpp" +#line 1978 "src/engine/jamgram.cpp" break; case 103: /* @42: %empty */ #line 332 "src/engine/jamgram.y" { yyval.number = yymode( SCAN_CALL ); } -#line 1996 "src/engine/jamgram.cpp" +#line 1984 "src/engine/jamgram.cpp" break; case 104: /* arg: _LBRACKET_t @42 func _RBRACKET_t */ #line 333 "src/engine/jamgram.y" { yyval.parse = yyvsp[-1].parse; yymode( yyvsp[-2].number ); } -#line 2002 "src/engine/jamgram.cpp" +#line 1990 "src/engine/jamgram.cpp" break; case 105: /* $@43: %empty */ #line 341 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 2008 "src/engine/jamgram.cpp" +#line 1996 "src/engine/jamgram.cpp" break; case 106: /* func: ARG $@43 lol */ #line 342 "src/engine/jamgram.y" { yyval.parse = prule( yyvsp[-2].string, yyvsp[0].parse ); } -#line 2014 "src/engine/jamgram.cpp" +#line 2002 "src/engine/jamgram.cpp" break; case 107: /* $@44: %empty */ #line 343 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 2020 "src/engine/jamgram.cpp" +#line 2008 "src/engine/jamgram.cpp" break; case 108: /* func: ON_t arg ARG $@44 lol */ #line 344 "src/engine/jamgram.y" { yyval.parse = pon( yyvsp[-3].parse, prule( yyvsp[-2].string, yyvsp[0].parse ) ); } -#line 2026 "src/engine/jamgram.cpp" +#line 2014 "src/engine/jamgram.cpp" break; case 109: /* $@45: %empty */ #line 345 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 2032 "src/engine/jamgram.cpp" +#line 2020 "src/engine/jamgram.cpp" break; case 110: /* func: ON_t arg RETURN_t $@45 list */ #line 346 "src/engine/jamgram.y" { yyval.parse = pon( yyvsp[-3].parse, yyvsp[0].parse ); } -#line 2038 "src/engine/jamgram.cpp" +#line 2026 "src/engine/jamgram.cpp" break; case 111: /* eflags: %empty */ #line 356 "src/engine/jamgram.y" { yyval.number = 0; } -#line 2044 "src/engine/jamgram.cpp" +#line 2032 "src/engine/jamgram.cpp" break; case 112: /* eflags: eflags eflag */ #line 358 "src/engine/jamgram.y" { yyval.number = yyvsp[-1].number | yyvsp[0].number; } -#line 2050 "src/engine/jamgram.cpp" +#line 2038 "src/engine/jamgram.cpp" break; case 113: /* eflag: UPDATED_t */ #line 362 "src/engine/jamgram.y" { yyval.number = EXEC_UPDATED; } -#line 2056 "src/engine/jamgram.cpp" +#line 2044 "src/engine/jamgram.cpp" break; case 114: /* eflag: TOGETHER_t */ #line 364 "src/engine/jamgram.y" { yyval.number = EXEC_TOGETHER; } -#line 2062 "src/engine/jamgram.cpp" +#line 2050 "src/engine/jamgram.cpp" break; case 115: /* eflag: IGNORE_t */ #line 366 "src/engine/jamgram.y" { yyval.number = EXEC_IGNORE; } -#line 2068 "src/engine/jamgram.cpp" +#line 2056 "src/engine/jamgram.cpp" break; case 116: /* eflag: QUIETLY_t */ #line 368 "src/engine/jamgram.y" { yyval.number = EXEC_QUIETLY; } -#line 2074 "src/engine/jamgram.cpp" +#line 2062 "src/engine/jamgram.cpp" break; case 117: /* eflag: PIECEMEAL_t */ #line 370 "src/engine/jamgram.y" { yyval.number = EXEC_PIECEMEAL; } -#line 2080 "src/engine/jamgram.cpp" +#line 2068 "src/engine/jamgram.cpp" break; case 118: /* eflag: EXISTING_t */ #line 372 "src/engine/jamgram.y" { yyval.number = EXEC_EXISTING; } -#line 2086 "src/engine/jamgram.cpp" +#line 2074 "src/engine/jamgram.cpp" break; case 119: /* bindlist: %empty */ #line 381 "src/engine/jamgram.y" { yyval.parse = pnull(); } -#line 2092 "src/engine/jamgram.cpp" +#line 2080 "src/engine/jamgram.cpp" break; case 120: /* $@46: %empty */ #line 382 "src/engine/jamgram.y" { yymode( SCAN_PUNCT ); } -#line 2098 "src/engine/jamgram.cpp" +#line 2086 "src/engine/jamgram.cpp" break; case 121: /* bindlist: BIND_t $@46 list */ #line 383 "src/engine/jamgram.y" { yyval.parse = yyvsp[0].parse; } -#line 2104 "src/engine/jamgram.cpp" +#line 2092 "src/engine/jamgram.cpp" break; -#line 2108 "src/engine/jamgram.cpp" +#line 2096 "src/engine/jamgram.cpp" default: break; } @@ -2186,6 +2174,7 @@ yyerrorlab: label yyerrorlab therefore never appears in user code. */ if (0) YYERROR; + ++yynerrs; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2246,7 +2235,7 @@ yyerrlab1: `-------------------------------------*/ yyacceptlab: yyresult = 0; - goto yyreturn; + goto yyreturnlab; /*-----------------------------------. @@ -2254,24 +2243,22 @@ yyacceptlab: `-----------------------------------*/ yyabortlab: yyresult = 1; - goto yyreturn; + goto yyreturnlab; -#if !defined yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ +/*-----------------------------------------------------------. +| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | +`-----------------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - goto yyreturn; -#endif + goto yyreturnlab; -/*-------------------------------------------------------. -| yyreturn -- parsing is finished, clean up and return. | -`-------------------------------------------------------*/ -yyreturn: +/*----------------------------------------------------------. +| yyreturnlab -- parsing is finished, clean up and return. | +`----------------------------------------------------------*/ +yyreturnlab: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at diff --git a/src/engine/jamgram.hpp b/src/engine/jamgram.hpp index 77a98929e..f836468c6 100644 --- a/src/engine/jamgram.hpp +++ b/src/engine/jamgram.hpp @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.7.6. */ +/* A Bison parser, made by GNU Bison 3.8.2. */ /* Bison interface for Yacc-like parsers in C @@ -169,6 +169,8 @@ typedef int YYSTYPE; extern YYSTYPE yylval; + int yyparse (void); + #endif /* !YY_YY_SRC_ENGINE_JAMGRAM_HPP_INCLUDED */ diff --git a/src/engine/lists.h b/src/engine/lists.h index 24b9298d6..98fad2e68 100644 --- a/src/engine/lists.h +++ b/src/engine/lists.h @@ -5,6 +5,7 @@ */ /* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -52,14 +53,15 @@ * LIST - list of strings */ -typedef struct _list { +struct LIST { union { int32_t size; - struct _list * next; + struct LIST * next; OBJECT * align; } impl; -} LIST; +}; +typedef LIST * list_ptr; typedef OBJECT * * LISTITER; /* diff --git a/src/engine/make.cpp b/src/engine/make.cpp index 610278bfa..e6bbc9756 100644 --- a/src/engine/make.cpp +++ b/src/engine/make.cpp @@ -5,6 +5,7 @@ */ /* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -53,7 +54,7 @@ # define max(a,b) ((a)>(b)?(a):(b)) #endif -static TARGETS * make0sort( TARGETS * c ); +static targets_ptr make0sort( targets_ptr c ); #ifdef OPT_GRAPH_DEBUG_EXT static void dependGraphOutput( TARGET * t, int32_t depth ); @@ -171,7 +172,7 @@ static void force_rebuilds( TARGET * t ); static void update_dependants( TARGET * t ) { - TARGETS * q; + targets_ptr q; for ( q = t->dependants; q; q = q->next ) { @@ -209,7 +210,7 @@ static void update_dependants( TARGET * t ) static void force_rebuilds( TARGET * t ) { - TARGETS * d; + targets_ptr d; for ( d = t->rebuilds; d; d = d->next ) { TARGET * r = d->target; @@ -234,7 +235,7 @@ static void force_rebuilds( TARGET * t ) int32_t make0rescan( TARGET * t, TARGET * rescanning ) { int32_t result = 0; - TARGETS * c; + targets_ptr c; /* Check whether we have already found a cycle. */ if ( target_scc( t ) == rescanning ) @@ -287,7 +288,7 @@ void make0 TARGET * rescanning ) /* forcibly touch all (real) targets */ { - TARGETS * c; + targets_ptr c; TARGET * ptime = t; TARGET * located_target = 0; timestamp last; @@ -441,7 +442,7 @@ void make0 /* Step 3c: Add dependencies' includes to our direct dependencies. */ { - TARGETS * incs = 0; + targets_ptr incs = 0; for ( c = t->depends; c; c = c->next ) if ( c->target->includes ) incs = targetentry( incs, c->target->includes ); @@ -696,7 +697,7 @@ void make0 if ( ( fate >= T_FATE_BUILD ) && ( fate < T_FATE_BROKEN ) ) { ACTIONS * a; - TARGETS * c; + targets_ptr c; for ( a = t->actions; a; a = a->next ) { for ( c = a->action->targets; c; c = c->next ) @@ -785,7 +786,7 @@ static char const * target_name( TARGET * t ) static void dependGraphOutput( TARGET * t, int32_t depth ) { - TARGETS * c; + targets_ptr c; if ( ( t->flags & T_FLAG_VISITED ) || !t->name || !t->boundname ) return; @@ -886,17 +887,17 @@ static void dependGraphOutput( TARGET * t, int32_t depth ) * that while tail is a loop, next ends at the end of the chain. */ -static TARGETS * make0sort( TARGETS * chain ) +static targets_ptr make0sort( targets_ptr chain ) { PROFILE_ENTER( MAKE_MAKE0SORT ); - TARGETS * result = 0; + targets_ptr result = 0; /* Walk the current target list. */ while ( chain ) { - TARGETS * c = chain; - TARGETS * s = result; + targets_ptr c = chain; + targets_ptr s = result; chain = chain->next; diff --git a/src/engine/make1.cpp b/src/engine/make1.cpp index 5d147c492..d51d712c2 100644 --- a/src/engine/make1.cpp +++ b/src/engine/make1.cpp @@ -5,6 +5,7 @@ */ /* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -59,15 +60,15 @@ #endif static CMD * make1cmds ( TARGET * ); -static LIST * make1list ( LIST *, TARGETS *, int32_t flags ); +static LIST * make1list ( LIST *, targets_ptr, int32_t flags ); static SETTINGS * make1settings ( struct module_t *, LIST * vars ); static void make1bind ( TARGET * ); static void push_cmds( CMDLIST * cmds, int32_t status ); static int32_t cmd_sem_lock( TARGET * t ); static void cmd_sem_unlock( TARGET * t ); -static int32_t targets_contains( TARGETS * l, TARGET * t ); -static int32_t targets_equal( TARGETS * l1, TARGETS * l2 ); +static int32_t targets_contains( targets_ptr l, TARGET * t ); +static int32_t targets_equal( targets_ptr l1, targets_ptr l2 ); /* Ugly static - it is too hard to carry it through the callbacks. */ @@ -343,7 +344,7 @@ static void make1a( state * const pState ) /* Push dependency build requests (to be executed in the natural order). */ { stack temp_stack = { NULL }; - TARGETS * c; + targets_ptr c; for ( c = t->depends; c && !quit; c = c->next ) push_state( &temp_stack, c->target, t, T_STATE_MAKE1A ); push_stack_on_stack( &state_stack, &temp_stack ); @@ -396,7 +397,7 @@ static void make1b( state * const pState ) */ if ( !globs.noexec ) { - TARGETS * c; + targets_ptr c; for ( c = t->depends; c; c = c->next ) if ( c->target->status > t->status && !( c->target->flags & T_FLAG_NOCARE ) ) @@ -637,7 +638,7 @@ static void make1c( state const * const pState ) /* Tell parents their dependency has been built. */ { - TARGETS * c; + targets_ptr c; stack temp_stack = { NULL }; TARGET * additional_includes = NULL; @@ -1077,7 +1078,7 @@ static CMD * make1cmds( TARGET * t ) for ( a0 = t->actions; a0; a0 = a0->next ) { RULE * rule = a0->action->rule; - rule_actions * actions = rule->actions; + rule_actions_ptr actions = rule->actions; SETTINGS * boundvars; LIST * nt; LIST * ns; @@ -1172,8 +1173,8 @@ static CMD * make1cmds( TARGET * t ) int32_t start = 0; int32_t chunk = length; int32_t cmd_count = 0; - TARGETS * semaphores = NULL; - TARGETS * targets_iter; + targets_ptr semaphores = NULL; + targets_ptr targets_iter; int32_t unique_targets; do { @@ -1315,7 +1316,7 @@ static CMD * make1cmds( TARGET * t ) * make1list() - turn a list of targets into a LIST, for $(<) and $(>) */ -static LIST * make1list( LIST * l, TARGETS * targets, int32_t flags ) +static LIST * make1list( LIST * l, targets_ptr targets, int32_t flags ) { for ( ; targets; targets = targets->next ) { @@ -1418,7 +1419,7 @@ static void make1bind( TARGET * t ) } -static int32_t targets_contains( TARGETS * l, TARGET * t ) +static int32_t targets_contains( targets_ptr l, TARGET * t ) { for ( ; l; l = l->next ) { @@ -1430,7 +1431,7 @@ static int32_t targets_contains( TARGETS * l, TARGET * t ) return 0; } -static int32_t targets_equal( TARGETS * l1, TARGETS * l2 ) +static int32_t targets_equal( targets_ptr l1, targets_ptr l2 ) { for ( ; l1 && l2; l1 = l1->next, l2 = l2->next ) { @@ -1446,7 +1447,7 @@ static int32_t targets_equal( TARGETS * l1, TARGETS * l2 ) static int32_t cmd_sem_lock( TARGET * t ) { CMD * cmd = (CMD *)t->cmds; - TARGETS * iter; + targets_ptr iter; /* Check whether all the semaphores required for updating * this target are free. */ @@ -1480,7 +1481,7 @@ static int32_t cmd_sem_lock( TARGET * t ) static void cmd_sem_unlock( TARGET * t ) { CMD * cmd = ( CMD * )t->cmds; - TARGETS * iter; + targets_ptr iter; /* Release the semaphores. */ for ( iter = cmd->unlock; iter; iter = iter->next ) { @@ -1495,7 +1496,7 @@ static void cmd_sem_unlock( TARGET * t ) /* Find a waiting target that's ready */ while ( iter->target->parents ) { - TARGETS * first = iter->target->parents; + targets_ptr first = iter->target->parents; TARGET * t1 = first->target; /* Pop the first waiting CMD */ diff --git a/src/engine/modules.h b/src/engine/modules.h index 151b64712..3a07b11c3 100644 --- a/src/engine/modules.h +++ b/src/engine/modules.h @@ -1,4 +1,5 @@ /* + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -11,6 +12,9 @@ #include "object.h" typedef struct module_t module_t ; + +typedef module_t * module_ptr; + struct module_t { OBJECT * name; diff --git a/src/engine/object.h b/src/engine/object.h index 555e9851c..53df10892 100644 --- a/src/engine/object.h +++ b/src/engine/object.h @@ -1,4 +1,5 @@ /* + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2011 Steven Watanabe * * This file is part of Jam - see jam.c for Copyright information. @@ -17,6 +18,8 @@ typedef struct _object OBJECT; +typedef OBJECT * object_ptr; + OBJECT * object_new( char const * const ); OBJECT * object_new_range( char const * const, int32_t size ); void object_done( void ); diff --git a/src/engine/rules.cpp b/src/engine/rules.cpp index 69593aa87..7b77b920d 100644 --- a/src/engine/rules.cpp +++ b/src/engine/rules.cpp @@ -5,6 +5,7 @@ */ /* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -39,8 +40,8 @@ #include "variable.h" -static void set_rule_actions( RULE *, rule_actions * ); -static void set_rule_body ( RULE *, FUNCTION * ); +static void set_rule_actions( rule_ptr, rule_actions_ptr ); +static void set_rule_body ( rule_ptr, function_ptr ); static struct hash * targethash = 0; @@ -54,11 +55,11 @@ static struct hash * targethash = 0; * then read the internal includes node from there. */ -static TARGET * get_target_includes( TARGET * const t ) +static target_ptr get_target_includes( target_ptr const t ) { if ( !t->includes ) { - TARGET * const i = (TARGET *)BJAM_MALLOC( sizeof( *t ) ); + target_ptr const i = (target_ptr)BJAM_MALLOC( sizeof( *t ) ); memset( (char *)i, '\0', sizeof( *i ) ); i->name = object_copy( t->name ); i->boundname = object_copy( i->name ); @@ -77,16 +78,16 @@ static TARGET * get_target_includes( TARGET * const t ) * internal include node. */ -void target_include( TARGET * const including, TARGET * const included ) +void target_include( target_ptr const including, target_ptr const included ) { - TARGET * const internal = get_target_includes( including ); + target_ptr const internal = get_target_includes( including ); internal->depends = targetentry( internal->depends, included ); } -void target_include_many( TARGET * const including, LIST * const included_names +void target_include_many( target_ptr const including, list_ptr const included_names ) { - TARGET * const internal = get_target_includes( including ); + target_ptr const internal = get_target_includes( including ); internal->depends = targetlist( internal->depends, included_names ); } @@ -96,10 +97,10 @@ void target_include_many( TARGET * const including, LIST * const included_names * target_module. */ -static RULE * enter_rule( OBJECT * rulename, module_t * target_module ) +static rule_ptr enter_rule( object_ptr rulename, module_ptr target_module ) { int found; - RULE * const r = (RULE *)hash_insert( demand_rules( target_module ), + rule_ptr const r = (rule_ptr)hash_insert( demand_rules( target_module ), rulename, &found ); if ( !found ) { @@ -120,10 +121,10 @@ static RULE * enter_rule( OBJECT * rulename, module_t * target_module ) * src_module. */ -static RULE * define_rule( module_t * src_module, OBJECT * rulename, - module_t * target_module ) +static rule_ptr define_rule( module_ptr src_module, object_ptr rulename, + module_ptr target_module ) { - RULE * const r = enter_rule( rulename, target_module ); + rule_ptr const r = enter_rule( rulename, target_module ); if ( r->module != src_module ) { /* If the rule was imported from elsewhere, clear it now. */ @@ -136,7 +137,7 @@ static RULE * define_rule( module_t * src_module, OBJECT * rulename, } -void rule_free( RULE * r ) +void rule_free( rule_ptr r ) { object_free( r->name ); r->name = 0; @@ -153,15 +154,15 @@ void rule_free( RULE * r ) * bindtarget() - return pointer to TARGET, creating it if necessary. */ -TARGET * bindtarget( OBJECT * const target_name ) +target_ptr bindtarget( object_ptr const target_name ) { int found; - TARGET * t; + target_ptr t; if ( !targethash ) targethash = hashinit( sizeof( TARGET ), "targets" ); - t = (TARGET *)hash_insert( targethash, target_name, &found ); + t = (target_ptr)hash_insert( targethash, target_name, &found ); if ( !found ) { memset( (char *)t, '\0', sizeof( *t ) ); @@ -173,13 +174,12 @@ TARGET * bindtarget( OBJECT * const target_name ) } -static void bind_explicitly_located_target( void * xtarget, void * data ) +static void bind_explicitly_located_target( target_ptr t, void * ) { - TARGET * t = (TARGET *)xtarget; if ( !( t->flags & T_FLAG_NOTFILE ) ) { /* Check if there is a setting for LOCATE. */ - SETTINGS * s = t->settings; + settings_ptr s = t->settings; for ( ; s ; s = s->next ) { if ( object_equal( s->symbol, constant_LOCATE ) && ! list_empty( s->value ) ) @@ -195,7 +195,7 @@ static void bind_explicitly_located_target( void * xtarget, void * data ) void bind_explicitly_located_targets() { if ( targethash ) - hashenumerate( targethash, bind_explicitly_located_target, (void *)0 ); + hash_enumerate( targethash, bind_explicitly_located_target ); } @@ -203,7 +203,7 @@ void bind_explicitly_located_targets() * touch_target() - mark a target to simulate being new. */ -void touch_target( OBJECT * const t ) +void touch_target( object_ptr const t ) { bindtarget( t )->flags |= T_FLAG_TOUCHED; } @@ -214,14 +214,14 @@ void touch_target( OBJECT * const t ) * target is a part of. */ -TARGET * target_scc( TARGET * t ) +target_ptr target_scc( target_ptr t ) { - TARGET * result = t; + target_ptr result = t; while ( result->scc_root ) result = result->scc_root; while ( t->scc_root ) { - TARGET * const tmp = t->scc_root; + target_ptr const tmp = t->scc_root; t->scc_root = result; t = tmp; } @@ -237,7 +237,7 @@ TARGET * target_scc( TARGET * t ) * targets list of target names */ -TARGETS * targetlist( TARGETS * chain, LIST * target_names ) +targets_ptr targetlist( targets_ptr chain, list_ptr target_names ) { LISTITER iter = list_begin( target_names ); LISTITER const end = list_end( target_names ); @@ -255,9 +255,9 @@ TARGETS * targetlist( TARGETS * chain, LIST * target_names ) * target new target to append */ -TARGETS * targetentry( TARGETS * chain, TARGET * target ) +targets_ptr targetentry( targets_ptr chain, target_ptr target ) { - TARGETS * const c = (TARGETS *)BJAM_MALLOC( sizeof( TARGETS ) ); + targets_ptr const c = (targets_ptr)BJAM_MALLOC( sizeof( TARGETS ) ); c->target = target; if ( !chain ) chain = c; @@ -277,7 +277,7 @@ TARGETS * targetentry( TARGETS * chain, TARGET * target ) * target new target to append */ -TARGETS * targetchain( TARGETS * chain, TARGETS * targets ) +targets_ptr targetchain( targets_ptr chain, targets_ptr targets ) { if ( !targets ) return chain; if ( !chain ) return targets; @@ -291,7 +291,7 @@ TARGETS * targetchain( TARGETS * chain, TARGETS * targets ) * action_free - decrement the ACTIONs reference count and (maybe) free it. */ -void action_free( ACTION * action ) +void action_free( action_ptr action ) { if ( --action->refs == 0 ) { @@ -306,9 +306,9 @@ void action_free( ACTION * action ) * actionlist() - append to an ACTION chain. */ -ACTIONS * actionlist( ACTIONS * chain, ACTION * action ) +actions_ptr actionlist( actions_ptr chain, action_ptr action ) { - ACTIONS * const actions = (ACTIONS *)BJAM_MALLOC( sizeof( ACTIONS ) ); + actions_ptr const actions = (actions_ptr)BJAM_MALLOC( sizeof( ACTIONS ) ); actions->action = action; ++action->refs; if ( !chain ) chain = actions; @@ -318,7 +318,7 @@ ACTIONS * actionlist( ACTIONS * chain, ACTION * action ) return chain; } -static SETTINGS * settings_freelist; +static settings_ptr settings_freelist; /* @@ -330,10 +330,10 @@ static SETTINGS * settings_freelist; * head of the settings chain. */ -SETTINGS * addsettings( SETTINGS * head, int flag, OBJECT * symbol, - LIST * value ) +settings_ptr addsettings( settings_ptr head, int flag, object_ptr symbol, + list_ptr value ) { - SETTINGS * v; + settings_ptr v; /* Look for previous settings. */ for ( v = head; v; v = v->next ) @@ -349,7 +349,7 @@ SETTINGS * addsettings( SETTINGS * head, int flag, OBJECT * symbol, if ( v ) settings_freelist = v->next; else - v = (SETTINGS *)BJAM_MALLOC( sizeof( *v ) ); + v = (settings_ptr)BJAM_MALLOC( sizeof( *v ) ); v->symbol = object_copy( symbol ); v->value = value; @@ -377,7 +377,7 @@ SETTINGS * addsettings( SETTINGS * head, int flag, OBJECT * symbol, * pushsettings() - set all target specific variables. */ -void pushsettings( struct module_t * module, SETTINGS * v ) +void pushsettings( module_ptr module, settings_ptr v ) { for ( ; v; v = v->next ) v->value = var_swap( module, v->symbol, v->value ); @@ -388,7 +388,7 @@ void pushsettings( struct module_t * module, SETTINGS * v ) * popsettings() - reset target specific variables to their pre-push values. */ -void popsettings( struct module_t * module, SETTINGS * v ) +void popsettings( module_ptr module, settings_ptr v ) { pushsettings( module, v ); /* just swap again */ } @@ -398,10 +398,10 @@ void popsettings( struct module_t * module, SETTINGS * v ) * copysettings() - duplicate a settings list, returning the new copy. */ -SETTINGS * copysettings( SETTINGS * head ) +settings_ptr copysettings( settings_ptr head ) { - SETTINGS * copy = 0; - SETTINGS * v; + settings_ptr copy = 0; + settings_ptr v; for ( v = head; v; v = v->next ) copy = addsettings( copy, VAR_SET, v->symbol, list_copy( v->value ) ); return copy; @@ -412,11 +412,11 @@ SETTINGS * copysettings( SETTINGS * head ) * freetargets() - delete a targets list. */ -void freetargets( TARGETS * chain ) +void freetargets( targets_ptr chain ) { while ( chain ) { - TARGETS * const n = chain->next; + targets_ptr const n = chain->next; BJAM_FREE( chain ); chain = n; } @@ -427,11 +427,11 @@ void freetargets( TARGETS * chain ) * freeactions() - delete an action list. */ -void freeactions( ACTIONS * chain ) +void freeactions( actions_ptr chain ) { while ( chain ) { - ACTIONS * const n = chain->next; + actions_ptr const n = chain->next; action_free( chain->action ); BJAM_FREE( chain ); chain = n; @@ -443,11 +443,11 @@ void freeactions( ACTIONS * chain ) * freesettings() - delete a settings list. */ -void freesettings( SETTINGS * v ) +void freesettings( settings_ptr v ) { while ( v ) { - SETTINGS * const n = v->next; + settings_ptr const n = v->next; object_free( v->symbol ); list_free( v->value ); v->next = settings_freelist; @@ -457,9 +457,8 @@ void freesettings( SETTINGS * v ) } -static void freetarget( void * xt, void * data ) +static void freetarget( target_ptr const t, void * ) { - TARGET * const t = (TARGET *)xt; if ( t->name ) object_free ( t->name ); if ( t->boundname ) object_free ( t->boundname ); if ( t->settings ) freesettings( t->settings ); @@ -483,12 +482,12 @@ void rules_done() { if ( targethash ) { - hashenumerate( targethash, freetarget, 0 ); + hash_enumerate( targethash, freetarget ); hashdone( targethash ); } while ( settings_freelist ) { - SETTINGS * const n = settings_freelist->next; + settings_ptr const n = settings_freelist->next; BJAM_FREE( settings_freelist ); settings_freelist = n; } @@ -499,7 +498,7 @@ void rules_done() * actions_refer() - add a new reference to the given actions. */ -void actions_refer( rule_actions * a ) +void actions_refer( rule_actions_ptr a ) { ++a->reference_count; } @@ -509,7 +508,7 @@ void actions_refer( rule_actions * a ) * actions_free() - release a reference to given actions. */ -void actions_free( rule_actions * a ) +void actions_free( rule_actions_ptr a ) { if ( --a->reference_count <= 0 ) { @@ -524,7 +523,7 @@ void actions_free( rule_actions * a ) * set_rule_body() - set the argument list and procedure of the given rule. */ -static void set_rule_body( RULE * rule, FUNCTION * procedure ) +static void set_rule_body( rule_ptr rule, function_ptr procedure ) { if ( procedure ) function_refer( procedure ); @@ -539,7 +538,7 @@ static void set_rule_body( RULE * rule, FUNCTION * procedure ) * global module. */ -static OBJECT * global_rule_name( RULE * r ) +static object_ptr global_rule_name( rule_ptr r ) { if ( r->module == root_module() ) return object_copy( r->name ); @@ -562,14 +561,14 @@ static OBJECT * global_rule_name( RULE * r ) * module. */ -static RULE * global_rule( RULE * r ) +static rule_ptr global_rule( rule_ptr r ) { if ( r->module == root_module() ) return r; { - OBJECT * const name = global_rule_name( r ); - RULE * const result = define_rule( r->module, name, root_module() ); + object_ptr const name = global_rule_name( r ); + rule_ptr const result = define_rule( r->module, name, root_module() ); object_free( name ); return result; } @@ -582,10 +581,10 @@ static RULE * global_rule( RULE * r ) * exported to the global module as modulename.rulename. */ -RULE * new_rule_body( module_t * m, OBJECT * rulename, FUNCTION * procedure, +rule_ptr new_rule_body( module_ptr m, object_ptr rulename, function_ptr procedure, int exported ) { - RULE * const local = define_rule( m, rulename, m ); + rule_ptr const local = define_rule( m, rulename, m ); local->exported = exported; set_rule_body( local, procedure ); @@ -601,7 +600,7 @@ RULE * new_rule_body( module_t * m, OBJECT * rulename, FUNCTION * procedure, } -static void set_rule_actions( RULE * rule, rule_actions * actions ) +static void set_rule_actions( rule_ptr rule, rule_actions_ptr actions ) { if ( actions ) actions_refer( actions ); @@ -611,10 +610,10 @@ static void set_rule_actions( RULE * rule, rule_actions * actions ) } -static rule_actions * actions_new( FUNCTION * command, LIST * bindlist, +static rule_actions_ptr actions_new( function_ptr command, list_ptr bindlist, int flags ) { - rule_actions * const result = (rule_actions *)BJAM_MALLOC( sizeof( + rule_actions_ptr const result = (rule_actions_ptr)BJAM_MALLOC( sizeof( rule_actions ) ); function_refer( command ); result->command = command; @@ -625,11 +624,11 @@ static rule_actions * actions_new( FUNCTION * command, LIST * bindlist, } -RULE * new_rule_actions( module_t * m, OBJECT * rulename, FUNCTION * command, - LIST * bindlist, int flags ) +rule_ptr new_rule_actions( module_ptr m, object_ptr rulename, function_ptr command, + list_ptr bindlist, int flags ) { - RULE * const local = define_rule( m, rulename, m ); - RULE * const global = global_rule( local ); + rule_ptr const local = define_rule( m, rulename, m ); + rule_ptr const global = global_rule( local ); set_rule_actions( local, actions_new( command, bindlist, flags ) ); set_rule_actions( global, local->actions ); return local; @@ -643,16 +642,16 @@ RULE * new_rule_actions( module_t * m, OBJECT * rulename, FUNCTION * command, * modules, look in module 'name1' for rule 'name2'. */ -RULE * lookup_rule( OBJECT * rulename, module_t * m, int local_only ) +rule_ptr lookup_rule( object_ptr rulename, module_ptr m, int local_only ) { - RULE * r; - RULE * result = 0; - module_t * original_module = m; + rule_ptr r; + rule_ptr result = 0; + module_ptr original_module = m; if ( m->class_module ) m = m->class_module; - if ( m->rules && ( r = (RULE *)hash_find( m->rules, rulename ) ) ) + if ( m->rules && ( r = (rule_ptr)hash_find( m->rules, rulename ) ) ) result = r; else if ( !local_only && m->imported_modules ) { @@ -663,8 +662,8 @@ RULE * lookup_rule( OBJECT * rulename, module_t * m, int local_only ) /* Now, r->name keeps the module name, and p + 1 keeps the rule * name. */ - OBJECT * rule_part = object_new( p + 1 ); - OBJECT * module_part; + object_ptr rule_part = object_new( p + 1 ); + object_ptr module_part; { string buf[ 1 ]; string_new( buf ); @@ -702,9 +701,9 @@ RULE * lookup_rule( OBJECT * rulename, module_t * m, int local_only ) } -RULE * bindrule( OBJECT * rulename, module_t * m ) +rule_ptr bindrule( object_ptr rulename, module_ptr m ) { - RULE * result = lookup_rule( rulename, m, 0 ); + rule_ptr result = lookup_rule( rulename, m, 0 ); if ( !result ) result = lookup_rule( rulename, root_module(), 0 ); /* We have only one caller, 'evaluate_rule', which will complain about @@ -717,21 +716,21 @@ RULE * bindrule( OBJECT * rulename, module_t * m ) } -RULE * import_rule( RULE * source, module_t * m, OBJECT * name ) +rule_ptr import_rule( rule_ptr source, module_ptr m, object_ptr name ) { - RULE * const dest = define_rule( source->module, name, m ); + rule_ptr const dest = define_rule( source->module, name, m ); set_rule_body( dest, source->procedure ); set_rule_actions( dest, source->actions ); return dest; } -void rule_localize( RULE * rule, module_t * m ) +void rule_localize( rule_ptr rule, module_ptr m ) { rule->module = m; if ( rule->procedure ) { - FUNCTION * procedure = function_unbind_variables( rule->procedure ); + function_ptr procedure = function_unbind_variables( rule->procedure ); function_refer( procedure ); function_free( rule->procedure ); rule->procedure = procedure; diff --git a/src/engine/rules.h b/src/engine/rules.h index 8e475aeec..43934b938 100644 --- a/src/engine/rules.h +++ b/src/engine/rules.h @@ -5,6 +5,7 @@ */ /* This file is ALSO: + * Copyright 2022 René Ferdinand Rivera Morell * Copyright 2001-2004 David Abrahams. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) @@ -34,239 +35,236 @@ #include "modules.h" #include "timestamp.h" - typedef struct _rule RULE; typedef struct _target TARGET; typedef struct _targets TARGETS; typedef struct _action ACTION; typedef struct _actions ACTIONS; -typedef struct _settings SETTINGS ; +typedef struct _settings SETTINGS; + +typedef RULE* rule_ptr; +typedef TARGET* target_ptr; +typedef TARGETS* targets_ptr; +typedef ACTION* action_ptr; +typedef ACTIONS* actions_ptr; +typedef SETTINGS* settings_ptr; /* RULE - a generic jam rule, the product of RULE and ACTIONS. */ /* Build actions corresponding to a rule. */ -struct rule_actions -{ - int reference_count; - FUNCTION * command; /* command string from ACTIONS */ - LIST * bindlist; - int flags; /* modifiers on ACTIONS */ - -#define RULE_NEWSRCS 0x01 /* $(>) is updated sources only */ -#define RULE_TOGETHER 0x02 /* combine actions on single target */ -#define RULE_IGNORE 0x04 /* ignore return status of executes */ -#define RULE_QUIETLY 0x08 /* do not mention it unless verbose */ -#define RULE_PIECEMEAL 0x10 /* split exec so each $(>) is small */ -#define RULE_EXISTING 0x20 /* $(>) is pre-exisitng sources only */ +struct rule_actions { + int reference_count; + function_ptr command; /* command string from ACTIONS */ + list_ptr bindlist; + int flags; /* modifiers on ACTIONS */ }; -typedef struct rule_actions rule_actions; -typedef struct argument_list argument_list; +#define RULE_NEWSRCS 0x01 /* $(>) is updated sources only */ +#define RULE_TOGETHER 0x02 /* combine actions on single target */ +#define RULE_IGNORE 0x04 /* ignore return status of executes */ +#define RULE_QUIETLY 0x08 /* do not mention it unless verbose */ +#define RULE_PIECEMEAL 0x10 /* split exec so each $(>) is small */ +#define RULE_EXISTING 0x20 /* $(>) is pre-existing sources only */ -struct _rule -{ - OBJECT * name; - FUNCTION * procedure; - rule_actions * actions; /* build actions, or NULL for no actions */ - module_t * module; /* module in which this rule is executed */ - int exported; /* nonzero if this rule is supposed to appear in - * the global module and be automatically - * imported into other modules - */ +typedef struct rule_actions* rule_actions_ptr; + +struct _rule { + object_ptr name; + function_ptr procedure; + rule_actions_ptr actions; /* build actions, or NULL for no actions */ + module_ptr module; /* module in which this rule is executed */ + int exported; /* nonzero if this rule is supposed to appear in + * the global module and be automatically + * imported into other modules + */ }; /* ACTIONS - a chain of ACTIONs. */ -struct _actions -{ - ACTIONS * next; - ACTIONS * tail; /* valid only for head */ - ACTION * action; +struct _actions { + actions_ptr next; + actions_ptr tail; /* valid only for head */ + action_ptr action; }; /* ACTION - a RULE instance with targets and sources. */ -struct _action -{ - RULE * rule; - TARGETS * targets; - TARGETS * sources; /* aka $(>) */ - char running; /* has been started */ -#define A_INIT 0 +struct _action { + rule_ptr rule; + targets_ptr targets; + targets_ptr sources; /* aka $(>) */ + char running; /* has been started */ +#define A_INIT 0 #define A_RUNNING_NOEXEC 1 -#define A_RUNNING 2 - int refs; +#define A_RUNNING 2 + int refs; /* WARNING: These variables are used to pass state required by make1cmds and * are not valid anywhere else. */ - void * first_cmd; /* Pointer to the first CMD created by this action */ - void * last_cmd; /* Pointer to the last CMD created by this action */ + void* first_cmd; /* Pointer to the first CMD created by this action */ + void* last_cmd; /* Pointer to the last CMD created by this action */ }; /* SETTINGS - variables to set when executing a TARGET's ACTIONS. */ -struct _settings -{ - SETTINGS * next; - OBJECT * symbol; /* symbol name for var_set() */ - LIST * value; /* symbol value for var_set() */ +struct _settings { + settings_ptr next; + object_ptr symbol; /* symbol name for var_set() */ + list_ptr value; /* symbol value for var_set() */ }; /* TARGETS - a chain of TARGETs. */ -struct _targets -{ - TARGETS * next; - TARGETS * tail; /* valid only for head */ - TARGET * target; +struct _targets { + targets_ptr next; + targets_ptr tail; /* valid only for head */ + target_ptr target; }; /* TARGET - an entity (e.g. a file) that can be built. */ -struct _target -{ - OBJECT * name; - OBJECT * boundname; /* if search() relocates target */ - ACTIONS * actions; /* rules to execute, if any */ - SETTINGS * settings; /* variables to define */ +struct _target { + object_ptr name; + object_ptr boundname; /* if search() relocates target */ + actions_ptr actions; /* rules to execute, if any */ + settings_ptr settings; /* variables to define */ - TARGETS * depends; /* dependencies */ - TARGETS * dependants; /* the inverse of dependencies */ - TARGETS * rebuilds; /* targets that should be force-rebuilt - * whenever this one is - */ - TARGET * includes; /* internal includes node */ + targets_ptr depends; /* dependencies */ + targets_ptr dependants; /* the inverse of dependencies */ + targets_ptr rebuilds; /* targets that should be force-rebuilt + * whenever this one is + */ + target_ptr includes; /* internal includes node */ - timestamp time; /* update time */ - timestamp leaf; /* update time of leaf sources */ + timestamp time; /* update time */ + timestamp leaf; /* update time of leaf sources */ - short flags; /* status info */ + short flags; /* status info */ -#define T_FLAG_TEMP 0x0001 /* TEMPORARY applied */ -#define T_FLAG_NOCARE 0x0002 /* NOCARE applied */ -#define T_FLAG_NOTFILE 0x0004 /* NOTFILE applied */ -#define T_FLAG_TOUCHED 0x0008 /* ALWAYS applied or -t target */ -#define T_FLAG_LEAVES 0x0010 /* LEAVES applied */ -#define T_FLAG_NOUPDATE 0x0020 /* NOUPDATE applied */ -#define T_FLAG_VISITED 0x0040 /* CWM: Used in debugging */ +#define T_FLAG_TEMP 0x0001 /* TEMPORARY applied */ +#define T_FLAG_NOCARE 0x0002 /* NOCARE applied */ +#define T_FLAG_NOTFILE 0x0004 /* NOTFILE applied */ +#define T_FLAG_TOUCHED 0x0008 /* ALWAYS applied or -t target */ +#define T_FLAG_LEAVES 0x0010 /* LEAVES applied */ +#define T_FLAG_NOUPDATE 0x0020 /* NOUPDATE applied */ +#define T_FLAG_VISITED 0x0040 /* CWM: Used in debugging */ /* This flag has been added to support a new built-in rule named "RMBAD". It is * used to force removal of outdated targets whose dependencies fail to build. */ -#define T_FLAG_RMOLD 0x0080 /* RMBAD applied */ +#define T_FLAG_RMOLD 0x0080 /* RMBAD applied */ /* This flag was added to support a new built-in rule named "FAIL_EXPECTED" used * to indicate that the result of running a given action should be inverted, * i.e. ok <=> fail. Useful for launching certain test runs from a Jamfile. */ -#define T_FLAG_FAIL_EXPECTED 0x0100 /* FAIL_EXPECTED applied */ +#define T_FLAG_FAIL_EXPECTED 0x0100 /* FAIL_EXPECTED applied */ -#define T_FLAG_INTERNAL 0x0200 /* internal INCLUDES node */ +#define T_FLAG_INTERNAL 0x0200 /* internal INCLUDES node */ /* Indicates that the target must be a file. Prevents matching non-files, like * directories, when a target is searched. */ -#define T_FLAG_ISFILE 0x0400 +#define T_FLAG_ISFILE 0x0400 -#define T_FLAG_PRECIOUS 0x0800 +#define T_FLAG_PRECIOUS 0x0800 - char binding; /* how target relates to a real file or - * folder - */ + char binding; /* how target relates to a real file or + * folder + */ -#define T_BIND_UNBOUND 0 /* a disembodied name */ -#define T_BIND_MISSING 1 /* could not find real file */ -#define T_BIND_PARENTS 2 /* using parent's timestamp */ -#define T_BIND_EXISTS 3 /* real file, timestamp valid */ +#define T_BIND_UNBOUND 0 /* a disembodied name */ +#define T_BIND_MISSING 1 /* could not find real file */ +#define T_BIND_PARENTS 2 /* using parent's timestamp */ +#define T_BIND_EXISTS 3 /* real file, timestamp valid */ - char fate; /* make0()'s diagnosis */ + char fate; /* make0()'s diagnosis */ -#define T_FATE_INIT 0 /* nothing done to target */ -#define T_FATE_MAKING 1 /* make0(target) on stack */ +#define T_FATE_INIT 0 /* nothing done to target */ +#define T_FATE_MAKING 1 /* make0(target) on stack */ -#define T_FATE_STABLE 2 /* target did not need updating */ -#define T_FATE_NEWER 3 /* target newer than parent */ +#define T_FATE_STABLE 2 /* target did not need updating */ +#define T_FATE_NEWER 3 /* target newer than parent */ -#define T_FATE_SPOIL 4 /* >= SPOIL rebuilds parents */ -#define T_FATE_ISTMP 4 /* unneeded temp target oddly present */ +#define T_FATE_SPOIL 4 /* >= SPOIL rebuilds parents */ +#define T_FATE_ISTMP 4 /* unneeded temp target oddly present */ -#define T_FATE_BUILD 5 /* >= BUILD rebuilds target */ -#define T_FATE_TOUCHED 5 /* manually touched with -t */ -#define T_FATE_REBUILD 6 -#define T_FATE_MISSING 7 /* is missing, needs updating */ -#define T_FATE_NEEDTMP 8 /* missing temp that must be rebuild */ -#define T_FATE_OUTDATED 9 /* is out of date, needs updating */ -#define T_FATE_UPDATE 10 /* deps updated, needs updating */ +#define T_FATE_BUILD 5 /* >= BUILD rebuilds target */ +#define T_FATE_TOUCHED 5 /* manually touched with -t */ +#define T_FATE_REBUILD 6 +#define T_FATE_MISSING 7 /* is missing, needs updating */ +#define T_FATE_NEEDTMP 8 /* missing temp that must be rebuild */ +#define T_FATE_OUTDATED 9 /* is out of date, needs updating */ +#define T_FATE_UPDATE 10 /* deps updated, needs updating */ -#define T_FATE_BROKEN 11 /* >= BROKEN ruins parents */ -#define T_FATE_CANTFIND 11 /* no rules to make missing target */ -#define T_FATE_CANTMAKE 12 /* can not find dependencies */ +#define T_FATE_BROKEN 11 /* >= BROKEN ruins parents */ +#define T_FATE_CANTFIND 11 /* no rules to make missing target */ +#define T_FATE_CANTMAKE 12 /* can not find dependencies */ - char progress; /* tracks make1() progress */ + char progress; /* tracks make1() progress */ -#define T_MAKE_INIT 0 /* make1(target) not yet called */ -#define T_MAKE_ONSTACK 1 /* make1(target) on stack */ -#define T_MAKE_ACTIVE 2 /* make1(target) in make1b() */ -#define T_MAKE_RUNNING 3 /* make1(target) running commands */ -#define T_MAKE_DONE 4 /* make1(target) done */ -#define T_MAKE_NOEXEC_DONE 5 /* make1(target) done with -n in effect */ +#define T_MAKE_INIT 0 /* make1(target) not yet called */ +#define T_MAKE_ONSTACK 1 /* make1(target) on stack */ +#define T_MAKE_ACTIVE 2 /* make1(target) in make1b() */ +#define T_MAKE_RUNNING 3 /* make1(target) running commands */ +#define T_MAKE_DONE 4 /* make1(target) done */ +#define T_MAKE_NOEXEC_DONE 5 /* make1(target) done with -n in effect */ #ifdef OPT_SEMAPHORE - #define T_MAKE_SEMAPHORE 5 /* Special target type for semaphores */ +#define T_MAKE_SEMAPHORE 5 /* Special target type for semaphores */ #endif - char status; /* exec_cmd() result */ + char status; /* exec_cmd() result */ #ifdef OPT_SEMAPHORE - TARGET * semaphore; /* used in serialization */ + target_ptr semaphore; /* used in serialization */ #endif - int asynccnt; /* child deps outstanding */ - TARGETS * parents; /* used by make1() for completion */ - TARGET * scc_root; /* used by make to resolve cyclic includes - */ - TARGET * rescanning; /* used by make0 to mark visited targets - * when rescanning - */ - int depth; /* The depth of the target in the make0 - * stack. - */ - char * cmds; /* type-punned command list */ + int asynccnt; /* child deps outstanding */ + targets_ptr parents; /* used by make1() for completion */ + target_ptr scc_root; /* used by make to resolve cyclic includes + */ + target_ptr rescanning; /* used by make0 to mark visited targets + * when rescanning + */ + int depth; /* The depth of the target in the make0 + * stack. + */ + char* cmds; /* type-punned command list */ - char const * failed; + char const* failed; }; - /* Action related functions. */ -void action_free ( ACTION * ); -ACTIONS * actionlist ( ACTIONS *, ACTION * ); -void freeactions ( ACTIONS * ); -SETTINGS * addsettings ( SETTINGS *, int flag, OBJECT * symbol, LIST * value ); -void pushsettings ( module_t *, SETTINGS * ); -void popsettings ( module_t *, SETTINGS * ); -SETTINGS * copysettings ( SETTINGS * ); -void freesettings ( SETTINGS * ); -void actions_refer( rule_actions * ); -void actions_free ( rule_actions * ); +void action_free(action_ptr); +actions_ptr actionlist(actions_ptr, action_ptr); +void freeactions(actions_ptr); +settings_ptr addsettings(settings_ptr, int flag, object_ptr symbol, list_ptr value); +void pushsettings(module_ptr, settings_ptr); +void popsettings(module_ptr, settings_ptr); +settings_ptr copysettings(settings_ptr); +void freesettings(settings_ptr); +void actions_refer(rule_actions_ptr); +void actions_free(rule_actions_ptr); /* Rule related functions. */ -RULE * bindrule ( OBJECT * rulename, module_t * ); -RULE * import_rule ( RULE * source, module_t *, OBJECT * name ); -void rule_localize ( RULE * rule, module_t * module ); -RULE * new_rule_body ( module_t *, OBJECT * rulename, FUNCTION * func, int exprt ); -RULE * new_rule_actions( module_t *, OBJECT * rulename, FUNCTION * command, LIST * bindlist, int flags ); -void rule_free ( RULE * ); +rule_ptr bindrule(object_ptr rulename, module_ptr); +rule_ptr import_rule(rule_ptr source, module_ptr, object_ptr name); +void rule_localize(rule_ptr rule, module_ptr module); +rule_ptr new_rule_body(module_ptr, object_ptr rulename, function_ptr func, int exprt); +rule_ptr new_rule_actions(module_ptr, object_ptr rulename, function_ptr command, list_ptr bindlist, int flags); +void rule_free(rule_ptr); /* Target related functions. */ -void bind_explicitly_located_targets(); -TARGET * bindtarget ( OBJECT * const ); -void freetargets ( TARGETS * ); -TARGETS * targetchain ( TARGETS *, TARGETS * ); -TARGETS * targetentry ( TARGETS *, TARGET * ); -void target_include ( TARGET * const including, - TARGET * const included ); -void target_include_many ( TARGET * const including, - LIST * const included_names ); -TARGETS * targetlist ( TARGETS *, LIST * target_names ); -void touch_target ( OBJECT * const ); -void clear_includes ( TARGET * ); -TARGET * target_scc ( TARGET * ); +void bind_explicitly_located_targets(); +target_ptr bindtarget(object_ptr const); +void freetargets(targets_ptr); +targets_ptr targetchain(targets_ptr, targets_ptr); +targets_ptr targetentry(targets_ptr, target_ptr); +void target_include(target_ptr const including, + target_ptr const included); +void target_include_many(target_ptr const including, + list_ptr const included_names); +targets_ptr targetlist(targets_ptr, list_ptr target_names); +void touch_target(object_ptr const); +void clear_includes(target_ptr); +target_ptr target_scc(target_ptr); /* Final module cleanup. */ void rules_done();