diff options
author | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
---|---|---|
committer | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
commit | bae9f6d2fd5eb5bc80929bd393932b23f14d7c93 (patch) | |
tree | ca9ab12a7d78b1fc27a8f734729081357ce6d252 /vendor/github.com/hashicorp/hil/ast/call.go | |
parent | 254c495b6bebab3fb72a243c4bce858d79e6ee99 (diff) | |
download | terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.gz terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.zst terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.zip |
Initial transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/hil/ast/call.go')
-rw-r--r-- | vendor/github.com/hashicorp/hil/ast/call.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hil/ast/call.go b/vendor/github.com/hashicorp/hil/ast/call.go new file mode 100644 index 0000000..0557011 --- /dev/null +++ b/vendor/github.com/hashicorp/hil/ast/call.go | |||
@@ -0,0 +1,47 @@ | |||
1 | package ast | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | "strings" | ||
6 | ) | ||
7 | |||
8 | // Call represents a function call. | ||
9 | type Call struct { | ||
10 | Func string | ||
11 | Args []Node | ||
12 | Posx Pos | ||
13 | } | ||
14 | |||
15 | func (n *Call) Accept(v Visitor) Node { | ||
16 | for i, a := range n.Args { | ||
17 | n.Args[i] = a.Accept(v) | ||
18 | } | ||
19 | |||
20 | return v(n) | ||
21 | } | ||
22 | |||
23 | func (n *Call) Pos() Pos { | ||
24 | return n.Posx | ||
25 | } | ||
26 | |||
27 | func (n *Call) String() string { | ||
28 | args := make([]string, len(n.Args)) | ||
29 | for i, arg := range n.Args { | ||
30 | args[i] = fmt.Sprintf("%s", arg) | ||
31 | } | ||
32 | |||
33 | return fmt.Sprintf("Call(%s, %s)", n.Func, strings.Join(args, ", ")) | ||
34 | } | ||
35 | |||
36 | func (n *Call) Type(s Scope) (Type, error) { | ||
37 | f, ok := s.LookupFunc(n.Func) | ||
38 | if !ok { | ||
39 | return TypeInvalid, fmt.Errorf("unknown function: %s", n.Func) | ||
40 | } | ||
41 | |||
42 | return f.ReturnType, nil | ||
43 | } | ||
44 | |||
45 | func (n *Call) GoString() string { | ||
46 | return fmt.Sprintf("*%#v", *n) | ||
47 | } | ||