github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/config/lang/ast/arithmetic.go (about)

     1  package ast
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  )
     7  
     8  // Arithmetic represents a node where the result is arithmetic of
     9  // two or more operands in the order given.
    10  type Arithmetic struct {
    11  	Op    ArithmeticOp
    12  	Exprs []Node
    13  	Posx  Pos
    14  }
    15  
    16  func (n *Arithmetic) Accept(v Visitor) Node {
    17  	for i, expr := range n.Exprs {
    18  		n.Exprs[i] = expr.Accept(v)
    19  	}
    20  
    21  	return v(n)
    22  }
    23  
    24  func (n *Arithmetic) Pos() Pos {
    25  	return n.Posx
    26  }
    27  
    28  func (n *Arithmetic) GoString() string {
    29  	return fmt.Sprintf("*%#v", *n)
    30  }
    31  
    32  func (n *Arithmetic) String() string {
    33  	var b bytes.Buffer
    34  	for _, expr := range n.Exprs {
    35  		b.WriteString(fmt.Sprintf("%s", expr))
    36  	}
    37  
    38  	return b.String()
    39  }
    40  
    41  func (n *Arithmetic) Type(Scope) (Type, error) {
    42  	return TypeInt, nil
    43  }