<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'>Here is a smaller fix that fixes more cases, i.e. large sets and fixed sized arrays.<br><br><br>Index: values/Formal.m3<br>===================================================================<br>RCS file: /usr/cvs/cm3/m3-sys/m3front/src/values/Formal.m3,v<br>retrieving revision 1.18<br>diff -u -r1.18 Formal.m3<br>--- values/Formal.m3    26 Sep 2012 17:12:37 -0000    1.18<br>+++ values/Formal.m3    19 Apr 2013 04:19:55 -0000<br>@@ -470,6 +470,7 @@<br>       CG.Pop_param (CG.Type.Addr)<br>     ELSIF (is_struct) THEN<br>       EVAL Type.CheckInfo (t.tipe, info);<br>+      Type.Compile (t.tipe);<br>       CG.Pop_struct (Type.GlobalUID (t.tipe), info.size, info.alignment);<br>     ELSE (* by-value scalar *)<br>       CG.Pop_param (Type.CGType (t.tipe, in_memory := TRUE));<br><br><br> - Jay<br><br><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Wed, 17 Apr 2013 16:24:51 +0000<br>Subject: Re: [M3devel] frontend misses a few types<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--></style>
<div dir="ltr">ok, so this fixes it.<br>I still have to build everything to verify.<br>But which of the two lines is right? Both?<br>And what about the comment about the assert?<br>And what about other types like fixed size arrays? I'll try them.<br><br>===================================================================<br>RCS file: /usr/cvs/cm3/m3-sys/m3front/src/values/Formal.m3,v<br>retrieving revision 1.18<br>diff -u -r1.18 Formal.m3<br>--- Formal.m3    26 Sep 2012 17:12:37 -0000    1.18<br>+++ Formal.m3    17 Apr 2013 16:23:29 -0000<br>@@ -600,6 +600,8 @@<br> PROCEDURE GenRecord (t: T;  actual: Expr.T) =<br>   BEGIN<br>     (* <* ASSERT Type.IsEqual (t.tipe, Expr.TypeOf (actual), NIL) *> *)<br>+    Type.Compile (t.tipe);<br>+    Type.Compile (Expr.TypeOf (actual));<br>     CASE t.mode OF<br>     | Mode.mVALUE =><br>         Expr.Compile (actual);<br><br><br>PROCEDURE GenRecord (t: T;  actual: Expr.T) =<br>  BEGIN<br>    (* <* ASSERT Type.IsEqual (t.tipe, Expr.TypeOf (actual), NIL) *> *)<br>    Type.Compile (t.tipe);<br>    Type.Compile (Expr.TypeOf (actual));<br>    CASE t.mode OF<br>    | Mode.mVALUE =><br>        Expr.Compile (actual);<br>    | Mode.mVAR =><br>        Expr.CompileAddress (actual, traced := TRUE);<br>    | Mode.mCONST =><br>        IF Expr.IsDesignator (actual) THEN<br>          Expr.CompileAddress (actual, traced := FALSE);<br>        ELSE<br>          Expr.Compile (actual);<br>          (* not needed because of the ASSERT above: GenCopy (t.tipe); *)<br>        END;<br>    END;<br>  END GenRecord;<br><br><br><br><br><div><div id="ecxSkyDrivePlaceholder"></div><hr id="ecxstopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Wed, 17 Apr 2013 02:47:47 +0000<br>Subject: Re: [M3devel] frontend misses a few types<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}


