Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bbq/vm/builtin_globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,21 @@ func init() {
for _, declaration := range interpreter.ConverterDeclarations {
// NOTE: declare in loop, as captured in closure below
convert := declaration.Convert
convertWithRounding := declaration.ConvertWithRounding

functionType := sema.BaseValueActivation.Find(declaration.Name).Type.(*sema.FunctionType)

var nativeFn interpreter.NativeFunction
if convertWithRounding != nil {
nativeFn = interpreter.NativeConverterFunctionWithRounding(convert, convertWithRounding)
} else {
nativeFn = interpreter.NativeConverterFunction(convert)
}

function := NewNativeFunctionValue(
declaration.Name,
functionType,
interpreter.NativeConverterFunction(convert),
nativeFn,
)
registerBuiltinFunction(function)

Expand Down
7 changes: 7 additions & 0 deletions bbq/vm/value_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ func (v *NativeFunctionValue) GetMember(
)
}

func (v *NativeFunctionValue) SetField(name string, value interpreter.Value) {
if v.fields == nil {
v.fields = make(map[string]interpreter.Value)
}
v.fields[name] = value
}

func (*NativeFunctionValue) RemoveMember(_ interpreter.ValueTransferContext, _ string) interpreter.Value {
panic(errors.NewUnreachableError())
}
Expand Down
Loading
Loading