<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>why this loop/multipass stuff<br><br><br>So people understand where I'm going here -- and Tony asked. I had already written this up..<br><br><br><br>1) in the past working on m3cc/parse.c, I found that "declare"s<br>weren't always "topologically sorted".<br><br><br>That is, like, I might see:<br><br>given TYPE T1 = INTEGER;<br>TYPE T2 = RECORD = a:T1; END;<br><br><br>I might have seen type T1 declared before T2, or not.<br>I'm not sure if it was record/fields or other relationships.<br>I just remember that building up a map of typeid to data, and<br>looking up it when needed, didn't always work, with one pass.<br><br><br>So what I did is that I was willing to "skip" declares<br>that referred to typeids I hadn't seen yet, and then loop<br>again, hoping for progress at each loop (fewer skips).<br><br><br>2) It looks like declare_local/temp don't all come in<br>"at the start" of a procedure. I'm not sure if I'm generating<br>C or C++, but if I'm generating C, it helps to have declare_local/temp<br>right after begin_procedure/block. Multiple passes let me make that<br>so, without changing m3front.<br>(Upon further looking..it seems this is mostly done right, but<br>not for "try" blocks; maybe reasonable to change m3front here.).<br><br><br>Now, generating C++ is an option, and I'm ignoring all declares<br>currently anyway, so these don't force the matter, but:<br><br><br>3) nested functions.<br>If a function contains any nested functions, I want to put all of<br>its locals in a local struct, and use the address of that struct<br>as the "static link". Or at least the locals that are referenced<br>by nested functions. As well, m3front contains options as to<br>the order of outputing functions. It uses one order for m3back and<br>a different order for m3cc. I wouldn't mind if M3C.m3 worked either<br>way.<br><br><br>There are possibly other benefits that could be derived from multiple passes.<br>Nothing offhand though.<br><br><br> - Jay<br> </div></body>
</html>