• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VirtualMachine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VirtualMachine的典型用法代码示例。如果您正苦于以下问题:C++ VirtualMachine类的具体用法?C++ VirtualMachine怎么用?C++ VirtualMachine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VirtualMachine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Module

 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[])
{
    if(argc < 2)
    {
        std::cout << "Invalid number of arguments passed. Expected script path." << std::endl;
        return -1;
    }

    std::vector<unsigned int> bytes;
    BytecodeIO::readBytecode(argv[1], bytes);

    VirtualMachine VM;

    try
    {
        VM.interpret(&bytes[0], bytes.size());
    }
    catch(const std::string &e)
    {
        std::cout << "\nException: " << e;
    }
    catch(const std::exception &e)
    {
        std::cout << "\nException: " << e.what();
    }
    return 0;
}
开发者ID:Cloaked9000,项目名称:Fryte,代码行数:27,代码来源:main.cpp


示例3: VirtualMachine

void StartInstance::Launch()
{
	isInit = true;
	VirtualMachine *vm = new VirtualMachine();


	if (isInit)
	{
		  Power *p = new Power();

            std::cout << "V1" << std::endl;
			map->seeMap();
            std::cout << "-----------" << std::endl;
            map = p->findPowerOnMap(map);
            std::cout << "V2" << std::endl;
            map->seeMap();
			std::cout << "-----------" << std::endl;
	
			vm->setMap(map->getMap());		
			vm->Launch(*map->getMap());

	}
	else
	{
	std::string error = "Error Initialisation";
		throw myException(error);

	}
}
开发者ID:F4Ke,项目名称:microMachineCpp,代码行数:29,代码来源:StartInstance.cpp


示例4: main

int main(int argc, char** argv)
{
	(void)argc;
	(void)argv;

	VirtualMachine vm;
	vm.LoadFile("script.as");
	vm.Call("void main()");

	JavaVM *jvm;       /* denotes a Java VM */
    JNIEnv *env;       /* pointer to native method interface */
    JavaVMInitArgs vm_args; /* JDK/JRE 6 VM initialization arguments */
    JavaVMOption* options = new JavaVMOption[1];
    options[0].optionString = "-Djava.class.path=/usr/lib/java";
    vm_args.version = JNI_VERSION_1_6;
    vm_args.nOptions = 1;
    vm_args.options = options;
    vm_args.ignoreUnrecognized = false;
    /* load and initialize a Java VM, return a JNI interface
     * pointer in env */
    JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    delete options;
    /* invoke the Main.test method using the JNI */
    jclass cls = env->FindClass("Main");
    jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V");
    env->CallStaticVoidMethod(cls, mid, 100);
    /* We are done. */
    jvm->DestroyJavaVM();

	std::cout << "Hello World! (C++)" << std::endl;
}
开发者ID:BennyQBD,项目名称:Experiments,代码行数:31,代码来源:main.cpp


示例5: 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


示例6: execute

void MinusCommand::execute(VirtualMachine& vm, AbstractFunctionCall& node)
{
    auto supergeheimeToken = node.getToken();
	vector<string>& parameters = node.getContentArrayNonConstant();

	Variable variable1 = *vm.getVariable(parameters.at(1));
	Variable variable2 = *vm.getVariable(parameters.at(2));

	if (isUndefined(variable1, variable2, vm))
	{
		return;
	}

	if (variable1.getTokenType() == IToken::TYPE_NUMBER && variable2.getTokenType() == IToken::TYPE_NUMBER) 
	{
		double number1 = atof(variable1.getValue().c_str());
		double number2 = atof(variable2.getValue().c_str());

		vm.setReturnValue(to_string(number1 - number2));
		vm.setReturnToken(variable1.getTokenType());
	}
	else 
	{
		// Exception minus requires 2 numbers
		throwCustomError("cannot subtract " + variable1.getValue() + " by " + variable2.getValue(), vm, supergeheimeToken);

		return;
	}
}
开发者ID:terryvdgriend,项目名称:Compiler-Project,代码行数:29,代码来源:MinusCommand.cpp


示例7: execute

void AddLengthToArrayCommand::execute(VirtualMachine& vm, AbstractFunctionCall& node)
{
	vector<string>& parameters = node.getContentArrayNonConstant();

	if (parameters.size() > 3)
	{
		string retVal = "";

		for (size_t i = 1; i < parameters.size()-1; i++)
		{
			if (i != parameters.size() - 2) 
			{
				retVal += vm.getVariable(parameters.at(i))->getValue() + ";";
			}
			else
			{
				retVal += vm.getVariable(parameters.at(i))->getValue();
			}
		}
		vm.setReturnValue(retVal);
	}
	else
	{
		vm.setReturnValue(vm.getVariable(parameters[1])->getValue());
	}
}
开发者ID:terryvdgriend,项目名称:Compiler-Project,代码行数:26,代码来源:AddLengthToArrayCommand.cpp


示例8: main

int main(int argc, char* argv[])
{
	VirtualMachine vm;
	vm.readProgram("test.vm");
	vm.start();
	return 0;
}
开发者ID:Freakmiko,项目名称:tinyVM,代码行数:7,代码来源:main.cpp


示例9: execute

