Sprucing up some of alloy.

This commit is contained in:
Ben Vanik
2014-07-13 21:15:37 -07:00
parent 48425da8ff
commit 9437d0b564
40 changed files with 246 additions and 228 deletions

View File

@@ -75,12 +75,10 @@ int Processor::Setup() {
return 1;
}
Backend* backend = 0;
// Backend* backend = new alloy::backend::ivm::IVMBackend(
// runtime);
// Backend* backend = new alloy::backend::x64::X64Backend(
// runtime);
int result = runtime_->Initialize(backend);
std::unique_ptr<Backend> backend;
// backend.reset(new alloy::backend::ivm::IVMBackend(runtime));
// backend.reset(new alloy::backend::x64::X64Backend(runtime));
int result = runtime_->Initialize(std::move(backend));
if (result) {
return result;
}

View File

@@ -23,8 +23,8 @@ using namespace xe::cpu;
XenonRuntime::XenonRuntime(
alloy::Memory* memory, ExportResolver* export_resolver) :
export_resolver_(export_resolver),
Runtime(memory) {
Runtime(memory),
export_resolver_(export_resolver) {
}
XenonRuntime::~XenonRuntime() {
@@ -32,11 +32,11 @@ XenonRuntime::~XenonRuntime() {
}));
}
int XenonRuntime::Initialize(backend::Backend* backend) {
PPCFrontend* frontend = new PPCFrontend(this);
int XenonRuntime::Initialize(std::unique_ptr<backend::Backend> backend) {
std::unique_ptr<PPCFrontend> frontend(new PPCFrontend(this));
// TODO(benvanik): set options/etc.
int result = Runtime::Initialize(frontend, backend);
int result = Runtime::Initialize(std::move(frontend), std::move(backend));
if (result) {
return result;
}

View File

@@ -31,7 +31,7 @@ public:
ExportResolver* export_resolver() const { return export_resolver_; }
virtual int Initialize(alloy::backend::Backend* backend = 0);
virtual int Initialize(std::unique_ptr<alloy::backend::Backend> backend = 0);
private:
ExportResolver* export_resolver_;

View File

@@ -29,18 +29,16 @@ void UndefinedImport(PPCContext* ppc_state, void* arg0, void* arg1) {
XexModule::XexModule(
XenonRuntime* runtime) :
runtime_(runtime),
name_(0), path_(0), xex_(0),
xex_(0),
base_address_(0), low_address_(0), high_address_(0),
Module(runtime) {
}
XexModule::~XexModule() {
xe_xex2_release(xex_);
xe_free(name_);
xe_free(path_);
}
int XexModule::Load(const char* name, const char* path, xe_xex2_ref xex) {
int XexModule::Load(const std::string& name, const std::string& path, xe_xex2_ref xex) {
int result;
xex_ = xe_xex2_retain(xex);
@@ -79,8 +77,8 @@ int XexModule::Load(const char* name, const char* path, xe_xex2_ref xex) {
}
// Setup debug info.
name_ = xestrdupa(name);
path_ = xestrdupa(path);
name_ = std::string(name);
path_ = std::string(path);
// TODO(benvanik): debug info
// Load a specified module map and diff.

View File

@@ -10,6 +10,8 @@
#ifndef XENIA_CPU_XEX_MODULE_H_
#define XENIA_CPU_XEX_MODULE_H_
#include <string>
#include <alloy/runtime/module.h>
#include <xenia/core.h>
#include <xenia/kernel/util/xex2.h>
@@ -28,11 +30,11 @@ public:
xe_xex2_ref xex() const { return xex_; }
int Load(const char* name, const char* path, xe_xex2_ref xex);
int Load(const std::string& name, const std::string& path, xe_xex2_ref xex);
virtual const char* name() const { return name_; }
const std::string& name() const override { return name_; }
virtual bool ContainsAddress(uint64_t address);
bool ContainsAddress(uint64_t address) override;
private:
int SetupImports(xe_xex2_ref xex);
@@ -41,13 +43,13 @@ private:
private:
XenonRuntime* runtime_;
char* name_;
char* path_;
xe_xex2_ref xex_;
std::string name_;
std::string path_;
xe_xex2_ref xex_;
uint64_t base_address_;
uint64_t low_address_;
uint64_t high_address_;
uint64_t base_address_;
uint64_t low_address_;
uint64_t high_address_;
};