Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 14 for CompositeLit (0.24 sec)

  1. src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go

    }
    
    func run(pass *analysis.Pass) (interface{}, error) {
    	inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
    
    	nodeFilter := []ast.Node{
    		(*ast.AssignStmt)(nil),
    		(*ast.CallExpr)(nil),
    		(*ast.CompositeLit)(nil),
    		(*ast.FuncDecl)(nil),
    		(*ast.FuncLit)(nil),
    		(*ast.GenDecl)(nil),
    		(*ast.RangeStmt)(nil),
    		(*ast.ReturnStmt)(nil),
    	}
    	inspect.Preorder(nodeFilter, func(node ast.Node) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 04 16:19:04 UTC 2024
    - 9.9K bytes
    - Viewed (0)
  2. src/cmd/compile/internal/syntax/positions.go

    		// case *ImportDecl:
    		// case *ConstDecl:
    		// case *TypeDecl:
    		// case *VarDecl:
    		// case *FuncDecl:
    
    		// expressions
    		// case *BadExpr:
    		// case *Name:
    		// case *BasicLit:
    		case *CompositeLit:
    			if n.Type != nil {
    				m = n.Type
    				continue
    			}
    			return n.Pos()
    		case *KeyValueExpr:
    			m = n.Key
    		// case *FuncLit:
    		// case *ParenExpr:
    		case *SelectorExpr:
    			m = n.X
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jun 10 17:49:19 UTC 2024
    - 6.5K bytes
    - Viewed (0)
  3. src/go/ast/filter.go

    	return
    }
    
    func filterCompositeLit(lit *CompositeLit, filter Filter, export bool) {
    	n := len(lit.Elts)
    	lit.Elts = filterExprList(lit.Elts, filter, export)
    	if len(lit.Elts) < n {
    		lit.Incomplete = true
    	}
    }
    
    func filterExprList(list []Expr, filter Filter, export bool) []Expr {
    	j := 0
    	for _, exp := range list {
    		switch x := exp.(type) {
    		case *CompositeLit:
    			filterCompositeLit(x, filter, export)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 13.3K bytes
    - Viewed (0)
  4. src/go/ast/walk.go

    	// Expressions
    	case *BadExpr, *Ident, *BasicLit:
    		// nothing to do
    
    	case *Ellipsis:
    		if n.Elt != nil {
    			Walk(v, n.Elt)
    		}
    
    	case *FuncLit:
    		Walk(v, n.Type)
    		Walk(v, n.Body)
    
    	case *CompositeLit:
    		if n.Type != nil {
    			Walk(v, n.Type)
    		}
    		walkList(v, n.Elts)
    
    	case *ParenExpr:
    		Walk(v, n.X)
    
    	case *SelectorExpr:
    		Walk(v, n.X)
    		Walk(v, n.Sel)
    
    	case *IndexExpr:
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 16 16:34:10 UTC 2024
    - 6.4K bytes
    - Viewed (0)
  5. src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go

    		return ast.NewIdent("nil")
    	case *types.Struct:
    		texpr := TypeExpr(f, pkg, typ) // typ because we want the name here.
    		if texpr == nil {
    			return nil
    		}
    		return &ast.CompositeLit{
    			Type: texpr,
    		}
    	}
    	return nil
    }
    
    // IsZeroValue checks whether the given expression is a 'zero value' (as determined by output of
    // analysisinternal.ZeroValue)
    func IsZeroValue(expr ast.Expr) bool {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 04 16:19:04 UTC 2024
    - 11.7K bytes
    - Viewed (0)
  6. src/cmd/compile/internal/syntax/parser.go

    		return p.complitexpr()
    	}
    
    	return p.expr()
    }
    
    // LiteralValue = "{" [ ElementList [ "," ] ] "}" .
    func (p *parser) complitexpr() *CompositeLit {
    	if trace {
    		defer p.trace("complitexpr")()
    	}
    
    	x := new(CompositeLit)
    	x.pos = p.pos()
    
    	p.xnest++
    	p.want(_Lbrace)
    	x.Rbrace = p.list("composite literal", _Comma, _Rbrace, func() bool {
    		// value
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 30 19:19:55 UTC 2024
    - 62.9K bytes
    - Viewed (0)
  7. 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)
  8. 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)
  9. 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)
  10. 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)
Back to top