本文整理汇总了C++中Tuple::put方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::put方法的具体用法?C++ Tuple::put怎么用?C++ Tuple::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_tuple
Tuple* UnMarshaller::get_tuple() {
size_t count;
stream >> count;
Tuple* tup = Tuple::create(state, count);
for(size_t i = 0; i < count; i++) {
tup->put(state, i, unmarshal());
}
return tup;
}
示例2: rbx_zsuper_send
Object* rbx_zsuper_send(STATE, CallFrame* call_frame, CallSite* call_site, Object* block) {
Object* const recv = call_frame->self();
VariableScope* scope = call_frame->method_scope(state);
assert(scope);
MachineCode* v = scope->method()->machine_code();
Object* splat_obj = 0;
Array* splat = 0;
size_t arg_count = v->total_args;
if(v->splat_position >= 0) {
splat_obj = scope->get_local(state, v->splat_position);
splat = try_as<Array>(splat_obj);
if(splat) {
arg_count += splat->size();
} else {
arg_count++;
}
}
Tuple* tup = Tuple::create_dirty(state, arg_count);
for(int i = 0; i < v->total_args; i++) {
tup->put(state, i, scope->get_local(state, i));
}
if(splat) {
for(native_int i = 0; i < splat->size(); i++) {
tup->put(state, i + v->total_args, splat->get(state, i));
}
} else if(splat_obj) {
tup->put(state, v->total_args, splat_obj);
}
Arguments out_args(call_site->name(), recv, block, arg_count, 0);
out_args.use_tuple(tup, arg_count);
return call_site->execute(state, call_frame, out_args);
}
示例3: update_ruby_values
void Metrics::update_ruby_values(STATE) {
GCDependent guard(state, 0);
Tuple* values = values_.get();
int index = 0;
for(MetricsMap::iterator i = metrics_map_.begin();
i != metrics_map_.end();
++i)
{
values->put(state, index++, Integer::from(state, (*i)->second));
}
}
示例4: test_dup_ignores_singleton_class
void test_dup_ignores_singleton_class() {
Tuple* tup = Tuple::create(state, 1);
tup->put(state, 0, Qtrue);
// Force it to exist.
tup->singleton_class(state);
Tuple* tup2 = as<Tuple>(tup->duplicate(state));
TS_ASSERT(!try_as<SingletonClass>(tup2->klass_));
TS_ASSERT_DIFFERS(tup->singleton_class(state), tup2->singleton_class(state));
}
示例5: from
Tuple* Tuple::from(STATE, native_int fields, ...) {
Tuple* tup = Tuple::create(state, fields);
va_list ar;
va_start(ar, fields);
for(native_int i = 0; i < fields; i++) {
Object *obj = va_arg(ar, Object*);
// fields equals size so bounds checking is unecessary
tup->put(state, i, obj);
}
va_end(ar);
return tup;
}
示例6: store
Object* LookupTable::store(STATE, Object* key, Object* val) {
unsigned int num_entries, num_bins, bin;
Object* new_ent;
Tuple* cur;
Tuple* entry;
key_to_sym(key);
num_entries = entries_->to_native();
num_bins = bins_->to_native();
if(max_density_p(num_entries, num_bins)) {
redistribute(state, num_bins <<= 1);
}
bin = find_bin(key_hash(key), num_bins);
cur = entry = try_as<Tuple>(values_->at(state, bin));
while(entry) {
if(entry->at(state, 0) == key) {
entry->put(state, 1, val);
return val;
}
cur = entry;
entry = try_as<Tuple>(entry->at(state, 2));
}
new_ent = entry_new(state, key, val);
if(cur) {
cur->put(state, 2, new_ent);
} else {
values_->put(state, bin, new_ent);
}
entries(state, Fixnum::from(num_entries + 1));
return val;
}
示例7: vm_thread_state
Tuple* System::vm_thread_state(STATE) {
ThreadState* ts = state->thread_state();
Tuple* tuple = Tuple::create(state, 5);
Symbol* reason = 0;
switch(ts->raise_reason()) {
case cNone:
reason = state->symbol("none");
break;
case cException:
reason = state->symbol("exception");
break;
case cReturn:
reason = state->symbol("return");
break;
case cBreak:
reason = state->symbol("break");
break;
case cExit:
reason = state->symbol("exit");
break;
case cCatchThrow:
reason = state->symbol("catch_throw");
break;
default:
reason = state->symbol("unknown");
}
tuple->put(state, 0, reason);
tuple->put(state, 1, ts->raise_value());
tuple->put(state, 2, ts->destination_scope());
tuple->put(state, 3, ts->current_exception());
tuple->put(state, 4, ts->throw_dest());
return tuple;
}
示例8: shift
Object* Arguments::shift(STATE) {
Object* first = arguments_[0];
if(argument_container_) {
Tuple* tup = Tuple::create_dirty(state, total() - 1);
for(uint32_t i = 1; i < total_; i++) {
tup->put(state, i - 1, get_argument(i));
}
use_tuple(tup, total_ - 1);
} else {
total_--;
arguments_++;
}
return first;
}
示例9: get_iseq
InstructionSequence* UnMarshaller::get_iseq() {
size_t count;
long op;
stream >> count;
InstructionSequence* iseq = InstructionSequence::create(state, count);
Tuple* ops = iseq->opcodes();
for(size_t i = 0; i < count; i++) {
stream >> op;
ops->put(state, i, Fixnum::from(op));
}
iseq->post_marshal(state);
return iseq;
}
示例10: make_array
inline void make_array(STATE, CallFrame* call_frame, intptr_t count) {
Object* t2;
Array* ary = Array::create(state, count);
Tuple* tup = ary->tuple();
#ifdef RBX_ALLOC_TRACKING
if(unlikely(state->vm()->allocation_tracking())) {
ary->setup_allocation_site(state);
}
#endif
int j = count - 1;
for(; j >= 0; j--) {
t2 = stack_pop();
tup->put(state, j, t2);
}
ary->total(state, Fixnum::from(count));
stack_push(ary);
}
示例11: unshift
void Array::unshift(STATE, Object* val) {
native_int new_size = total_->to_native() + 1;
native_int lend = start_->to_native();
if(lend > 0) {
tuple_->put(state, lend-1, val);
start(state, Fixnum::from(lend-1));
total(state, Fixnum::from(new_size));
} else {
Tuple* nt = Tuple::create(state, new_size);
nt->copy_from(state, tuple_, start_, total_,
Fixnum::from(1));
nt->put(state, 0, val);
total(state, Fixnum::from(new_size));
start(state, Fixnum::from(0));
tuple(state, nt);
}
}
示例12: new_range
Array* Array::new_range(STATE, Fixnum* start, Fixnum* count) {
Array* ary = state->new_object<Array>(class_object(state));
ary->total(state, count);
ary->start(state, Fixnum::from(0));
native_int total = count->to_native();
if(total <= 0) {
ary->tuple(state, Tuple::create(state, 0));
} else {
Tuple* tup = Tuple::create(state, total);
Tuple* orig = tuple_;
for(native_int i = 0, j = start->to_native(); i < total; i++, j++) {
tup->put(state, i, orig->at(state, j));
}
ary->tuple(state, tup);
}
return ary;
}
示例13: get_iseq
InstructionSequence* UnMarshaller::get_iseq() {
size_t count;
char data[OPCODE_LENGTH];
stream >> count;
// Read off newline
stream.get();
InstructionSequence* iseq = InstructionSequence::create(state, count);
Tuple* ops = iseq->opcodes();
for(size_t i = 0; i < count; i++) {
stream.getline(data, OPCODE_LENGTH);
long op = strtol(data, NULL, 10);
ops->put(state, i, Fixnum::from(op));
}
iseq->post_marshal(state);
return iseq;
}
示例14: init_ruby_metrics
void Metrics::init_ruby_metrics(STATE) {
LookupTable* map = LookupTable::create(state);
Module* mod = as<Module>(G(rubinius)->get_const(state, state->symbol("Metrics")));
mod->set_const(state, "Map", map);
Tuple* values = Tuple::create(state, metrics_map_.size());
values_.set(values);
mod->set_const(state, "Values", values);
int index = 0;
for(MetricsMap::iterator i = metrics_map_.begin();
i != metrics_map_.end();
++i)
{
values->put(state, index, Bignum::from(state, (*i)->second));
Object* key = reinterpret_cast<Object*>(state->symbol((*i)->first.c_str()));
map->store(state, key, Fixnum::from(index++));
}
}
示例15: remove
Object* LookupTable::remove(STATE, Object* key) {
hashval bin;
Object* val;
Tuple* entry;
Tuple* lst;
key_to_sym(key);
size_t num_entries = entries_->to_native();
size_t num_bins = bins_->to_native();
if(min_density_p(num_entries, num_bins) && (num_bins >> 1) >= LOOKUPTABLE_MIN_SIZE) {
redistribute(state, num_bins >>= 1);
}
bin = find_bin(key_hash(key), num_bins);
entry = try_as<Tuple>(values_->at(state, bin));
lst = NULL;
while(entry) {
Object* link = entry->at(state, 2);
if(entry->at(state, 0) == key) {
val = entry->at(state, 1);
if(lst) {
lst->put(state, 2, link);
} else {
values_->put(state, bin, link);
}
entries(state, Fixnum::from(entries_->to_native() - 1));
return val;
}
lst = entry;
entry = try_as<Tuple>(link);
}
return Qnil;
}