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;
|
2021-04-23 13:07:19 +01:00
|
|
|
import std.string : cmp;
|
|
|
|
|
2021-04-24 12:16:48 +01:00
|
|
|
public import compiler.symbols.typing.builtins;
|
|
|
|
|
2021-04-16 22:44:56 +01:00
|
|
|
public class Type : Entity
|
|
|
|
{
|
2021-04-24 12:16:48 +01:00
|
|
|
/* 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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-24 12:16:48 +01:00
|
|
|
/* TODO: Move width to Type class */
|
2021-04-21 22:27:44 +01:00
|
|
|
public class Number : Type
|
|
|
|
{
|
2021-04-21 22:29:00 +01:00
|
|
|
/* Number of bytes (1,2,4,8) */
|
|
|
|
private ubyte width;
|
2021-04-21 22:29:14 +01:00
|
|
|
|
2021-04-24 12:16:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* TODO: Aligbment details etc. */
|
|
|
|
|
|
|
|
this(string name, ubyte width)
|
2021-04-21 22:27:44 +01:00
|
|
|
{
|
|
|
|
super(name);
|
2021-04-24 12:16:48 +01:00
|
|
|
this.width = width;
|
2021-04-21 22:27:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class Integer : Number
|
|
|
|
{
|
2021-04-24 12:16:48 +01:00
|
|
|
/* Whether or not signed (if so, then 2's complement) */
|
|
|
|
private bool signed;
|
2021-04-26 09:04:24 +01:00
|
|
|
|
2021-04-24 12:16:48 +01:00
|
|
|
this(string name, ubyte width, bool signed = false)
|
2021-04-21 22:27:44 +01:00
|
|
|
{
|
2021-04-24 12:16:48 +01:00
|
|
|
super(name, width);
|
|
|
|
this.signed = signed;
|
2021-04-21 22:27:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class Float : Number
|
|
|
|
{
|
|
|
|
this(string name)
|
|
|
|
{
|
2021-04-24 12:16:48 +01:00
|
|
|
/* TODO: Change */
|
|
|
|
super(name, 69);
|
2021-04-21 22:27:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class Double : Number
|
|
|
|
{
|
|
|
|
this(string name)
|
|
|
|
{
|
2021-04-24 12:16:48 +01:00
|
|
|
/* TODO: Change */
|
|
|
|
super(name, 69);
|
2021-04-21 22:27:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-24 12:16:48 +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
|
|
|
{
|
2021-04-24 12:16:48 +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
|
|
|
}
|
|
|
|
}
|