Skip to content

Commit

Permalink
[Truffle] Straightfoward translation for Rubinius.check_frozen.
Browse files Browse the repository at this point in the history
* static call to frozen? like it should be.
  • Loading branch information
eregon committed Oct 7, 2015
1 parent c0be331 commit 797e181
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,31 +563,7 @@ public RubyNode translateRubiniusSingleBlockArg(SourceSection sourceSection, Cal
}

private RubyNode translateRubiniusCheckFrozen(SourceSection sourceSection) {
/*
* Translate
*
* Rubinius.check_frozen
*
* into
*
* raise RuntimeError.new("can't modify frozen ClassName") if frozen?
*
* TODO(CS, 30-Jan-15) usual questions about monkey patching of the methods we're using
*/

final RubyNode frozen = new RubyCallNode(context, sourceSection, "frozen?", new SelfNode(context, sourceSection), null, false);

final RubyNode constructException = new RubyCallNode(context, sourceSection, "new",
new LiteralNode(context, sourceSection, context.getCoreLibrary().getRuntimeErrorClass()),
null, false,
new StringLiteralNode(context, sourceSection, ByteList.create("FrozenError: can't modify frozen TODO"), StringSupport.CR_UNKNOWN));

final RubyNode raise = new RubyCallNode(context, sourceSection, "raise", new SelfNode(context, sourceSection), null, false, true, constructException);

return new IfNode(context, sourceSection,
frozen,
raise,
nilNode(sourceSection));
return new RaiseIfFrozenNode(new SelfNode(context, sourceSection));
}

/**
Expand Down

0 comments on commit 797e181

Please sign in to comment.