<div class="gmail_quote">On Mon, Mar 16, 2009 at 3:26 AM, Aaron Gray <span dir="ltr"><<a href="mailto:aaronngray.lists@googlemail.com">aaronngray.lists@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="gmail_quote">
<div class="im">On Sun, Mar 15, 2009 at 10:52 PM, Aaron Gray <span dir="ltr"><<a href="mailto:aaronngray.lists@googlemail.com" target="_blank">aaronngray.lists@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I like the idea of a generic MachineCodeWriter, although I prefer the<br>name 'ObjectFileWriter'...<br>
</blockquote><br></div>Thats much more descriptive of the functionality. 
<div></div></blockquote>
<div> </div></div>
<div>Sorry, I disagree actually the MachineCodeEmitter or the 'MachineCodeWritter' does not do any file handling at all. Do look at the code for the MachineCodeWritter and you will see it only writes to memory and if it reaches the end of the allotted memory I believe higher ordered logic reallocates a larget buffer and starts again from scratch. This could be avoided if they generated fixus for absolute memory references refering within the outputted code. Then a alloc function could be called before outputting say a 4 byte int and could realloc and copy code and when finally written the fixups could be applied.</div>

<div> </div>
<div>I am also wondering about the efficiency of std::vector whether we could use that for the MachineCodeWriter, or whether we write out own code output stream/buffering ?</div>
<div> </div>
<div>I still think this is where the crux of the problem lies the upper logic is relatively simple compared to this buy looking at what you say it is important to get it right.</div>
<div></div></div></blockquote>
<div> </div>
<div> </div>
<div>'ObjectCodeEmitter' looks like the right description to parallel the MachineCodeEmitter. Its emitting object code to a data stream (which is an object file section) and not direct to a file.</div>
<div> </div>
<div>I will knock to gether an ObjectCodeEmitter that is call compatible with the MachineCodeEmitter and wtites to a std::vector<byte>, so it could replace the MachineCodeEmitter class generically in usage.</div>
<div> </div>
<div>This needs alot of thought and to get things right, and provide the right incremental patches to get this accepted.</div>
<div> </div>
<div>Cheers,</div>
<div> </div>
<div>Aaron</div>
<div> </div></div>