<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <font size="4"><font face="monospace">Before we start to do
        architectural surgery, let's back up a bit and try to distill
        some requirements and goals.  What problems led you here?  Are
        these tools we expect people to run full-time, or mostly for
        debugging when something goes wrong?  Can they be applied to
        ordinary classfiles, or do they have to work during building? 
        Could this be framed as a kind of transform, instead of a new
        concept?  <br>
        <br>
        <br>
      </font></font><br>
    <div class="moz-cite-prefix">On 8/19/2022 2:34 AM, Adam Sotona
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CY4PR1001MB2150449B26B42D24F24EDC688C6C9@CY4PR1001MB2150.namprd10.prod.outlook.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";
        mso-fareast-language:EN-GB;}span.literal
        {mso-style-name:literal;}span.st0
        {mso-style-name:st0;}span.comment
        {mso-style-name:comment;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}ol
        {margin-bottom:0cm;}ul
        {margin-bottom:0cm;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Hi,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">I’ve
            started working on various helper tools that can give user
            answers during code building.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Answers
            to questions like:<o:p></o:p></span></p>
        <ul style="margin-top:0cm" type="disc">
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">What is actual
              instructions count<o:p></o:p></span></li>
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">What is actual/max
              depts of the stack<o:p></o:p></span></li>
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">Which locals have
              been used<o:p></o:p></span></li>
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">What kinds or exact
              types are at locals<o:p></o:p></span></li>
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">What kinds or exact
              types are on stack<o:p></o:p></span></li>
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">Show me a log of all
              instructions<o:p></o:p></span></li>
          <li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt" lang="EN-US">…<o:p></o:p></span></li>
        </ul>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Each
            of this question has specific use case and calculation of
            each answer scarifies different amount of resources.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Unfortunately
            implementation of tool answering any of the above questions
            requires:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">-
            either heavy use of BufferedCodeBuilder (and complicate
            existing building or transformation blocks a lot)<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">-
            or hacking into CodeBuilder(s) implementation<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">I
            would like to propose a similar approach as Linux “tee” tool
            does, so user can attach another consumer of the
            CodeElements passed to the CodeBuilder.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">It
            might be just a single method in CodeBuilder:<o:p></o:p></span></p>
        <p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier
            New";color:#336BDD;mso-fareast-language:EN-GB" lang="EN-US">   
          </span><span style="font-size:10.0pt;font-family:"Courier
            New";color:#336BDD;mso-fareast-language:EN-GB">default</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">
          </span><span style="font-size:10.0pt;font-family:"Courier
            New";color:#336BDD;mso-fareast-language:EN-GB">void</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">
            <b>tee</b>(Consumer<CodeElement> </span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB" lang="EN-US">secondListener</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">,
            Consumer<CodeBuilder> handler) {<o:p></o:p></span></p>
        <p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">       
            handler.accept(</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:#336BDD;mso-fareast-language:EN-GB">new</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">
            TeeCodeBuilder(</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:#336BDD;mso-fareast-language:EN-GB">this</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">,
          </span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB" lang="EN-US">secondListener</span><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">));<o:p></o:p></span></p>
        <p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier
            New";color:black;mso-fareast-language:EN-GB">    }<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Use
            case may then look for example like this:<o:p></o:p></span></p>
        <pre style="background:white"><span style="color:black">        </span><span class="literal"><span style="color:#336BDD">var</span></span><span style="color:black"> stackCounter = ...</span><span class="comment"><span style="color:#969696">//custom computation tool</span></span><span style="color:black"><o:p></o:p></span></pre>
        <pre style="background:white"><span style="color:black">        <span class="st0"><i>codeBuilder</i></span>.<span class="st0"><i>tee</i></span>(stackCounter, cb -> {<o:p></o:p></span></pre>
        <pre style="background:white"><span style="color:black">            ... </span><span class="comment"><span style="color:#969696">//block of instructions to be counted</span></span><span style="color:black"><o:p></o:p></span></pre>
        <pre style="background:white"><span style="color:black">        });<o:p></o:p></span></pre>
        <pre style="background:white"><span style="color:black">        stackCounter.<span class="st0"><i>actual</i></span>();<o:p></o:p></span></pre>
        <pre style="background:white"><span style="color:black">        stackCounter.<span class="st0"><i>max</i></span>();<o:p></o:p></span></pre>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">What
            do you think about this CodeBuilder hook for various
            instructions-consuming computation tools?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Thanks,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Adam<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>