mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
Make command line arguments setup be endian correct!!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4605 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -980,6 +980,28 @@ static void executeStoreInst(StoreInst &I, ExecutionContext &SF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GenericValue Interpreter::CreateArgv(const std::vector<std::string> &InputArgv){
|
||||||
|
// Pointers are 64 bits...
|
||||||
|
PointerTy *Result = new PointerTy[InputArgv.size()+1]; // 64 bit assumption
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < InputArgv.size(); ++i) {
|
||||||
|
unsigned Size = InputArgv[i].size()+1;
|
||||||
|
char *Dest = new char[Size];
|
||||||
|
copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
|
||||||
|
Dest[Size-1] = 0;
|
||||||
|
|
||||||
|
GenericValue GV; GV.PointerVal = (PointerTy)Dest;
|
||||||
|
// Endian safe: Result[i] = (PointerTy)Dest;
|
||||||
|
StoreValueToMemory(GV, (GenericValue*)(Result+i),
|
||||||
|
Type::LongTy); // 64 bit assumption
|
||||||
|
}
|
||||||
|
|
||||||
|
Result[InputArgv.size()] = 0;
|
||||||
|
GenericValue GV; GV.PointerVal = (PointerTy)Result;
|
||||||
|
return GV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Miscellaneous Instruction Implementations
|
// Miscellaneous Instruction Implementations
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|||||||
@@ -126,9 +126,9 @@ public:
|
|||||||
static void print(const Type *Ty, GenericValue V);
|
static void print(const Type *Ty, GenericValue V);
|
||||||
static void printValue(const Type *Ty, GenericValue V);
|
static void printValue(const Type *Ty, GenericValue V);
|
||||||
|
|
||||||
// Hack until we can parse command line args...
|
|
||||||
bool callMainMethod(const std::string &MainName,
|
bool callMainMethod(const std::string &MainName,
|
||||||
const std::vector<std::string> &InputFilename);
|
const std::vector<std::string> &InputFilename);
|
||||||
|
GenericValue CreateArgv(const std::vector<std::string> &InputArgv);
|
||||||
|
|
||||||
void list(); // Do the 'list' command
|
void list(); // Do the 'list' command
|
||||||
void printStackTrace(); // Do the 'backtrace' command
|
void printStackTrace(); // Do the 'backtrace' command
|
||||||
|
|||||||
@@ -238,23 +238,6 @@ bool Interpreter::callMethod(const string &Name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *CreateArgv(const std::vector<string> &InputArgv) {
|
|
||||||
// Pointers are 64 bits...
|
|
||||||
uint64_t *Result = new PointerTy[InputArgv.size()+1];
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < InputArgv.size(); ++i) {
|
|
||||||
unsigned Size = InputArgv[i].size()+1;
|
|
||||||
char *Dest = new char[Size];
|
|
||||||
copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
|
|
||||||
Dest[Size-1] = 0;
|
|
||||||
Result[i] = (PointerTy)Dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result[InputArgv.size()] = 0;
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// callMainMethod - This is a nasty gross hack that will dissapear when
|
// callMainMethod - This is a nasty gross hack that will dissapear when
|
||||||
// callMethod can parse command line options and stuff for us.
|
// callMethod can parse command line options and stuff for us.
|
||||||
//
|
//
|
||||||
@@ -289,8 +272,7 @@ bool Interpreter::callMainMethod(const string &Name,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericValue GV; GV.PointerVal = (uint64_t)CreateArgv(InputArgv);
|
Args.push_back(CreateArgv(InputArgv));
|
||||||
Args.push_back(GV);
|
|
||||||
}
|
}
|
||||||
// fallthrough
|
// fallthrough
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user