Skip to content

Commit bdfa979

Browse files
committed
prioritised TODO's
1 parent ff4e5aa commit bdfa979

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

object.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func ObjectGetProperty(obj Object, name string) Value {
120120
}
121121
}
122122

123-
// TODO: we only support `struct` for now. Perhaps simple types (int, float, etc) are worthwhile an enhancement?
123+
// TODO: we only support `struct` receivers for now. Perhaps simple types (int, float, etc) are worthwhile an enhancement?
124124
if t.Kind() != reflect.Struct {
125125
return NewUndefinedWithReasonf("object is '%s' but only 'struct' and '*struct' are currently supported", t.Kind())
126126
}
@@ -143,7 +143,7 @@ func ObjectGetProperty(obj Object, name string) Value {
143143
// allow support for (non-empty) interfaces
144144
return ObjectValue{Object: fieldReflectValue.Interface()}
145145
}
146-
case reflect.Struct: // TODO: incomplete code: see ObjectGetProperty to handle `*struct` scenario.
146+
case reflect.Struct: // TODO: (!!) incomplete code: see ObjectGetProperty to handle `*struct` scenario.
147147
// allow support for struct types
148148
return ObjectValue{Object: fieldReflectValue.Interface()}
149149
}
@@ -246,7 +246,7 @@ func ObjectGetMethod(obj Object, name string) (FunctionalValue, bool) {
246246
// allow support for (non-empty) interfaces
247247
return ObjectValue{Object: out[0].Interface()}
248248
}
249-
case reflect.Struct: // TODO: incomplete code: see ObjectGetProperty to handle `*struct` scenario.
249+
case reflect.Struct: // TODO: (!!) incomplete code: see ObjectGetProperty to handle `*struct` scenario.
250250
// allow support for struct types
251251
return ObjectValue{Object: out[0].Interface()}
252252
}

tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (tree Tree) Calc(isOperatorInPrecedenceGroup func(Operator) bool, cfg *tree
156156
}
157157
}
158158

159-
// TODO: implement Calc() on all entry types (Value, Function, Variable, ObjectProperty, ObjectAccessor, etc.)
159+
// TODO: (!!) implement Calc() on all entry types (Value, Function, Variable, ObjectProperty, ObjectAccessor, etc.)
160160
// ... and move the logic of each case below to the entry type itself.
161161
switch e.kind() {
162162
case valueEntryKind:

tree_builder_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,10 @@ func TestTreeBuilder_FromExpr_Dot_Accessor_Property(t *testing.T) {
274274
assert.Equal(t, gal.NewNumberFromFloat(100), gotVal)
275275
}
276276

277-
// TODO: this is an idea for a future feature
277+
// TODO: (!) this is an idea for a future feature
278278
// func TestTreeBuilder_FromExpr_Arrays(t *testing.T) {
279-
// expr := `f(1 2 3)[1]`
279+
// expr := `f(1 2 3)[1]` // simple example
280+
// expr := `f(1 2 3)[1 + sum(1 2 3)]` // complex example
280281

281282
// funcs := gal.Functions{
282283
// "f": func(args ...gal.Value) gal.Value { return gal.NewMultiValue(args...) },
@@ -297,6 +298,11 @@ func TestTreeBuilder_FromExpr_Dot_Accessor_Property(t *testing.T) {
297298
// gal.Tree{
298299
// gal.NewNumberFromInt(3),
299300
// },
301+
// gal.Collection{ // this would work similarly to gal.Dot but with the lhs as the collection and the rhs as the index
302+
// gal.Tree{
303+
// gal.NewNumberFromInt(1),
304+
// },
305+
// },
300306
// ),
301307
// }
302308

tree_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type treeConfig struct {
4444
}
4545

4646
// Variable returns the value of the variable specified by name.
47-
// TODO: add support for arrays and maps via `[...]`
47+
// TODO: (!) add support for arrays and maps via `[...]`
4848
// ... NOTE: it may be more adequate to create a new `[]` operator.
4949
// ... This would also permit its use on any Value, including those returned from function calls.
5050
// ... We would likely need to create new types (unless MultiValue can work for this).

0 commit comments

Comments
 (0)