diff options
author | jkim <jkim@FreeBSD.org> | 2012-04-20 23:39:48 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2012-04-20 23:39:48 +0000 |
commit | eb364ef2c90291c41e896d265d93fe21e48d02a7 (patch) | |
tree | 79677aa8d9d6e5b97246264fe36dcad25ae471a1 /source/compiler/prscan.c | |
parent | 1c3442fdc2bf7441ce8d61d4ce8920ce2fdd9c3e (diff) | |
download | FreeBSD-src-eb364ef2c90291c41e896d265d93fe21e48d02a7.zip FreeBSD-src-eb364ef2c90291c41e896d265d93fe21e48d02a7.tar.gz |
Import ACPICA 20120420.
Diffstat (limited to 'source/compiler/prscan.c')
-rw-r--r-- | source/compiler/prscan.c | 71 |
1 files changed, 47 insertions, 24 deletions
diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c index 3719ca6..3013951 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -161,9 +161,6 @@ PrInitializeGlobals ( Gbl_CurrentLineNumber = 0; Gbl_PreprocessorLineNumber = 1; Gbl_PreprocessorError = FALSE; - - Gbl_MapBlockHead = UtLocalCalloc (sizeof (PR_LINE_MAPPING)); - Gbl_MapBlockHead->Map = UtLocalCalloc (PR_LINES_PER_BLOCK * sizeof (UINT32)); } @@ -186,7 +183,6 @@ PrTerminatePreprocessor ( void) { PR_DEFINE_INFO *DefineInfo; - PR_LINE_MAPPING *MapInfo; /* @@ -202,17 +198,6 @@ PrTerminatePreprocessor ( ACPI_FREE (DefineInfo->Identifier); ACPI_FREE (DefineInfo); } - - /* Clear the line number mappings */ - - while (Gbl_MapBlockHead) - { - MapInfo = Gbl_MapBlockHead; - Gbl_MapBlockHead = MapInfo->Next; - - ACPI_FREE (MapInfo->Map); - ACPI_FREE (MapInfo); - } } @@ -393,8 +378,6 @@ PrPreprocessInputFile ( Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); } - /* Write the possibly modified line to the .i file*/ - #if 0 /* Line prefix */ FlPrintFile (ASL_FILE_PREPROCESSOR, "/* %14s %.5u i:%.5u */ ", @@ -402,11 +385,27 @@ PrPreprocessInputFile ( Gbl_CurrentLineNumber, Gbl_PreprocessorLineNumber); #endif - FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer, - strlen (Gbl_CurrentLineBuffer)); + /* + * Emit a #line directive if necessary, to keep the line numbers in + * the (.i) file synchronized with the original source code file, so + * that the correct line number appears in any error messages + * generated by the actual compiler. + */ + if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1)) + { + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n", + Gbl_CurrentLineNumber); + } - PrSetLineNumber (Gbl_CurrentLineNumber, Gbl_PreprocessorLineNumber); + Gbl_PreviousLineNumber = Gbl_CurrentLineNumber; Gbl_PreprocessorLineNumber++; + + /* + * Now we can write the possibly modified source line to the + * preprocessor (.i) file + */ + FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer, + strlen (Gbl_CurrentLineBuffer)); } } @@ -546,8 +545,9 @@ PrDoDirective ( if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(') { #ifndef MACROS_SUPPORTED - AcpiOsPrintf ("#define macros not supported\n"); - goto SyntaxError; + AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n", + Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber); + exit(1); #else PrAddMacro (Token, Next); #endif @@ -660,6 +660,31 @@ PrDoDirective ( PrOpenIncludeFile (Token); break; + case PR_DIRECTIVE_LINE: + TokenOffset = Token - Gbl_MainTokenBuffer; + + Status = PrResolveIntegerExpression ( + &Gbl_CurrentLineBuffer[TokenOffset-1], &Value); + if (ACPI_FAILURE (Status)) + { + return; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "User #line invocation %s\n", Gbl_CurrentLineNumber, + Token); + + /* Update local line numbers */ + + Gbl_CurrentLineNumber = (UINT32) Value; + Gbl_PreviousLineNumber = 0; + + /* Emit #line into the preprocessor file */ + + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", + Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename); + break; + case PR_DIRECTIVE_PRAGMA: /* Only "#pragma message" supported at this time */ @@ -692,8 +717,6 @@ PrDoDirective ( THIS_TOKEN_OFFSET (Token)); break; - case PR_DIRECTIVE_LINE: - /* TBD: set line number -- or, do this in main compiler */ default: /* Should never get here */ DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID |