本文整理汇总了C++中OperationArgs类的典型用法代码示例。如果您正苦于以下问题:C++ OperationArgs类的具体用法?C++ OperationArgs怎么用?C++ OperationArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OperationArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: builtin_function_vector_from_list
extern "C" closure builtin_function_vector_from_list(OperationArgs& Args)
{
object_ptr<EVector> v (new EVector);
const closure* top = &Args.evaluate_slot_to_closure(0);
while(top->exp.size())
{
assert(has_constructor(top->exp,":"));
assert(top->exp.size() == 2);
int element_index = top->exp.sub()[0].as_index_var();
int element_reg = top->lookup_in_env( element_index );
int next_index = top->exp.sub()[1].as_index_var();
int next_reg = top->lookup_in_env( next_index );
// Add the element to the list.
v->push_back( Args.evaluate_reg_to_object(element_reg) );
// Move to the next element or end
top = &Args.evaluate_reg_to_closure(next_reg);
}
assert(has_constructor(top->exp,"[]"));
return v;
}
示例2: builtin_function_join
extern "C" closure builtin_function_join(OperationArgs& Args)
{
Args.evaluate_slot_to_reg(0);
int R = Args.evaluate_slot_to_reg(1);
return {index_var(0),{R}};
}
示例3: builtin_function_get_modifiable_for_index
extern "C" closure builtin_function_get_modifiable_for_index(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int R1 = Args.evaluate(0).as_int();
return {index_var(0),{R1}};
}
示例4: builtin_function_seq
extern "C" closure builtin_function_seq(OperationArgs& Args)
{
Args.evaluate_slot_no_record(0);
int index = Args.reference(1).as_index_var();
int R = Args.current_closure().lookup_in_env( index);
return {index_var(0),{R}};
}
示例5: builtin_function_get_modifiable_index
extern "C" closure builtin_function_get_modifiable_index(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int R1 = Args.evaluate_slot_to_reg(0);
const reg_heap& M = Args.memory();
assert(is_modifiable(M.access(R1).C.exp));
return {R1};
}
示例6: builtin_function_is_modifiable
extern "C" closure builtin_function_is_modifiable(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int R1 = Args.evaluate_slot_to_reg(0);
const reg_heap& M = Args.memory();
if (M.access(R1).C.exp.head().type() == modifiable_type)
return constructor("Prelude.True",0);
else
return constructor("Prelude.False",0);
}
示例7: builtin_function_is_changeable
extern "C" closure builtin_function_is_changeable(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int R1 = Args.evaluate_slot_to_reg(0);
const reg_heap& M = Args.memory();
if (M.reg_is_changeable(R1))
return constructor("Prelude.True",0);
else
return constructor("Prelude.False",0);
}
示例8: builtin_function_trigger
extern "C" closure builtin_function_trigger(OperationArgs& Args)
{
int i = Args.evaluate(0).as_int();
reg_heap& M = Args.memory();
// We should be executing in the root token
M.triggers().push_back(i);
return constructor("()",0);
}
示例9: builtin_function_register_probability
extern "C" closure builtin_function_register_probability(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int R = Args.reg_for_slot(0);
auto& M = Args.memory();
M.register_probability(R);
return constructor("()",0);
}
示例10: builtin_function_set_modifiable_value
extern "C" closure builtin_function_set_modifiable_value(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int c = Args.evaluate(0).as_int();
int R1 = Args.evaluate_slot_to_reg(1);
int R2 = Args.evaluate_slot_to_reg(2);
Args.memory().set_reg_value_in_context(R1, {index_var(0),{R2}}, c);
return constructor("()",0);
}
示例11: builtin_function_get_modifiable_value
extern "C" closure builtin_function_get_modifiable_value(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
int c = Args.evaluate(0).as_int();
int R1 = Args.evaluate_slot_to_reg(1);
int R2 = Args.memory().get_modifiable_value_in_context(R1, c);
assert( R2 );
return {index_var(0),{R2}};
}
示例12: builtin_function_add_parameter
extern "C" closure builtin_function_add_parameter(OperationArgs& Args)
{
assert(not Args.evaluate_changeables());
const std::string name = Args.evaluate(0).as_<String>();
int R = Args.evaluate_slot_to_reg(1);
auto& M = Args.memory();
M.parameters.push_back({name,R});
return constructor("()",0);
}
示例13: M
shared_ptr<const Object> Model::operator()(OperationArgs& Args) const
{
shared_ptr<Model> M (clone());
for(int i=0;i<n_parameters();i++)
M->set_parameter_value(i,Args.evaluate(i));
return M->result();
}
示例14: builtin_function_floor
extern "C" closure builtin_function_floor(OperationArgs& Args)
{
double x = Args.evaluate(0).as_double();
assert(x > 0.0);
return {floor(x)};
}
示例15: builtin_function_pow
extern "C" closure builtin_function_pow(OperationArgs& Args)
{
auto x = Args.evaluate(0);
auto y = Args.evaluate(1);
double yy = 0;
if (y.is_double())
yy = y.as_double();
else if (y.is_int())
yy = y.as_int();
else
throw myexception()<<"pow: exponent '"<<x.print()<<"' is not double or int";
if (x.is_double())
{
double xx = x.as_double();
assert(xx > 0.0);
return {pow(xx,yy)};
}
else if (x.is_int())
{
double xx = x.as_int();
assert(xx > 0.0);
return {pow(xx,yy)};
}
else if (x.is_log_double())
{
log_double_t xx = x.as_log_double();
return {pow(xx,yy)};
}
throw myexception()<<"pow: object '"<<x.print()<<"' is not double, int, or log_double";
}