diff options
Diffstat (limited to 'pkg/lang/modules/natives/natives.go')
| -rw-r--r-- | pkg/lang/modules/natives/natives.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/lang/modules/natives/natives.go b/pkg/lang/modules/natives/natives.go new file mode 100644 index 0000000..a1b09b6 --- /dev/null +++ b/pkg/lang/modules/natives/natives.go @@ -0,0 +1,39 @@ +package natives + +import ( + "jinx/pkg/lang/modules/core" + "jinx/pkg/lang/vm/executor" +) + +var Natives = makeNatives( + core.Natives, +) + +func makeNatives(moduleNativesArrays ...[]any) []Native { + natives := make([]Native, 0) + + for _, moduleNatives := range moduleNativesArrays { + for _, moduleNativeI := range moduleNatives { + moduleNative := moduleNativeI.(moduleNative) + + natives = append(natives, Native{ + Name: moduleNative.Name(), + ArgCount: moduleNative.ArgCount(), + Fn: moduleNative.Fn(), + }) + } + } + return natives +} + +type Native struct { + Name string + ArgCount int + Fn executor.NativeFunc +} + +type moduleNative interface { + Name() string + ArgCount() int + Fn() executor.NativeFunc +} |
