Clean up some TODOs

Some were stale, some were transformed into issues, some were fixed
This commit is contained in:
Stanisław Barzowski 2017-10-05 18:47:02 -04:00 committed by Dave Cunningham
parent a4058fc177
commit f0f70419f8
10 changed files with 24 additions and 22 deletions

View File

@ -468,8 +468,6 @@ type ObjectField struct {
Expr2, Expr3 Node // In scope of the object (can see self).
}
// TODO(jbeda): Add the remaining constructor helpers here
func ObjectFieldLocalNoMethod(id *Identifier, body Node) ObjectField {
return ObjectField{ObjectLocal, ObjectFieldVisible, false, false, nil, nil, id, nil, false, body, nil}
}

View File

@ -25,7 +25,6 @@ import (
)
type ErrorFormatter struct {
// TODO(sbarzowski) use this
// MaxStackTraceSize is the maximum length of stack trace before cropping
MaxStackTraceSize int

View File

@ -1,5 +1,3 @@
testdata/insuper2:1:11-13 Expected token OPERATOR but got (in, "in")
{ } { "x" in super }
{
"x": false
}

View File

@ -1 +1 @@
{ } { "x" in super }
{ } { x: "x" in super }

10
testdata/missing_super.golden vendored Normal file
View File

@ -0,0 +1,10 @@
RUNTIME ERROR: Attempt to use super when there is no super class.
-------------------------------------------------
testdata/missing_super:1:6-11 object <anonymous>
{ x: super.x }
-------------------------------------------------
During manifestation

1
testdata/missing_super.jsonnet vendored Normal file
View File

@ -0,0 +1 @@
{ x: super.x }

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Field does not exist: x
RUNTIME ERROR: Attempt to use super when there is no super class.
-------------------------------------------------
testdata/object_invariant7:1:16-21 object <anonymous>

View File

@ -100,8 +100,6 @@ func (th *callThunk) getValue(i *interpreter, trace *TraceElement) (value, error
// the first evaluation.
// Note: All potentialValues are required to provide the same value every time,
// so it's only there for efficiency.
// TODO(sbarzowski) better name?
// TODO(sbarzowski) force use cached/ready everywhere? perhaps an interface tag?
// TODO(sbarzowski) investigate efficiency of various representations
type cachedThunk struct {
pv evaluable

View File

@ -166,13 +166,14 @@ func int64ToValue(i int64) *valueNumber {
return makeValueNumber(float64(i))
}
// TODO(dcunnin): Maybe intern values null, true, and false?
type valueNull struct {
valueBase
}
var nullValue valueNull
func makeValueNull() *valueNull {
return &valueNull{}
return &nullValue
}
func (*valueNull) typename() string {
@ -274,9 +275,8 @@ func args(xs ...potentialValue) callArguments {
// Object is a value that allows indexing (taking a value of a field)
// and combining through mixin inheritence (operator +).
//
// Accessing a field multiple times results in multiple evaluations.
// TODO(sbarzowski) This can be very easily avoided and currently innocent looking
// code may be in fact exponential.
// Note that every time a field is indexed it evaluates it again, there is
// no caching of field values. See: https://github.com/google/go-jsonnet/issues/113
type valueObject interface {
value
inheritanceSize() int
@ -471,7 +471,6 @@ type unboundField interface {
// This represenation allows us to implement "+" in O(1),
// but requires going through the tree and trying subsequent leafs for field access.
//
// TODO(sbarzowski) consider other representations (this representation was chosen to stay close to C++ version)
type valueExtendedObject struct {
valueObjectBase
left, right valueObject
@ -515,7 +514,6 @@ func findField(curr value, minSuperDepth int, f string) (*valueSimpleObjectField
return &field, curr.upValues, 0
}
}
// TODO(sbarzowski) add handling of "Attempt to use super when there is no super class."
return nil, nil, 0
default:
panic(fmt.Sprintf("Unknown object type %#v", curr))
@ -527,6 +525,9 @@ func objectIndex(e *evaluator, sb selfBinding, fieldName string) (value, error)
if err != nil {
return nil, err
}
if sb.superDepth >= sb.self.inheritanceSize() {
return nil, e.Error("Attempt to use super when there is no super class.")
}
objp := tryObjectIndex(sb, fieldName, withHidden)
if objp == nil {
return nil, e.Error(fmt.Sprintf("Field does not exist: %s", fieldName))

3
vm.go
View File

@ -28,8 +28,6 @@ import (
// Note: There are no garbage collection params because we're using the native
// Go garbage collector.
// TODO(sbarzowski) prepare API that maps 1-1 to libjsonnet api
// VM is the core interpreter and is the touchpoint used to parse and execute
// Jsonnet.
type VM struct {
@ -40,7 +38,6 @@ type VM struct {
ef ErrorFormatter
}
// TODO(sbarzowski) actually support these
// External variable (or code) provided before execution
type vmExt struct {
value string // what is it?