Encapsulate Script::compiler -> Script::mCompiler.
diff --git a/lib/bcc/Script.h b/lib/bcc/Script.h
index 874507c..a22bd74 100644
--- a/lib/bcc/Script.h
+++ b/lib/bcc/Script.h
@@ -21,25 +21,19 @@
#include <bcc/bcc.h>
+namespace llvm {
+ class Module;
+}
+
namespace bcc {
class Script {
private:
BCCenum mErrorCode;
+ Compiler mCompiler;
+
public:
- //////////////////////////////////////////////////////////////////////////
- // Part I. Compiler
- //////////////////////////////////////////////////////////////////////////
- Compiler compiler;
-
- void registerSymbolCallback(BCCSymbolLookupFn pFn, BCCvoid *pContext) {
- compiler.registerSymbolCallback(pFn, pContext);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Part II. Logistics & Error handling
- //////////////////////////////////////////////////////////////////////////
Script() {
mErrorCode = BCC_NO_ERROR;
}
@@ -47,6 +41,84 @@
~Script() {
}
+ //////////////////////////////////////////////////////////////////////////
+ // Part I. Compiler
+ //////////////////////////////////////////////////////////////////////////
+
+ int readBC(const char *bitcode,
+ size_t bitcodeSize,
+ long bitcodeFileModTime,
+ long bitcodeFileCRC32,
+ const BCCchar *resName,
+ const BCCchar *cacheDir) {
+ return mCompiler.readBC(bitcode, bitcodeSize,
+ bitcodeFileModTime, bitcodeFileCRC32,
+ resName, cacheDir);
+ }
+
+ int linkBC(const char *bitcode, size_t bitcodeSize) {
+ return mCompiler.linkBC(bitcode, bitcodeSize);
+ }
+
+ int loadCacheFile() {
+ return mCompiler.loadCacheFile();
+ }
+
+ int compile() {
+ return mCompiler.compile();
+ }
+
+ char const *getCompilerErrorMessage() {
+ return mCompiler.getErrorMessage();
+ }
+
+ void *lookup(const char *name) {
+ return mCompiler.lookup(name);
+ }
+
+ void getExportVars(BCCsizei *actualVarCount,
+ BCCsizei maxVarCount,
+ BCCvoid **vars) {
+ mCompiler.getExportVars(actualVarCount, maxVarCount, vars);
+ }
+
+ void getExportFuncs(BCCsizei *actualFuncCount,
+ BCCsizei maxFuncCount,
+ BCCvoid **funcs) {
+ mCompiler.getExportFuncs(actualFuncCount, maxFuncCount, funcs);
+ }
+
+ void getPragmas(BCCsizei *actualStringCount,
+ BCCsizei maxStringCount,
+ BCCchar **strings) {
+ mCompiler.getPragmas(actualStringCount, maxStringCount, strings);
+ }
+
+ void getFunctions(BCCsizei *actualFunctionCount,
+ BCCsizei maxFunctionCount,
+ BCCchar **functions) {
+ mCompiler.getFunctions(actualFunctionCount, maxFunctionCount, functions);
+ }
+
+ void getFunctionBinary(BCCchar *function,
+ BCCvoid **base,
+ BCCsizei *length) {
+ mCompiler.getFunctionBinary(function, base, length);
+ }
+
+ void registerSymbolCallback(BCCSymbolLookupFn pFn, BCCvoid *pContext) {
+ mCompiler.registerSymbolCallback(pFn, pContext);
+ }
+
+ int readModule(llvm::Module *module) {
+ return mCompiler.readModule(module);
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////
+ // Error handling
+ //////////////////////////////////////////////////////////////////////////
+
void setError(BCCenum error) {
if (mErrorCode == BCC_NO_ERROR && error != BCC_NO_ERROR) {
mErrorCode = error;
diff --git a/lib/bcc/bcc.cpp b/lib/bcc/bcc.cpp
index 97d53f3..7bd4633 100644
--- a/lib/bcc/bcc.cpp
+++ b/lib/bcc/bcc.cpp
@@ -75,7 +75,7 @@
extern "C" int bccReadModule(BCCscript *script, BCCvoid *module) {
BCC_FUNC_LOGGER();
- return script->compiler.readModule(reinterpret_cast<llvm::Module*>(module));
+ return script->readModule(reinterpret_cast<llvm::Module*>(module));
}
extern "C" int bccReadBC(BCCscript *script,
@@ -86,21 +86,21 @@
const BCCchar *resName,
const BCCchar *cacheDir) {
BCC_FUNC_LOGGER();
- return script->compiler.readBC(bitcode, bitcodeSize,
- bitcodeFileModTime, bitcodeFileCRC32,
- resName, cacheDir);
+ return script->readBC(bitcode, bitcodeSize,
+ bitcodeFileModTime, bitcodeFileCRC32,
+ resName, cacheDir);
}
extern "C" void bccLinkBC(BCCscript *script,
const BCCchar *bitcode,
BCCint size) {
BCC_FUNC_LOGGER();
- script->compiler.linkBC(bitcode, size);
+ script->linkBC(bitcode, size);
}
extern "C" int bccLoadBinary(BCCscript *script) {
BCC_FUNC_LOGGER();
- int result = script->compiler.loadCacheFile();
+ int result = script->loadCacheFile();
#if defined(USE_DISASSEMBLER_FILE)
LOGI("[LoadBinary] result=%d", result);
@@ -118,7 +118,7 @@
android::StopWatch compileTimer("RenderScript compile time");
#endif
- int result = script->compiler.compile();
+ int result = script->compile();
if (result)
script->setError(BCC_INVALID_OPERATION);
@@ -130,7 +130,7 @@
BCCsizei *length,
BCCchar *infoLog) {
BCC_FUNC_LOGGER();
- char const *message = script->compiler.getErrorMessage();
+ char const *message = script->getCompilerErrorMessage();
int messageLength = strlen(message) + 1;
if (length)
*length = messageLength;
@@ -149,7 +149,7 @@
const BCCchar *name,
BCCvoid **address) {
BCC_FUNC_LOGGER();
- void *value = script->compiler.lookup(name);
+ void *value = script->lookup(name);
if (value) {
*address = value;
#if defined(USE_DISASSEMBLER_FILE)
@@ -165,7 +165,7 @@
BCCsizei maxVarCount,
BCCvoid **vars) {
BCC_FUNC_LOGGER();
- script->compiler.getExportVars(actualVarCount, maxVarCount, vars);
+ script->getExportVars(actualVarCount, maxVarCount, vars);
#if defined(USE_DISASSEMBLER_FILE)
int i;
@@ -184,7 +184,7 @@
BCCsizei maxFuncCount,
BCCvoid **funcs) {
BCC_FUNC_LOGGER();
- script->compiler.getExportFuncs(actualFuncCount, maxFuncCount, funcs);
+ script->getExportFuncs(actualFuncCount, maxFuncCount, funcs);
#if defined(USE_DISASSEMBLER_FILE)
int i;
@@ -203,7 +203,7 @@
BCCsizei maxStringCount,
BCCchar **strings) {
BCC_FUNC_LOGGER();
- script->compiler.getPragmas(actualStringCount, maxStringCount, strings);
+ script->getPragmas(actualStringCount, maxStringCount, strings);
#if defined(USE_DISASSEMBLER_FILE)
int i;
@@ -219,7 +219,7 @@
BCCsizei maxFunctionCount,
BCCchar **functions) {
BCC_FUNC_LOGGER();
- script->compiler.getFunctions(actualFunctionCount,
+ script->getFunctions(actualFunctionCount,
maxFunctionCount,
functions);
}
@@ -229,5 +229,5 @@
BCCvoid **base,
BCCsizei *length) {
BCC_FUNC_LOGGER();
- script->compiler.getFunctionBinary(function, base, length);
+ script->getFunctionBinary(function, base, length);
}