本文整理汇总了C++中VariableScope类的典型用法代码示例。如果您正苦于以下问题:C++ VariableScope类的具体用法?C++ VariableScope怎么用?C++ VariableScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VariableScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: auto_visit
void VariableScope::Info::visit(Object* obj, ObjectVisitor& visit) {
auto_visit(obj, visit);
VariableScope* vs = as<VariableScope>(obj);
if(!vs->isolated()) {
Object** ary = vs->stack_locals();
if(Fiber* fib = try_as<Fiber>(vs->fiber())) {
FiberData* data = fib->data();
AddressDisplacement dis(data->data_offset(),
data->data_lower_bound(),
data->data_upper_bound());
ary = dis.displace(ary);
}
size_t locals = vs->number_of_locals();
for(size_t i = 0; i < locals; i++) {
visit.call(ary[i]);
}
}
}
示例2: auto_mark
void VariableScope::Info::mark(Object* obj, ObjectMark& mark) {
auto_mark(obj, mark);
VariableScope* vs = as<VariableScope>(obj);
if(!vs->isolated()) {
Object** ary = vs->locals_;
if(Fiber* fib = try_as<Fiber>(vs->fiber())) {
FiberData* data = fib->data();
if(data) {
AddressDisplacement dis(data->data_offset(),
data->data_lower_bound(),
data->data_upper_bound());
ary = dis.displace(ary);
}
}
size_t locals = vs->number_of_locals();
for(size_t i = 0; i < locals; i++) {
if(Object* tmp = mark.call(ary[i])) {
ary[i] = tmp;
}
}
}
}
示例3: visit_variable_scope
void GarbageCollector::visit_variable_scope(CallFrame* call_frame,
StackVariables* scope, ObjectVisitor& visit)
{
scope->self_ = visit.call(scope->self());
scope->block_ = visit.call(scope->block());
scope->module_ = (Module*)visit.call(scope->module());
int locals = call_frame->cm->backend_method()->number_of_locals;
for(int i = 0; i < locals; i++) {
Object* local = scope->get_local(i);
if(local->reference_p()) {
scope->set_local(i, visit.call(local));
}
}
VariableScope* parent = scope->parent();
if(parent && parent->reference_p()) {
scope->parent_ = ((VariableScope*)visit.call(parent));
}
VariableScope* on_heap = scope->on_heap();
if(on_heap) {
scope->on_heap_ = ((VariableScope*)visit.call(on_heap));
}
}
示例4: set_locked
Object* VariableScope::set_locked(STATE) {
_flags_ |= CallFrame::cScopeLocked;
VariableScope* parent = this->parent();
while(parent && !parent->nil_p()) {
parent->set_locked(state);
parent = parent->parent();
}
return cNil;
}
示例5: G
VariableScope* StackVariables::create_heap_alias(STATE,
CallFrame* call_frame, bool full)
{
if(on_heap_) return on_heap_;
VMMethod* vmm = call_frame->cm->backend_method();
VariableScope* scope = state->new_struct<VariableScope>(
G(variable_scope), vmm->number_of_locals * sizeof(Object*));
if(parent_) {
scope->parent(state, parent_);
} else {
scope->parent(state, (VariableScope*)Qnil);
}
scope->self(state, self_);
scope->block(state, block_);
scope->module(state, module_);
scope->method(state, call_frame->cm);
scope->number_of_locals_ = vmm->number_of_locals;
if(full) {
scope->isolated_ = false;
scope->point_locals_to(locals_);
} else {
scope->isolated_ = true;
scope->point_locals_to(scope->heap_locals_);
}
on_heap_ = scope;
return scope;
}
示例6: synthesize
VariableScope* VariableScope::synthesize(STATE, CompiledMethod* method,
Module* module, Object* parent,
Object* self, Object* block,
Tuple* locals)
{
VariableScope* scope = state->new_object<VariableScope>(G(variable_scope));
scope->block(state, block);
scope->module(state, module);
scope->method(state, method);
if(VariableScope* vs = try_as<VariableScope>(parent)) {
scope->parent(state, vs);
} else {
scope->parent(state, nil<VariableScope>());
}
scope->heap_locals(state, locals);
scope->last_match(state, cNil);
scope->self(state, self);
scope->number_of_locals_ = locals->num_fields();
scope->isolated_ = true;
scope->locals_ = 0;
scope->block_as_method_ = 0;
return scope;
}
示例7: while
/**
* Walks the chain of objects accessible from the specified CallFrame.
*/
void GarbageCollector::verify_call_frame(CallFrame* top_call_frame,
AddressDisplacement* offset)
{
CallFrame* call_frame = top_call_frame;
while(call_frame) {
call_frame = displace(call_frame, offset);
if(call_frame->constant_scope_) {
call_frame->constant_scope_->validate();
}
if(call_frame->compiled_code) {
call_frame->compiled_code->validate();
}
if(call_frame->compiled_code) {
native_int stack_size = call_frame->compiled_code->stack_size()->to_native();
for(native_int i = 0; i < stack_size; i++) {
Object* obj = call_frame->stk[i];
obj->validate();
}
}
VariableScope* scope = call_frame->top_scope_;
if(call_frame->multiple_scopes_p() && scope && !scope->nil_p()) {
scope->validate();
}
if(BlockEnvironment* env = call_frame->block_env()) {
env->validate();
}
Arguments* args = displace(call_frame->arguments, offset);
if(!call_frame->inline_method_p() && args) {
args->recv()->validate();
args->block()->validate();
Object** ary = displace(args->arguments(), offset);
for(uint32_t i = 0; i < args->total(); i++) {
ary[i]->validate();
}
}
if(call_frame->scope && call_frame->compiled_code) {
verify_variable_scope(call_frame, displace(call_frame->scope, offset));
}
call_frame = call_frame->previous;
}
}
示例8: auto_visit
void VariableScope::Info::visit(Object* obj, ObjectVisitor& visit) {
auto_visit(obj, visit);
VariableScope* vs = as<VariableScope>(obj);
if(!vs->isolated()) {
Object** ary = vs->stack_locals();
size_t locals = vs->number_of_locals();
for(size_t i = 0; i < locals; i++) {
visit.call(ary[i]);
}
}
}
示例9: promote_scope
VariableScope* CallFrame::method_scope(STATE) {
VariableScope* current = promote_scope(state);
if(!multiple_scopes_p()) return current;
for(;;) {
if(current->block_as_method_p()) return current;
VariableScope* parent = current->parent();
if(!parent->nil_p()) {
current = parent;
} else {
return current;
}
}
assert("should not be here" && 0);
}
示例10: auto_mark
void VariableScope::Info::mark(Object* obj, ObjectMark& mark) {
auto_mark(obj, mark);
VariableScope* vs = as<VariableScope>(obj);
vs->fixup();
Object* tmp;
size_t locals = vs->number_of_locals();
for(size_t i = 0; i < locals; i++) {
tmp = mark.call(vs->get_local(i));
if(tmp) vs->set_local(mark.state(), i, tmp);
}
}
示例11: vardump
std::string DocumentImpl::vardump( VariableScope& vscope)
{
std::ostringstream rt;
VariableScope::const_iterator vi = vscope.begin(), ve = vscope.end();
while (vi != ve)
{
if (vi != vscope.begin())
{
rt << ", ";
}
rt << variableName( vi->first) << " = '" << vscope.getValue( vi->second) << "'";
++vi;
}
return rt.str();
}
示例12: promote_scope
VariableScope* CallFrame::method_scope(STATE) {
VariableScope* current = promote_scope(state);
if(!multiple_scopes_p()) return current;
for(;;) {
if(current->block_as_method_p()) return current;
VariableScope* parent = current->parent();
if(!parent->nil_p()) {
current = parent;
} else {
return current;
}
}
// Shouldn't ever get here.
return 0;
}
示例13: auto_mark
void VariableScope::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);
VariableScope* vs = as<VariableScope>(obj);
if(!vs->isolated_p()) {
Object** ary = vs->locals();
size_t locals = vs->number_of_locals();
for(size_t i = 0; i < locals; i++) {
if(Object* tmp = mark.call(ary[i])) {
ary[i] = tmp;
}
}
}
}
示例14: rbx_zsuper_send
Object* rbx_zsuper_send(STATE, CallFrame* call_frame, Symbol* name, Object* block) {
Object* const recv = call_frame->self();
VariableScope* scope = call_frame->method_scope(state);
assert(scope);
VMMethod* v = scope->method()->backend_method();
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(state, arg_count);
for(int i = 0; i < v->total_args; i++) {
tup->put(state, i, scope->get_local(state, i));
}
if(splat) {
for(size_t 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(name, recv, block, arg_count, 0);
out_args.use_tuple(tup, arg_count);
LookupData lookup(recv, call_frame->module()->superclass(), G(sym_private));
Dispatch dis(name);
return dis.send(state, call_frame, lookup, out_args, eSuper);
}
示例15: last_match
Object* StackVariables::last_match(STATE) {
// For closures, get back to the top of the chain and get that
// last_match.
if(parent_) {
VariableScope* scope = parent_;
while(RTEST(scope->parent())) {
scope = scope->parent();
}
return scope->last_match();
}
// Otherwise, if this has a heap alias, get the last_match from there.
if(on_heap_) {
return on_heap_->last_match();
// Lastly, use the local one. This is where a last_match begins life.
} else {
return last_match_;
}
}