Make array types their own type object

We now offer much simpler functionality from type objects. In addition,
we attach type objects to the appropriate AST nodes, so generators can
just read and trust the model.

Test: Unit tests pass
Bug: 25939691
Change-Id: Id274a933c7bd4f1e5d6daf2b89a64b3553a37069
diff --git a/aidl.cpp b/aidl.cpp
index 85d9772..6ca7bd5 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -198,6 +198,15 @@
       err = 1;  // return type is invalid
     }
 
+    const ValidatableType* return_type =
+        types->GetValidatableType(m->GetType().GetName());
+
+    if (m->GetType().IsArray()) {
+      return_type = return_type->ArrayType();
+    }
+
+    m->GetMutableType()->SetLanguageType(return_type);
+
     if (oneway && m->GetType().GetName() != "void") {
         cerr << filename << ":" << m->GetLine()
             << " oneway method '" << m->GetName() << "' cannot return a value"
@@ -212,6 +221,15 @@
         err = 1;
       }
 
+      const ValidatableType* arg_type =
+          types->GetValidatableType(arg->GetType().GetName());
+
+      if (arg->GetType().IsArray()) {
+        arg_type = arg_type->ArrayType();
+      }
+
+      arg->GetMutableType()->SetLanguageType(arg_type);
+
       if (oneway && arg->IsOut()) {
         cerr << filename << ":" << m->GetLine()
             << " oneway method '" << m->GetName()
@@ -544,6 +562,8 @@
     err = AidlError::BAD_TYPE;
   }
 
+  interface->SetLanguageType(types->GetValidatableType(interface->GetCanonicalName()));
+
   for (const auto& import : p.GetImports()) {
     // If we skipped an unresolved import above (see comment there) we'll have
     // an empty bucket here.