From 35f1292815ca3c315222ebac0c91c2bf0e495eee Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Wed, 28 Mar 2012 14:18:42 -0700 Subject: iASL: Implement #line directive in compiler lexer. Move main compiler support for #line from the parser to the lexer. This simplifies the implementation, and allows #line to appear within any ASL statement (the entire line where #line appears is simply removed from the input after the new line number is set.) --- source/compiler/prscan.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'source/compiler/prscan.c') diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c index 5c8ca199a..e98e18603 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -732,6 +732,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 */ @@ -764,8 +789,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 -- cgit v1.2.3