[Refactor] "Nothing node" strip
Summary
This merge request makes an adjustment to the node parser so statement nodes with nothing nodes inside of them actually get stripped, thus aiding data-flow analysis.
System
- Processor architecture: All
Additional Notes
- When
TBlockNode.pass_1
is called, it actually skipped calling pass_1 for the statement nodes and only called it for their children, thus the statement nods'pass_1
andsimplify
methods were never called. - The compiler may run slightly slower due to all of the statement nodes being directly processed rather than skipped.
- Due to being processed, the statement nodes now receive a resultdef (usually
$void
- see below). - Extra compiler code ensures that if a block's first statement is removed, it does not leave a dangling pointer.
- Actual generated code does not change.
Relevant logs and/or screenshots
Using the node dump of x86_64's aoptcpub
- before:
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="255">
<statementn pos="102,1">
<nothingn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0" />
</statementn>
<statementn pos="102,1">
<asmn resultdef="$void" pos="102,1" flags="nf_pass1_done,nf_get_asm_position" complexity="255">
</asmn>
</statementn>
...
After:
<firstpass>
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="255">
<statementn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="255">
<asmn resultdef="$void" pos="102,1" flags="nf_pass1_done,nf_get_asm_position" complexity="255">
</asmn>
</statementn>
...
Later in the same file - before:
...
<statementn pos="102,1">
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0">
<statementn pos="102,1">
<nothingn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0" />
</statementn>
<statementn pos="102,1">
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done,nf_usercode_entry" complexity="0">
</blockn>
</statementn>
<statementn pos="102,1">
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0">
</blockn>
</statementn>
</blockn>
</statementn>
...
After:
...
<statementn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="255">
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0">
<statementn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0">
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done,nf_usercode_entry" complexity="0">
</blockn>
</statementn>
<statementn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0">
<blockn resultdef="$void" pos="102,1" flags="nf_pass1_done" complexity="0">
</blockn>
</statementn>
</blockn>
</statementn>
...
A future merge request should easily be able to strip out these empty blocks (they are functionally the same as nothing nodes), thus simplifying the node tree further.