]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/hil/ast/conditional.go
Initial transfer of provider code
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / hil / ast / conditional.go
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 }