File: Impls_Macros_1.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (32 lines) | stat: -rw-r--r-- 2,174 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import scala.reflect.macros.blackbox.Context
import language.experimental.macros

object Macros {
  def impl1_0_0(c: Context)() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl1_1_1(c: Context)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def m1_0_0() = macro impl1_0_0
  def m1_1_1(x: Int) = macro impl1_1_1
  def m1_2_2(x: Int, y: Int) = macro impl1_2_2

  def impl1_0_inf(c: Context)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl1_2_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def m1_0_inf(x: Int*) = macro impl1_0_inf
  def m1_1_inf(x: Int, y: Int*) = macro impl1_1_inf
  def m1_2_inf(x: Int, y: Int, z: Int*) = macro impl1_2_inf

  def impl2_0_0(c: Context)()() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl2_1_1(c: Context)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def m2_0_0()() = macro impl2_0_0
  def m2_1_1()(x: Int) = macro impl2_1_1
  def m2_2_2()(x: Int, y: Int) = macro impl2_2_2

  def impl2_0_inf(c: Context)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def impl2_2_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
  def m2_0_inf()(x: Int*) = macro impl2_0_inf
  def m2_1_inf()(x: Int, y: Int*) = macro impl2_1_inf
  def m2_2_inf()(x: Int, y: Int, z: Int*) = macro impl2_2_inf
}