<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'><div><font face="Calibri, sans-serif">We get uplevel locals declared while within a function.</font></div><div><font face="Calibri, sans-serif">So I think I'll bite the bullet and make multiple passes now.</font></div><div><font face="Calibri, sans-serif">Otherwise I build up the frame struct "too early".</font></div><div><font face="Calibri, sans-serif">I need to see all the locals -- all the uplevels, early in a function.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">There is also a chance they don't all have unique names.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">I do NOT expect I should have separate frames/static_links per-scope,</font></div><div><font face="Calibri, sans-serif">just per-function.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">I could put structs inside the frame, named after the line they start</font></div><div><font face="Calibri, sans-serif">on or such.. that might be prettier and more readable, or not.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">The structs could then be unioned at some point -- parallel scopes</font></div><div><font face="Calibri, sans-serif">can/should share storage.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">M3C.m3:</font></div><div><font face="Calibri, sans-serif">PROCEDURE declare_local(...)</font></div><div><font face="Calibri, sans-serif">BEGIN</font></div><div><font face="Calibri, sans-serif">...</font></div><div><font face="Calibri, sans-serif">IF u.in_proc THEN</font></div><div><font face="Calibri, sans-serif"> ExtraScope_Open(u);</font></div><div><font face="Calibri, sans-serif"> print(u, var.Declare() & " M3_INIT;");</font></div><div><font face="Calibri, sans-serif"> <* ASSERT up_level = FALSE *> this fails</font></div><div><font face="Calibri, sans-serif"> ELSE</font></div><div><font face="Calibri, sans-serif"> IF up_level THEN</font></div><div><font face="Calibri, sans-serif"> u.current_proc.uplevels := TRUE;</font></div><div><font face="Calibri, sans-serif"> END;</font></div><div><font face="Calibri, sans-serif"> u.current_proc.locals.addhi(var);</font></div><div><font face="Calibri, sans-serif"> END;</font></div><div><font face="Calibri, sans-serif"> RETURN var;</font></div><div><font face="Calibri, sans-serif">END declare_local;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">== package /Users/jay/dev2/cm3/m3-libs/m3tk-misc ==</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">...</font></div><div><font face="Calibri, sans-serif">new source -> compiling Args.m3</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">***</font></div><div><font face="Calibri, sans-serif">*** runtime error:</font></div><div><font face="Calibri, sans-serif">*** <*ASSERT*> failed.</font></div><div><font face="Calibri, sans-serif">*** file "../src/M3C.m3", line 1778</font></div><div><font face="Calibri, sans-serif">***</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> m3_backend => 1536</font></div><div><font face="Calibri, sans-serif">m3cc (aka cm3cg) failed compiling: Args.mc</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">I'm guessing the code is here:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">PROCEDURE Errors(h: Handle; indent: CARDINAL := 0): Text.T RAISES {}=</font></div><div><font face="Calibri, sans-serif"> BEGIN</font></div><div><font face="Calibri, sans-serif"> IF h.errors = 0 THEN</font></div><div><font face="Calibri, sans-serif"> <*FATAL Fatal*> BEGIN RAISE Fatal; END;</font></div><div><font face="Calibri, sans-serif"> ELSE</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> VAR</font></div><div><font face="Calibri, sans-serif"> texts := NEW(REF ARRAY OF TEXT, h.errors * 2);</font></div><div><font face="Calibri, sans-serif"> (* allocates space for all the error messages + padding *)</font></div><div><font face="Calibri, sans-serif"> pos: CARDINAL := 0;</font></div><div><font face="Calibri, sans-serif"> padding := Fmt.Pad("", indent);</font></div><div><font face="Calibri, sans-serif"> fmt: Text.T;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> <*INLINE*> PROCEDURE Add(t: Text.T) RAISES {}=</font></div><div><font face="Calibri, sans-serif"> BEGIN texts[pos] := t; INC(pos) END Add;</font></div><div><font face="Calibri, sans-serif"> <*INLINE*> PROCEDURE PaddedAdd(t: Text.T) RAISES {}=</font></div><div><font face="Calibri, sans-serif"> BEGIN Add(padding); Add(t) END PaddedAdd;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">see how "texts" is both uplevel and "not at the start" of the function.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">This is going to take a few days to deal with.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Compiler can compile itself, and a large swath of the system now.</font></div><div><font face="Calibri, sans-serif">I didn't use the self-built compiler, but I will do that next. It probably works.</font></div><div><font face="Calibri, sans-serif">Very good.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif"> - Jay</font></div><br> </div></body>
</html>