LabelDef parameters - previously defined vs new

23 views
Skip to first unread message

Vlad Ureche

unread,
May 16, 2012, 7:51:49 AM5/16/12
to scala-i...@googlegroups.com
Hi,

I've been working on SI-5788 and I stumbled upon two very different ways LabelDefs are generated:
 - if generated by the tailcalls phase, their parameters are existing symbols defined in the code before the tailcall
 - if generated by the virtualized pattern matcher, their parameters are new symbols, appearing there for the first time
Gist here - look for BEHAVIOR1 and BEHAVIOR2 for a quick lookup.

My question is: what should be the behavior of LabelDefs? Should they pick up existing symbols or not?

Thanks,
Vlad

Adriaan Moors

unread,
May 16, 2012, 8:18:01 AM5/16/12
to scala-i...@googlegroups.com
On Wed, May 16, 2012 at 1:51 PM, Vlad Ureche <vlad....@gmail.com> wrote:
Hi,

I've been working on SI-5788 and I stumbled upon two very different ways LabelDefs are generated:
really?

they seem to be generated quite similarly

 - if generated by the tailcalls phase, their parameters are existing symbols defined in the code before the tailcall
          val label     = method.newLabel(newTermName("_" + method.name), method.pos)
          val thisParam = method.newSyntheticValueParam(currentClass.typeOfThis)
          label setInfo MethodType(thisParam :: method.tpe.params, method.tpe.finalResultType)

 
 - if generated by the virtualized pattern matcher, their parameters are new symbols, appearing there for the first time
        val matchEnd = NoSymbol.newLabel(freshName("matchEnd"), NoPosition) setFlag SYNTH_CASE
        val matchRes = NoSymbol.newValueParameter(newTermName("x"), NoPosition, SYNTHETIC) setInfo restpe.withoutAnnotations //
        matchEnd setInfo MethodType(List(matchRes), restpe)

ignore the NoSymbol -- the owner is changed later (yes, I know, this needs to be fixed, and I will get to that)



Adriaan Moors

unread,
May 16, 2012, 8:21:38 AM5/16/12
to scala-i...@googlegroups.com
ah whoops, i missed the ` :: method.tpe.params`, sorry about that
so the same label has one symbol that's created for it, and reuses the parameters from the method
that seems pretty icky to me
Reply all
Reply to author
Forward
0 new messages