blob: 03b1fcdef1ff4ea3d164072ab5eb9e9bc0de9564 [file] [log] [blame]
Logancf3e5212010-12-29 01:44:55 +08001/*
2 * Copyright 2010, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef BCC_SCRIPTCOMPILED_H
18#define BCC_SCRIPTCOMPILED_H
19
20#include "Compiler.h"
21
22#include <bcc/bcc.h>
23
24namespace llvm {
25 class Module;
26}
27
28namespace bcc {
29 class Script;
30
31 class ScriptCompiled {
32 private:
33 Script *mpOwner;
34
35 Compiler mCompiler;
36
37 public:
38 ScriptCompiled(Script *owner) : mpOwner(owner) {
39 }
40
41 int readBC(const char *bitcode,
42 size_t bitcodeSize,
43 long bitcodeFileModTime,
44 long bitcodeFileCRC32,
45 const BCCchar *resName,
46 const BCCchar *cacheDir) {
47 return mCompiler.readBC(bitcode, bitcodeSize,
48 bitcodeFileModTime, bitcodeFileCRC32,
49 resName, cacheDir);
50 }
51
52 int linkBC(const char *bitcode, size_t bitcodeSize) {
53 return mCompiler.linkBC(bitcode, bitcodeSize);
54 }
55
56 int loadCacheFile() {
57 return mCompiler.loadCacheFile();
58 }
59
60 int compile() {
61 return mCompiler.compile();
62 }
63
64 char const *getCompilerErrorMessage() {
65 return mCompiler.getErrorMessage();
66 }
67
68 void *lookup(const char *name) {
69 return mCompiler.lookup(name);
70 }
71
72 void getExportVars(BCCsizei *actualVarCount,
73 BCCsizei maxVarCount,
74 BCCvoid **vars) {
75 mCompiler.getExportVars(actualVarCount, maxVarCount, vars);
76 }
77
78 void getExportFuncs(BCCsizei *actualFuncCount,
79 BCCsizei maxFuncCount,
80 BCCvoid **funcs) {
81 mCompiler.getExportFuncs(actualFuncCount, maxFuncCount, funcs);
82 }
83
84 void getPragmas(BCCsizei *actualStringCount,
85 BCCsizei maxStringCount,
86 BCCchar **strings) {
87 mCompiler.getPragmas(actualStringCount, maxStringCount, strings);
88 }
89
90 void getFunctions(BCCsizei *actualFunctionCount,
91 BCCsizei maxFunctionCount,
92 BCCchar **functions) {
93 mCompiler.getFunctions(actualFunctionCount, maxFunctionCount, functions);
94 }
95
96 void getFunctionBinary(BCCchar *function,
97 BCCvoid **base,
98 BCCsizei *length) {
99 mCompiler.getFunctionBinary(function, base, length);
100 }
101
102 void registerSymbolCallback(BCCSymbolLookupFn pFn, BCCvoid *pContext) {
103 mCompiler.registerSymbolCallback(pFn, pContext);
104 }
105
106 int readModule(llvm::Module *module) {
107 return mCompiler.readModule(module);
108 }
109 };
110
111} // namespace bcc
112
113#endif // BCC_SCRIPTCOMPILED_H