Skip to content

Commit 7c00a00

Browse files
committed
fix usage and .sizeof not working
1 parent c599c4d commit 7c00a00

File tree

6 files changed

+62
-18
lines changed

6 files changed

+62
-18
lines changed

source/app.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Flags:
4747
4848
Backends and their operating systems:
4949
rm86 - Real mode x86, for bare-metal, DOS
50-
x86_64 - 64-bit x86, for bare-metal, Linux
51-
arm64 - 64-bit ARM, for Linux
50+
x86_64 - 64-bit x86, for bare-metal, linux, osx
51+
arm64 - 64-bit ARM, for linux
5252
uxn - Varvara/Uxn
5353
lua - Lua, uses subset CallistoScript
5454

source/backends/arm64.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class BackendARM64 : CompilerBackend {
114114
types ~= Type("size", 8);
115115
types ~= Type("usize", 8);
116116
types ~= Type("cell", 8);
117+
types ~= Type("bool", 8);
117118

118119
// built in structs
119120
types ~= Type("Array", 24, true, [
@@ -126,8 +127,16 @@ class BackendARM64 : CompilerBackend {
126127
NewConst("Array.elements", 16);
127128
NewConst("Array.sizeof", 8 * 3);
128129

129-
foreach (name, ref type ; types) {
130-
NewConst(format("%s.sizeof", name), cast(long) type.size);
130+
types ~= Type("Exception", 24 + 8, true, [
131+
StructEntry(GetType("bool"), "error"),
132+
StructEntry(GetType("Array"), "msg")
133+
]);
134+
NewConst("Exception.bool", 0);
135+
NewConst("Exception.msg", 8);
136+
NewConst("Exception.sizeof", 24 + 8);
137+
138+
foreach (ref type ; types) {
139+
NewConst(format("%s.sizeof", type.name), cast(long) type.size);
131140
}
132141
}
133142

source/backends/lua.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class BackendLua : CompilerBackend {
9696
types ~= Type("size", 1);
9797
types ~= Type("usize", 1);
9898
types ~= Type("cell", 1);
99+
types ~= Type("bool", 1);
99100

100101
// built in structs
101102
types ~= Type("Array", 3, true, [
@@ -108,8 +109,16 @@ class BackendLua : CompilerBackend {
108109
NewConst("Array.elements", 2);
109110
NewConst("Array.sizeof", 3);
110111

111-
foreach (name, ref type ; types) {
112-
NewConst(format("%s.sizeof", name), cast(long) type.size);
112+
types ~= Type("Exception", 3 + 1, true, [
113+
StructEntry(GetType("bool"), "error"),
114+
StructEntry(GetType("Array"), "msg")
115+
]);
116+
NewConst("Exception.bool", 0);
117+
NewConst("Exception.msg", 1);
118+
NewConst("Exception.sizeof", 3 + 1);
119+
120+
foreach (ref type ; types) {
121+
NewConst(format("%s.sizeof", type.name), cast(long) type.size);
113122
}
114123
}
115124

source/backends/rm86.d

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,15 @@ class BackendRM86 : CompilerBackend {
8484
this() {
8585
defaultOS = "dos";
8686

87-
types ~= Type("u8", 1);
88-
types ~= Type("i8", 1);
89-
types ~= Type("u16", 2);
90-
types ~= Type("i16", 2);
91-
types ~= Type("addr", 2);
92-
types ~= Type("size", 2);
87+
types ~= Type("u8", 1);
88+
types ~= Type("i8", 1);
89+
types ~= Type("u16", 2);
90+
types ~= Type("i16", 2);
91+
types ~= Type("addr", 2);
92+
types ~= Type("size", 2);
9393
types ~= Type("usize", 2);
94-
types ~= Type("cell", 2);
94+
types ~= Type("cell", 2);
95+
types ~= Type("bool", 2);
9596

9697
// built in structs
9798
types ~= Type("Array", 6, true, [
@@ -104,11 +105,19 @@ class BackendRM86 : CompilerBackend {
104105
NewConst("Array.elements", 4);
105106
NewConst("Array.sizeof", 2 * 3);
106107

108+
types ~= Type("Exception", 6 + 2, true, [
109+
StructEntry(GetType("bool"), "error"),
110+
StructEntry(GetType("Array"), "msg")
111+
]);
112+
NewConst("Exception.bool", 0);
113+
NewConst("Exception.msg", 2);
114+
NewConst("Exception.sizeof", 6 + 2);
115+
107116
foreach (ref type ; types) {
108117
NewConst(format("%s.sizeof", type.name), cast(long) type.size);
109118
}
110119

111-
if (!opts.noDos) {
120+
if (!opts.noDos) { // TODO: remove this
112121
globals["__rm86_argv"] = Global(GetType("addr"), false, 0);
113122
globals["__rm86_arglen"] = Global(GetType("cell"), false, 0);
114123
}

source/backends/uxn.d

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,16 @@ class BackendUXN : CompilerBackend {
9797
NewConst("Array.elements", 4);
9898
NewConst("Array.sizeof", 2 * 3);
9999

100-
foreach (name, ref type ; types) {
101-
NewConst(format("%s.sizeof", name), cast(long) type.size);
100+
types ~= Type("Exception", 6 + 2, true, [
101+
StructEntry(GetType("bool"), "error"),
102+
StructEntry(GetType("Array"), "msg")
103+
]);
104+
NewConst("Exception.bool", 0);
105+
NewConst("Exception.msg", 2);
106+
NewConst("Exception.sizeof", 6 + 2);
107+
108+
foreach (ref type ; types) {
109+
NewConst(format("%s.sizeof", type.name), cast(long) type.size);
102110
}
103111
}
104112

source/backends/x86_64.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class BackendX86_64 : CompilerBackend {
116116
types ~= Type("size", 8);
117117
types ~= Type("usize", 8);
118118
types ~= Type("cell", 8);
119+
types ~= Type("bool", 8);
119120

120121
// built in structs
121122
types ~= Type("Array", 24, true, [
@@ -128,8 +129,16 @@ class BackendX86_64 : CompilerBackend {
128129
NewConst("Array.elements", 16);
129130
NewConst("Array.sizeof", 8 * 3);
130131

131-
foreach (name, ref type ; types) {
132-
NewConst(format("%s.sizeof", name), cast(long) type.size);
132+
types ~= Type("Exception", 24 + 8, true, [
133+
StructEntry(GetType("bool"), "error"),
134+
StructEntry(GetType("Array"), "msg")
135+
]);
136+
NewConst("Exception.bool", 0);
137+
NewConst("Exception.msg", 8);
138+
NewConst("Exception.sizeof", 24 + 8);
139+
140+
foreach (ref type ; types) {
141+
NewConst(format("%s.sizeof", type.name), cast(long) type.size);
133142
}
134143
}
135144

0 commit comments

Comments
 (0)