VirtualBox

Changeset 2802 in kBuild for trunk


Ignore:
Timestamp:
Oct 10, 2015 6:28:07 PM (9 years ago)
Author:
bird
Message:

kmk_cc_exec.c: Some more code handling export, unexport and undefine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmk_cc_exec.c

    r2801 r2802  
    556556    kKmkCcEvalInstr_assign_define,
    557557
    558     /** export variable1 [variable2...] - KMKCCEVALEXPORT. */
     558    /** export variable1 [variable2...] - KMKCCEVALVARIABLES. */
    559559    kKmkCcEvalInstr_export,
    560     /** unexport variable1 [variable2...] - KMKCCEVALEXPORT. */
     560    /** unexport variable1 [variable2...] - KMKCCEVALVARIABLES. */
    561561    kKmkCcEvalInstr_unexport,
    562562    /** export - KMKCCEVALCORE. */
     
    564564    /** unexport - KMKCCEVALCORE. */
    565565    kKmkCcEvalInstr_unexport_all,
     566    /** [local|override] undefine - KMKCCEVALVARIABLES. */
     567    kKmkCcEvalInstr_undefine,
     568
    566569
    567570    /** [else] ifdef variable - KMKCCEVALIFDEFPLAIN. */
     
    688691
    689692/**
    690  * Instruction format for kKmkCcEvalInstr_export and kKmkCcEvalInstr_unexport.
    691  */
    692 typedef struct kmk_cc_eval_export
     693 * Instruction format for kKmkCcEvalInstr_export, kKmkCcEvalInstr_unexport and
     694 * kKmkCcEvalInstr_undefine.
     695 */
     696typedef struct kmk_cc_eval_variables
    693697{
    694698    /** The core instruction. */
     
    696700    /** The number of variables named in aVars. */
    697701    uint32_t                cVars;
     702    /** Whether the 'local' qualifier was used (undefine only). */
     703    uint8_t                 fLocal;
    698704    /** Pointer to the next instruction. */
    699705    PKMKCCEVALCORE          pNext;
     
    702708     * @remarks Plain text names are in variable_strcache. */
    703709    KMKCCEXPSUBPROGORPLAIN  aVars[1];
    704 } KMKCCEVALEXPORT;
    705 typedef KMKCCEVALEXPORT *PKMKCCEVALEXPORT;
    706 /** Calculates the size of an KMKCCEVALEXPORT structure for @a a_cVars. */
    707 #define KMKCCEVALEXPORT_SIZE(a_cVars) KMK_CC_SIZEOF_VAR_STRUCT(KMKCCEVALVPATH, aVars, a_cVars)
     710} KMKCCEVALVARIABLES;
     711typedef KMKCCEVALVARIABLES *PKMKCCEVALVARIABLES;
     712/** Calculates the size of an KMKCCEVALVARIABLES structure for @a a_cVars. */
     713#define KMKCCEVALVARIABLES_SIZE(a_cVars) KMK_CC_SIZEOF_VAR_STRUCT(KMKCCEVALVARIABLES, aVars, a_cVars)
    708714
    709715/**
     
    11151121    KMK_CC_EVAL_BM_OR(g_abEvalCcChars, 'o', KMK_CC_EVAL_CH_1ST_IN_VARIABLE_KEYWORD); /* override */
    11161122    KMK_CC_EVAL_BM_OR(g_abEvalCcChars, 'p', KMK_CC_EVAL_CH_1ST_IN_VARIABLE_KEYWORD); /* private */
    1117     KMK_CC_EVAL_BM_OR(g_abEvalCcChars, 'u', KMK_CC_EVAL_CH_1ST_IN_VARIABLE_KEYWORD); /* undefine */
     1123    KMK_CC_EVAL_BM_OR(g_abEvalCcChars, 'u', KMK_CC_EVAL_CH_1ST_IN_VARIABLE_KEYWORD); /* undefine, unexport */
    11181124
    11191125    /* Assignment punctuation and recipe stuff. */
     
    33913397         && (a_pchLine)[15] == (a_pszWord)[15])
    33923398#endif
     3399
     3400/** See if the given string match a constant string. */
     3401#define KMK_CC_STRCMP_CONST(a_pchLeft, a_cchLeft, a_pszConst, a_cchConst) \
     3402    (   (a_cchLeft) == (a_cchConst) \
     3403     && KMK_CC_WORD_COMP_CONST_##a_cchConst(a_pchLeft, a_pszConst) )
     3404
    33933405/** See if a starting of a given length starts with a constant word. */
    3394 #define KMK_CC_WORD_COMP_IS_EOL(a_pCompiler, a_pchLine, a_cchLine) \
     3406#define KMK_CC_EVAL_WORD_COMP_IS_EOL(a_pCompiler, a_pchLine, a_cchLine) \
    33953407    (   (a_cchLine) == 0 \
    33963408     || KMK_CC_EVAL_IS_SPACE((a_pchLine)[0]) \
     
    33983410
    33993411/** See if a starting of a given length starts with a constant word. */
    3400 #define KMK_CC_WORD_COMP_CONST(a_pCompiler, a_pchLine, a_cchLine, a_pszWord, a_cchWord) \
     3412#define KMK_CC_EVAL_WORD_COMP_CONST(a_pCompiler, a_pchLine, a_cchLine, a_pszWord, a_cchWord) \
    34013413    (    (a_cchLine) >= (a_cchWord) \
    34023414      && (   (a_cchLine) == (a_cchWord) \
     
    51875199            cchLeft -= 2;
    51885200
    5189             if (KMK_CC_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
     5201            if (KMK_CC_EVAL_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
    51905202                return kmk_cc_eval_do_if(pCompiler, pchWord, cchLeft, 1 /* in else */);
    51915203
    5192             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "eq", 2))
     5204            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "eq", 2))
    51935205                return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 2, cchLeft - 2, 1 /* in else */, 1 /* positive */);
    51945206
    5195             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "def", 3))
     5207            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "def", 3))
    51965208                return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 3, cchLeft - 3, 1 /* in else */, 1 /* positive */);
    51975209
    5198             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "neq", 3))
     5210            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "neq", 3))
    51995211                return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 3, cchLeft - 3, 1 /* in else */, 0 /* positive */);
    52005212
    5201             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "1of", 3))
     5213            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "1of", 3))
    52025214                return kmk_cc_eval_do_if1of(pCompiler, pchWord + 3, cchLeft - 3, 1 /* in else */, 1 /* positive */);
    52035215
    5204             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "ndef", 4))
     5216            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "ndef", 4))
    52055217                return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 4, cchLeft - 4, 1 /* in else */, 0 /* positive */);
    52065218
    5207             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "n1of", 4))
     5219            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "n1of", 4))
    52085220                return kmk_cc_eval_do_if1of(pCompiler, pchWord + 4, cchLeft - 4, 1 /* in else */, 0 /* positive */);
    52095221
     
    53005312                                                                                  KMKCCEVALINCLUDE_SIZE(cWords));
    53015313            pInstr->Core.enmOpcode = enmOpcode;
    5302             pInstr->Core.iLine     = 0;
     5314            pInstr->Core.iLine     = pCompiler->iLine;
    53035315            pInstr->cFiles         = cWords;
    53045316            kmk_cc_eval_init_spp_array_from_duplicated_words(pCompiler, cWords, pCompiler->paWords, pInstr->aFiles);
     
    53305342                                                const char *pchColon, size_t cchLeft, unsigned fQualifiers)
    53315343{
    5332     kmk_cc_eval_fatal(pCompiler, pchWord0, "recipe handling not implemented yet");
     5344    kmk_cc_eval_fatal(pCompiler, pchWord0, "recipe handling not implemented yet (#1)");
    53335345    return 1;
    53345346}
     
    53385350                                                   const char *pchWord, size_t cchLeft, unsigned fQualifiers)
    53395351{
    5340     kmk_cc_eval_fatal(pCompiler, pchWord, "recipe handling not implemented yet");
     5352    kmk_cc_eval_fatal(pCompiler, pchWord, "recipe handling not implemented yet (#2)");
    53415353    return 1;
    53425354}
     
    53455357static void kmk_cc_eval_handle_recipe(PKMKCCEVALCOMPILER pCompiler, const char *pszEqual, const char *pchWord, size_t cchLeft)
    53465358{
    5347     kmk_cc_eval_fatal(pCompiler, pchWord, "recipe handling not implemented yet");
     5359    kmk_cc_eval_fatal(pCompiler, pchWord, "recipe handling not implemented yet (#3)");
    53485360}
    53495361
     
    53585370
    53595371/**
    5360  * Parses a 'undefine variable [..]' expression.
     5372 * Common worker for handling export (non-assign), undefine and unexport.
     5373 *
     5374 * For instructions using the KMKCCEVALVARIABLES structure.
     5375 *
     5376 * @returns 1 to indicate we've handled a keyword (see
     5377 *          kmk_cc_eval_try_handle_keyword).
     5378 * @param   pCompiler   The compiler state.
     5379 * @param   pchWord     First non-space chare after the keyword.
     5380 * @param   cchLeft     The number of chars left to parse on this line.
     5381 * @param   fQualifiers The qualifiers.
     5382 */
     5383static int kmk_cc_eval_do_with_variable_list(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft,
     5384                                             KMKCCEVALINSTR enmOpcode, unsigned fQualifiers)
     5385{
     5386    if (cchLeft)
     5387    {
     5388        /*
     5389         * Parse the variable name list.  GNU make is using normal word
     5390         * handling here, so we can share code with the include directives.
     5391         */
     5392        unsigned cWords = kmk_cc_eval_parse_words(pCompiler, pchWord, cchLeft);
     5393        KMK_CC_EVAL_DPRINTF(("%s: cWords=%d\n", g_apszEvalInstrNms[enmOpcode], cWords));
     5394        if (cWords)
     5395        {
     5396            PKMKCCEVALVARIABLES pInstr = (PKMKCCEVALVARIABLES)kmk_cc_block_alloc_eval(pCompiler->ppBlockTail,
     5397                                                                                      KMKCCEVALVARIABLES_SIZE(cWords));
     5398            pInstr->Core.enmOpcode = enmOpcode;
     5399            pInstr->Core.iLine     = pCompiler->iLine;
     5400            pInstr->cVars         = cWords;
     5401            kmk_cc_eval_init_spp_array_from_duplicated_words(pCompiler, cWords, pCompiler->paWords, pInstr->aVars);
     5402            kmk_cc_block_realign(pCompiler->ppBlockTail);
     5403        }
     5404        else
     5405            KMK_CC_ASSERT(0);
     5406    }
     5407    /* else: NOP */
     5408    return 1;
     5409}
     5410
     5411
     5412/**
     5413 * Parses a '[qualifiers] undefine variable [..]' expression.
    53615414 *
    53625415 * A 'undefine' directive is final, any qualifiers must preceed it.  So, we just
     
    53725425static int kmk_cc_eval_do_var_undefine(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, unsigned fQualifiers)
    53735426{
    5374     kmk_cc_eval_fatal(pCompiler, pchWord, "undefine handling not implemented yet");
    5375     return 1;
    5376 }
    5377 
    5378 
    5379 /**
    5380  * Parses a 'define variable' expression.
    5381  *
    5382  * A 'define' directive is final, any qualifiers must preceed it.  So, we just
    5383  * have to extract the variable name now, well and find the corresponding
    5384  * 'endef'.
     5427    KMK_CC_EVAL_SKIP_SPACES_AFTER_WORD(pCompiler, pchWord, cchLeft);
     5428    if (!cchLeft)
     5429        kmk_cc_eval_fatal(pCompiler, pchWord, "undefine requires a variable name");
     5430
     5431    /** @todo GNU make doesn't actually do the list thing for undefine, it seems
     5432     *        to assume everything after it is a single variable...  Going with
     5433     *        simple common code for now. */
     5434    return kmk_cc_eval_do_with_variable_list(pCompiler, pchWord, cchLeft, kKmkCcEvalInstr_undefine, fQualifiers);
     5435}
     5436
     5437
     5438/**
     5439 * Parses a '[qualifiers] unexport variable [..]' expression.
     5440 *
     5441 * A 'unexport' directive is final, any qualifiers must preceed it.  So, we just
     5442 * have to extract the variable names now.
    53855443 *
    53865444 * @returns 1 to indicate we've handled a keyword (see
     
    53915449 * @param   fQualifiers The qualifiers.
    53925450 */
     5451static int kmk_cc_eval_do_var_unexport(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, unsigned fQualifiers)
     5452{
     5453    /*
     5454     * Join paths with undefine and export, unless it's an unexport all directive.
     5455     */
     5456    KMK_CC_EVAL_SKIP_SPACES_AFTER_WORD(pCompiler, pchWord, cchLeft);
     5457    if (cchLeft)
     5458        return kmk_cc_eval_do_with_variable_list(pCompiler, pchWord, cchLeft, kKmkCcEvalInstr_unexport, fQualifiers);
     5459
     5460    /*
     5461     * We're unexporting all variables.
     5462     */
     5463    PKMKCCEVALCORE pInstr = kmk_cc_block_alloc_eval(pCompiler->ppBlockTail, sizeof(*pInstr));
     5464    pInstr->enmOpcode = kKmkCcEvalInstr_unexport_all;
     5465    pInstr->iLine     = pCompiler->iLine;
     5466    return 1;
     5467}
     5468
     5469
     5470/**
     5471 * Parses a 'define variable' expression.
     5472 *
     5473 * A 'define' directive is final, any qualifiers must preceed it.  So, we just
     5474 * have to extract the variable name now, well and find the corresponding
     5475 * 'endef'.
     5476 *
     5477 * @returns 1 to indicate we've handled a keyword (see
     5478 *          kmk_cc_eval_try_handle_keyword).
     5479 * @param   pCompiler   The compiler state.
     5480 * @param   pchWord     First char after 'define'.
     5481 * @param   cchLeft     The number of chars left to parse on this line.
     5482 * @param   fQualifiers The qualifiers.
     5483 */
    53935484static int kmk_cc_eval_do_var_define(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, unsigned fQualifiers)
    53945485{
     
    54005491
    54015492
    5402 static int kmk_cc_eval_handle_assignment_or_recipe(PKMKCCEVALCOMPILER pCompiler, const char *pchTmp,
    5403                                                    const char *pchWord, size_t cchLeft, unsigned fQualifiers)
     5493static int kmk_cc_eval_handle_assignment_or_recipe(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft,
     5494                                                   unsigned fQualifiers)
    54045495{
    54055496    /*
     
    56185709        fPlainValue = memchr(pchWord, '$', cchLeft) == NULL;
    56195710
     5711
    56205712        /*
    56215713         * Emit the instruction.
     
    56575749
    56585750/**
    5659  * Parses a 'local [override] variable = value' expression.
     5751 * Parses a 'local [override] variable = value', 'local define variable', and
     5752 * 'local undefine variable [...]' expressions.
    56605753 *
    56615754 * The 'local' directive must be first and it does not permit any qualifiers at
     
    56755768    {
    56765769        /*
    5677          * Find the end of the variable name.
     5770         * Check for 'local define' and 'local undefine'
    56785771         */
    5679 
    5680     }
    5681     else
    5682         kmk_cc_eval_fatal(pCompiler, pchWord, "Expected variable name, assignment operator and value after 'local'");
    5683     return 1;
    5684 }
    5685 
    5686 
    5687 /**
    5688  * Parses 'export [variable]' and 'export [qualifiers] variable = value'
    5689  * expressions.
    5690  *
    5691  * When we find the 'export' directive at the start of a line, we need to
    5692  * continue parsing with till we can tell the difference between the two forms.
    5693  *
    5694  * @returns 1 to indicate we've handled a keyword (see
    5695  *          kmk_cc_eval_try_handle_keyword).
    5696  * @param   pCompiler   The compiler state.
    5697  * @param   pchWord     First char after 'define'.
    5698  * @param   cchLeft     The number of chars left to parse on this line.
    5699  * @param   fQualifiers The qualifiers.
    5700  */
    5701 static int kmk_cc_eval_handle_var_export(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, unsigned fQualifiers)
    5702 {
    5703     kmk_cc_eval_fatal(pCompiler, pchWord, "export not implemented yet");
     5772        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6))   /* final */
     5773            return kmk_cc_eval_do_var_define(pCompiler, pchWord + 6, cchLeft + 6, KMK_CC_EVAL_QUALIFIER_LOCAL);
     5774        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8))   /* final */
     5775            return kmk_cc_eval_do_var_undefine(pCompiler, pchWord + 8, cchLeft + 8, KMK_CC_EVAL_QUALIFIER_LOCAL);
     5776
     5777        /*
     5778         * Simpler to just join paths with the rest here, even if we could
     5779         * probably optimize the parsing a little if we liked.
     5780         */
     5781        return kmk_cc_eval_handle_assignment_or_recipe(pCompiler, pchWord, cchLeft, KMK_CC_EVAL_QUALIFIER_LOCAL);
     5782    }
     5783    kmk_cc_eval_fatal(pCompiler, pchWord, "Expected variable name, assignment operator and value after 'local'");
    57045784    return 1;
    57055785}
     
    57275807            if (KMK_CC_EVAL_IS_1ST_IN_VARIABLE_KEYWORD(ch))
    57285808            {
    5729                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6))   /* final */
     5809                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6))   /* final */
    57305810                    return kmk_cc_eval_do_var_define(pCompiler, pchWord + 6, cchLeft - 6, fQualifiers);
    57315811
    5732                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8)) /* final */
    5733                     return kmk_cc_eval_do_var_undefine(pCompiler, pchWord + 6, cchLeft - 6, fQualifiers);
    5734 
    5735                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "export", 6))
     5812                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8)) /* final */
     5813                    return kmk_cc_eval_do_var_undefine(pCompiler, pchWord + 8, cchLeft -86, fQualifiers);
     5814
     5815                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "unexport", 8)) /* final */
     5816                    return kmk_cc_eval_do_var_unexport(pCompiler, pchWord + 8, cchLeft - 8, fQualifiers);
     5817
     5818                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "export", 6))
    57365819                {
    57375820                    if (!(fQualifiers & KMK_CC_EVAL_QUALIFIER_EXPORT))
     
    57445827                }
    57455828
    5746                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "override", 8))
     5829                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "override", 8))
    57475830                {
    57485831                    if (!(fQualifiers & KMK_CC_EVAL_QUALIFIER_OVERRIDE))
     
    57555838                }
    57565839
    5757                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "private", 7))
     5840                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "private", 7))
    57585841                {
    57595842                    if (!(fQualifiers & KMK_CC_EVAL_QUALIFIER_PRIVATE))
     
    57755858                const char *pchEqual = (const char *)memchr(pchWord, '=', cchLeft);
    57765859                if (pchEqual)
    5777                     return kmk_cc_eval_handle_assignment_or_recipe(pCompiler, pchEqual, pchWord, cchLeft, fQualifiers);
     5860                    return kmk_cc_eval_handle_assignment_or_recipe(pCompiler, pchWord, cchLeft, fQualifiers);
    57785861            }
    57795862            return 0;
     
    57875870
    57885871/**
     5872 * Parses 'export [variable]' and 'export [qualifiers] variable = value'
     5873 * expressions.
     5874 *
     5875 * When we find the 'export' directive at the start of a line, we need to
     5876 * continue parsing with till we can tell the difference between the two forms.
     5877 *
     5878 * @returns 1 to indicate we've handled a keyword (see
     5879 *          kmk_cc_eval_try_handle_keyword).
     5880 * @param   pCompiler   The compiler state.
     5881 * @param   pchWord     First char after 'define'.
     5882 * @param   cchLeft     The number of chars left to parse on this line.
     5883 */
     5884static int kmk_cc_eval_handle_var_export(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft)
     5885{
     5886    KMK_CC_EVAL_SKIP_SPACES_AFTER_WORD(pCompiler, pchWord, cchLeft);
     5887
     5888    if (cchLeft)
     5889    {
     5890        /*
     5891         * We need to figure out whether this is an assignment or a export statement,
     5892         * in the latter case join paths with 'export' and 'undefine'.
     5893         */
     5894        const char *pchEqual = (const char *)memchr(pchWord, '=', cchLeft);
     5895        if (!pchEqual)
     5896            return kmk_cc_eval_do_with_variable_list(pCompiler, pchWord, cchLeft, kKmkCcEvalInstr_export, 0 /*fQualifiers*/);
     5897
     5898        /*
     5899         * Found an '=', could be an assignment.  Let's take the easy way out
     5900         * and just parse the whole statement into words like we would do if
     5901         * it wasn't an assignment, and then check the words out for
     5902         * assignment keywords and operators.
     5903         */
     5904        unsigned iSavedEscEol = pCompiler->iEscEol;
     5905        unsigned cWords       = kmk_cc_eval_parse_words(pCompiler, pchWord, cchLeft);
     5906        if (cWords)
     5907        {
     5908            PKMKCCEVALWORD pWord = pCompiler->paWords;
     5909            unsigned       iWord = 0;
     5910            while (iWord < cWords)
     5911            {
     5912                /* Trailing assignment operator or terminal assignment directive ('undefine'
     5913                   and 'unexport' makes no sense here but GNU make ignores that). */
     5914                if (   (   pWord->cchWord > 1
     5915                        && pWord->pchWord[pWord->cchWord - 1] == '=')
     5916                    || KMK_CC_STRCMP_CONST(pWord->pchWord, pWord->cchWord, "define", 6)
     5917                    || KMK_CC_STRCMP_CONST(pWord->pchWord, pWord->cchWord, "undefine", 8)
     5918                    || KMK_CC_STRCMP_CONST(pWord->pchWord, pWord->cchWord, "unexport", 8) )
     5919                {
     5920                    pCompiler->iEscEol = iSavedEscEol;
     5921                    return kmk_cc_eval_try_handle_var_with_keywords(pCompiler, pchWord, cchLeft, KMK_CC_EVAL_QUALIFIER_EXPORT);
     5922                }
     5923
     5924                /* If not a variable assignment qualifier, it must be a variable name
     5925                   followed by an assignment operator. */
     5926                if (iWord + 1 < cWords)
     5927                {
     5928                    if (   !KMK_CC_STRCMP_CONST(pWord->pchWord, pWord->cchWord, "export", 6)
     5929                        && !KMK_CC_STRCMP_CONST(pWord->pchWord, pWord->cchWord, "private", 7)
     5930                        && !KMK_CC_STRCMP_CONST(pWord->pchWord, pWord->cchWord, "override", 8))
     5931                    {
     5932                        pWord++;
     5933                        if (   pWord->cchWord > 0
     5934                            && (   pWord->pchWord[0] == '='
     5935                                || (   pWord->cchWord > 1
     5936                                    && pWord->pchWord[1] == '='
     5937                                    && (   pWord->pchWord[0] == ':'
     5938                                        || pWord->pchWord[0] == '+'
     5939                                        || pWord->pchWord[0] == '?'
     5940                                        || pWord->pchWord[0] == '<') ) ) )
     5941                        {
     5942                            pCompiler->iEscEol = iSavedEscEol;
     5943                            return kmk_cc_eval_try_handle_var_with_keywords(pCompiler, pchWord, cchLeft,
     5944                                                                            KMK_CC_EVAL_QUALIFIER_EXPORT);
     5945                        }
     5946                        break;
     5947                    }
     5948                }
     5949                else
     5950                    break;
     5951                /* next */
     5952                pWord++;
     5953                iWord++;
     5954            }
     5955
     5956            /*
     5957             * It's not an assignment.
     5958             * (This is the same as kmk_cc_eval_do_with_variable_list does.)
     5959             */
     5960            PKMKCCEVALVARIABLES pInstr = (PKMKCCEVALVARIABLES)kmk_cc_block_alloc_eval(pCompiler->ppBlockTail,
     5961                                                                                      KMKCCEVALVARIABLES_SIZE(cWords));
     5962            pInstr->Core.enmOpcode = kKmkCcEvalInstr_export;
     5963            pInstr->Core.iLine     = pCompiler->iLine;
     5964            pInstr->cVars          = cWords;
     5965            kmk_cc_eval_init_spp_array_from_duplicated_words(pCompiler, cWords, pCompiler->paWords, pInstr->aVars);
     5966            kmk_cc_block_realign(pCompiler->ppBlockTail);
     5967        }
     5968        else
     5969            KMK_CC_ASSERT(0);
     5970    }
     5971    else
     5972    {
     5973        /*
     5974         * We're exporting all variables.
     5975         */
     5976        PKMKCCEVALCORE pInstr = kmk_cc_block_alloc_eval(pCompiler->ppBlockTail, sizeof(*pInstr));
     5977        pInstr->enmOpcode = kKmkCcEvalInstr_export_all;
     5978        pInstr->iLine     = pCompiler->iLine;
     5979    }
     5980    return 1;
     5981}
     5982
     5983
     5984/**
    57895985 * When entering this function we know that the first two character in the first
    57905986 * word both independently occurs in keywords.
     
    58116007    if (KMK_CC_EVAL_IS_1ST_IN_VARIABLE_KEYWORD(ch))
    58126008    {
    5813         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "local", 5))
     6009        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "local", 5))
    58146010            return kmk_cc_eval_do_var_local(pCompiler, pchWord + 5, cchLeft - 5);
    5815         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6))
     6011        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6))
    58166012            return kmk_cc_eval_do_var_define(pCompiler, pchWord + 6, cchLeft - 6, 0);
    5817         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "export", 6))
    5818             return kmk_cc_eval_handle_var_export(pCompiler, pchWord + 6, cchLeft - 6, 0);
    5819         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8))
     6013        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "export", 6))
     6014            return kmk_cc_eval_handle_var_export(pCompiler, pchWord + 6, cchLeft - 6);
     6015        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8))
    58206016            return kmk_cc_eval_do_var_undefine(pCompiler, pchWord + 8, cchLeft - 8, 0);
    5821         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "override", 8))
     6017        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "unexport", 8))
     6018            return kmk_cc_eval_do_var_unexport(pCompiler, pchWord + 8, cchLeft - 8, 0);
     6019        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "override", 8))
    58226020        {
    58236021            if (kmk_cc_eval_try_handle_var_with_keywords(pCompiler, pchWord + 8, cchLeft - 8, KMK_CC_EVAL_QUALIFIER_OVERRIDE))
     
    58256023            pCompiler->iEscEol = iSavedEscEol;
    58266024        }
    5827         else if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "private", 7))
     6025        else if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "private", 7))
    58286026        {
    58296027            if (kmk_cc_eval_try_handle_var_with_keywords(pCompiler, pchWord + 7, cchLeft - 7, KMK_CC_EVAL_QUALIFIER_PRIVATE))
     
    58456043        if (ch2 == 'f')
    58466044        {
    5847             if (KMK_CC_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
     6045            if (KMK_CC_EVAL_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
    58486046                return kmk_cc_eval_do_if(pCompiler, pchWord, cchLeft, 0 /* in else */);
    58496047
    5850             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "eq", 2))
     6048            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "eq", 2))
    58516049                return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 2, cchLeft - 2, 0 /* in else */, 1 /* positive */);
    58526050
    5853             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "def", 3))
     6051            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "def", 3))
    58546052                return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 3, cchLeft - 3, 0 /* in else */, 1 /* positive */);
    58556053
    5856             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "neq", 3))
     6054            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "neq", 3))
    58576055                return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 3, cchLeft - 3, 0 /* in else */, 0 /* positive */);
    58586056
    5859             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "1of", 3))
     6057            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "1of", 3))
    58606058                return kmk_cc_eval_do_if1of(pCompiler, pchWord + 3, cchLeft - 3, 0 /* in else */, 1 /* positive */);
    58616059
    5862             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "ndef", 4))
     6060            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "ndef", 4))
    58636061                return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 4, cchLeft - 4, 0 /* in else */, 0 /* positive */);
    58646062
    5865             if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "n1of", 4))
     6063            if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "n1of", 4))
    58666064                return kmk_cc_eval_do_if1of(pCompiler, pchWord + 4, cchLeft - 4, 0 /* in else */, 0 /* positive */);
    58676065        }
     
    58716069            pchWord += 5;
    58726070            cchLeft -= 5;
    5873             if (KMK_CC_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
     6071            if (KMK_CC_EVAL_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
    58746072                return kmk_cc_eval_do_include(pCompiler, pchWord, cchLeft, kKmkCcEvalInstr_include);
    58756073            if (cchLeft >= 3 && KMK_CC_WORD_COMP_CONST_3(pchWord, "dep"))
     
    58776075                pchWord += 3;
    58786076                cchLeft -= 3;
    5879                 if (KMK_CC_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
     6077                if (KMK_CC_EVAL_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))
    58806078                    return kmk_cc_eval_do_include(pCompiler, pchWord, cchLeft, kKmkCcEvalInstr_includedep);
    5881                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "-queue", 6))
     6079                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "-queue", 6))
    58826080                    return kmk_cc_eval_do_include(pCompiler, pchWord + 6, cchLeft - 6, kKmkCcEvalInstr_includedep_queue);
    5883                 if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "-flush", 6))
     6081                if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "-flush", 6))
    58846082                    return kmk_cc_eval_do_include(pCompiler, pchWord + 6, cchLeft - 6, kKmkCcEvalInstr_includedep_flush);
    58856083            }
     
    58886086    else if (ch == 'e') /* A few directives starts with 'e'. */
    58896087    {
    5890         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "else", 4))
     6088        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "else", 4))
    58916089            return kmk_cc_eval_do_else(pCompiler, pchWord + 4, cchLeft - 4);
    5892         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "endif", 5))
     6090        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "endif", 5))
    58936091            return kmk_cc_eval_do_endif(pCompiler, pchWord + 5, cchLeft - 5);
    58946092        /* export and endef are handled elsewhere, though stray endef's may end up here... */
    5895         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "export", 6));
     6093        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "export", 6));
    58966094
    58976095    }
    58986096    else /* the rest. */
    58996097    {
    5900         if (   KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "sinclude", 8)
    5901             || KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "-include", 8))
     6098        if (   KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "sinclude", 8)
     6099            || KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "-include", 8))
    59026100            return kmk_cc_eval_do_include(pCompiler, pchWord + 8, cchLeft - 8, kKmkCcEvalInstr_include_silent);
    5903         if (KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "vpath", 5))
     6101        if (KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "vpath", 5))
    59046102            return kmk_cc_eval_do_vpath(pCompiler, pchWord + 5, cchLeft - 5);
    59056103
    5906         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "local", 5));
    5907         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6));
    5908         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "private", 7));
    5909         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "override", 8));
    5910         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "unexport", 8));
    5911         KMK_CC_ASSERT(!KMK_CC_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8));
     6104        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "local", 5));
     6105        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "define", 6));
     6106        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "private", 7));
     6107        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "override", 8));
     6108        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "unexport", 8));
     6109        KMK_CC_ASSERT(!KMK_CC_EVAL_WORD_COMP_CONST(pCompiler, pchWord, cchLeft, "undefine", 8));
    59126110    }
    59136111
     
    61496347                        pchTmp = (const char *)memchr(pchWord, '=', cchLeft);
    61506348                        if (pchTmp)
    6151                             kmk_cc_eval_handle_assignment_or_recipe(&Compiler, pchTmp, pchWord, cchLeft, 0);
     6349                            kmk_cc_eval_handle_assignment_or_recipe(&Compiler, pchWord, cchLeft, 0 /*fQualifiers*/);
    61526350                        else
    61536351                            kmk_cc_eval_handle_recipe(&Compiler, pchTmp, pchWord, cchLeft);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette