-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stubs for more unimplemented reflect methods #2574
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,7 @@ func (v Value) IsNil() bool { | |
_, val := decomposeInterface(*(*interface{})(v.value)) | ||
return val == nil | ||
default: | ||
panic(&ValueError{"IsNil"}) | ||
panic(&ValueError{Method: "IsNil"}) | ||
} | ||
} | ||
|
||
|
@@ -144,7 +144,7 @@ func (v Value) Pointer() uintptr { | |
case Func: | ||
panic("unimplemented: (reflect.Value).Pointer()") | ||
default: // not implemented: Func | ||
panic(&ValueError{"Pointer"}) | ||
panic(&ValueError{Method: "Pointer"}) | ||
} | ||
} | ||
|
||
|
@@ -187,7 +187,7 @@ func (v Value) Bool() bool { | |
return uintptr(v.value) != 0 | ||
} | ||
default: | ||
panic(&ValueError{"Bool"}) | ||
panic(&ValueError{Method: "Bool"}) | ||
} | ||
} | ||
|
||
|
@@ -224,7 +224,7 @@ func (v Value) Int() int64 { | |
return int64(int64(uintptr(v.value))) | ||
} | ||
default: | ||
panic(&ValueError{"Int"}) | ||
panic(&ValueError{Method: "Int"}) | ||
} | ||
} | ||
|
||
|
@@ -267,7 +267,7 @@ func (v Value) Uint() uint64 { | |
return uint64(uintptr(v.value)) | ||
} | ||
default: | ||
panic(&ValueError{"Uint"}) | ||
panic(&ValueError{Method: "Uint"}) | ||
} | ||
} | ||
|
||
|
@@ -293,7 +293,7 @@ func (v Value) Float() float64 { | |
return *(*float64)(unsafe.Pointer(&v.value)) | ||
} | ||
default: | ||
panic(&ValueError{"Float"}) | ||
panic(&ValueError{Method: "Float"}) | ||
} | ||
} | ||
|
||
|
@@ -315,7 +315,7 @@ func (v Value) Complex() complex128 { | |
// architectures with 128-bit pointers, however. | ||
return *(*complex128)(v.value) | ||
default: | ||
panic(&ValueError{"Complex"}) | ||
panic(&ValueError{Method: "Complex"}) | ||
} | ||
} | ||
|
||
|
@@ -360,7 +360,7 @@ func (v Value) Len() int { | |
case String: | ||
return int((*stringHeader)(v.value).len) | ||
default: | ||
panic(&ValueError{"Len"}) | ||
panic(&ValueError{Method: "Len"}) | ||
} | ||
} | ||
|
||
|
@@ -378,7 +378,7 @@ func (v Value) Cap() int { | |
case Slice: | ||
return int((*sliceHeader)(v.value).cap) | ||
default: | ||
panic(&ValueError{"Cap"}) | ||
panic(&ValueError{Method: "Cap"}) | ||
} | ||
} | ||
|
||
|
@@ -408,7 +408,7 @@ func (v Value) Elem() Value { | |
flags: v.flags &^ valueFlagIndirect, | ||
} | ||
default: | ||
panic(&ValueError{"Elem"}) | ||
panic(&ValueError{Method: "Elem"}) | ||
} | ||
} | ||
|
||
|
@@ -552,7 +552,7 @@ func (v Value) Index(i int) Value { | |
value: unsafe.Pointer(value), | ||
} | ||
default: | ||
panic(&ValueError{"Index"}) | ||
panic(&ValueError{Method: "Index"}) | ||
} | ||
} | ||
|
||
|
@@ -631,7 +631,7 @@ func (v Value) SetBool(x bool) { | |
case Bool: | ||
*(*bool)(v.value) = x | ||
default: | ||
panic(&ValueError{"SetBool"}) | ||
panic(&ValueError{Method: "SetBool"}) | ||
} | ||
} | ||
|
||
|
@@ -649,7 +649,7 @@ func (v Value) SetInt(x int64) { | |
case Int64: | ||
*(*int64)(v.value) = x | ||
default: | ||
panic(&ValueError{"SetInt"}) | ||
panic(&ValueError{Method: "SetInt"}) | ||
} | ||
} | ||
|
||
|
@@ -669,7 +669,7 @@ func (v Value) SetUint(x uint64) { | |
case Uintptr: | ||
*(*uintptr)(v.value) = uintptr(x) | ||
default: | ||
panic(&ValueError{"SetUint"}) | ||
panic(&ValueError{Method: "SetUint"}) | ||
} | ||
} | ||
|
||
|
@@ -681,7 +681,7 @@ func (v Value) SetFloat(x float64) { | |
case Float64: | ||
*(*float64)(v.value) = x | ||
default: | ||
panic(&ValueError{"SetFloat"}) | ||
panic(&ValueError{Method: "SetFloat"}) | ||
} | ||
} | ||
|
||
|
@@ -693,7 +693,7 @@ func (v Value) SetComplex(x complex128) { | |
case Complex128: | ||
*(*complex128)(v.value) = x | ||
default: | ||
panic(&ValueError{"SetComplex"}) | ||
panic(&ValueError{Method: "SetComplex"}) | ||
} | ||
} | ||
|
||
|
@@ -703,7 +703,7 @@ func (v Value) SetString(x string) { | |
case String: | ||
*(*string)(v.value) = x | ||
default: | ||
panic(&ValueError{"SetString"}) | ||
panic(&ValueError{Method: "SetString"}) | ||
} | ||
} | ||
|
||
|
@@ -788,10 +788,14 @@ type stringHeader struct { | |
|
||
type ValueError struct { | ||
Method string | ||
Kind Kind | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to match the ValueError from Go |
||
} | ||
|
||
func (e *ValueError) Error() string { | ||
return "reflect: call of reflect.Value." + e.Method + " on invalid type" | ||
if e.Kind == 0 { | ||
return "reflect: call of " + e.Method + " on zero Value" | ||
} | ||
return "reflect: call of " + e.Method + " on " + e.Kind.String() + " Value" | ||
Comment on lines
+795
to
+798
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from Go source |
||
} | ||
|
||
// Calls to this function are converted to LLVM intrinsic calls such as | ||
|
@@ -865,3 +869,11 @@ func MakeMap(typ Type) Value { | |
func (v Value) Call(in []Value) []Value { | ||
panic("unimplemented: (reflect.Value).Call()") | ||
} | ||
|
||
func (v Value) MethodByName(name string) Value { | ||
panic("unimplemented: (reflect.Value).MethodByName()") | ||
} | ||
|
||
func NewAt(typ Type, p unsafe.Pointer) Value { | ||
panic("unimplemented: reflect.New()") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from Go source