当前位置: 首页>>代码示例>>C++>>正文


C++ VirtualMachine::run方法代码示例

本文整理汇总了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";
    }
}
开发者ID:keebus,项目名称:IonScript,代码行数:33,代码来源:Main.cpp

示例3: main

int main( int argc, char * argv[] )
{
    Assembler ass;
    VirtualMachine vm;
    ass.assemble( argv[1] );
    vm.run( argv[1] );
} // end main function
开发者ID:dannyboycurtis,项目名称:cse460,代码行数:7,代码来源:os.cpp

示例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 );
}
开发者ID:ldaniels528,项目名称:cortex,代码行数:15,代码来源:Main.cpp

示例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;
}
开发者ID:taxilian,项目名称:old_cs_vm,代码行数:24,代码来源:main.cpp


注:本文中的VirtualMachine::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。