Change the meaning of member Script::mObjectType.

Script::mObjectType is The type of the object behind this script
after compilation. For example, after returning from a successful
call to prepareRelocatable(), the value of mObjectType will be
ScriptObject::Relocatable.

Change-Id: I82ae2990772a9fb424150d3711e31f13acc521e6
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index 6e3774b..ac231b4 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -186,6 +186,7 @@
   CompilerOption option;
   option.RelocModelOpt = RelocModel;
   option.LoadAfterCompile = false;
+
   int status = internalCompile(option);
   if (status != 0) {
     ALOGE("LLVM error message: %s\n", getCompilerErrorMessage());
@@ -206,6 +207,8 @@
       return false;
   }
 
+  mObjectType = ScriptObject::Relocatable;
+
   return 0;
 }
 
@@ -229,10 +232,7 @@
 
   int status = -1;
 #if USE_CACHE
-  if (internalLoadCache(cacheDir, cacheName,
-                        ScriptObject::Executable, /* checkOnly */ false) == 0) {
-    status = 0;
-  }
+  status = internalLoadCache(cacheDir, cacheName, /* checkOnly */ false);
 #endif
 
   if (status != 0) {
@@ -254,15 +254,14 @@
   // FIXME: Registration can be conditional on the presence of debug metadata
   registerObjectWithGDB(getELF(), getELFSize()); // thread-safe registration
 
+  mObjectType = ScriptObject::Executable;
+
   return status;
 }
 
 #if USE_CACHE
 int Script::internalLoadCache(char const *cacheDir, char const *cacheName,
-                              ScriptObject::ObjectType objectType,
                               bool checkOnly) {
-  mObjectType = objectType;
-
   if ((cacheDir == NULL) || (cacheName == NULL)) {
     return 1;
   }
diff --git a/lib/ExecutionEngine/Script.h b/lib/ExecutionEngine/Script.h
index 629fd7a..b05fc07 100644
--- a/lib/ExecutionEngine/Script.h
+++ b/lib/ExecutionEngine/Script.h
@@ -64,6 +64,9 @@
     int mErrorCode;
 
     ScriptStatus::StatusType mStatus;
+    // The type of the object behind this script after compilation. For
+    // example, after returning from a successful call to prepareRelocatable(),
+    // the value of mObjectType will be ScriptObject::Relocatable.
     ScriptObject::ObjectType mObjectType;
 
     union {
@@ -81,26 +84,7 @@
 #if USE_OLD_JIT
       return std::string(mCacheDir + mCacheName + ".jit-image");
 #elif USE_MCJIT
-      std::string objPath(mCacheDir + mCacheName);
-
-      // Append suffix depends on the object type
-      switch (mObjectType) {
-        case ScriptObject::Relocatable:
-        case ScriptObject::Executable: {
-          objPath.append(".o");
-          break;
-        }
-
-        case ScriptObject::SharedObject: {
-          objPath.append(".so");
-          break;
-        }
-
-        default: {
-          assert(false && "Unknown object type!");
-        }
-      }
-      return objPath;
+      return std::string(mCacheDir + mCacheName + ".o");
 #endif
     }
 
@@ -256,9 +240,9 @@
     //
     // It returns 0 if there's a cache hit.
     //
-    // Side effect: it will set mCacheDir, mCacheName and mObjectType.
+    // Side effect: it will set mCacheDir, mCacheName.
     int internalLoadCache(char const *cacheDir, char const *cacheName,
-                          ScriptObject::ObjectType objectType, bool checkOnly);
+                          bool checkOnly);
 #endif
     int internalCompile(const CompilerOption&);
   };