Skip to content

Commit

Permalink
[Truffle] Lazily create the require node as it's only needed for auto…
Browse files Browse the repository at this point in the history
…loading modules.
  • Loading branch information
nirvdrum committed Feb 18, 2015
1 parent 2d0e094 commit c68a018
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -47,7 +47,6 @@ public UnresolvedDispatchNode(
this.ignoreVisibility = ignoreVisibility;
this.indirect = indirect;
this.missingBehavior = missingBehavior;
requireNode = KernelNodesFactory.RequireNodeFactory.create(context, getSourceSection(), new RubyNode[]{});
}

@Override
Expand Down Expand Up @@ -203,6 +202,11 @@ private Object doRubyBasicObject(
}

if (constant.isAutoload()) {
if (requireNode == null) {
CompilerDirectives.transferToInterpreter();
requireNode = insert(KernelNodesFactory.RequireNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{}));
}

module.removeConstant(this, (String) methodName);

requireNode.require((RubyString) constant.getValue());
Expand Down

0 comments on commit c68a018

Please sign in to comment.