[fpc-devel] tree.log

Adriaan van Os fpc at microbizz.nl
Mon Feb 8 16:23:10 CET 2010


When compiling with verbose option -vp, a tree.log file is created with a parse tree. This is quite 
useful for compiler development.

The tree.log is created right after parsing. This means that
- location information is still invalid
- tree changes in the first pass of code generation are not reflected in the tree.

So, if we are interested in the missing information, we need a tree print after the first pass of 
code generation also. The attached patch does that. Below an example of the result.

Regards,

Adriaan van Os


OLD tree.log fragment

*******************************************************************************
r(objproc);
*******************************************************************************
(blockn, resultdef = "untyped", pos = (16,3), loc = LOC_INVALID, expectloc = LOC_INVALID
    (statementn, resultdef = <nil>, pos = (18,3), loc = LOC_INVALID, expectloc = LOC_INVALID
       (calln, resultdef = "untyped", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_INVALID
          proc = <nil>
          right =
          (loadn, resultdef = "<procedure variable type of procedure(<Pointer>) of 
object;Register>", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_INVALID
             nil
             symbol = PP
          )
          left =
          (callparan, resultdef = <nil>, pos = (18,3), loc = LOC_INVALID, expectloc = LOC_INVALID
             (nothingn, resultdef = "untyped", pos = (18,3), loc = LOC_INVALID, expectloc = LOC_INVALID
             )

          )
       )

    )
)


NEW tree.log fragment

*******************************************************************************
after parsing
r(objproc);
*******************************************************************************
(blockn, resultdef = "untyped", pos = (16,3), loc = LOC_INVALID, expectloc = LOC_INVALID
    (statementn, resultdef = <nil>, pos = (18,3), loc = LOC_INVALID, expectloc = LOC_INVALID
       (calln, resultdef = "untyped", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_INVALID
          proc = <nil>
          right =
          (loadn, resultdef = "<procedure variable type of procedure(<Pointer>) of 
object;Register>", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_INVALID
             nil
             symbol = PP
          )
          left =
          (callparan, resultdef = <nil>, pos = (18,3), loc = LOC_INVALID, expectloc = LOC_INVALID
             (nothingn, resultdef = "untyped", pos = (18,3), loc = LOC_INVALID, expectloc = LOC_INVALID
             )

          )
       )

    )
)

*******************************************************************************
after the firstpass
r(objproc);
*******************************************************************************
(blockn, resultdef = "untyped", pos = (16,3), loc = LOC_INVALID, expectloc = LOC_VOID
    (statementn, resultdef = <nil>, pos = (18,3), loc = LOC_INVALID, expectloc = LOC_VOID
       (calln, resultdef = "untyped", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_VOID
          proc = <nil>
          right =
          (loadn, resultdef = "<procedure variable type of procedure(<Pointer>) of 
object;Register>", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_REF
             nil
             symbol = PP
          )
          left =
          (callparan, resultdef = "^untyped", pos = (18,3), loc = LOC_INVALID, expectloc = LOC_REF
             (subscriptn, resultdef = "^untyped", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_REF
                (typeconvn, resultdef = "<record type>", pos = (17,5), loc = LOC_INVALID, expectloc 
= LOC_REF, convtype = tc_equal
                   (loadn, resultdef = "<procedure variable type of procedure(<Pointer>) of 
object;Register>", pos = (17,5), loc = LOC_INVALID, expectloc = LOC_REF
                      nil
                      symbol = PP
                   )
                )
             )

          )
       )

    )
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fpc-treelog.diff.zip
Type: application/zip
Size: 1176 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20100208/22186aa9/attachment.zip>


More information about the fpc-devel mailing list