Created
August 3, 2012 18:56
-
-
Save frabbit/3250423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function getFirstPath (from:ClassType, to:ClassType):Option<Path> | |
{ | |
function loop(from:ClassType, to:ClassType, path:Path) | |
{ | |
trace(loop); | |
return if (ClassTypes.eq(from, to)) { | |
Some(path); | |
} else { | |
var fromSuper = function () | |
{ | |
return | |
if (from.superClass != null) | |
{ | |
var r = loop(from.superClass.t.get(), to, path.concat([SuperClass])); | |
r; | |
} | |
else None; | |
} | |
var fromInterf = function () | |
{ | |
return from.interfaces.foldLeftWithIndex( | |
function (acc:Option<Path>, cur, index) | |
{ | |
return acc.orElse( | |
function () return loop(cur.t.get(), to, path.concat([InterfaceAt(index)])) | |
); | |
}, None); | |
} | |
fromSuper().orElse(fromInterf); | |
} | |
} | |
trace(loop); | |
return loop(from, to, []); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment