summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/compiler/prscan.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/prscan.c')
-rw-r--r--sys/contrib/dev/acpica/compiler/prscan.c71
1 files changed, 47 insertions, 24 deletions
diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c
index deabbcb..a47f07f 100644
--- a/sys/contrib/dev/acpica/compiler/prscan.c
+++ b/sys/contrib/dev/acpica/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
OpenPOWER on IntegriCloud