Code Monkey home page Code Monkey logo

Comments (4)

pgoodman avatar pgoodman commented on July 22, 2024

Uninformed guess: the code to go from while to do+while finds the conditional break, but either doesn't check that it is lexically first, or that all sub-statements of the while are conditional.

from rellic.

pgoodman avatar pgoodman commented on July 22, 2024

Here is a fun idea! What if the transform proceeded like this, and I am not claiming correctness of this:

while(1U) {
  a = sth;
  if(a == 10) {  <-- break condition identifier
    break;  <-- break objserved
  }
  if(a != 10) {
    body;
  }
}

wrap all sub-statements in exit condition, after re-forming do-which

  if (a != 10) {
    a = sth;
  }
  if (a != 10) {
    if(a == 10) {
      break;
    }
  }
  if (a != 10) {
    if(a != 10) {
      body;
    }
  }
} while (a != 10);

refine1:

do {
  if (a != 10) {
    a = sth;
  }
  if (a != 10) {
    if(0) {
      break;
    }
  }
  if (a != 10) {
    if(1) {
      body;
    }
  }
} while (a != 10);

refine2:

do {
  if (a != 10) {
    a = sth;
  }
  if (a != 10) {
    
  }
  if (a != 10) {
    body;
  }
} while (a != 10);

refine3:

do {
  if (a != 10) {
    a = sth;
  }
  if (a != 10) {
    body;
  }
} while (a != 10);

refine4:

do {
  if (a != 10) {
    a = sth;
    body;
  }
} while (a != 10);

not sure where this is going

from rellic.

pgoodman avatar pgoodman commented on July 22, 2024

anyway, could it possibly be because the do-while condition refinement asserts the while condition before entering the do, which wouldn't be valid?

from rellic.

frabert avatar frabert commented on July 22, 2024

What is happening is:

  1. the if(a == 10) { break; } if(!(a == 10)) { body; } is turned into if(a == 10) {break;} else {body;}
  2. the if is recognized as being the stopping condition for a do...while by LoopRefine. The else body is added to the loop without a guard

What should happen instead is that the else body should be added guarded by !(a == 10).

from rellic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.