Allow querying whether a type exists.

This commit is contained in:
back2dos
2017-03-06 17:57:30 +01:00
parent 4c523e02a5
commit dbebd0d70d

View File

@@ -13,6 +13,16 @@ using tink.macro.Functions;
using tink.CoreApi;
class Types {
static public function definedType(typeName:String)
return
try {
Some(Context.getType(typeName));
}
catch (e:Dynamic)
if (Std.string(e) == 'Type not found \'$typeName\'') None;
else neko.Lib.rethrow(e);
static var types = new Map<Int,Void->Type>();
static var idCounter = 0;
static public function getID(t:Type, ?reduced = true)