From fb6ad7f636816b80ae16c4b74229b9b45a3479f8 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 12 Jul 2021 20:06:56 -0600 Subject: [PATCH] add compiler warnings --- src/kiss/CompileError.hx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kiss/CompileError.hx b/src/kiss/CompileError.hx index 45ad3a3..110623e 100644 --- a/src/kiss/CompileError.hx +++ b/src/kiss/CompileError.hx @@ -23,7 +23,7 @@ class CompileError { return new CompileError(exps, message); } - public function toString() { + public function toString(warning=false) { var posPrefix = switch (exps.length) { case 1: exps[0].pos.toPrint(); @@ -34,11 +34,17 @@ class CompileError { firstPos + '-' + lastPos.substr(justLineAndColumnIdx); } - return '\nKiss compilation failed!\n' + var failed = if (warning) "warning!"; else "failed!"; + + return '\nKiss compilation $failed\n' + posPrefix + ": " + message + "\nFrom:" + [for (exp in exps) exp.def.toString()].toString(); } + + public static function warnFromExp(exp:ReaderExp, message:String) { + Prelude.print(new CompileError([exp], message).toString(true)); + } }