summaryrefslogtreecommitdiff
path: root/usr/austin/eval/value.go
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-07-15 17:56:17 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-07-15 17:56:17 -0700
commitc80bd89be272cd3fe530ce221c4bc07839895cdf (patch)
tree772a8caacd99a2ea2fcaa94985621dc3ef1911d0 /usr/austin/eval/value.go
parente01dea063f2dea16d7285634421547ed65e7280c (diff)
downloadgolang-c80bd89be272cd3fe530ce221c4bc07839895cdf.tar.gz
Make Value always represent an l-value and never a generic
container for values. Instead of having one evaluator function that returns a generic Value, there is now an evaluator function for each generalized type that simply returns a native type. The compiler is more type-safe now because there are almost no type conversions at evaluation time and it's impossible to invoke a nil evaluator function during evaluation. This also makes ideals and pointers really clean. As an added bonus, expression evaluation should be faster because it doesn't require heap allocation for every intermediate value, type switches, or lots of conversions to and from Value. It also involves fewer function calls. R=rsc APPROVED=rsc DELTA=431 (280 added, 115 deleted, 36 changed) OCL=31705 CL=31709
Diffstat (limited to 'usr/austin/eval/value.go')
-rw-r--r--usr/austin/eval/value.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr/austin/eval/value.go b/usr/austin/eval/value.go
index 9ca09cd35..5849c16d8 100644
--- a/usr/austin/eval/value.go
+++ b/usr/austin/eval/value.go
@@ -32,6 +32,11 @@ func (v *boolV) Set(x bool) {
*v = boolV(x);
}
+func (t *boolType) value(v bool) BoolValue {
+ res := boolV(v);
+ return &res;
+}
+
/*
* Uint
*/
@@ -145,8 +150,8 @@ func (v *uintptrV) Set(x uint64) {
}
func (t *uintType) value(v uint64) UintValue {
- // TODO(austin) This executes are run-time, even though
- // virtually all of the logic can be done at type-check time.
+ // TODO(austin) The 'value' methods are only used for
+ // testing right now. Get rid of them.
// TODO(austin) Deal with named types
switch Type(t) {
case Uint8Type: