1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-08-13 19:52:52 +02:00

Feature/inner html element child (#82)

* SOme wokrd

* Renamed example

* Updated example
This commit is contained in:
Tim Voronov
2018-10-08 20:20:40 -04:00
committed by GitHub
parent 0004667df6
commit 05a7582bba
13 changed files with 322 additions and 209 deletions

View File

@@ -54,24 +54,37 @@ func (operator *RangeOperator) Exec(ctx context.Context, scope *core.Scope) (cor
}
func (operator *RangeOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error) {
err := core.ValidateType(left, core.IntType)
err := core.ValidateType(left, core.IntType, core.FloatType)
if err != nil {
return values.None, core.SourceError(operator.src, err)
}
err = core.ValidateType(right, core.IntType)
err = core.ValidateType(right, core.IntType, core.FloatType)
if err != nil {
return values.None, core.SourceError(operator.src, err)
}
var start int
var end int
if left.Type() == core.FloatType {
start = int(left.(values.Float))
} else {
start = int(left.(values.Int))
}
if right.Type() == core.FloatType {
end = int(right.(values.Float))
} else {
end = int(right.(values.Int))
}
arr := values.NewArray(10)
start := left.(values.Int)
end := right.(values.Int)
for i := start; i <= end; i++ {
arr.Push(i)
arr.Push(values.NewInt(i))
}
return arr, nil