Skip to content

Commit

Permalink
Allow knobs to be queried directly
Browse files Browse the repository at this point in the history
...so that you can write things like site(Knob("foo")) without having
to indirectly access the knob through a dummy parameter.
  • Loading branch information
Andrew Waterman committed Aug 17, 2016
1 parent dc0537b commit ae2ca70
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/scala/Parameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ abstract class View {
def sym[T](pname:Any, site:View):Ex[T]

// query for a parameters value using the default site
def apply[T](knob:Knob[T]):T
final def apply[T](pname:Any):T = apply[T](pname, deftSite)
final def apply[T](field:Field[T]):T = apply[T](field.asInstanceOf[Any], deftSite)

Expand Down Expand Up @@ -103,6 +104,9 @@ abstract class World(
abstract class _View extends View {
val look: _Lookup

def apply[T](knob:Knob[T]):T = {
_eval(ExVar[T](_VarKnob[T](knob.name)))
}
def apply[T](pname:Any, site:View):T = {
_eval(look(pname, site).asInstanceOf[Ex[T]])
}
Expand Down

0 comments on commit ae2ca70

Please sign in to comment.