diff --git a/source/app.d b/source/app.d index b864b19..12fe29d 100644 --- a/source/app.d +++ b/source/app.d @@ -47,8 +47,8 @@ Flags: Backends and their operating systems: rm86 - Real mode x86, for bare-metal, DOS - x86_64 - 64-bit x86, for bare-metal, Linux - arm64 - 64-bit ARM, for Linux + x86_64 - 64-bit x86, for bare-metal, linux, osx + arm64 - 64-bit ARM, for linux uxn - Varvara/Uxn lua - Lua, uses subset CallistoScript diff --git a/source/backends/arm64.d b/source/backends/arm64.d index add8ab0..3a7bbc2 100644 --- a/source/backends/arm64.d +++ b/source/backends/arm64.d @@ -114,6 +114,7 @@ class BackendARM64 : CompilerBackend { types ~= Type("size", 8); types ~= Type("usize", 8); types ~= Type("cell", 8); + types ~= Type("bool", 8); // built in structs types ~= Type("Array", 24, true, [ @@ -126,8 +127,16 @@ class BackendARM64 : CompilerBackend { NewConst("Array.elements", 16); NewConst("Array.sizeof", 8 * 3); - foreach (name, ref type ; types) { - NewConst(format("%s.sizeof", name), cast(long) type.size); + types ~= Type("Exception", 24 + 8, true, [ + StructEntry(GetType("bool"), "error"), + StructEntry(GetType("Array"), "msg") + ]); + NewConst("Exception.bool", 0); + NewConst("Exception.msg", 8); + NewConst("Exception.sizeof", 24 + 8); + + foreach (ref type ; types) { + NewConst(format("%s.sizeof", type.name), cast(long) type.size); } } diff --git a/source/backends/lua.d b/source/backends/lua.d index f18f726..84af844 100644 --- a/source/backends/lua.d +++ b/source/backends/lua.d @@ -96,6 +96,7 @@ class BackendLua : CompilerBackend { types ~= Type("size", 1); types ~= Type("usize", 1); types ~= Type("cell", 1); + types ~= Type("bool", 1); // built in structs types ~= Type("Array", 3, true, [ @@ -108,8 +109,16 @@ class BackendLua : CompilerBackend { NewConst("Array.elements", 2); NewConst("Array.sizeof", 3); - foreach (name, ref type ; types) { - NewConst(format("%s.sizeof", name), cast(long) type.size); + types ~= Type("Exception", 3 + 1, true, [ + StructEntry(GetType("bool"), "error"), + StructEntry(GetType("Array"), "msg") + ]); + NewConst("Exception.bool", 0); + NewConst("Exception.msg", 1); + NewConst("Exception.sizeof", 3 + 1); + + foreach (ref type ; types) { + NewConst(format("%s.sizeof", type.name), cast(long) type.size); } } diff --git a/source/backends/rm86.d b/source/backends/rm86.d index 4cfac30..f14b35d 100644 --- a/source/backends/rm86.d +++ b/source/backends/rm86.d @@ -84,14 +84,15 @@ class BackendRM86 : CompilerBackend { this() { defaultOS = "dos"; - types ~= Type("u8", 1); - types ~= Type("i8", 1); - types ~= Type("u16", 2); - types ~= Type("i16", 2); - types ~= Type("addr", 2); - types ~= Type("size", 2); + types ~= Type("u8", 1); + types ~= Type("i8", 1); + types ~= Type("u16", 2); + types ~= Type("i16", 2); + types ~= Type("addr", 2); + types ~= Type("size", 2); types ~= Type("usize", 2); - types ~= Type("cell", 2); + types ~= Type("cell", 2); + types ~= Type("bool", 2); // built in structs types ~= Type("Array", 6, true, [ @@ -104,11 +105,19 @@ class BackendRM86 : CompilerBackend { NewConst("Array.elements", 4); NewConst("Array.sizeof", 2 * 3); + types ~= Type("Exception", 6 + 2, true, [ + StructEntry(GetType("bool"), "error"), + StructEntry(GetType("Array"), "msg") + ]); + NewConst("Exception.bool", 0); + NewConst("Exception.msg", 2); + NewConst("Exception.sizeof", 6 + 2); + foreach (ref type ; types) { NewConst(format("%s.sizeof", type.name), cast(long) type.size); } - if (!opts.noDos) { + if (!opts.noDos) { // TODO: remove this globals["__rm86_argv"] = Global(GetType("addr"), false, 0); globals["__rm86_arglen"] = Global(GetType("cell"), false, 0); } diff --git a/source/backends/uxn.d b/source/backends/uxn.d index 10c04dc..2d172d1 100644 --- a/source/backends/uxn.d +++ b/source/backends/uxn.d @@ -97,8 +97,16 @@ class BackendUXN : CompilerBackend { NewConst("Array.elements", 4); NewConst("Array.sizeof", 2 * 3); - foreach (name, ref type ; types) { - NewConst(format("%s.sizeof", name), cast(long) type.size); + types ~= Type("Exception", 6 + 2, true, [ + StructEntry(GetType("bool"), "error"), + StructEntry(GetType("Array"), "msg") + ]); + NewConst("Exception.bool", 0); + NewConst("Exception.msg", 2); + NewConst("Exception.sizeof", 6 + 2); + + foreach (ref type ; types) { + NewConst(format("%s.sizeof", type.name), cast(long) type.size); } } diff --git a/source/backends/x86_64.d b/source/backends/x86_64.d index 573f11c..9cfc0bb 100644 --- a/source/backends/x86_64.d +++ b/source/backends/x86_64.d @@ -116,6 +116,7 @@ class BackendX86_64 : CompilerBackend { types ~= Type("size", 8); types ~= Type("usize", 8); types ~= Type("cell", 8); + types ~= Type("bool", 8); // built in structs types ~= Type("Array", 24, true, [ @@ -128,8 +129,16 @@ class BackendX86_64 : CompilerBackend { NewConst("Array.elements", 16); NewConst("Array.sizeof", 8 * 3); - foreach (name, ref type ; types) { - NewConst(format("%s.sizeof", name), cast(long) type.size); + types ~= Type("Exception", 24 + 8, true, [ + StructEntry(GetType("bool"), "error"), + StructEntry(GetType("Array"), "msg") + ]); + NewConst("Exception.bool", 0); + NewConst("Exception.msg", 8); + NewConst("Exception.sizeof", 24 + 8); + + foreach (ref type ; types) { + NewConst(format("%s.sizeof", type.name), cast(long) type.size); } }