2019-01-09 10:17:42 +03:00
|
|
|
package ast
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
"github.com/d5/tengo/source"
|
2019-01-09 10:17:42 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type MapLit struct {
|
2019-01-11 12:16:34 +03:00
|
|
|
LBrace source.Pos
|
2019-01-09 10:17:42 +03:00
|
|
|
Elements []*MapElementLit
|
2019-01-11 12:16:34 +03:00
|
|
|
RBrace source.Pos
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e *MapLit) exprNode() {}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
func (e *MapLit) Pos() source.Pos {
|
2019-01-09 10:17:42 +03:00
|
|
|
return e.LBrace
|
|
|
|
}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
func (e *MapLit) End() source.Pos {
|
2019-01-09 10:17:42 +03:00
|
|
|
return e.RBrace + 1
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *MapLit) String() string {
|
|
|
|
var elts []string
|
|
|
|
for _, m := range e.Elements {
|
|
|
|
elts = append(elts, m.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
return "{" + strings.Join(elts, ", ") + "}"
|
|
|
|
}
|