add file trace to parser, refactor, fix inner type

This commit is contained in:
Neemek 2025-09-30 14:09:05 +02:00
parent bcf0978b68
commit c8660a6471
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
10 changed files with 131 additions and 51 deletions

View file

@ -467,6 +467,31 @@ var ListPrototype = map[string]*BuiltinFunctionValue{
nil,
false,
},
"put": {
"put",
&FunctionSignature{
[]TypeSignature{
&NumberSignature{}, &InnerSignature{},
},
&NilSignature{},
},
func(_ *VM, this Value, args []Value) (Value, error) {
l := this.(*ListValue)
i := int(args[0].(*NumberValue).Number)
v := args[1]
// bounds check
if i < 0 || i >= len(l.Items) {
return nil, errors.New(fmt.Sprintf("index %x out of range", i))
}
l.Items[i] = v
return &NilValue{}, nil
},
nil,
false,
},
"length": {
"length",
&FunctionSignature{