本文整理汇总了C++中VirtualMachine::run方法的典型用法代码示例。如果您正苦于以下问题:C++ VirtualMachine::run方法的具体用法?C++ VirtualMachine::run怎么用?C++ VirtualMachine::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine::run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: in
Module(GC*gc,std::string path){
vm = new VirtualMachine(gc);
Parser * par;
if(path.length()<3 || std::string(path.end()-4,path.end()) != ".nls"){
vm->LoadAssembly(path.c_str());
BINDALL(vm,setSysFunction);
vm->run();
}else{
try{
std::ifstream in (path);
std::string res( ( std::istreambuf_iterator<char>( in ) ),
std::istreambuf_iterator<char>());
in.close();
par = new Parser(new Lexer(res,path),path);
par->Parse();
RefHolder rh;
BasicBlock bb (&rh);
par->getRoot()->emit(&bb);
bb.ReplaceLabels();
bb.emit(IL::hlt);
vm->SetBasicBlock(&bb);
vm->run();
}catch(...){
NLogger::log("Cannot load module:"+path);
}
delete par;
}
}
开发者ID:TakeOver,项目名称:yet-another-useless-scripting-language-with-javascript-like-syntax-and-non-optimized-virtual-machine,代码行数:28,代码来源:nmodule.hpp
示例2: main
int main(int argc, char** argv) {
bool opTree = false;
string filename = "";
for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 't': // Print the tree
opTree = true;
break;
}
} else
filename = string(argv[i]);
}
try {
SyntaxTree tree;
vector<char> bytecode;
ifstream ifs(filename.c_str());
VirtualMachine vm;
vm.compile(ifs, bytecode, tree);
if (opTree)
tree.dump(std::cout);
vm.run(&bytecode[0]);
} catch (std::exception &e) {
std::cerr << e.what() << "\n";
}
}
示例3: main
int main( int argc, char * argv[] )
{
Assembler ass;
VirtualMachine vm;
ass.assemble( argv[1] );
vm.run( argv[1] );
} // end main function
示例4: executeBinary
/**
* Executes the given SVM class
* @param argc the number of arguments passed
* @param argv the given file arguments
*/
int Main::executeBinary( int argc, char* argv[] ) {
// cache the class name
const char* classname = argv[1];
// startup the virtual machine
VirtualMachine *vm = new VirtualMachine();
// execute the class
return vm->run( classname, argc, argv );
}
示例5: main
int main(int argc, char *argv[] )
{
Assembler assembler(argv[1]);
unsigned short startAddr(0);
try {
startAddr = assembler.start();
} catch (std::exception &ex) {
std::cout << "Assembler error: " << ex.what() << std::endl;
return 1;
}
boost::shared_array<unsigned int> data(assembler.getBlock());
VirtualMachine vm;
try {
vm.setDebugInfo(assembler.byteToLineMap);
vm.load(data);
vm.run(startAddr);
} catch (std::exception &ex) {
std::cout << "VM error: " << ex.what() << std::endl;
return 1;
}
return 0;
}