--></style>
<div dir="ltr">In the frontend, when pop_struct is called, is that too late to declare_record? To compile the type, is it?<br><br><br><br>#0  M3CG_MultiPass__pop_struct (self_L_1033=0x101551758 "", m3_typeid_L_1034=1557134085, byte_size_L_1035=8, alignment_L_1036=8) at M3CG_MultiPass.m3.c:38639<br>#1  0x000000010044718a in M3CG_Check__pop_struct (self_L_369=0x1015525b8, t_L_370=1557134085, s_L_371=8, a_L_372=8) at M3CG_Check.m3.c:34613<br>#2  0x000000010024a584 in CG__Pop_struct (t_L_578=1557134085, s_L_579=64, a_L_580=64) at CG.m3.c:83537<br>#3  0x00000001002ddcd7 in Formal__EmitArg (proc_L_215=0x10151e4c8 "??h", formal_L_216=0x10151c7a0 "?Bj", actual_L_217=0x10151c758 "??h") at Formal.m3.c:15818<br>#4  0x00000001002c3aa7 in UserProc (ce_L_148=0x10151e540 "@\034\020\001\001") at UserProc.m3.c:5026<br>#5  0x000000010019b893 in CallExpr (p_L_149=0x10151e540 "@\034\020\001\001") at CallExpr.m3.c:12276<br>#6  0x0000000100186765 in Expr (t_L_126=0x10151e540 "@\034\020\001\001") at Expr.m3.c:4085<br>#7  0x000000010025a70f in CallStmt__Compile (p_L_36=0x10151e598) at CallStmt.m3.c:1411<br>#8  0x0000000100252d32 in Stmt__Compile (t_L_43=0x10151e598 "??i") at Stmt.m3.c:2881<br>#9  0x0000000100259e79 in BlockStmt__Compile (p_L_69=0x10151e320) at BlockStmt.m3.c:4642<br>#10 0x0000000100252d32 in Stmt__Compile (t_L_43=0x10151e320 "Ċi") at Stmt.m3.c:2881<br>#11 0x00000001002f35b5 in Procedure__GenBody (p_L_318=0x10151e0b0 "?`j") at Procedure.m3.c:21223<br>#12 0x00000001002f38ec in Procedure__EmitBody (x_L_310=0x10151e268) at Procedure.m3.c:19937<br>#13 0x00000001002275b3 in ProcBody__EmitBody (t_L_64=0x10151e268 "?\030\020\001\001") at ProcBody.m3.c:6940<br>#14 0x000000010022794d in ProcBody__EmitAll (proc_info_L_56=0x7fff5fbfdeb8) at ProcBody.m3.c:2822<br>#15 0x00000001002e73d6 in Module__CompileModule (t_L_379=0x101512fe0 "?Xj") at Module.m3.c:25364<br>#16 0x00000001002eafe8 in Module__Compile (t_L_283=0x101512fe0 "?Xj") at Module.m3.c:23264<br>#17 0x00000001001f78df in M3Front__DoCompile () at M3Front.m3.c:7176<br>#18 0x00000001001f8391 in M3Front__Compile (input_L_88=0x7fff5fbfe150, env_L_89=0x1013910a8, options_L_90=0x101355840) at M3Front.m3.c:3827<br>#19 0x0000000100021886 in Builder__RunM3 (s_L_494=0x10136fdb0, u_L_495=0x1012df768, object_L_496=0x1013557a0 "??n") at Builder.m3.c:56168<br>#20 0x0000000100022bac in Builder__PushOneM3 (s_L_444=0x10136fdb0, u_L_445=0x1012df768) at Builder.m3.c:48299<br>#21 0x0000000100023cb5 in Builder__CompileM3 (s_L_423=0x10136fdb0, u_L_424=0x1012df768) at Builder.m3.c:45901<br>#22 0x000000010001ea71 in Builder__CompileOne (s_L_404=0x10136fdb0, u_L_405=0x1012df768) at Builder.m3.c<br><br><br><br> - Jay<br><br><br><br><div><div id="ecxSkyDrivePlaceholder"></div><hr id="ecxstopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Wed, 17 Apr 2013 02:32:15 +0000<br>Subject: Re: [M3devel] frontend misses a few types<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}


