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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* __ *\
** ________ ___ / / ___ __ ____ Scala.js tools **
** / __/ __// _ | / / / _ | __ / // __/ (c) 2014, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
** /____/\___/_/ |_/____/_/ | |__/ /____/ **
** |/____/ **
\* */
package scala.scalajs.tools.javascript
import scala.language.implicitConversions
import scala.scalajs.ir.Position
import Trees._
private[javascript] object TreeDSL {
implicit class TreeOps(val self: Tree) extends AnyVal {
/** Select a member */
def DOT(field: Ident)(implicit pos: Position): DotSelect =
DotSelect(self, field)
/** Select a member */
def DOT(field: String)(implicit pos: Position): DotSelect =
DotSelect(self, Ident(field))
// Some operators that we use
def ===(that: Tree)(implicit pos: Position): Tree =
BinaryOp("===", self, that)
def ===(that: String)(implicit pos: Position): Tree =
BinaryOp("===", self, StringLiteral(that))
def unary_!()(implicit pos: Position): Tree =
UnaryOp("!", self)
def &&(that: Tree)(implicit pos: Position): Tree =
BinaryOp("&&", self, that)
def ||(that: Tree)(implicit pos: Position): Tree =
BinaryOp("||", self, that)
// Other constructs
def :=(that: Tree)(implicit pos: Position): Tree =
Assign(self, that)
}
def typeof(expr: Tree)(implicit pos: Position): Tree =
UnaryOp("typeof", expr)
}
|