From 86f31acf6789be116dcc54ed85b069a37c0f7aa8 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 11 Aug 2022 01:25:47 +0000 Subject: Actual modules and core --- pkg/lang/modules/natives/natives.go | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pkg/lang/modules/natives/natives.go (limited to 'pkg/lang/modules/natives/natives.go') 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 +} -- cgit 1.4.1