void ModuloCommand::execute(VirtualMachine& vm, AbstractFunctionCall& node)
{
    auto supergeheimeToken = node.getToken();
	vector<string>& parameters = node.getContentArrayNonConstant();

	Variable variable1 = *vm.getVariable(parameters.at(1));
	Variable variable2 = *vm.getVariable(parameters.at(2));

	if (isUndefined(variable1, variable2, vm))
	{
		return;
	}

	if (variable1.getTokenType() == IToken::TYPE_NUMBER && variable2.getTokenType() == IToken::TYPE_NUMBER)
	{
		int number1 = atoi(variable1.getValue().c_str());
		int number2 = atoi(variable2.getValue().c_str());

		vm.setReturnValue(to_string(number1 % number2));
		vm.setReturnToken(variable1.getTokenType());
	}
	else 
	{
		throwCustomError("cannot get remainder (modulo) " + variable1.getValue() + " from " + variable2.getValue(), vm,supergeheimeToken);

		return;
	}
}
开发者ID:terryvdgriend,项目名称:Compiler-Project,代码行数:28,代码来源:ModuloCommand.cpp


示例10: 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


示例11: main

int main(int argc, char** args)
{	
	std::unique_ptr<BytecodeGenerator> g;

	try
	{
		g = std::unique_ptr<BytecodeGenerator>(new BytecodeGenerator());
	}
	catch(SourceException e)
	{
		std::cout << e.Get() << std::endl;
		return 1;
	}

	VirtualMachine vm;	

	vm.LoadProgram(g->GetBytecode(), g->GetBytecodeSize(), g->GetConstants());

	char* result = vm.TrackByte(2000);

	vm.Run();

	std::cout << "The value of tracked variable is: " << (int)*result << std::endl;

	return 0;	
}
开发者ID:carriercomm,项目名称:Tiny-Virtual-Machine,代码行数:26,代码来源:main.cpp


示例12: VMCodeBufferManage

 explicit VMCodeBufferManage(VirtualMachineManage *vmmanage)
   :var_combos(&var_pcode)
 {
   if ( !vmmanage )
     throw;
   VirtualMachine *vm = vmmanage->rand_virtual_machine();
    var_pcode.init_handle_table(vm->get_vm_handle_table());
    var_pcode.init_sign( vm->get_vm_handle().sign );
 }
开发者ID:DeDf,项目名称:WProtect,代码行数:9,代码来源:vmcodebuffer.hpp


示例13: execute

void IdentifierToReturnValueCommand::execute(VirtualMachine& vm, AbstractFunctionCall& node)
{
	vector<string>& parameters = node.getContentArrayNonConstant();
	vm.setReturnValue(parameters.at(1));
	vm.setReturnToken(node.getToken()->getSubType());
	vm.addIdentifer(parameters.at(1));

	vm.addArrayTypeToArrayTypes(node.getToken()->getText(), node.getToken()->getSubType());
}
开发者ID:terryvdgriend,项目名称:Compiler-Project,代码行数:9,代码来源:IdentifierToReturnValueCommand.cpp


示例14: finalize

void VirtualObject::finalize(VirtualMachine& vm)
{
   if ( mpNativeObject != NULL )
   {
      vm.unregisterNative(*this);
   }

   vm.release(*this);
}
开发者ID:crafter2d,项目名称:crafter2d,代码行数:9,代码来源:virtualobject.cpp


示例15: setFctHook

VirtualMachine::Debugger::Debugger(VirtualMachine &vm)
  : VM_(vm)
{
  setFctHook();
  if (vm.isFonctionnal())
    {
      vm.addDebugger(this);
      lua_sethook(vm.getLua(), HookEvents, 0, 0);
    }
}
开发者ID:teamBICYCLE,项目名称:Bomberman,代码行数:10,代码来源:Debugger.cpp


示例16: VirtualMachine

/**
 * 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


示例17: VMCodeBufferManage

 explicit VMCodeBufferManage(VirtualMachineManage *vmmanage)
   :var_combos(&var_pcode)
 {
   if ( !vmmanage )
     throw;
   VirtualMachine *vm = vmmanage->rand_virtual_machine();
    var_pcode.init_handle_table(vm->get_vm_handle_table());
    var_pcode.init_sign( vm->get_vm_handle().fuc_select.addorsub );
    //var_combos.link_pcode( &var_pcode );    
 }
开发者ID:dellsun,项目名称:WProtect,代码行数:10,代码来源:VMCodeBuffer.hpp


示例18:

int	VirtualMachine::Debugger::setHook(lua_State *lua)
{
  VirtualMachine	*VM;

  VM = VirtualMachine::getVm();
  if (VM->isFonctionnal())
    if (lua_gettop(lua) == 2 && lua_isnumber(lua, 1)
	&& lua_isnumber(lua, 2))
      lua_sethook(VM->getLua(), HookEvents, lua_tonumber(lua, 1), lua_tonumber(lua, 2));
  return 0;
}
开发者ID:teamBICYCLE,项目名称:Bomberman,代码行数:11,代码来源:Debugger.cpp


示例19: main

int main(int argc, char** argv)
{
	(void)argc;
	(void)argv;

	VirtualMachine vm;
	vm.LoadFile("script.as");
	vm.Call("void main()");

	std::cout << "Hello World! (C++)" << std::endl;
}
开发者ID:BennyQBD,项目名称:Experiments,代码行数:11,代码来源:main.cpp


示例20: checkIndex

static size_t checkIndex(void* state, List* list, Object& obj){
	VirtualMachine *vm = (VirtualMachine*)state;
	if (obj.type != NUMOBJ){
		vm->throwError("list index type isn't num",TYPEERROR);
	}
	float index = obj.value.numval;
	if (index != (int)index){
		vm->throwError("index isn't int",ARGUMENTERROR);
	}
	if (index < 0 || (size_t)index >= list->vec.size()){
		vm->throwError("index out of range",ARGUMENTERROR);
	}
	return (size_t)index;
}
开发者ID:supertanglang,项目名称:VirtualMachine-1,代码行数:14,代码来源:List.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VirtualProgram类代码示例发布时间:2022-05-31
下一篇:
C++ VirtualDrive类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap