Skip to content

Commit

Permalink
Make any flip flop usage throw exception if used (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Mar 6, 2015
1 parent df80df4 commit 795ed6b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Expand Up @@ -2314,6 +2314,19 @@ public Operand buildFlip(FlipNode flipNode) {

// Create a variable to hold the flip state
IRBuilder nearestNonClosureBuilder = getNearestFlipVariableScopeBuilder();

// Flip is completely broken atm and it was semi-broken in its last incarnation.
// Method and closures (or evals) are not built at the same time and if -X-C or JIT or AOT
// and jit.threshold=0 then the non-closure where we want to store the hidden flip variable
// is unable to get more instrs added to it (not quite true for -X-C but definitely true
// for JIT/AOT. Also it means needing to grow the size of any heap scope for variables.
if (nearestNonClosureBuilder == null) {
Variable excType = createTemporaryVariable();
addInstr(new InheritanceSearchConstInstr(excType, new ObjectClass(), "NotImplementedError", false));
Variable exc = addResultInstr(CallInstr.create(createTemporaryVariable(), "new", excType, new Operand[] {new ConstantStringLiteral("Flip support currently broken")}, null));
addInstr(new ThrowExceptionInstr(exc));
return buildNil();
}
Variable flipState = nearestNonClosureBuilder.scope.getNewFlipStateVariable();
nearestNonClosureBuilder.initFlipStateVariable(flipState, s1);
if (scope instanceof IRClosure) {
Expand Down
12 changes: 12 additions & 0 deletions spec/tags/ruby/language/if_tags.txt
@@ -0,0 +1,12 @@
fails:The if expression with a boolean range ('flip-flop' operator) mimics an awk conditional with a single-element inclusive-end range
The if expression with a boolean range ('flip-flop' operator) mimics an awk conditional with a many-element inclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) mimics an awk conditional with a many-element inclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) mimics a sed conditional with a zero-element exclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) mimics a sed conditional with a many-element exclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) allows combining two flip-flops
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the first conditions lazily with inclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the first conditions lazily with exclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the second conditions lazily with inclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the second conditions lazily with exclusive-end range
fails:The if expression with a boolean range ('flip-flop' operator) scopes state by flip-flop
fails:The if expression with a boolean range ('flip-flop' operator) keeps flip-flops from interfering

0 comments on commit 795ed6b

Please sign in to comment.