Create an expression parser for Go.

The Go interpreter doesn't JIT or use LLVM, so this also
moves all the JIT related code from UserExpression to a new class LLVMUserExpression.

Differential Revision: http://reviews.llvm.org/D13073

Fix merge

llvm-svn: 251820
diff --git a/lldb/source/Symbol/GoASTContext.cpp b/lldb/source/Symbol/GoASTContext.cpp
index c46fcb1..e025f21 100644
--- a/lldb/source/Symbol/GoASTContext.cpp
+++ b/lldb/source/Symbol/GoASTContext.cpp
@@ -24,6 +24,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Target.h"
 
+#include "Plugins/ExpressionParser/Go/GoUserExpression.h"
 #include "Plugins/SymbolFile/DWARF/DWARFASTParserGo.h"
 
 using namespace lldb;
@@ -200,9 +201,7 @@
     };
 
     GoStruct(int kind, const ConstString &name, int64_t byte_size)
-        : GoType(kind, name)
-        , m_is_complete(false)
-        , m_byte_size(byte_size)
+        : GoType(kind == 0 ? KIND_STRUCT : kind, name), m_is_complete(false), m_byte_size(byte_size)
     {
     }
 
@@ -327,14 +326,20 @@
     if (language == eLanguageTypeGo)
     {
         ArchSpec arch;
+        std::shared_ptr<GoASTContext> go_ast_sp;
         if (module)
+        {
             arch = module->GetArchitecture();
+            go_ast_sp = std::shared_ptr<GoASTContext>(new GoASTContext);
+        }
         else if (target)
+        {
             arch = target->GetArchitecture();
+            go_ast_sp = std::shared_ptr<GoASTContextForExpr>(new GoASTContextForExpr(target->shared_from_this()));
+        }
 
         if (arch.IsValid())
         {
-            std::shared_ptr<GoASTContext> go_ast_sp(new GoASTContext);
             go_ast_sp->SetAddressByteSize(arch.GetAddressByteSize());
             return go_ast_sp;
         }
@@ -414,6 +419,10 @@
         return false;
     if (kind == GoType::KIND_PTR)
         return false;
+    if (kind == GoType::KIND_CHAN)
+        return false;
+    if (kind == GoType::KIND_MAP)
+        return false;
     if (kind == GoType::KIND_STRING)
         return false;
     if (kind == GoType::KIND_UNSAFEPOINTER)
@@ -583,7 +592,8 @@
         case GoType::KIND_PTR:
         case GoType::KIND_UNSAFEPOINTER:
         case GoType::KIND_CHAN:
-            // TODO: is map a pointer? string? function?
+        case GoType::KIND_MAP:
+            // TODO: is function a pointer?
             return true;
         default:
             return false;
@@ -1064,6 +1074,11 @@
     {
         return array->GetLength();
     }
+    else if (t->IsTypedef())
+    {
+        return t->GetElementType().GetNumChildren(omit_empty_base_classes);
+    }
+
     return GetNumFields(type);
 }
 
@@ -1491,3 +1506,13 @@
         m_dwarf_ast_parser_ap.reset(new DWARFASTParserGo(*this));
     return m_dwarf_ast_parser_ap.get();
 }
+
+UserExpression *
+GoASTContextForExpr::GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
+                                       Expression::ResultType desired_type)
+{
+    TargetSP target = m_target_wp.lock();
+    if (target)
+        return new GoUserExpression(*target, expr, expr_prefix, language, desired_type);
+    return nullptr;
+}