diff --git a/src/kernel/Init.hx b/src/kernel/Init.hx index 6ab1f1c..acde5ab 100644 --- a/src/kernel/Init.hx +++ b/src/kernel/Init.hx @@ -1,5 +1,6 @@ package kernel; +import kernel.binstore.BinStore; import kernel.gps.INS; import kernel.fs.FS; import kernel.gps.GPS; @@ -27,6 +28,8 @@ class Init { WindowManager.instance = new WindowManager(); MainTerm.instance = new MainTerm(); + BinStore.instance = new BinStore(); + if (Turtle.isTurtle()){ Turtle.instance = new Turtle(); } diff --git a/src/kernel/binstore/Bin.hx b/src/kernel/binstore/Bin.hx new file mode 100644 index 0000000..3104944 --- /dev/null +++ b/src/kernel/binstore/Bin.hx @@ -0,0 +1,12 @@ +package kernel.binstore; + +import kernel.ps.Process; + +/** + Represents a callable program. +**/ +typedef Bin = { + c: Class, + name: String, + aliases: Array, +} diff --git a/src/kernel/binstore/BinStore.hx b/src/kernel/binstore/BinStore.hx new file mode 100644 index 0000000..d100983 --- /dev/null +++ b/src/kernel/binstore/BinStore.hx @@ -0,0 +1,51 @@ +package kernel.binstore; + +import bin.Turtle; +import bin.Terminal; +import haxe.ds.ReadOnlyArray; +import bin.Redstone; +import bin.Net; +import bin.KernelLog; +import bin.HelloWorld; +import bin.GPS; +import bin.Disk; + +class BinStore { + public static var instance: BinStore; + + private final store:ReadOnlyArray = [ + {c: Disk, name: "Disk", aliases: ["disk"]}, + {c: GPS, name: "GPS", aliases: ["gps"]}, + {c: HelloWorld, name: "HelloWorld", aliases: ["hello"]}, + {c: KernelLog, name: "KernelLog", aliases: ["log"]}, + {c: Net, name: "Net", aliases: ["net"]}, + {c: Redstone, name: "Redstone", aliases: ["redstone","rs"]}, + {c: Terminal, name: "Terminal", aliases: ["terminal","term"]}, + {c: Turtle, name: "Turtle", aliases: ["turtle"]} + ]; + + @:allow(kernel.Init) + private function new() { + + } + + public function getBinByName(name:String):Null { + for (bin in store) { + if (bin.name == name) { + return bin; + } + } + return null; + } + + public function getBinByAlias(alias:String):Null { + for (bin in store) { + for (a in bin.aliases) { + if (a == alias) { + return bin; + } + } + } + return null; + } +}