mirror of
				https://github.com/golang/go.git
				synced 2025-10-31 08:40:55 +00:00 
			
		
		
		
	cmd/compile: change ir.NewCompLitExpr from Ntype to *types.Type
All callers were already using TypeNode to get an Ntype anyway, so just push the TypeNode constructor down into NewCompLitExpr. Prep refactoring for next CL to remove the Ntype field. Change-Id: I671935afca707aaab11d1c46e39902bd37a485ba Reviewed-on: https://go-review.googlesource.com/c/go/+/403840 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
		
							parent
							
								
									a6a49d128b
								
							
						
					
					
						commit
						3ffc230a9f
					
				
					 8 changed files with 14 additions and 15 deletions
				
			
		|  | @ -200,11 +200,13 @@ type CompLitExpr struct { | |||
| 	Len int64 | ||||
| } | ||||
| 
 | ||||
| func NewCompLitExpr(pos src.XPos, op Op, typ Ntype, list []Node) *CompLitExpr { | ||||
| 	n := &CompLitExpr{Ntype: typ} | ||||
| func NewCompLitExpr(pos src.XPos, op Op, typ *types.Type, list []Node) *CompLitExpr { | ||||
| 	n := &CompLitExpr{List: list} | ||||
| 	n.pos = pos | ||||
| 	n.SetOp(op) | ||||
| 	n.List = list | ||||
| 	if typ != nil { | ||||
| 		n.Ntype = TypeNode(typ) | ||||
| 	} | ||||
| 	n.orig = n | ||||
| 	return n | ||||
| } | ||||
|  |  | |||
|  | @ -1728,7 +1728,7 @@ func (r *reader) compLit() ir.Node { | |||
| 		*elemp = wrapName(r.pos(), r.expr()) | ||||
| 	} | ||||
| 
 | ||||
| 	lit := typecheck.Expr(ir.NewCompLitExpr(pos, ir.OCOMPLIT, ir.TypeNode(typ), elems)) | ||||
| 	lit := typecheck.Expr(ir.NewCompLitExpr(pos, ir.OCOMPLIT, typ, elems)) | ||||
| 	if typ0.IsPtr() { | ||||
| 		lit = typecheck.Expr(typecheck.NodAddrAt(pos, lit)) | ||||
| 		lit.SetType(typ0) | ||||
|  |  | |||
|  | @ -74,8 +74,7 @@ func stringtoruneslit(n *ir.ConvExpr) ir.Node { | |||
| 		i++ | ||||
| 	} | ||||
| 
 | ||||
| 	nn := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(n.Type()), nil) | ||||
| 	nn.List = list | ||||
| 	nn := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, n.Type(), list) | ||||
| 	typed(n.Type(), nn) | ||||
| 	// Need to transform the OCOMPLIT. | ||||
| 	return transformCompLit(nn) | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ func MakeDotArgs(pos src.XPos, typ *types.Type, args []ir.Node) ir.Node { | |||
| 		n.SetType(typ) | ||||
| 	} else { | ||||
| 		args = append([]ir.Node(nil), args...) | ||||
| 		lit := ir.NewCompLitExpr(pos, ir.OCOMPLIT, ir.TypeNode(typ), args) | ||||
| 		lit := ir.NewCompLitExpr(pos, ir.OCOMPLIT, typ, args) | ||||
| 		lit.SetImplicit(true) | ||||
| 		n = lit | ||||
| 	} | ||||
|  |  | |||
|  | @ -1417,7 +1417,7 @@ func (r *importReader) node() ir.Node { | |||
| 	case ir.OCOMPLIT: | ||||
| 		pos := r.pos() | ||||
| 		t := r.typ() | ||||
| 		n := ir.NewCompLitExpr(pos, ir.OCOMPLIT, ir.TypeNode(t), r.exprList()) | ||||
| 		n := ir.NewCompLitExpr(pos, ir.OCOMPLIT, t, r.exprList()) | ||||
| 		n.SetType(t) | ||||
| 		return n | ||||
| 
 | ||||
|  | @ -1425,7 +1425,7 @@ func (r *importReader) node() ir.Node { | |||
| 		pos := r.pos() | ||||
| 		typ := r.typ() | ||||
| 		list := r.exprList() | ||||
| 		n := ir.NewCompLitExpr(pos, op, ir.TypeNode(typ), list) | ||||
| 		n := ir.NewCompLitExpr(pos, op, typ, list) | ||||
| 		n.SetType(typ) | ||||
| 		if op == ir.OSLICELIT { | ||||
| 			n.Len = int64(r.uint64()) | ||||
|  |  | |||
|  | @ -1624,9 +1624,7 @@ func stringtoruneslit(n *ir.ConvExpr) ir.Node { | |||
| 		i++ | ||||
| 	} | ||||
| 
 | ||||
| 	nn := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(n.Type()), nil) | ||||
| 	nn.List = l | ||||
| 	return Expr(nn) | ||||
| 	return Expr(ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, n.Type(), l)) | ||||
| } | ||||
| 
 | ||||
| func checkmake(t *types.Type, arg string, np *ir.Node) bool { | ||||
|  |  | |||
|  | @ -120,7 +120,7 @@ func walkClosure(clo *ir.ClosureExpr, init *ir.Nodes) ir.Node { | |||
| 
 | ||||
| 	typ := typecheck.ClosureType(clo) | ||||
| 
 | ||||
| 	clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(typ), nil) | ||||
| 	clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, typ, nil) | ||||
| 	clos.SetEsc(clo.Esc()) | ||||
| 	clos.List = append([]ir.Node{ir.NewUnaryExpr(base.Pos, ir.OCFUNC, clofn.Nname)}, closureArgs(clo)...) | ||||
| 	for i, value := range clos.List { | ||||
|  | @ -186,7 +186,7 @@ func walkMethodValue(n *ir.SelectorExpr, init *ir.Nodes) ir.Node { | |||
| 
 | ||||
| 	typ := typecheck.MethodValueType(n) | ||||
| 
 | ||||
| 	clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(typ), nil) | ||||
| 	clos := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, typ, nil) | ||||
| 	clos.SetEsc(n.Esc()) | ||||
| 	clos.List = []ir.Node{ir.NewUnaryExpr(base.Pos, ir.OCFUNC, methodValueWrapper(n)), n.X} | ||||
| 
 | ||||
|  |  | |||
|  | @ -480,7 +480,7 @@ func walkAddString(n *ir.AddStringExpr, init *ir.Nodes) ir.Node { | |||
| 
 | ||||
| 		t := types.NewSlice(types.Types[types.TSTRING]) | ||||
| 		// args[1:] to skip buf arg | ||||
| 		slice := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, ir.TypeNode(t), args[1:]) | ||||
| 		slice := ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, t, args[1:]) | ||||
| 		slice.Prealloc = n.Prealloc | ||||
| 		args = []ir.Node{buf, slice} | ||||
| 		slice.SetEsc(ir.EscNone) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Matthew Dempsky
						Matthew Dempsky