[Note: fixed Jira number: LPP-6834]

Change 20080818-dda-Z by [EMAIL PROTECTED] on 2008-08-18 14:43:32 EDT
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk-a
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: SWF9: line number fixes for error messages

New Features:

Bugs Fixed: LPP-6834 [Line unkown compiler error]

Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    Multiple fixes for line number error messages.

First - line number information was being suppressed unless debug was on. This can make sense for debugging information, but some line number info is needed to remap error messages from generated .as files back to original file/line numbers. The suppression was previously added since building LFC with full linenumber info can blow up memory in the unparser (the line number info in the unparsed strings can get very long as they are replicated over and over in the bottom up unparser (*)). Now we force 'trackLines' to true when not building LFC.

Second - we are careful when we emit: '/* -*- file: foo.lzx#123 - *- */' source locators that are used for the IDE debugger. It turns out that we need to save additional line number information to be used for translating error messages. In the test program given by this Jira, the code that had the error did not correspond to a user input line number (it was an error in lps/ components/rpc/rpc.lzx), the debugger was not told about that line. But the error message still needs to be translated. Now we separate the decision of whether to save line number info for translating error messages vs emitting line number info for the debugger.

Third - there was a tacit assumption on my part that each .as file (i.e. class) generated had source mainly from a single input file. This is not true, for one example, the LzApplication class can contain code from many sources. Now, the line number mapping in TranslationUnit contains both a source file name and a source file line number. In anticipation of future work (see below), I encapsulated a source file name into an object along with a SourceFileMap
    that allows us to give each source file a unique index within
the compilation. This could make for some shorthand notations for file names
    used internally.

(*) Potentially we could fix the out of memory errors by rewriting the unparser to not build up its result using Strings with 'annotated' line numbers but use a more structured output. Possible future work. Or, the annotated strings could become much shorter by using our new source file indices.

In addition, this changeset has a way to dump line number annotations, and introduces an option to consolidate outputs used for debugging the compiler. Now, in addition to saving script files via lzc -S foo.lzx, one can use lzc -SS foo.lzx to generate several files (all named beginning with "NAME-" for
    input file "NAME.lzx") that are useful for debugging the compiler:

NAME-astin-N.txt dumped AST input to the generator (N chosen uniquely)
        NAME-astout-N.txt     dumped AST output from the generator
        NAME-lineann-N.txt    line annotations
        NAME.lzs              script file

    Changes by file:

    SourceFile.java
    SourceFileMap.java
        new files
encapsulate source file names, assigning a unique index for each

    CommonGenerator.java
        Create a SourceFileMap to be used during the compilation

    SWF9Generator.java
    JavascriptGenerator.java
        Use the SourceFileMap with ParseTreePrinter
        Pass the dumpLineAnnotations option to ParseTreePrinter
        turn on trackLines appropriately (SWF9Generator.java)

    SWF9External.java
        Show file and line number from error mapped by TranslationUnit.

    TranslationUnit.java
        Track both filenames (SourceFiles) and line numbers in the
        line number mapping.

    compiler/Main.java
        Implement -SS option

    SWF9ParseTreePrinter.java
        implement dumpAnnotationsFile option

    ParseTreePrinter.java
        implement dumpAnnotationsFile option
Break out the decision to emit source locations for debugger use and tell TranslationUnit about line number info that can be used
        for mapping error messages.
Fixed error where 'previous' line number was given to translation unit.

    sc/Compiler.java
        implement unique numbered file for debug output
        e.g. -dumpASTInput='foo-*.txt' will dump to
        foo-1.txt, then foo-2.txt, etc.
This is convenient when there are multiple calls to the compiler


Tests:
- Backported this change to r10708, which includes the mistake in rpc,
     and tried the test case from LPP-6834, and get the error line:
org.openlaszlo.sc.CompilerError: rpc/rpc.lzx: 202: Error: Access of undefined property LzJavaRPCService, in line: return LzJavaRPCService - Used the same test case in the current tree, but inserted an error (call to undefined 'stuff()',
     and got a valid error message and accurate file and line .
- Tried nexb619.lzx to verify that source locations for debugger are unaffected.

  -  smokecheck SWF8, DHTML
  -  weather+lzpix  ALL
  -  hello   SWF9

Files:
A      WEB-INF/lps/server/src/org/openlaszlo/sc/SourceFile.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
A      WEB-INF/lps/server/src/org/openlaszlo/sc/SourceFileMap.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/ SWF9ParseTreePrinter.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
M      WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20080818-dda-Z.tar



--

Don Anderson
Java/C/C++, Berkeley DB, systems consultant

voice: 617-547-7881
email: [EMAIL PROTECTED]
www: http://www.ddanderson.com



Reply via email to