- Timestamp:
- Oct 10, 2015 6:28:07 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmk_cc_exec.c
r2801 r2802 556 556 kKmkCcEvalInstr_assign_define, 557 557 558 /** export variable1 [variable2...] - KMKCCEVAL EXPORT. */558 /** export variable1 [variable2...] - KMKCCEVALVARIABLES. */ 559 559 kKmkCcEvalInstr_export, 560 /** unexport variable1 [variable2...] - KMKCCEVAL EXPORT. */560 /** unexport variable1 [variable2...] - KMKCCEVALVARIABLES. */ 561 561 kKmkCcEvalInstr_unexport, 562 562 /** export - KMKCCEVALCORE. */ … … 564 564 /** unexport - KMKCCEVALCORE. */ 565 565 kKmkCcEvalInstr_unexport_all, 566 /** [local|override] undefine - KMKCCEVALVARIABLES. */ 567 kKmkCcEvalInstr_undefine, 568 566 569 567 570 /** [else] ifdef variable - KMKCCEVALIFDEFPLAIN. */ … … 688 691 689 692 /** 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 */ 696 typedef struct kmk_cc_eval_variables 693 697 { 694 698 /** The core instruction. */ … … 696 700 /** The number of variables named in aVars. */ 697 701 uint32_t cVars; 702 /** Whether the 'local' qualifier was used (undefine only). */ 703 uint8_t fLocal; 698 704 /** Pointer to the next instruction. */ 699 705 PKMKCCEVALCORE pNext; … … 702 708 * @remarks Plain text names are in variable_strcache. */ 703 709 KMKCCEXPSUBPROGORPLAIN aVars[1]; 704 } KMKCCEVAL EXPORT;705 typedef KMKCCEVAL EXPORT *PKMKCCEVALEXPORT;706 /** Calculates the size of an KMKCCEVAL EXPORTstructure for @a a_cVars. */707 #define KMKCCEVAL EXPORT_SIZE(a_cVars) KMK_CC_SIZEOF_VAR_STRUCT(KMKCCEVALVPATH, aVars, a_cVars)710 } KMKCCEVALVARIABLES; 711 typedef 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) 708 714 709 715 /** … … 1115 1121 KMK_CC_EVAL_BM_OR(g_abEvalCcChars, 'o', KMK_CC_EVAL_CH_1ST_IN_VARIABLE_KEYWORD); /* override */ 1116 1122 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 */ 1118 1124 1119 1125 /* Assignment punctuation and recipe stuff. */ … … 3391 3397 && (a_pchLine)[15] == (a_pszWord)[15]) 3392 3398 #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 3393 3405 /** 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) \ 3395 3407 ( (a_cchLine) == 0 \ 3396 3408 || KMK_CC_EVAL_IS_SPACE((a_pchLine)[0]) \ … … 3398 3410 3399 3411 /** 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) \ 3401 3413 ( (a_cchLine) >= (a_cchWord) \ 3402 3414 && ( (a_cchLine) == (a_cchWord) \ … … 5187 5199 cchLeft -= 2; 5188 5200 5189 if (KMK_CC_ WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))5201 if (KMK_CC_EVAL_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft)) 5190 5202 return kmk_cc_eval_do_if(pCompiler, pchWord, cchLeft, 1 /* in else */); 5191 5203 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)) 5193 5205 return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 2, cchLeft - 2, 1 /* in else */, 1 /* positive */); 5194 5206 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)) 5196 5208 return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 3, cchLeft - 3, 1 /* in else */, 1 /* positive */); 5197 5209 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)) 5199 5211 return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 3, cchLeft - 3, 1 /* in else */, 0 /* positive */); 5200 5212 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)) 5202 5214 return kmk_cc_eval_do_if1of(pCompiler, pchWord + 3, cchLeft - 3, 1 /* in else */, 1 /* positive */); 5203 5215 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)) 5205 5217 return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 4, cchLeft - 4, 1 /* in else */, 0 /* positive */); 5206 5218 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)) 5208 5220 return kmk_cc_eval_do_if1of(pCompiler, pchWord + 4, cchLeft - 4, 1 /* in else */, 0 /* positive */); 5209 5221 … … 5300 5312 KMKCCEVALINCLUDE_SIZE(cWords)); 5301 5313 pInstr->Core.enmOpcode = enmOpcode; 5302 pInstr->Core.iLine = 0;5314 pInstr->Core.iLine = pCompiler->iLine; 5303 5315 pInstr->cFiles = cWords; 5304 5316 kmk_cc_eval_init_spp_array_from_duplicated_words(pCompiler, cWords, pCompiler->paWords, pInstr->aFiles); … … 5330 5342 const char *pchColon, size_t cchLeft, unsigned fQualifiers) 5331 5343 { 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)"); 5333 5345 return 1; 5334 5346 } … … 5338 5350 const char *pchWord, size_t cchLeft, unsigned fQualifiers) 5339 5351 { 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)"); 5341 5353 return 1; 5342 5354 } … … 5345 5357 static void kmk_cc_eval_handle_recipe(PKMKCCEVALCOMPILER pCompiler, const char *pszEqual, const char *pchWord, size_t cchLeft) 5346 5358 { 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)"); 5348 5360 } 5349 5361 … … 5358 5370 5359 5371 /** 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 */ 5383 static 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. 5361 5414 * 5362 5415 * A 'undefine' directive is final, any qualifiers must preceed it. So, we just … … 5372 5425 static int kmk_cc_eval_do_var_undefine(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, unsigned fQualifiers) 5373 5426 { 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. 5385 5443 * 5386 5444 * @returns 1 to indicate we've handled a keyword (see … … 5391 5449 * @param fQualifiers The qualifiers. 5392 5450 */ 5451 static 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 */ 5393 5484 static int kmk_cc_eval_do_var_define(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, unsigned fQualifiers) 5394 5485 { … … 5400 5491 5401 5492 5402 static int kmk_cc_eval_handle_assignment_or_recipe(PKMKCCEVALCOMPILER pCompiler, const char *pch Tmp,5403 const char *pchWord, size_t cchLeft,unsigned fQualifiers)5493 static int kmk_cc_eval_handle_assignment_or_recipe(PKMKCCEVALCOMPILER pCompiler, const char *pchWord, size_t cchLeft, 5494 unsigned fQualifiers) 5404 5495 { 5405 5496 /* … … 5618 5709 fPlainValue = memchr(pchWord, '$', cchLeft) == NULL; 5619 5710 5711 5620 5712 /* 5621 5713 * Emit the instruction. … … 5657 5749 5658 5750 /** 5659 * Parses a 'local [override] variable = value' expression. 5751 * Parses a 'local [override] variable = value', 'local define variable', and 5752 * 'local undefine variable [...]' expressions. 5660 5753 * 5661 5754 * The 'local' directive must be first and it does not permit any qualifiers at … … 5675 5768 { 5676 5769 /* 5677 * Find the end of the variable name.5770 * Check for 'local define' and 'local undefine' 5678 5771 */ 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'"); 5704 5784 return 1; 5705 5785 } … … 5727 5807 if (KMK_CC_EVAL_IS_1ST_IN_VARIABLE_KEYWORD(ch)) 5728 5808 { 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 */ 5730 5810 return kmk_cc_eval_do_var_define(pCompiler, pchWord + 6, cchLeft - 6, fQualifiers); 5731 5811 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)) 5736 5819 { 5737 5820 if (!(fQualifiers & KMK_CC_EVAL_QUALIFIER_EXPORT)) … … 5744 5827 } 5745 5828 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)) 5747 5830 { 5748 5831 if (!(fQualifiers & KMK_CC_EVAL_QUALIFIER_OVERRIDE)) … … 5755 5838 } 5756 5839 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)) 5758 5841 { 5759 5842 if (!(fQualifiers & KMK_CC_EVAL_QUALIFIER_PRIVATE)) … … 5775 5858 const char *pchEqual = (const char *)memchr(pchWord, '=', cchLeft); 5776 5859 if (pchEqual) 5777 return kmk_cc_eval_handle_assignment_or_recipe(pCompiler, pch Equal, pchWord, cchLeft, fQualifiers);5860 return kmk_cc_eval_handle_assignment_or_recipe(pCompiler, pchWord, cchLeft, fQualifiers); 5778 5861 } 5779 5862 return 0; … … 5787 5870 5788 5871 /** 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 */ 5884 static 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 /** 5789 5985 * When entering this function we know that the first two character in the first 5790 5986 * word both independently occurs in keywords. … … 5811 6007 if (KMK_CC_EVAL_IS_1ST_IN_VARIABLE_KEYWORD(ch)) 5812 6008 { 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)) 5814 6010 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)) 5816 6012 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)) 5820 6016 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)) 5822 6020 { 5823 6021 if (kmk_cc_eval_try_handle_var_with_keywords(pCompiler, pchWord + 8, cchLeft - 8, KMK_CC_EVAL_QUALIFIER_OVERRIDE)) … … 5825 6023 pCompiler->iEscEol = iSavedEscEol; 5826 6024 } 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)) 5828 6026 { 5829 6027 if (kmk_cc_eval_try_handle_var_with_keywords(pCompiler, pchWord + 7, cchLeft - 7, KMK_CC_EVAL_QUALIFIER_PRIVATE)) … … 5845 6043 if (ch2 == 'f') 5846 6044 { 5847 if (KMK_CC_ WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft))6045 if (KMK_CC_EVAL_WORD_COMP_IS_EOL(pCompiler, pchWord, cchLeft)) 5848 6046 return kmk_cc_eval_do_if(pCompiler, pchWord, cchLeft, 0 /* in else */); 5849 6047 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)) 5851 6049 return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 2, cchLeft - 2, 0 /* in else */, 1 /* positive */); 5852 6050 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)) 5854 6052 return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 3, cchLeft - 3, 0 /* in else */, 1 /* positive */); 5855 6053 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)) 5857 6055 return kmk_cc_eval_do_ifeq( pCompiler, pchWord + 3, cchLeft - 3, 0 /* in else */, 0 /* positive */); 5858 6056 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)) 5860 6058 return kmk_cc_eval_do_if1of(pCompiler, pchWord + 3, cchLeft - 3, 0 /* in else */, 1 /* positive */); 5861 6059 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)) 5863 6061 return kmk_cc_eval_do_ifdef(pCompiler, pchWord + 4, cchLeft - 4, 0 /* in else */, 0 /* positive */); 5864 6062 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)) 5866 6064 return kmk_cc_eval_do_if1of(pCompiler, pchWord + 4, cchLeft - 4, 0 /* in else */, 0 /* positive */); 5867 6065 } … … 5871 6069 pchWord += 5; 5872 6070 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)) 5874 6072 return kmk_cc_eval_do_include(pCompiler, pchWord, cchLeft, kKmkCcEvalInstr_include); 5875 6073 if (cchLeft >= 3 && KMK_CC_WORD_COMP_CONST_3(pchWord, "dep")) … … 5877 6075 pchWord += 3; 5878 6076 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)) 5880 6078 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)) 5882 6080 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)) 5884 6082 return kmk_cc_eval_do_include(pCompiler, pchWord + 6, cchLeft - 6, kKmkCcEvalInstr_includedep_flush); 5885 6083 } … … 5888 6086 else if (ch == 'e') /* A few directives starts with 'e'. */ 5889 6087 { 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)) 5891 6089 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)) 5893 6091 return kmk_cc_eval_do_endif(pCompiler, pchWord + 5, cchLeft - 5); 5894 6092 /* 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)); 5896 6094 5897 6095 } 5898 6096 else /* the rest. */ 5899 6097 { 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)) 5902 6100 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)) 5904 6102 return kmk_cc_eval_do_vpath(pCompiler, pchWord + 5, cchLeft - 5); 5905 6103 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)); 5912 6110 } 5913 6111 … … 6149 6347 pchTmp = (const char *)memchr(pchWord, '=', cchLeft); 6150 6348 if (pchTmp) 6151 kmk_cc_eval_handle_assignment_or_recipe(&Compiler, pch Tmp, pchWord, cchLeft, 0);6349 kmk_cc_eval_handle_assignment_or_recipe(&Compiler, pchWord, cchLeft, 0 /*fQualifiers*/); 6152 6350 else 6153 6351 kmk_cc_eval_handle_recipe(&Compiler, pchTmp, pchWord, cchLeft);
Note:
See TracChangeset
for help on using the changeset viewer.