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


C++ function::Ptr类代码示例

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


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

示例1: edgeOrganization

void
CfgEmitter::selectFunctionCallees(const Function::Ptr &function) {
    // Use an iteration rather than a traversal because we want to consider all vertices that belong to the function, including
    // those not reachable from the entry vertex.
    BOOST_FOREACH (const ControlFlowGraph::VertexNode &vertex, graph_.vertices()) {
        if (vertexOrganization(vertex).isSelected() && owningFunction(vertex) == function) {
            BOOST_FOREACH (const ControlFlowGraph::EdgeNode &edge, vertex.outEdges()) {
                if (isInterFunctionEdge(edge)) {
                    if (!edgeOrganization(edge).isSelected()) {
                        edgeOrganization(edge).select();
                        edgeOrganization(edge).label(edgeLabel(edge));
                        edgeOrganization(edge).attributes(edgeAttributes(edge));
                    }
                    
                    Organization &tgt = vertexOrganization(edge.target());
                    if (!tgt.isSelected()) {
                        tgt.select();
                        Function::Ptr callee = owningFunction(edge.target());
                        if (callee && edge.target()->value().type() == V_BASIC_BLOCK &&
                            edge.target()->value().address() == callee->address()) {
                            // target is the entry block of a function
                            tgt.label(functionLabel(callee));
                            tgt.attributes(functionAttributes(callee));
                        } else {
                            // target is some block that isn't a function entry
                            tgt.label(vertexLabel(edge.target()));
                            tgt.attributes(vertexAttributes(edge.target()));
                        }
                    }
                }
            }
        }
    }
开发者ID:Sciumo,项目名称:rose,代码行数:33,代码来源:GraphViz.C

示例2: operator

void CCodeGenerator::operator()(Construct* expr) {
    // Look up the function by name in the current context.
    String::Ptr id = env_->name("@init");
    Class::Ptr clazz = expr->type()->clazz();
    Function::Ptr func = clazz->function(id);
    
    std::vector<Operand> args;
    for (Expression::Ptr a = expr->arguments(); a; a = a->next()) {
        args.push_back(emit(a));
    }

    return_ = alloc_temp(clazz->type());
    out_ << func->label() << "(";

    Formal::Ptr formal = func->formals();
    Expression::Ptr arg = expr->arguments();
    for (int i = 0; i < args.size(); i++) {
        if(!formal->is_self() && !formal->type()->equals(arg->type())) {
            // Cast to the appropriate C-type, since C doesn't know anything 
            // about subtypes, etc..
            out_ << "(";
            operator()(formal->type());
            out_ << ")";
        }
        out_ << args[i];
        if (i < args.size() - 1) {
            out_ << ", ";
        }
        formal = formal->next();
        arg = arg->next();
    }
    out_ << ");\n";
}
开发者ID:mfichman,项目名称:jogo,代码行数:33,代码来源:CCodeGenerator.cpp

示例3: SyntaxError

SAWYER_EXPORT std::string
Grammar::evalFunction(TokenStream &tokens, ErrorLocation &eloc) const {
    ASSERT_require(tokens.isa(TOK_FUNCTION));
    std::string funcName = tokens.lexeme();
    ASSERT_require(funcName.size() >= 2 && '@' == funcName[0]);
    funcName = funcName.substr(1);
    tokens.consume();

    // Get the function declaration
    const Function::Ptr func = functions_.getOrDefault(funcName);
    if (!func)
        throw SyntaxError("function \"" + funcName + "\" is not declared");

    // Parse the actual arguments
    std::vector<std::string> actuals;
    while (tokens.isa(TOK_LEFT)) {
        tokens.consume();
        if (func->isMacro()) {
            actuals.push_back(readArgument(tokens, eloc, CONSUME));
        } else {
            actuals.push_back(evalArgument(tokens, eloc, CONSUME));
        }
    }
    func->validateArgs(actuals, tokens);

    ErrorLocation::Trap t(eloc, tokens, "in function \"" + funcName + "\"");
    std::string retval = func->eval(*this, actuals);
    t.passed();
    return retval;
}
开发者ID:billhoffman,项目名称:rose-develop,代码行数:30,代码来源:DocumentMarkup.C

示例4: operator

 bool operator()(const ControlFlowGraph &cfg, const ControlFlowGraph::ConstEdgeIterator &callEdge, size_t depth) {
     if (depth > partitioner.stackDeltaInterproceduralLimit())
         return false;
     ASSERT_require(callEdge != cfg.edges().end());
     ASSERT_require(callEdge->target()->value().type() == V_BASIC_BLOCK);
     Function::Ptr function = callEdge->target()->value().function();
     return function && !function->stackDelta().getOptional().orDefault();
 }
开发者ID:brushington,项目名称:rose-develop,代码行数:8,代码来源:StackDeltaAnalysis.C

示例5: FunctionCall

static Value FunctionCall(const std::vector<Value>& args)
{
	if (args.size() < 1)
		BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for call()"));

	ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
	Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
	REQUIRE_NOT_NULL(self);

	std::vector<Value> uargs(args.begin() + 1, args.end());
	return self->InvokeThis(args[0], uargs);
}
开发者ID:Icinga,项目名称:icinga2,代码行数:12,代码来源:function-script.cpp

示例6: FunctionCallV

static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
{
	ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
	Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
	REQUIRE_NOT_NULL(self);

	std::vector<Value> uargs;

	{
		ObjectLock olock(args);
		uargs = std::vector<Value>(args->Begin(), args->End());
	}

	return self->InvokeThis(thisArg, uargs);
}
开发者ID:Icinga,项目名称:icinga2,代码行数:15,代码来源:function-script.cpp

示例7: InvokeAttributeHandlerHelper

static void InvokeAttributeHandlerHelper(const Function::Ptr& callback,
    const Object::Ptr& object, const Value& cookie)
{
	std::vector<Value> arguments;
	arguments.push_back(object);
	callback->Invoke(arguments);
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:7,代码来源:typetype-script.cpp

示例8: ArraySortCmp

static bool ArraySortCmp(const Function::Ptr& cmp, const Value& a, const Value& b)
{
	std::vector<Value> args;
	args.push_back(a);
	args.push_back(b);
	return cmp->Invoke(args);
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:7,代码来源:array-script.cpp

示例9: FunctionCall

	static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Function::Ptr& func, const std::vector<Value>& arguments)
	{
		ScriptFrame vframe;
		
		if (!self.IsEmpty())
			vframe.Self = self;

		return func->Invoke(arguments);
	}
开发者ID:Nadahar,项目名称:icinga2,代码行数:9,代码来源:vmops.hpp

示例10: DoEvaluate

ExpressionResult FunctionCallExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
	Value self, vfunc;
	String index;

	if (m_FName->GetReference(frame, false, &self, &index))
		vfunc = VMOps::GetField(self, index, frame.Sandboxed, m_DebugInfo);
	else {
		ExpressionResult vfuncres = m_FName->Evaluate(frame);
		CHECK_RESULT(vfuncres);

		vfunc = vfuncres.GetValue();
	}

	if (vfunc.IsObjectType<Type>()) {
		std::vector<Value> arguments;
		for (Expression *arg : m_Args) {
			ExpressionResult argres = arg->Evaluate(frame);
			CHECK_RESULT(argres);

			arguments.push_back(argres.GetValue());
		}

		return VMOps::ConstructorCall(vfunc, arguments, m_DebugInfo);
	}

	if (!vfunc.IsObjectType<Function>())
		BOOST_THROW_EXCEPTION(ScriptError("Argument is not a callable object.", m_DebugInfo));

	Function::Ptr func = vfunc;

	if (!func->IsSideEffectFree() && frame.Sandboxed)
		BOOST_THROW_EXCEPTION(ScriptError("Function is not marked as safe for sandbox mode.", m_DebugInfo));

	std::vector<Value> arguments;
	for (Expression *arg : m_Args) {
		ExpressionResult argres = arg->Evaluate(frame);
		CHECK_RESULT(argres);

		arguments.push_back(argres.GetValue());
	}

	return VMOps::FunctionCall(frame, self, func, arguments);
}
开发者ID:wopfel,项目名称:icinga2,代码行数:44,代码来源:expression.cpp

示例11: olock

static Array::Ptr ArrayMap(const Function::Ptr& function)
{
	ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
	Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);

	if (vframe->Sandboxed && !function->IsSideEffectFree())
		BOOST_THROW_EXCEPTION(ScriptError("Map function must be side-effect free."));

	Array::Ptr result = new Array();

	ObjectLock olock(self);
	for (const Value& item : self) {
		std::vector<Value> args;
		args.push_back(item);
		result->Add(function->Invoke(args));
	}

	return result;
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:19,代码来源:array-script.cpp

示例12: ArrayReduce

static Value ArrayReduce(const Function::Ptr& function)
{
	ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
	Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);

	if (vframe->Sandboxed && !function->IsSideEffectFree())
		BOOST_THROW_EXCEPTION(ScriptError("Reduce function must be side-effect free."));

	if (self->GetLength() == 0)
		return Empty;

	Value result = self->Get(0);

	ObjectLock olock(self);
	for (size_t i = 1; i < self->GetLength(); i++) {
		std::vector<Value> args;
		args.push_back(result);
		args.push_back(self->Get(i));
		result = function->Invoke(args);
	}

	return result;
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:23,代码来源:array-script.cpp

示例13:

TEST(GTestFunction, TestInstanceOf) {
    Function::Ptr add = GTestFunctionAdd::create();
    ASSERT_TRUE(add->instanceof(Type<GTestFunctionAdd>::id()));
    ASSERT_TRUE(add->instanceof(Type<Function>::id()));
    ASSERT_TRUE(add->instanceof(Type<Mutable>::id()));
    ASSERT_TRUE(add->instanceof(Type<Object>::id()));

    ASSERT_FALSE(add->instanceof(Type<Immutable>::id()));
}
开发者ID:louisyoo,项目名称:libj,代码行数:9,代码来源:gtest_function.cpp

示例14: guard

void
CodeExpander::functor(Class* clazz) {
    // Generate the @call method for the functor, which contains a switch on
    // the type of the arugment passed to @call method.
    Function::Ptr func = clazz->function(env_->name("@call"));
    Location loc = clazz->location();
    String::Ptr fn = func->formals()->next()->name();
    IdentifierRef::Ptr guard(new IdentifierRef(loc, env_->name(""), fn));

    Expression::Ptr stmt;
    for (Feature::Ptr feat = clazz->features(); feat; feat = feat->next()) {
        if (Function* func = dynamic_cast<Function*>(feat.pointer())) {
            String* nm = func->name();
            if (nm->string().find("@case") == 0) {
                // This is a functor case, so generate a branch for it.  Each 
                // branch looks like this: [email protected]_Type(obj)
                Type::Ptr type = func->formals()->next()->type();
                Expression::Ptr arg0(new IdentifierRef(loc, env_->name(""), env_->name("__self")));
                Expression::Ptr arg1(new Cast(loc, type, new IdentifierRef(loc, env_->name(""), fn)));
                arg0->type(func->formals()->type());
                arg1->type(func->formals()->next()->type());
                
                Expression::Ptr arg;
                arg = append(arg.pointer(), arg0.pointer());
                arg = append(arg.pointer(), arg1.pointer());
                IdentifierRef::Ptr id(new IdentifierRef(loc, env_->name(""), nm));
                Call::Ptr expr(new Call(loc, id, arg));
                expr->function(func);
                Is::Ptr is(new Is(loc, guard, type));
                stmt = new Conditional(loc, is, expr, stmt);
            }
        }
    }
    Block::Ptr block = new Block(loc, env_->string(""), stmt);
    func->block(block);  
    func->is_checked(false);
    semant_->operator()(func);
}
开发者ID:mfichman,项目名称:jogo,代码行数:38,代码来源:CodeExpander.cpp

示例15: InvokeAttributeHandlerHelper

static void InvokeAttributeHandlerHelper(const Function::Ptr& callback,
	const Object::Ptr& object, const Value& cookie)
{
	callback->Invoke({ object });
}
开发者ID:Icinga,项目名称:icinga2,代码行数:5,代码来源:typetype-script.cpp


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