Abstract variable declarations are written using VAR(...)
:
scala> import treehugger.forest._, definitions._, treehuggerDSL._
import treehugger.forest._
import definitions._
import treehuggerDSL._
scala> val tree = (VAR("foo", IntClass): Tree)
[1m[34mtree[0m: [1m[32mtreehugger.forest.Tree[0m = ValDef(Modifiers(<mutable>, , Map()),Typed(Ident(foo),TypeTree()),EmptyTree)
scala> treeToString(tree)
[1m[34mres0[0m: [1m[32mString[0m = var foo: Int
or in general:
VAR(sym|"x", typ|"C").tree
Value definitions are written as:
scala> val tree2 = VAR("foo", IntClass) := LIT(0)
[1m[34mtree2[0m: [1m[32mtreehugger.forest.ValDef[0m = ValDef(Modifiers(<mutable>, , Map()),Typed(Ident(foo),TypeTree()),Literal(Constant(0)))
scala> treeToString(tree2)
[1m[34mres1[0m: [1m[32mString[0m = var foo: Int = 0
as a special form of initializing the variable with the default value of the type, WILDCARD
can be used as follows:
scala> val tree3 = VAR("foo", IntClass) := WILDCARD
[1m[34mtree3[0m: [1m[32mtreehugger.forest.ValDef[0m = ValDef(Modifiers(<mutable>, , Map()),Typed(Ident(foo),TypeTree()),Ident(_))
scala> treeToString(tree3)
[1m[34mres2[0m: [1m[32mString[0m = var foo: Int = _