Replace MacroType with @:genericBuild for direct type converions.
This commit is contained in:
6
src/tink/macro/DirectType.hx
Normal file
6
src/tink/macro/DirectType.hx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package tink.macro;
|
||||||
|
|
||||||
|
@:genericBuild(tink.macro.Types.resolveDirectType())
|
||||||
|
class DirectType<Const> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,8 +16,8 @@ class Types {
|
|||||||
static var types = new Map<Int,Void->Type>();
|
static var types = new Map<Int,Void->Type>();
|
||||||
static var idCounter = 0;
|
static var idCounter = 0;
|
||||||
|
|
||||||
@:noUsing macro static public function getType(id:Int):Type
|
//@:noUsing macro static public function getType(id:Int):Type
|
||||||
return types.get(id)();
|
//return types.get(id)();
|
||||||
|
|
||||||
static public function getID(t:Type, ?reduced = true)
|
static public function getID(t:Type, ?reduced = true)
|
||||||
return
|
return
|
||||||
@@ -162,9 +162,20 @@ class Types {
|
|||||||
static public function lazyComplex(f:Void->Type)
|
static public function lazyComplex(f:Void->Type)
|
||||||
return
|
return
|
||||||
TPath({
|
TPath({
|
||||||
pack : ['haxe','macro'],
|
pack : ['tink','macro'],
|
||||||
name : 'MacroType',
|
name : 'DirectType',
|
||||||
params : [TPExpr('tink.macro.Types.getType'.resolve().call([register(f).toExpr()]))],
|
params : [TPExpr(register(f).toExpr())],
|
||||||
sub : null,
|
sub : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
static function resolveDirectType()
|
||||||
|
return
|
||||||
|
switch reduce(Context.getLocalType()) {
|
||||||
|
case TInst(_, [TInst(_.get() => { kind: KExpr(e) }, _)]):
|
||||||
|
types.get(Std.parseInt(e.toString()))();
|
||||||
|
default:
|
||||||
|
throw 'assert';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user