diff options
| author | Ben Winston | 2023-05-22 22:09:46 -0400 |
|---|---|---|
| committer | Ben Winston | 2023-05-22 22:09:46 -0400 |
| commit | 5b623d43c5681ed292a0d83a49255f035c40df91 (patch) | |
| tree | ad2a1ceee949b5067a83c8db39c79ebbecf049fc /parser.d | |
| parent | ab6deb5eb1244f566c8a8b22022c68d50d5eb4d7 (diff) | |
compile-time typechecking WIP
Diffstat (limited to 'parser.d')
| -rw-r--r-- | parser.d | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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 { |
