diff options
author | Chris Lattner <sabre@nondot.org> | 2001-10-27 05:54:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-10-27 05:54:31 +0000 |
commit | 204eec3f57aedd703fb73db78ac2b4087caf9f07 (patch) | |
tree | 32ef1058acc01d8c9c2b21db31ab25e80c3a24d5 /lib/ExecutionEngine/Interpreter/UserInput.cpp | |
parent | caccd761a6320d9068a44198b9e1b6c3659f8bb5 (diff) |
Provide argv for commands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/UserInput.cpp')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/UserInput.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp index 2989ae95e8..efe7150c13 100644 --- a/lib/ExecutionEngine/Interpreter/UserInput.cpp +++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp @@ -212,12 +212,28 @@ bool Interpreter::callMethod(const string &Name) { return false; } +static void *CreateArgv(const vector<string> &InputArgv) { + // Pointers are 64 bits... + uint64_t *Result = new uint64_t[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] = (uint64_t)Dest; + } + + Result[InputArgv.size()] = 0; + return Result; +} + // callMainMethod - This is a nasty gross hack that will dissapear when // callMethod can parse command line options and stuff for us. // bool Interpreter::callMainMethod(const string &Name, - const string &InputFilename) { + const vector<string> &InputArgv) { vector<Value*> Options = LookupMatchingNames(Name); for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches... @@ -246,8 +262,8 @@ bool Interpreter::callMainMethod(const string &Name, << SPP->getDescription() << "'!\n"; return true; } - // TODO: - GenericValue GV; GV.PointerVal = 0; + + GenericValue GV; GV.PointerVal = (GenericValue*)CreateArgv(InputArgv); Args.push_back(GV); } // fallthrough @@ -256,7 +272,7 @@ bool Interpreter::callMainMethod(const string &Name, cout << "First argument of '" << Name << "' should be integral!\n"; return true; } else { - GenericValue GV; GV.IntVal = 1; + GenericValue GV; GV.UIntVal = InputArgv.size(); Args.insert(Args.begin(), GV); } // fallthrough |