Build AST graph explicitly for simpler post-parsing passes

Puts all of AST parent-child dependencies into a graph.
This change also makes it able to not care about such case:
Type -> (non Type) -> Type (ex. Interface -> Method -> Type)
and to store only Type -> Type relations.

Test: hidl_test
Change-Id: Ic67d9833d9519d7bd6cbae603c556c5bd905167a
diff --git a/AST.cpp b/AST.cpp
index cf1f760..6602ba4 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -18,10 +18,10 @@
 
 #include "Coordinator.h"
 #include "EnumType.h"
+#include "FmqType.h"
 #include "HandleType.h"
 #include "Interface.h"
 #include "Location.h"
-#include "FmqType.h"
 #include "Scope.h"
 #include "TypeDef.h"
 
@@ -82,16 +82,30 @@
     return mRootScope.containsInterfaces();
 }
 
+status_t AST::postParse() {
+    status_t err = resolveInheritance();
+    if (err != OK) return err;
+    err = evaluate();
+    if (err != OK) return err;
+    err = validate();
+    if (err != OK) return err;
+
+    return OK;
+}
+
 status_t AST::resolveInheritance() {
-    return mRootScope.resolveInheritance();
+    std::unordered_set<const Type*> visited;
+    return mRootScope.recursivePass(&Type::resolveInheritance, &visited);
 }
 
 status_t AST::evaluate() {
-    return mRootScope.evaluate();
+    std::unordered_set<const Type*> visited;
+    return mRootScope.recursivePass(&Type::evaluate, &visited);
 }
 
 status_t AST::validate() const {
-    return mRootScope.validate();
+    std::unordered_set<const Type*> visited;
+    return mRootScope.recursivePass(&Type::validate, &visited);
 }
 
 bool AST::addImport(const char *import) {