]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - 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
diff --git a/vendor/github.com/hashicorp/hil/ast/conditional.go b/vendor/github.com/hashicorp/hil/ast/conditional.go
new file mode 100644 (file)
index 0000000..be48f89
--- /dev/null
@@ -0,0 +1,36 @@
+package ast
+
+import (
+       "fmt"
+)
+
+type Conditional struct {
+       CondExpr  Node
+       TrueExpr  Node
+       FalseExpr Node
+       Posx      Pos
+}
+
+// Accept passes the given visitor to the child nodes in this order:
+// CondExpr, TrueExpr, FalseExpr. It then finally passes itself to the visitor.
+func (n *Conditional) Accept(v Visitor) Node {
+       n.CondExpr = n.CondExpr.Accept(v)
+       n.TrueExpr = n.TrueExpr.Accept(v)
+       n.FalseExpr = n.FalseExpr.Accept(v)
+
+       return v(n)
+}
+
+func (n *Conditional) Pos() Pos {
+       return n.Posx
+}
+
+func (n *Conditional) Type(Scope) (Type, error) {
+       // This is not actually a useful value; the type checker ignores
+       // this function when analyzing conditionals, just as with Arithmetic.
+       return TypeInt, nil
+}
+
+func (n *Conditional) GoString() string {
+       return fmt.Sprintf("*%#v", *n)
+}