From 5b623d43c5681ed292a0d83a49255f035c40df91 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Mon, 22 May 2023 22:09:46 -0400 Subject: compile-time typechecking WIP --- parser.d | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'parser.d') diff --git a/parser.d b/parser.d index e219ec7..11691f9 100644 --- a/parser.d +++ b/parser.d @@ -34,6 +34,8 @@ abstract class Form { bool evaluate; int line; + ValueType returnType = ValueType.ANY; + //ubyte compile(Chunk chunk); //ubyte[] asBytecode(); //abstract void compile(Chunk chunk); @@ -170,6 +172,7 @@ class And : Form { this(int line) { this.line = line; this.type = FormType.AND; + this.returnType = ValueType.BOOLEAN; } void addClause(Form clause) { @@ -184,6 +187,7 @@ class Or : Form { this(int line) { this.line = line; this.type = FormType.OR; + this.returnType = ValueType.BOOLEAN; } void addClause(Form clause) { @@ -240,6 +244,7 @@ class Atom : Form { this.line = line; this.type = FormType.ATOM; this.evaluate = false; + this.returnType = this.value.type; } this(double value, int line) { @@ -247,6 +252,7 @@ class Atom : Form { this.line = line; this.type = FormType.ATOM; this.evaluate = false; + this.returnType = this.value.type; } this(bool value, int line) { @@ -254,6 +260,7 @@ class Atom : Form { this.line = line; this.type = FormType.ATOM; this.evaluate = false; + this.returnType = this.value.type; } } @@ -264,6 +271,8 @@ enum ValueType { BOOLEAN, TYPE, OBJ, + ANY, + NIL, } union As { -- cgit v1.2.3