本文整理汇总了C++中VirtualMachine::execute方法的典型用法代码示例。如果您正苦于以下问题:C++ VirtualMachine::execute方法的具体用法?C++ VirtualMachine::execute怎么用?C++ VirtualMachine::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine::execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
if (argc < 2)
{
std::cout << "Incorrect program call: Processor.exe <program names>" << std::endl;
return 0;
}
VirtualMachine processor;
for (int i = 1; i < argc; i++)
{
std::ifstream file;
file.open (argv[i], std::ios::in|std::ios::binary|std::ios::ate);
if (!file.is_open ())
{
std::cout << "Error: can't open " << argv[i] << std::endl;
return 0;
}
std::streampos size = file.tellg ();
unsigned char *data = (unsigned char*)malloc ((size_t)size);
assert (data && "Allocation error in Main function");
file.seekg (0, std::ios::beg);
file.read ((char *)data, size);
file.close ();
if (!processor.load (data, (size_t)size))
{
std::cout << "Error: can not get data from " << argv[i] << std::endl;
return 0;
}
clock_t t1 = clock ();
if (!processor.execute ())
{
std::cout << "Program " << argv[i] << " finished unsuccessfully" << std::endl;
return 0;
}
std::cout << "Execution time: " << (clock () - t1) * 1000 / CLOCKS_PER_SEC << " ms" << std::endl;
free (data);
file.close ();
}
return 0;
}
示例2: runVirtualMachine
void ProgramHandler::runVirtualMachine(const shared_ptr<LinkedActionList>& compiledList)
{
VirtualMachine virtualMachine;
virtualMachine.execute(compiledList);
}