コード例 #1
0
ファイル: Thread.cpp プロジェクト: tgfjt/wasmint
    wasm_module::Instruction* Thread::callFunction(
            const std::string& moduleName, const std::string& functionName,
            std::vector<wasm_module::Variable> parameters) {

        wasm_module::Function* func = nullptr;


        wasm_module::Module& module = env_.getModule(moduleName);

        if (module.hasImport(functionName)) {

            const wasm_module::ModuleImport& moduleImport = module.getImport(functionName);

            func = &env_.getFunction(moduleImport.module(), moduleImport.signature().name());
        } else {
            func = &env_.getFunction(moduleName, functionName);
        }

        enterFunction(*func);

        for (uint32_t i = 0; i < parameters.size(); i++) {
            variable(i) = parameters.at(i);
        }

        return func->mainInstruction();
    }
コード例 #2
0
ファイル: menu.c プロジェクト: muyiziye/OA
void showSelectMenu(DEILYPAYEARN_T_P head)
{
    int num = 0;
	while(1)
	{
        printf("1:add, 2:show, 3:modify, 4:select, 5:exit\n");    
	    printf("pls input yours choice\n");
        scanf("%d", &num);
    	enterFunction(head, num);
	}
}
コード例 #3
0
ファイル: aslanalysis.cpp プロジェクト: 8l/rose
void ASLAnalysis::visit(SgNode* node){

   // concrete classes of AST nodes
   switch(node->variantT()){

      // naming scheme for variants: V_<classname>
      case V_SgFunctionDeclaration:{
         SgFunctionDeclaration* fdecl=isSgFunctionDeclaration(node);
      
         if(SgFunctionDefinition* fdef=fdecl->get_definition()) {
            std::string functionName=fdecl->get_name().getString();
            Sg_File_Info* ptrFileInfo=node->get_file_info();
            
            std::string aslPrefix="";
            if(ptrFileInfo){
               aslPrefix=ptrFileInfo->get_filenameString()+"/";
            }
            
            enterFunction(aslPrefix+functionName);  // set function name and reset enumeration counter
         }
      }
      break;
 
      // function calls through function pointers
      case V_SgPointerDerefExp:{
         if(isSgFunctionCallExp(node->get_parent()) && !(isSgFunctionCallExp(node->get_parent())->get_function() != node)){
#ifdef DEBUG
            std::cout<<"Function Pointer at call-site"<<std::endl;
#endif
            storeLocalSite(node);
            callSiteCounter++;
            functionPointerCallCounter++;
         }
      }
      break;
      
      case V_SgFunctionCallExp:{
         SgFunctionCallExp* fcall=isSgFunctionCallExp(node);
      
         if(SgFunctionRefExp* func=isSgFunctionRefExp(fcall->get_function())) {
            // SgFunctionSymbol* functionSymbol=func->get_symbol();
            // std::string functionName=functionSymbol->get_name().getString();
            callSiteCounter++;
         }
      }
      break;
      
   }
}
コード例 #4
0
ファイル: parser.cpp プロジェクト: gliptic/milkshake
void Parser::constructor(string const& name, IntrusiveRefCntPtr<TypeDef> type, TypePtr const& typeRef)
{
	IntrusiveRefCntPtr<TypeConstructor> ctor(new TypeConstructor(name));
	type->constructors.push_back(ctor);
	ctor->type = typeRef;

	expect(TLParen);

	if(token != TRParen)
	{
		do
		{
			bool isLet = test(TLet);

			string name;

			// TODO: Common pattern?
			TypePtr type = maybeType(false);
			if(! type)
			{
				name = expectIdent();
				type = typeName(false);
			}

			ctor->members.push_back(TypeMember(name, type));
			++ctor->ctorParams;
		}
		while(test(TComma));
	}

	{
		string const& ctorName = name;
		// Constructor function
		IntrusiveRefCntPtr<FuncDef> ctorFunc(new FuncDef(ctorName));

		enterFunction(ctorFunc);
		enterScope(new Scope);

		// Constructor function has the same type parameters
		for(auto& p : type->typeParams)
			ctorFunc->typeParams.push_back(p);

		int dummy = 0;

		IntrusiveRefCntPtr<CreateExpr> body(new CreateExpr());

		body->ctor = ctor;

		for(int i = 0; i < ctor->ctorParams; ++i)
		{
			auto& member = ctor->members[i];
			auto p = declParam(ctorFunc, member.name, member.type->fresh(), &dummy);
			body->parameters.push_back(ExprPtr(new VarRef(p)));
		}

		ctorFunc->body = exitScope<Expr>(body);
		ctorFunc->returnType = typeRef;

		// TODO: Check for name collision
		mod->functions[ctorName] = ctorFunc;
		mod->constructorDefs[ctorName] = ctor;
		exitFunction();
	}

	expect(TRParen, true);
}
コード例 #5
0
ファイル: parser.cpp プロジェクト: gliptic/milkshake
IntrusiveRefCntPtr<FuncDef> Parser::funcDef(bool allowImplicitTypeVars)
{
	string const& name = nextIdent(false);

	// TODO: Always surround this in a type scope?

	IntrusiveRefCntPtr<FuncDef> def(new FuncDef(name));

	int paramCount = 0;
	enterFunction(def);
	enterScope(new Scope);

	if(test(TLParen))
	{
		if(token != TRParen)
		{
			do
			{
				TypePtr type;
				string paramName;
				if(allowImplicitTypeVars)
				{
					paramName = expectIdent();
					type = typeNameOrNewVar(false);
				}
				else
				{
					type = maybeType(false);
					if(! type)
					{
						paramName = expectIdent();
						type = typeName(false);
					}
				}

				declParam(def, paramName, type, &paramCount);
			}
			while(test(TComma));
		}

		expect(TRParen, true);
	}

	TypePtr returnType;
			
	if(firstType[token] || token == TIdent) // TODO: Types may be TIdent too, in certain circumstances
	{
		returnType = typeNameOrNewVar(true);
	}

	if(test(TLBrace))
	{
		auto const& body = statements();
		expect(TRBrace, true);

		def->body = exitScope<Expr>(body);
	}
	
	def->returnType = returnType;
	assert(paramCount == def->parameters.size());

	// TODO: Check for name collision
	mod->functions[def->name] = def;
	exitFunction();

	return def;
}