tlang/source/tlang/compiler/symbols/typing/core.d

90 lines
1.6 KiB
D
Raw Normal View History

2021-04-23 13:19:46 +01:00
module compiler.symbols.typing.core;
2021-04-16 21:50:53 +01:00
2021-04-16 22:44:56 +01:00
import compiler.symbols.data;
import std.string : cmp;
public import compiler.symbols.typing.builtins;
2021-04-16 22:44:56 +01:00
public class Type : Entity
{
/* TODO: Add width here */
2021-04-21 22:27:44 +01:00
/**
* TODO: See what we need in here, Entity name could be our Type name
* But to make it look nice we could just have `getType`
* Actually yeah, we should, as Number types won't be entities
* Wait lmao they will
*/
this(string name)
{
super(name);
}
}
2021-04-26 09:04:24 +01:00
public final class Void : Type
{
this()
{
super("void");
}
}
/* TODO: Move width to Type class */
2021-04-21 22:27:44 +01:00
public class Number : Type
{
/* Number of bytes (1,2,4,8) */
private ubyte width;
2021-04-21 22:29:14 +01:00
/* TODO: Aligbment details etc. */
this(string name, ubyte width)
2021-04-21 22:27:44 +01:00
{
super(name);
this.width = width;
2021-04-21 22:27:44 +01:00
}
}
public class Integer : Number
{
/* Whether or not signed (if so, then 2's complement) */
private bool signed;
2021-04-26 09:04:24 +01:00
this(string name, ubyte width, bool signed = false)
2021-04-21 22:27:44 +01:00
{
super(name, width);
this.signed = signed;
2021-04-21 22:27:44 +01:00
}
}
public class Float : Number
{
this(string name)
{
/* TODO: Change */
super(name, 69);
2021-04-21 22:27:44 +01:00
}
}
public class Double : Number
{
this(string name)
{
/* TODO: Change */
super(name, 69);
2021-04-21 22:27:44 +01:00
}
}
public class Pointer : Integer
2021-04-21 22:27:44 +01:00
{
2021-04-23 08:15:03 +01:00
/* Data type being pointed to */
private Type dataType;
2021-04-21 22:27:44 +01:00
2021-04-23 08:15:03 +01:00
this(string name, Type dataType)
2021-04-16 22:44:56 +01:00
{
/* TODO: Change below, per architetcure */
super(name, 8);
2021-04-23 08:15:03 +01:00
this.dataType = dataType;
2021-04-16 22:44:56 +01:00
}
}