about summary refs log tree commit diff
path: root/pkg/lang/modules/natives
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-08-11 01:25:47 +0000
committerMel <einebeere@gmail.com>2022-08-11 01:25:47 +0000
commit86f31acf6789be116dcc54ed85b069a37c0f7aa8 (patch)
treebc7afd6a8c340825996d29c6cfd392ae42b4fbd5 /pkg/lang/modules/natives
parentc46b2bc7ce6df1f2c6c9494ef08015ec29992da5 (diff)
downloadjinx-86f31acf6789be116dcc54ed85b069a37c0f7aa8.tar.zst
jinx-86f31acf6789be116dcc54ed85b069a37c0f7aa8.zip
Actual modules and core
Diffstat (limited to 'pkg/lang/modules/natives')
-rw-r--r--pkg/lang/modules/natives/natives.go39
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
+}