--></style>
<div dir="ltr">Here is what it looks like:<br><br><br>INTERFACE VBT;<br><br>TYPE VBT_T = OBJECT METHODS<br>init(op: PaintOp_T := PaintOp_TransparentSwap;<br>     txt: Pixmap_T := Pixmap_Gray;<br>     READONLY delta := Point_T{0});<br>END;<br><br>TYPE Pixmap_T = RECORD Pixmap_T_field: INTEGER END;<br>CONST Pixmap_Gray = Pixmap_T{1};<br><br>TYPE PaintOp_T = RECORD PaintOp_T_field:INTEGER END;<br>CONST PaintOp_Swap = PaintOp_T{2};<br>CONST PaintOp_TransparentSwap = PaintOp_T{3};<br><br>TYPE Point_T = RECORD Point_T_field: INTEGER END;<br><br>END VBT.<br><br><br><br>INTERFACE HighlightVBT;<br><br>IMPORT VBT;<br>TYPE HighlightVBT_T <: VBT.VBT_T;<br><br>END HighlightVBT.<br><br><br><br>MODULE Main;<br>IMPORT HighlightVBT;<br><br>PROCEDURE Main() =<br>BEGIN<br>    NEW(HighlightVBT.HighlightVBT_T).init();<br>    NEW(HighlightVBT.HighlightVBT_T).init();<br>END Main;<br><br><br>BEGIN<br>    Main();<br>END Main.<br><br><br><br>unit Main does not receive declare_record for <br>  PaintOp_T<br>  Pixmap_T<br>  and maybe Point_T<br><br>It is somewhat obvious why.<br>VBT is not directly imported by Main.<br><br><br>Point_T is passed by reference, so the backend can inject<br>a simple forward declaration:<br>struct T123; typedef struct T123 T123;<br><br><br>But PaintOp_T and Pixmap_T are passed by value<br>and it is desirable to have them fully defined, so I can use C's pass by struct by value feature.<br><br><br><br>Furthermore, multiple calls to init() generate multiple<br>instances of Point_T{0}.<br><br><br>Anyone interested in fixing it? I'll debug it probably..<br><br><br> - Jay<br><br><br><br><br><div><div id="ecxSkyDrivePlaceholder"></div><hr id="ecxstopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Tue, 16 Apr 2013 01:28:16 +0000<br>Subject: [M3devel] frontend misses a few types<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}


--></style>
<div dir="ltr">It'd be great to fix this in the frontend.<br><br><br>jbook2:p255 jay$ rm -rf AMD64_DARWIN && /dev2/cm3/m3-sys/cm3/AMD64_DARWIN/cm3 -keep<br>--- building in AMD64_DARWIN ---<br><br>ReadWish /cm3/pkg/libm3/AMD64_DARWIN/libm3.a ffffffffe90634a6<br>new source -> compiling VBT.i3<br>new source -> compiling HighlightVBT.i3<br>new source -> compiling HighlightVBT.m3<br>new source -> compiling Main.m3<br>warning: pop_struct: unknown typeid:T79A5AEBB<br>warning: pop_struct: unknown typeid:T23E73F69<br> -> linking pgm<br>./pgm >stdout.pgm.raw 2>stderr.pgm.raw<br>jbook2:p255 jay$ pwd<br>/dev2/cm3/m3-sys/m3tests/src/p2/p255<br><br><br>Also, in this example, each call creates another copy of the default parameter in the module globals.<br>That should be optimized in the frontend.<br>The test case here is really small.<br><br><br> - Jay<br><br><br><div><div id="ecxSkyDrivePlaceholder"></div>> Date: Tue, 16 Apr 2013 03:21:25 +0000<br>> To: m3commit@elegosoft.com<br>> From: jkrell@elego.de<br>> Subject: [M3commit] CVS Update: cm3<br>> <br>> CVSROOT:  /usr/cvs<br>> Changes by:      jkrell@birch.   13/04/16 03:21:25<br>> <br>> Added files:<br>>       cm3/m3-sys/m3tests/src/p2/p255/: HighlightVBT.i3 HighlightVBT.m3 <br>>                                          Main.m3 VBT.i3 m3makefile <br>> <br>> Log message:<br>>     This test case demonstrates a problem<br>>     where the frontend doesn't describe all the types<br>>         to the backend. And also where it doesn't single-instance<br>>         constants that it could/should.<br>>   <br>>  It is adapted from Trestle and a little of libm3.<br>>         It is reduced very much.<br>> <br></div>                                     </div></div>                                        </div></div>                                        </div></div>                                        </div></div>                                        </div></body>
</html>