Skip to content

Instantly share code, notes, and snippets.

@enebo
Created May 29, 2015 20:29
Show Gist options
  • Save enebo/f6b1d8a221a95031a6d4 to your computer and use it in GitHub Desktop.
Save enebo/f6b1d8a221a95031a6d4 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/ir/IRBuilder.java b/core/src/main/java/org/jruby/ir/IRBuilder.java
index ed368f0..59bcdcb 100644
--- a/core/src/main/java/org/jruby/ir/IRBuilder.java
+++ b/core/src/main/java/org/jruby/ir/IRBuilder.java
@@ -658,10 +658,10 @@ public class IRBuilder {
buildAttrAssignAssignment(node, rhsVal);
break;
case CLASSVARASGNNODE:
- addInstr(new PutClassVariableInstr(classVarDefinitionContainer(), ((ClassVarAsgnNode)node).getName(), rhsVal));
+ addInstr(new PutClassVariableInstr(((ClassVarAsgnNode)node).getName(), rhsVal));
break;
case CLASSVARDECLNODE:
- addInstr(new PutClassVariableInstr(classVarDeclarationContainer(), ((ClassVarDeclNode)node).getName(), rhsVal));
+ addInstr(new PutClassVariableInstr(((ClassVarDeclNode)node).getName(), rhsVal));
break;
case CONSTDECLNODE:
buildConstDeclAssignment((ConstDeclNode) node, rhsVal);
@@ -749,12 +749,12 @@ public class IRBuilder {
case CLASSVARASGNNODE:
v = createTemporaryVariable();
receiveBlockArg(v, argsArray, argIndex, isSplat);
- addInstr(new PutClassVariableInstr(classVarDefinitionContainer(), ((ClassVarAsgnNode)node).getName(), v));
+ addInstr(new PutClassVariableInstr(((ClassVarAsgnNode)node).getName(), v));
break;
case CLASSVARDECLNODE:
v = createTemporaryVariable();
receiveBlockArg(v, argsArray, argIndex, isSplat);
- addInstr(new PutClassVariableInstr(classVarDeclarationContainer(), ((ClassVarDeclNode)node).getName(), v));
+ addInstr(new PutClassVariableInstr(((ClassVarDeclNode)node).getName(), v));
break;
case CONSTDECLNODE:
v = createTemporaryVariable();
@@ -1183,7 +1183,7 @@ public class IRBuilder {
// end
public Operand buildClassVarAsgn(final ClassVarAsgnNode classVarAsgnNode) {
Operand val = build(classVarAsgnNode.getValueNode());
- addInstr(new PutClassVariableInstr(classVarDefinitionContainer(), classVarAsgnNode.getName(), val));
+ addInstr(new PutClassVariableInstr(classVarAsgnNode.getName(), val));
return val;
}
@@ -1194,7 +1194,7 @@ public class IRBuilder {
// end
public Operand buildClassVarDecl(final ClassVarDeclNode classVarDeclNode) {
Operand val = build(classVarDeclNode.getValueNode());
- addInstr(new PutClassVariableInstr(classVarDeclarationContainer(), classVarDeclNode.getName(), val));
+ addInstr(new PutClassVariableInstr(classVarDeclNode.getName(), val));
return val;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java b/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java
index beff16a..7be745b 100644
--- a/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java
@@ -6,6 +6,7 @@ import org.jruby.ir.Operation;
import org.jruby.ir.operands.CurrentScope;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRReaderDecoder;
+import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -13,19 +14,19 @@ import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
public class PutClassVariableInstr extends PutInstr implements FixedArityInstr {
- public PutClassVariableInstr(Operand scope, String varName, Operand value) {
- super(Operation.PUT_CVAR, scope, varName, value);
+ public PutClassVariableInstr(String varName, Operand value) {
+ super(Operation.PUT_CVAR, null, varName, value);
}
@Override
public Instr clone(CloneInfo ii) {
- return new PutClassVariableInstr(getTarget().cloneForInlining(ii), ref, getValue().cloneForInlining(ii));
+ return new PutClassVariableInstr(ref, getValue().cloneForInlining(ii));
}
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currScope, currDynScope, temp);
- RubyModule module = (RubyModule) getTarget().retrieve(context, self, currScope, currDynScope, temp);
+ RubyModule module = IRRuntimeHelpers.findInstanceMethodContainer(context, currDynScope, self);
assert module != null : "MODULE should always be something";
@@ -36,7 +37,7 @@ public class PutClassVariableInstr extends PutInstr implements FixedArityInstr {
}
public static PutClassVariableInstr decode(IRReaderDecoder d) {
- return new PutClassVariableInstr(d.decodeOperand(), d.decodeString(), d.decodeOperand());
+ return new PutClassVariableInstr(d.decodeString(), d.decodeOperand());
}
@Override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment