Nicholas Tung | 1 Jun 2010 04:00

Re: help with very simple compiler transformation

Thanks so much, normalize works great!!!

I'm not sure why the annotations are not showing up for you... I see them
after the typer. I'm running Scala 2.8.0 RC2 from Maven; the primary files
in my project are here (plugin, file, and library defining  <at> Range):

http://github.com/gatoatigrado/skalch/blob/564b7e6b97305e62faeee69a321cdd1faabdf1d3/plugin/src/main/scala/skalch/plugins/SketchRewriter.scala

http://github.com/gatoatigrado/skalch/blob/564b7e6b97305e62faeee69a321cdd1faabdf1d3/base/src/test/scala/angelic/simple/SugaredTest.scala

http://github.com/gatoatigrado/skalch/blob/564b7e6b97305e62faeee69a321cdd1faabdf1d3/base/src/main/scala/skalch/AngelicSketch.scala

regards,
Nicholas — ntung at ntung —  https://ntung.com — CS major  <at>  UC Berkeley

On Mon, May 31, 2010 at 5:39 PM, Paul Phillips <paulp@...> wrote:
> On Mon, May 31, 2010 at 03:23:52PM -0700, Nicholas Tung wrote:
>> Thanks very much. I have another question -- how can I follow a
>> TypeRef to get an annotation? Here's some example code:
>> type Int5 = Int  <at>  Range(-32 to 31)
>> val x = (fcn() : Int5)
>
> Do you have reason to believe this can work? I'll be surprised.  It'd be
> neat if so.  I don't think type aliases are sufficiently first class
> that you can annotate them and distinguish between the annotated alias
> and the underlying type.
>
> Here's a little repl session in my current repl, which I can't resist to
> demo the stuff I've been adding.  Not sure what if anything this will
> tell you -- I know little about the annotations implementation.  But it
> seems to support my suspicion since I only see the annotation at all if
> I normalize.
>
> scala> class Range(x: scala.Range) extends scala.StaticAnnotation
> defined class Range
>
> scala> type Int5 = Int  <at>  Range(-32 to 31)
> defined type alias Int5
>
> scala> :type Int5
> tpe7: global.Type = Int5
>
> scala> tpe7.normalize
> res10: global.Type = Int
>
> scala> repl.allPhases( tpe7.normalize.annotations)
>         parser -> List(Range(scala.this.Predef.intWrapper(-32).to(31)))
>          namer -> " " "
>  packageobjects -> " " "
>          typer -> " " "
>  superaccessors -> " " "
>        pickler -> " " "
>      refchecks -> " " "
>   selectiveanf -> " " "
>       liftcode -> " " "
>   selectivecps -> " " "
>        uncurry -> " " "
>      tailcalls -> " " "
>     specialize -> " " "
>  explicitouter -> " " "
>        erasure -> " " "
>       lazyvals -> List()
>     lambdalift -> " " "
>   constructors -> " " "
>        flatten -> " " "
>          mixin -> " " "
>        cleanup -> " " "
>          icode -> " " "
>        inliner -> " " "
>       closelim -> " " "
>            dce -> " " "
>            jvm -> " " "
>       terminal -> " " "
>
> scala> repl.allPhases( tpe7.annotations)
>         parser -> List()
>          namer -> " " "
>  packageobjects -> " " "
>          typer -> " " "
>  superaccessors -> " " "
>        pickler -> " " "
>      refchecks -> " " "
>   selectiveanf -> " " "
>       liftcode -> " " "
>   selectivecps -> " " "
>        uncurry -> " " "
>      tailcalls -> " " "
>     specialize -> " " "
>  explicitouter -> " " "
>        erasure -> " " "
>       lazyvals -> " " "
>     lambdalift -> " " "
>   constructors -> " " "
>        flatten -> " " "
>          mixin -> " " "
>        cleanup -> " " "
>          icode -> " " "
>        inliner -> " " "
>       closelim -> " " "
>            dce -> " " "
>            jvm -> " " "
>       terminal -> " " "
>
> --
> Paul Phillips      | On two occasions, I have been asked, 'Mr. Babbage, if you
> Caged Spirit       | put into the machine wrong figures, will the right answers
> Empiricist         | come out?' I am not able to rightly apprehend the kind of
> i'll ship a pulp   | confusion of ideas that could provoke such a question.
>


Gmane