Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 40 for CompositeLit (0.22 sec)

  1. src/cmd/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go

    		// nothing to do
    
    	case *ast.Ellipsis:
    		a.apply(n, "Elt", nil, n.Elt)
    
    	case *ast.FuncLit:
    		a.apply(n, "Type", nil, n.Type)
    		a.apply(n, "Body", nil, n.Body)
    
    	case *ast.CompositeLit:
    		a.apply(n, "Type", nil, n.Type)
    		a.applyList(n, "Elts")
    
    	case *ast.ParenExpr:
    		a.apply(n, "X", nil, n.X)
    
    	case *ast.SelectorExpr:
    		a.apply(n, "X", nil, n.X)
    		a.apply(n, "Sel", nil, n.Sel)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 18 21:28:13 UTC 2023
    - 12.2K bytes
    - Viewed (0)
  2. src/go/types/expr.go

    		return
    	}
    
    	op := e.Op
    	switch op {
    	case token.AND:
    		// spec: "As an exception to the addressability
    		// requirement x may also be a composite literal."
    		if _, ok := ast.Unparen(e.X).(*ast.CompositeLit); !ok && x.mode != variable {
    			check.errorf(x, UnaddressableOperand, invalidOp+"cannot take address of %s", x)
    			x.mode = invalid
    			return
    		}
    		x.mode = value
    		x.typ = &Pointer{base: x.typ}
    		return
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 29 02:09:54 UTC 2024
    - 49.7K bytes
    - Viewed (0)
  3. src/cmd/fix/fix.go

    	case *ast.Ellipsis:
    		walkBeforeAfter(&n.Elt, before, after)
    	case *ast.BasicLit:
    	case *ast.FuncLit:
    		walkBeforeAfter(&n.Type, before, after)
    		walkBeforeAfter(&n.Body, before, after)
    	case *ast.CompositeLit:
    		walkBeforeAfter(&n.Type, before, after)
    		walkBeforeAfter(&n.Elts, before, after)
    	case *ast.ParenExpr:
    		walkBeforeAfter(&n.X, before, after)
    	case *ast.SelectorExpr:
    		walkBeforeAfter(&n.X, before, after)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 13 18:45:54 UTC 2021
    - 14.6K bytes
    - Viewed (0)
  4. src/go/types/generate_test.go

    		switch n := n.(type) {
    		case *ast.ValueSpec:
    			// rewrite type Typ = [...]Type{...} to type Typ = []Type{...}
    			if len(n.Names) == 1 && n.Names[0].Name == "Typ" && len(n.Values) == 1 {
    				n.Values[0].(*ast.CompositeLit).Type.(*ast.ArrayType).Len = nil
    				return false
    			}
    		}
    		return true
    	})
    }
    
    // fixSprintf adds an extra nil argument for the *token.FileSet parameter in sprintf calls.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 03:01:18 UTC 2024
    - 16.5K bytes
    - Viewed (0)
  5. src/cmd/compile/internal/types2/expr.go

    		return
    	}
    
    	op := e.Op
    	switch op {
    	case syntax.And:
    		// spec: "As an exception to the addressability
    		// requirement x may also be a composite literal."
    		if _, ok := syntax.Unparen(e.X).(*syntax.CompositeLit); !ok && x.mode != variable {
    			check.errorf(x, UnaddressableOperand, invalidOp+"cannot take address of %s", x)
    			x.mode = invalid
    			return
    		}
    		x.mode = value
    		x.typ = &Pointer{base: x.typ}
    		return
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 29 02:09:54 UTC 2024
    - 51.7K bytes
    - Viewed (0)
  6. src/go/parser/resolver.go

    		r.openScope(n.Pos())
    		defer r.closeScope()
    		r.walkFieldList(n.Fields, ast.Var)
    
    	case *ast.FuncType:
    		r.openScope(n.Pos())
    		defer r.closeScope()
    		r.walkFuncType(n)
    
    	case *ast.CompositeLit:
    		if n.Type != nil {
    			ast.Walk(r, n.Type)
    		}
    		for _, e := range n.Elts {
    			if kv, _ := e.(*ast.KeyValueExpr); kv != nil {
    				// See go.dev/issue/45160: try to resolve composite lit keys, but don't
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Nov 02 12:56:53 UTC 2023
    - 15.8K bytes
    - Viewed (0)
  7. src/go/printer/printer_test.go

    		panic(err)
    	}
    
    	// Replace the result with call(), which is on the next line.
    	fd := file.Decls[0].(*ast.FuncDecl)
    	ret := fd.Body.List[0].(*ast.ReturnStmt)
    	ret.Results[0] = ret.Results[0].(*ast.CompositeLit).Elts[0]
    
    	var buf bytes.Buffer
    	if err := Fprint(&buf, fset, ret); err != nil {
    		t.Fatal(err)
    	}
    	want := "return call()"
    	if got := buf.String(); got != want {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jun 03 14:56:25 UTC 2024
    - 20.4K bytes
    - Viewed (0)
  8. src/cmd/fix/typecheck.go

    			}
    
    		case *ast.UnaryExpr:
    			// &x for x of type T has type *T.
    			t := typeof[n.X]
    			if t != "" && n.Op == token.AND {
    				typeof[n] = "*" + t
    			}
    
    		case *ast.CompositeLit:
    			// T{...} has type T.
    			typeof[n] = gofmt(n.Type)
    
    			// Propagate types down to values used in the composite literal.
    			t := expand(typeof[n])
    			if strings.HasPrefix(t, "[") { // array or slice
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Nov 16 22:02:42 UTC 2022
    - 20.1K bytes
    - Viewed (0)
  9. src/go/printer/testdata/parser.go

    	p.exprLev--
    	rbrace := p.expect(token.RBRACE)
    	return &ast.CompositeLit{typ, lbrace, elts, rbrace}
    }
    
    // checkExpr checks that x is an expression (and not a type).
    func (p *parser) checkExpr(x ast.Expr) ast.Expr {
    	switch t := ast.Unparen(x).(type) {
    	case *ast.BadExpr:
    	case *ast.Ident:
    	case *ast.BasicLit:
    	case *ast.FuncLit:
    	case *ast.CompositeLit:
    	case *ast.ParenExpr:
    		panic("unreachable")
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 20 20:19:51 UTC 2023
    - 50.5K bytes
    - Viewed (0)
  10. src/cmd/compile/internal/syntax/printer.go

    			if p.form == ShortForm {
    				p.print(_Lbrace)
    				if len(n.Body.List) > 0 {
    					p.print(_Name, "…")
    				}
    				p.print(_Rbrace)
    			} else {
    				p.print(n.Body)
    			}
    		}
    
    	case *CompositeLit:
    		if n.Type != nil {
    			p.print(n.Type)
    		}
    		p.print(_Lbrace)
    		if p.form == ShortForm {
    			if len(n.ElemList) > 0 {
    				p.print(_Name, "…")
    			}
    		} else {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Aug 24 07:17:27 UTC 2023
    - 21.5K bytes
    - Viewed (0)
Back to top