All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.ir.operands.CurrentScope Maven / Gradle / Ivy

There is a newer version: 9.4.9.0
Show newest version
package org.jruby.ir.operands;

import java.util.List;

import org.jruby.ir.IRScope;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

public class CurrentScope extends Operand {
    private final IRScope scope;

    public CurrentScope(IRScope scope) {
        this.scope = scope;
    }

    @Override
    public void addUsedVariables(List l) {
        /* Nothing to do */
    }

    @Override
    public Operand cloneForInlining(InlinerInfo ii) {
        return this;
    }

    public IRScope getScope() {
        return scope;
    }

    @Override
    public boolean canCopyPropagate() {
        return true;
    }

    @Override
    public String toString() {
        return "scope<" + scope.getName() + ">";
    }

    @Override
    public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
        return scope.getStaticScope();
    }

    @Override
    public void visit(IRVisitor visitor) {
        visitor.CurrentScope(this);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy