Merge pull request #24 from kevinresol/type_get_pos
Get Position from a Type
This commit is contained in:
@@ -102,6 +102,22 @@ class Types {
|
||||
default: Failure('type has no statics');
|
||||
}
|
||||
|
||||
|
||||
static public function getPosition(t:Type)
|
||||
return
|
||||
switch t {
|
||||
case TInst(_.get() => {pos: pos}, _)
|
||||
| TAbstract(_.get() => {pos: pos}, _)
|
||||
| TType(_.get() => {pos: pos}, _)
|
||||
| TEnum(_.get() => {pos: pos}, _) : Success(pos);
|
||||
case TMono(ref): getPosition(ref.get());
|
||||
case TLazy(f): getPosition(f());
|
||||
case TDynamic(v) if(v != null): getPosition(v);
|
||||
default: Failure('type "$t" has no position');
|
||||
}
|
||||
|
||||
|
||||
|
||||
static public function toString(t:ComplexType)
|
||||
return new Printer().printComplexType(t);
|
||||
|
||||
|
Reference in New Issue
Block a user