Compare commits

...

5 Commits

Author SHA1 Message Date
back2dos
b1012937fc Release 0.13.0 2017-03-06 17:58:24 +01:00
back2dos
bd4b8c436f Build cache works better with compiler server. 2017-03-06 17:58:07 +01:00
back2dos
dbebd0d70d Allow querying whether a type exists. 2017-03-06 17:57:30 +01:00
Juraj Kirchheim
4c523e02a5 Release 0.12.3 2017-03-06 14:31:20 +01:00
Juraj Kirchheim
f39fc3b296 Try to save TMono. 2017-03-06 09:16:31 +01:00
4 changed files with 31 additions and 9 deletions

View File

@@ -11,8 +11,8 @@
"contributors": [
"back2dos"
],
"releasenote": "Fix issue with .toComplex()",
"version": "0.12.2",
"releasenote": "Build cache works better with compiler server.",
"version": "0.13.0",
"url": "http://haxetink.org/tink_macro",
"dependencies": {
"tink_core": ""

View File

@@ -5,6 +5,7 @@ import haxe.macro.Expr;
import haxe.macro.Type;
import tink.macro.TypeMap;
using tink.MacroApi;
using haxe.macro.Tools;
typedef BuildContextN = {
@@ -104,7 +105,7 @@ class BuildCache {
usings: ctx.usings
}));
}
static public function getType(name, ?type, ?pos:Position, build:BuildContext->TypeDefinition) {
if (pos == null)
@@ -156,18 +157,29 @@ private class Group {
usings: usings,
name: path.split('.').pop()
});
Context.defineModule(path, [def], usings);
entries.set(type, { name: path } );
Context.defineModule(path, [def], usings);
return Context.getType(path);
}
function doMake()
while (true)
switch '$name${counter++}' {
case _.definedType() => Some(_):
case v:
return make(v);
}
return
switch entries.get(type) {
case null:
make('$name${counter++}');
doMake();
case v:
Context.getType(v.name);
switch v.name.definedType() {
case Some(v): v;
default: doMake();
}
}
}
}

View File

@@ -57,7 +57,7 @@ class Sisyphus {
case null:
null;
case TMono(_.get() => t):
t == null ? null : toComplexType(t);
t == null ? Types.toComplex(type, { direct: true }) : toComplexType(t);
case TEnum(_.get() => baseType, params):
TPath(toTypePath(baseType, params));
case TInst(_.get() => classType, params):

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)