diff options
Diffstat (limited to 'vendor/github.com/hashicorp/hil/ast/conditional.go')
-rw-r--r-- | vendor/github.com/hashicorp/hil/ast/conditional.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hil/ast/conditional.go b/vendor/github.com/hashicorp/hil/ast/conditional.go new file mode 100644 index 0000000..be48f89 --- /dev/null +++ b/vendor/github.com/hashicorp/hil/ast/conditional.go | |||
@@ -0,0 +1,36 @@ | |||
1 | package ast | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | ) | ||
6 | |||
7 | type Conditional struct { | ||
8 | CondExpr Node | ||
9 | TrueExpr Node | ||
10 | FalseExpr Node | ||
11 | Posx Pos | ||
12 | } | ||
13 | |||
14 | // Accept passes the given visitor to the child nodes in this order: | ||
15 | // CondExpr, TrueExpr, FalseExpr. It then finally passes itself to the visitor. | ||
16 | func (n *Conditional) Accept(v Visitor) Node { | ||
17 | n.CondExpr = n.CondExpr.Accept(v) | ||
18 | n.TrueExpr = n.TrueExpr.Accept(v) | ||
19 | n.FalseExpr = n.FalseExpr.Accept(v) | ||
20 | |||
21 | return v(n) | ||
22 | } | ||
23 | |||
24 | func (n *Conditional) Pos() Pos { | ||
25 | return n.Posx | ||
26 | } | ||
27 | |||
28 | func (n *Conditional) Type(Scope) (Type, error) { | ||
29 | // This is not actually a useful value; the type checker ignores | ||
30 | // this function when analyzing conditionals, just as with Arithmetic. | ||
31 | return TypeInt, nil | ||
32 | } | ||
33 | |||
34 | func (n *Conditional) GoString() string { | ||
35 | return fmt.Sprintf("*%#v", *n) | ||
36 | } | ||