summaryrefslogtreecommitdiff
path: root/Compiler/CType.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-27 21:22:55 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-27 21:22:55 +1000
commit634681ce2bb36cd686943102a0f071cd6a09049f (patch)
tree6710047aa231d50f57114bdd54a27c559fb20a73 /Compiler/CType.cs
parent94ddc02e03ab942d0c881e29053e8df3d2940c30 (diff)
fixed bugs and revolutionized the universe
Diffstat (limited to 'Compiler/CType.cs')
-rw-r--r--Compiler/CType.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Compiler/CType.cs b/Compiler/CType.cs
new file mode 100644
index 0000000..61b5108
--- /dev/null
+++ b/Compiler/CType.cs
@@ -0,0 +1,31 @@
+namespace Q1.Compiler.visitors;
+
+public class CType
+{
+ public string Name;
+ public int Size;
+
+ public CType(string name, int size)
+ {
+ this.Name = name;
+ this.Size = size;
+
+ if (size > 2)
+ throw new CompilerException("Types that take up more than 2 bytes are not supported");
+ }
+
+ public override string ToString() => this.Name;
+
+ public static readonly CType Int = new("int", 2);
+ public static readonly CType Char = new("char", 1);
+}
+
+public class CTypePtr : CType
+{
+ public CType Sub;
+
+ public CTypePtr(CType sub) : base($"{sub.Name}*",2)
+ {
+ this.Sub = sub;
+ }
+} \ No newline at end of file