Skip to content

Commit ea58dc2

Browse files
committed
[Truffle] Pass LexicalScope explicitly to OpenModuleNode.
* So it does not depend on runtime SharedMethodInfo's LexicalScope.
1 parent 3e4f49c commit ea58dc2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

core/src/main/java/org/jruby/truffle/nodes/objects/OpenModuleNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ public class OpenModuleNode extends RubyNode {
2828

2929
@Child protected RubyNode definingModule;
3030
@Child protected MethodDefinitionNode definitionMethod;
31+
final protected LexicalScope lexicalScope;
3132
@Child protected IndirectCallNode callModuleDefinitionNode;
3233

33-
public OpenModuleNode(RubyContext context, SourceSection sourceSection, RubyNode definingModule, MethodDefinitionNode definitionMethod) {
34+
public OpenModuleNode(RubyContext context, SourceSection sourceSection, RubyNode definingModule, MethodDefinitionNode definitionMethod, LexicalScope lexicalScope) {
3435
super(context, sourceSection);
3536
this.definingModule = definingModule;
3637
this.definitionMethod = definitionMethod;
38+
this.lexicalScope = lexicalScope;
3739
callModuleDefinitionNode = Truffle.getRuntime().createIndirectCallNode();
3840
}
3941

@@ -44,7 +46,6 @@ public Object execute(VirtualFrame frame) {
4446
// TODO(CS): cast
4547
final RubyModule module = (RubyModule) definingModule.execute(frame);
4648

47-
LexicalScope lexicalScope = definitionMethod.getSharedMethodInfo().getLexicalScope();
4849
lexicalScope.setLiveModule(module);
4950
lexicalScope.getParent().getLiveModule().addLexicalDependent(module);
5051

core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ private RubyNode openModule(SourceSection sourceSection, RubyNode defineOrGetNod
763763

764764
final MethodDefinitionNode definitionMethod = classTranslator.compileClassNode(sourceSection, name, bodyNode);
765765

766-
return new OpenModuleNode(context, sourceSection, defineOrGetNode, definitionMethod);
766+
return new OpenModuleNode(context, sourceSection, defineOrGetNode, definitionMethod, newLexicalScope);
767767
} finally {
768768
environment.popLexicalScope();
769769
}

0 commit comments

Comments
 (0)