1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-05 00:49:00 +02:00

New type system (#232)

* New type system

* Fixed dot notation for HTML elements
This commit is contained in:
Tim Voronov
2019-02-13 12:31:18 -05:00
committed by GitHub
parent b3bcbda3b9
commit 1af8b37a0f
185 changed files with 1379 additions and 820 deletions

View File

@ -1,12 +1,12 @@
package objects
import (
"fmt"
"context"
"fmt"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Zip returns an object assembled from the separate parameters keys and values.
@ -16,12 +16,13 @@ import (
// @returns (Object) - an object with the keys and values assembled.
func Zip(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
if err != nil {
return values.None, err
}
for _, arg := range args {
if err = core.ValidateType(arg, core.ArrayType); err != nil {
if err = core.ValidateType(arg, types.Array); err != nil {
return values.None, err
}
}
@ -38,7 +39,8 @@ func Zip(_ context.Context, args ...core.Value) (core.Value, error) {
)
}
err = validateArrayOf(core.StringType, keys)
err = validateArrayOf(types.String, keys)
if err != nil {
return values.None, err
}
@ -68,12 +70,14 @@ func Zip(_ context.Context, args ...core.Value) (core.Value, error) {
keyExists[k] = true
val = vals.Get(values.NewInt(idx))
cloneable, ok := val.(core.Cloneable)
if values.IsCloneable(val) {
val = val.(core.Cloneable).Clone()
if ok {
val = cloneable.Clone()
}
zipped.Set(k, val)
return true
})