mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 17:16:44 +00:00
37 lines
612 B
Go
37 lines
612 B
Go
![]() |
package ast
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
// VariableAccess represents a variable access.
|
||
|
type VariableAccess struct {
|
||
|
Name string
|
||
|
Posx Pos
|
||
|
}
|
||
|
|
||
|
func (n *VariableAccess) Accept(v Visitor) Node {
|
||
|
return v(n)
|
||
|
}
|
||
|
|
||
|
func (n *VariableAccess) Pos() Pos {
|
||
|
return n.Posx
|
||
|
}
|
||
|
|
||
|
func (n *VariableAccess) GoString() string {
|
||
|
return fmt.Sprintf("*%#v", *n)
|
||
|
}
|
||
|
|
||
|
func (n *VariableAccess) String() string {
|
||
|
return fmt.Sprintf("Variable(%s)", n.Name)
|
||
|
}
|
||
|
|
||
|
func (n *VariableAccess) Type(s Scope) (Type, error) {
|
||
|
v, ok := s.LookupVar(n.Name)
|
||
|
if !ok {
|
||
|
return TypeInvalid, fmt.Errorf("unknown variable: %s", n.Name)
|
||
|
}
|
||
|
|
||
|
return v.Type, nil
|
||
|
}
|