Refactoring of function types. Also fixes some library import bugs.

This commit is contained in:
Ben Vanik
2014-01-30 00:22:55 -08:00
parent bdee924494
commit f85b83709e
21 changed files with 198 additions and 160 deletions

View File

@@ -24,17 +24,11 @@ class ThreadState;
class Function {
public:
enum Type {
UNKNOWN_FUNCTION = 0,
EXTERN_FUNCTION,
USER_FUNCTION,
};
public:
Function(Type type, uint64_t address);
Function(FunctionInfo* symbol_info);
virtual ~Function();
Type type() const { return type_; }
uint64_t address() const { return address_; }
FunctionInfo* symbol_info() const { return symbol_info_; }
DebugInfo* debug_info() const { return debug_info_; }
void set_debug_info(DebugInfo* debug_info) { debug_info_ = debug_info; }
@@ -51,8 +45,8 @@ protected:
virtual int CallImpl(ThreadState* thread_state) = 0;
protected:
Type type_;
uint64_t address_;
FunctionInfo* symbol_info_;
DebugInfo* debug_info_;
// TODO(benvanik): move elsewhere? DebugData?
@@ -61,43 +55,6 @@ protected:
};
class ExternFunction : public Function {
public:
typedef void(*Handler)(void* context, void* arg0, void* arg1);
public:
ExternFunction(uint64_t address, Handler handler, void* arg0, void* arg1);
virtual ~ExternFunction();
const char* name() const { return name_; }
void set_name(const char* name);
Handler handler() const { return handler_; }
void* arg0() const { return arg0_; }
void* arg1() const { return arg1_; }
protected:
virtual int CallImpl(ThreadState* thread_state);
protected:
char* name_;
Handler handler_;
void* arg0_;
void* arg1_;
};
class GuestFunction : public Function {
public:
GuestFunction(FunctionInfo* symbol_info);
virtual ~GuestFunction();
FunctionInfo* symbol_info() const { return symbol_info_; }
protected:
FunctionInfo* symbol_info_;
};
} // namespace runtime
} // namespace alloy