func (n *BasicLit) Val() constant.Value { return n.val }
func (n *BasicLit) SetVal(val constant.Value) { n.val = val }
+// NewConstExpr returns an OLITERAL representing val, copying the
+// position and type from orig.
+func NewConstExpr(val constant.Value, orig Node) Node {
+ n := NewBasicLit(orig.Pos(), val)
+ n.SetType(orig.Type())
+ n.SetTypecheck(orig.Typecheck())
+ return n
+}
+
// A BinaryExpr is a binary expression X Op Y,
// or Op(X, Y) for builtin functions that do not become calls.
type BinaryExpr struct {
}
}
-type ConstExpr struct {
- miniExpr
- origNode
- val constant.Value
-}
-
-func NewConstExpr(val constant.Value, orig Node) Node {
- n := &ConstExpr{val: val}
- n.op = OLITERAL
- n.pos = orig.Pos()
- n.orig = orig
- n.SetType(orig.Type())
- n.SetTypecheck(orig.Typecheck())
- return n
-}
-
-func (n *ConstExpr) Sym() *types.Sym { return n.orig.Sym() }
-func (n *ConstExpr) Val() constant.Value { return n.val }
-
// A ConvExpr is a conversion Type(X).
// It may end up being a value or a type.
type ConvExpr struct {
}
}
-func (n *ConstExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
-func (n *ConstExpr) copy() Node {
- c := *n
- c.init = copyNodes(c.init)
- return &c
-}
-func (n *ConstExpr) doChildren(do func(Node) bool) bool {
- if doNodes(n.init, do) {
- return true
- }
- return false
-}
-func (n *ConstExpr) editChildren(edit func(Node) Node) {
- editNodes(n.init, edit)
-}
-func (n *ConstExpr) editChildrenWithHidden(edit func(Node) Node) {
- editNodes(n.init, edit)
-}
-
func (n *ConvExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
func (n *ConvExpr) copy() Node {
c := *n