cue/ast: rename EmitDecl

Preparaton for closed structs.

Change-Id: Ic8318a160a14aa1cc83da362bd86b573ee0398ee
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2704
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/import.go b/cmd/cue/cmd/import.go
index 574bf59..a7c5b26 100644
--- a/cmd/cue/cmd/import.go
+++ b/cmd/cue/cmd/import.go
@@ -509,7 +509,7 @@
 		case *ast.StructLit:
 			f.Decls = append(f.Decls, x.Elts...)
 		case *ast.ListLit:
-			f.Decls = append(f.Decls, &ast.EmitDecl{Expr: x})
+			f.Decls = append(f.Decls, &ast.EmbedDecl{Expr: x})
 		default:
 			panic("unreachable")
 		}
diff --git a/cue/ast.go b/cue/ast.go
index 8974b52..267a125 100644
--- a/cue/ast.go
+++ b/cue/ast.go
@@ -192,7 +192,7 @@
 		}
 		for _, e := range n.Decls {
 			switch x := e.(type) {
-			case *ast.EmitDecl:
+			case *ast.EmbedDecl:
 				if v1.object.emit == nil {
 					v1.object.emit = v1.walk(x.Expr)
 				} else {
@@ -229,7 +229,7 @@
 		ret = obj
 		for _, e := range n.Elts {
 			switch x := e.(type) {
-			case *ast.EmitDecl:
+			case *ast.EmbedDecl:
 				// Only allowed at top-level.
 				return v1.errf(x, "emitting values is only allowed at top level")
 			case *ast.Field, *ast.Alias:
@@ -586,7 +586,7 @@
 		// Nothing to do for a free-floating comment group.
 
 	// nothing to do
-	// case *syntax.EmitDecl:
+	// case *syntax.EmbedDecl:
 	default:
 		// TODO: unhandled node.
 		// value = ctx.mkErr(n, "unknown node type %T", n)
diff --git a/cue/ast/ast.go b/cue/ast/ast.go
index 4fe5c7b..3bbc5a6 100644
--- a/cue/ast/ast.go
+++ b/cue/ast/ast.go
@@ -83,7 +83,7 @@
 func (*ComprehensionDecl) declNode() {}
 func (*ImportDecl) declNode()        {}
 func (*BadDecl) declNode()           {}
-func (*EmitDecl) declNode()          {}
+func (*EmbedDecl) declNode()         {}
 func (*Alias) declNode()             {}
 func (*CommentGroup) declNode()      {}
 
@@ -610,12 +610,12 @@
 		Rparen token.Pos // position of ')', if any
 	}
 
-	// An EmitDecl node represents a single expression used as a declaration.
+	// An EmbedDecl node represents a single expression used as a declaration.
 	// The expressions in this declaration is what will be emitted as
 	// configuration output.
 	//
-	// An EmitDecl may only appear at the top level.
-	EmitDecl struct {
+	// An EmbedDecl may only appear at the top level.
+	EmbedDecl struct {
 		comments
 		Expr Expr
 	}
@@ -625,7 +625,7 @@
 
 func (d *BadDecl) Pos() token.Pos    { return d.From }
 func (d *ImportDecl) Pos() token.Pos { return d.Import }
-func (d *EmitDecl) Pos() token.Pos   { return d.Expr.Pos() }
+func (d *EmbedDecl) Pos() token.Pos  { return d.Expr.Pos() }
 
 func (d *BadDecl) End() token.Pos { return d.To }
 func (d *ImportDecl) End() token.Pos {
@@ -637,7 +637,7 @@
 	}
 	return d.Specs[0].End()
 }
-func (d *EmitDecl) End() token.Pos { return d.Expr.End() }
+func (d *EmbedDecl) End() token.Pos { return d.Expr.End() }
 
 // ----------------------------------------------------------------------------
 // Files and packages
diff --git a/cue/ast/walk.go b/cue/ast/walk.go
index 35c0167..49e6acd 100644
--- a/cue/ast/walk.go
+++ b/cue/ast/walk.go
@@ -160,7 +160,7 @@
 			walk(v, s)
 		}
 
-	case *EmitDecl:
+	case *EmbedDecl:
 		walk(v, n.Expr)
 
 	case *Alias:
diff --git a/cue/build.go b/cue/build.go
index 6883249..c0fb628 100644
--- a/cue/build.go
+++ b/cue/build.go
@@ -104,7 +104,7 @@
 		_ = p.AddSyntax(&ast.File{Decls: x.Elts})
 	default:
 		_ = p.AddSyntax(&ast.File{
-			Decls: []ast.Decl{&ast.EmitDecl{Expr: expr}},
+			Decls: []ast.Decl{&ast.EmbedDecl{Expr: expr}},
 		})
 	}
 	if p.Err != nil {
@@ -167,7 +167,7 @@
 func (r *Runtime) FromExpr(expr ast.Expr) (*Instance, error) {
 	i := r.index().newInstance(nil)
 	err := i.insertFile(&ast.File{
-		Decls: []ast.Decl{&ast.EmitDecl{Expr: expr}},
+		Decls: []ast.Decl{&ast.EmbedDecl{Expr: expr}},
 	})
 	if err != nil {
 		return nil, err
diff --git a/cue/export.go b/cue/export.go
index e856a30..df4c898 100644
--- a/cue/export.go
+++ b/cue/export.go
@@ -77,7 +77,7 @@
 	if obj, ok := value.(*ast.StructLit); ok {
 		file.Decls = append(file.Decls, obj.Elts...)
 	} else {
-		file.Decls = append(file.Decls, &ast.EmitDecl{Expr: value})
+		file.Decls = append(file.Decls, &ast.EmbedDecl{Expr: value})
 	}
 
 	// resolve the file.
@@ -345,7 +345,7 @@
 			}
 		}
 		if x.emit != nil {
-			obj.Elts = append(obj.Elts, &ast.EmitDecl{Expr: p.expr(x.emit)})
+			obj.Elts = append(obj.Elts, &ast.EmbedDecl{Expr: p.expr(x.emit)})
 		}
 		if !doEval(p.mode) && x.template != nil {
 			l, ok := x.template.evalPartial(p.ctx).(*lambdaExpr)
diff --git a/cue/format/format_test.go b/cue/format/format_test.go
index 2e5b66f..3ac03e0 100644
--- a/cue/format/format_test.go
+++ b/cue/format/format_test.go
@@ -237,7 +237,7 @@
 	f := &ast.File{
 		Name: ast.NewIdent("foo"),
 		Decls: []ast.Decl{
-			&ast.EmitDecl{
+			&ast.EmbedDecl{
 				Expr: &ast.BasicLit{
 					ValuePos: token.NoSpace.Pos(),
 					Value:    "1",
diff --git a/cue/format/node.go b/cue/format/node.go
index e373f4f..4e75dd6 100644
--- a/cue/format/node.go
+++ b/cue/format/node.go
@@ -244,7 +244,7 @@
 		}
 		f.print(newsection, nooverride)
 
-	case *ast.EmitDecl:
+	case *ast.EmbedDecl:
 		f.expr(n.Expr)
 		f.print(newline, newsection, nooverride) // force newline
 
diff --git a/cue/parser/parser.go b/cue/parser/parser.go
index 474c8f1..7e0715e 100644
--- a/cue/parser/parser.go
+++ b/cue/parser/parser.go
@@ -648,7 +648,7 @@
 
 	for p.tok != token.RBRACE && p.tok != token.EOF {
 		d := p.parseField(allowEmit)
-		if e, ok := d.(*ast.EmitDecl); ok {
+		if e, ok := d.(*ast.EmbedDecl); ok {
 			if origEmit && !allowEmit {
 				p.errf(p.pos, "only one emit allowed at top level")
 			}
@@ -692,7 +692,7 @@
 			if expr == nil {
 				expr = p.parseExpr()
 			}
-			e := &ast.EmitDecl{Expr: expr}
+			e := &ast.EmbedDecl{Expr: expr}
 			if p.atComma("file", token.RBRACE) {
 				p.next()
 			}
@@ -737,7 +737,7 @@
 			case token.IDENT, token.LBRACK, token.STRING, token.INTERPOLATION, token.NULL, token.TRUE, token.FALSE:
 				if p.tok == token.COMMA {
 					p.expectComma()
-					return &ast.EmitDecl{Expr: expr}
+					return &ast.EmbedDecl{Expr: expr}
 				}
 			}
 			return &ast.BadDecl{From: pos, To: p.pos}
diff --git a/cue/parser/print.go b/cue/parser/print.go
index 4c9b3a0..40a85cf 100644
--- a/cue/parser/print.go
+++ b/cue/parser/print.go
@@ -67,10 +67,8 @@
 		}
 		return out
 
-	case *ast.EmitDecl:
-		// out := "<"
+	case *ast.EmbedDecl:
 		out += debugStr(v.Expr)
-		// out += ">"
 		return out
 
 	case *ast.ImportDecl:
diff --git a/cue/parser/walk.go b/cue/parser/walk.go
index 6ffaf48..82f88c6 100644
--- a/cue/parser/walk.go
+++ b/cue/parser/walk.go
@@ -155,7 +155,7 @@
 			walk(v, s)
 		}
 
-	case *ast.EmitDecl:
+	case *ast.EmbedDecl:
 		walk(v, n.Expr)
 
 	case *ast.Alias:
diff --git a/encoding/yaml/yaml.go b/encoding/yaml/yaml.go
index 3db8b08..24f0f18 100644
--- a/encoding/yaml/yaml.go
+++ b/encoding/yaml/yaml.go
@@ -57,10 +57,10 @@
 		case *ast.StructLit:
 			f.Decls = x.Elts
 		default:
-			f.Decls = []ast.Decl{&ast.EmitDecl{Expr: x}}
+			f.Decls = []ast.Decl{&ast.EmbedDecl{Expr: x}}
 		}
 	default:
-		f.Decls = []ast.Decl{&ast.EmitDecl{Expr: &ast.ListLit{Elts: a}}}
+		f.Decls = []ast.Decl{&ast.EmbedDecl{Expr: &ast.ListLit{Elts: a}}}
 	}
 	return f, nil
 }