That is correct. The stackframe is for an internal call, so it does not
have a target object.

Rick

On Thu, Apr 25, 2024 at 6:27 AM Rony G. Flatscher <rony.flatsc...@wu.ac.at>
wrote:

> While experimenting and analyzing various traces I stumbled over the
> following: if calling a label within a method the stackframes for the
> called internal routine miss the reference to the method's TARGET object
> (and therefore to the method and scope), rather the TARGET entry is set to
> .nil (which is fine for PROGRAM and ROUTINE).
>
> Here an example program calling a label in the main program (prolog) and
> calling a label from within a method:
>
> -- test INTERNALCALL's stackframestrace 
> offarr=.array~new.traceObject~collector=arr.traceObject~option='F'say 
> .context~nametrace all
> sf1=hey()trace offsaysay "stackframes:"say sf1
> line="-"~copies(79)say line
> sf2=.test~new~ohasaysay "stackframes:"say sf2say lineexithey:
>   return dumpStackFrames(.context~stackframes)
> ::class test::method ohatrace all
>   return hey()trace off  exithey:
>   return dumpStackFrames(.context~stackframes)
> ::routine dumpStackFrames
>   trace off  use arg stackframes
>
>   mb=.MutableBuffer~new
>   do counter c sf over stackFrames
>      call dumpSF mb, c, sf
>   end  return mb~string
> ::routine dumpSF
>   trace off  use strict arg mb, c, SF
>
>   crlf="0d0a"x  tab="09"x  target=sf~target
>   mb~append("... stackFrame # ", c, ": ", -
>             "line=",  "[",sf~line, "]", " name=",  "[",sf~name, "]", crlf, -
>             tab, "type=",  "[",sf~type, "]", " target=",  "[",target~string, 
> "] ", crlf, -
>             tab, "executable~package~name=",  "[",sf~executable~package~name, 
> "]", crlf, -
>             tab, "traceline=", "[", sf~traceline, "]", crlf, crlf)
>   return::routine pp
>   trace off  return "["arg(1)"]"
>
> Running it yields the following output:
>
> [R1   T1   I1   ]                     9 *-* sf1=hey()
> [R1   T1   I2   ]                    23 *-*   hey:
> [R1   T1   I2   ]                    24 *-*   return 
> dumpStackFrames(.context~stackframes)
> [R1   T1   I1   ]                    10 *-* trace off
>
> stackframes:
> ... stackFrame # 1: line=[24] name=[HEY]
>         type=[INTERNALCALL] target=[The NIL object]
>         executable~package~name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         traceline=[    24 *-*   return dumpStackFrames(.context~stackframes)]
>
> ... stackFrame # 2: line=[9] name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         type=[PROGRAM] target=[The NIL object]
>         executable~package~name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         traceline=[     9 *-* sf1=hey()]
>
>
> -------------------------------------------------------------------------------
> [R1   T1   I3    G A1    L1   *]     29 *-* return hey()*[R1   T1   I4    G 
> A2    L0    ]     33 *-*   hey:
> [R1   T1   I4    G A2    L0    ]     34 *-*   return 
> dumpStackFrames(.context~stackframes)*
> [R1   T1   I3    G A1    L0    ]        <I< Method "OHA" with scope "TEST" in 
> package "G:\test\orx\trace\bug\test_stackframe.rex".
>
> stackframes:
> ... stackFrame # 1: line=[34] name=[HEY]
>         type=[INTERNALCALL] *target=[The NIL object]*
>         executable~package~name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         traceline=[    34 *-*   return dumpStackFrames(.context~stackframes)]
>
> ... stackFrame # 2: line=[29] name=[OHA]
>         type=[METHOD] *target=[a TEST]*
>         executable~package~name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         traceline=[    29 *-* return hey()]
>
> ... stackFrame # 3: line=[16] name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         type=[PROGRAM] target=[The NIL object]
>         executable~package~name=[G:\test\orx\trace\bug\test_stackframe.rex]
>         traceline=[    16 *-* sf2=.test~new~oha]
>
>
> -------------------------------------------------------------------------------
>
> The call to the label "hey" within the method reveals in full format that
> the attributepool id gets changed from "A1" ("a TEST" target) to "A2" ("The
> NIL object").
>
> Shouldn't the TARGET entry of called labels/internal routines within a
> method supply the reference to the context object ("a TEST") rather than
> .nil ("The NIL object")?
>
> ---rony
>
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to