LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package reflect | 5 package reflect |
6 | 6 |
7 import ( | 7 import ( |
8 "math" | 8 "math" |
9 "runtime" | 9 "runtime" |
10 "strconv" | 10 "strconv" |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 | 1441 |
1442 // SetString sets v's underlying value to x. | 1442 // SetString sets v's underlying value to x. |
1443 // It panics if v's Kind is not String or if CanSet() is false. | 1443 // It panics if v's Kind is not String or if CanSet() is false. |
1444 func (v Value) SetString(x string) { | 1444 func (v Value) SetString(x string) { |
1445 v.mustBeAssignable() | 1445 v.mustBeAssignable() |
1446 v.mustBe(String) | 1446 v.mustBe(String) |
1447 *(*string)(v.val) = x | 1447 *(*string)(v.val) = x |
1448 } | 1448 } |
1449 | 1449 |
1450 // Slice returns a slice of v. | 1450 // Slice returns a slice of v. |
1451 // It panics if v's Kind is not Array, Slice or String, or the array is not addr
essable. | 1451 // It panics if v's Kind is not Array, Slice or String, or if v is a non-address
able array. |
1452 func (v Value) Slice(beg, end int) Value { | 1452 func (v Value) Slice(beg, end int) Value { |
1453 var ( | 1453 var ( |
1454 cap int | 1454 cap int |
1455 typ *sliceType | 1455 typ *sliceType |
1456 base unsafe.Pointer | 1456 base unsafe.Pointer |
1457 ) | 1457 ) |
1458 switch k := v.kind(); k { | 1458 switch k := v.kind(); k { |
1459 default: | 1459 default: |
1460 panic(&ValueError{"reflect.Value.Slice", k}) | 1460 panic(&ValueError{"reflect.Value.Slice", k}) |
1461 | 1461 |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2359 func escapes(x interface{}) { | 2359 func escapes(x interface{}) { |
2360 if dummy.b { | 2360 if dummy.b { |
2361 dummy.x = x | 2361 dummy.x = x |
2362 } | 2362 } |
2363 } | 2363 } |
2364 | 2364 |
2365 var dummy struct { | 2365 var dummy struct { |
2366 b bool | 2366 b bool |
2367 x interface{} | 2367 x interface{} |
2368 } | 2368 } |
LEFT | RIGHT |