Skip to content

dragos/noboxing-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Noboxing Scala Compiler plugin
==============================

This compiler plugin issues warnings when the scalac compiler adds a
box or unbox operation in a @noboxing annotated definition. It
requires scala 2.9.2.

Build
=====

Use "sbt package".

Run
===

You can instruct scalac to pick up your plugin using
-Xplugin:path/to/jar, or you can copy the plugin jar to
$SCALA_HOME/misc/scala-devel/plugins.

Alternatively, if you are using SBT, you can drop the jar
in your /lib directory, and add the following to your scalac
options, like so:

    scalacOptions := Seq(..., "-Xplugin:lib/noboxing_2.9.2-0.1-SNAPSHOT.jar")

From the project root, type

$ scalac -Xplugin:target/scala-2.9.2/noboxing_2.9.2-0.1-SNAPSHOT.jar -Xplugin-list

You should see:

noboxing - checks for boxing operations
continuations - applies selective cps conversion

Use
===

In your source code, import ssol.tools.noboxing.noboxing and annotate
a class or definition.  For example:

import ssol.tools.noboxing.noboxing

class Test {
  def hello(x: String) {
    println("Hello, " + x)
  }

  @noboxing
  def arith(x: List[Int]) = x(0) + x(1)
}

Then run scalac with your plugin

$ scalac -Xplugin:target/scala_2.9.2/noboxing-plugin_2.9.2-0.1.jar -cp \
    target/scala_2.9.2/noboxing-plugin_2.9.2-0.1.jar test.scala

Don't forget to add the jar to your compilation classpath as well.

Credits
=======

Written originally for Scala 2.8.0 by:

    Iulian Dragos (https://github.com/dragos)

updated to Scala 2.9.2 by:

    Adam Klein (https://github.com/adamklein)

About

A Scala compiler plugin that issues warnings when boxing occurs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages