Skip to content

Commit

Permalink
Clean up some TODOs
Browse files Browse the repository at this point in the history
Some were stale, some were transformed into issues, some were fixed
  • Loading branch information
sbarzowski authored and sparkprime committed Oct 6, 2017
1 parent a4058fc commit f0f7041
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
2 changes: 0 additions & 2 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
1 change: 0 additions & 1 deletion error_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

type ErrorFormatter struct {
// TODO(sbarzowski) use this
// MaxStackTraceSize is the maximum length of stack trace before cropping
MaxStackTraceSize int

Expand Down
8 changes: 3 additions & 5 deletions testdata/insuper2.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
testdata/insuper2:1:11-13 Expected token OPERATOR but got (in, "in")

{ } { "x" in super }


{
"x": false
}
2 changes: 1 addition & 1 deletion testdata/insuper2.jsonnet
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ } { "x" in super }
{ } { x: "x" in super }
10 changes: 10 additions & 0 deletions testdata/missing_super.golden
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions testdata/missing_super.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ x: super.x }
2 changes: 1 addition & 1 deletion testdata/object_invariant7.golden
Original file line number Diff line number Diff line change
@@ -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>

Expand Down
2 changes: 0 additions & 2 deletions thunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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?
Expand Down

0 comments on commit f0f7041

Please sign in to comment.