mattunlv / ProcessJ-main-branch-old

ProcessJ Compiler Project
2 stars 4 forks source link

'doStat' foreverloop not set #15

Closed cabelshrestha closed 7 years ago

cabelshrestha commented 7 years ago
import std.io;
public proc void foo() {
  do {
    println("forever loop value should be set to true.");
  } while (true);
  println("unreachable code");
}

Reachability pass not checking for this. Should set foreverLoop = true and should not allow any stats after it.

mattunlv commented 7 years ago

?? don't know what you mean here - does it work if you change true to 1<2?

Matt

On Dec 4, 2016, at 9:49 AM, Cabel Shrestha wrote:

import std.io; public proc void foo() { do { println("forever loop value should be set to true."); } while (true); } Forever loop value is not set to true before code generator phase.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

cabelshrestha commented 7 years ago

No, it doesn't work with 1<2, 1==1, etc. either - any constant value equating to true. Java doesn't like it. This will be the same thing you did in the reachability pass for the forever while loops and for loops. while(true) for( ; ; )

mattunlv commented 7 years ago

I’m still confused

On Dec 5, 2016, at 5:15 PM, Cabel Shrestha notifications@github.com wrote:

while(true)


cabelshrestha commented 7 years ago

Compile the following and see what happens:

proc void foo() {
  while(true) {
    println("hello world");
  }
  println("oops");
}

Also, debug the value of foreverLoop boolean of the WhileStat in the code generator.

mattunlv commented 7 years ago

yes it thrown an error (though it doesn’t stop - it probably should!)

but

import std.io http://std.io/; public proc void foo() { do { println("forever loop value should be set to true."); } while (true) println("forever loop value should be set to true."); } also produces:

oops2.pj:5: Do-statement is an infinite loop. Error number: 5011 oops2.pj:5: Unreachable code following statement beginning on line 5. Error number: 5003

so isn’t that ok?

matt

On Dec 5, 2016, at 5:57 PM, Cabel Shrestha notifications@github.com wrote:

Compile the following and see what happens:

proc void foo() { while(true) { println("hello world"); } println("oops"); } Also, debug the value of foreverLoop boolean of the WhileStat in the code generator.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/mattunlv/ProcessJ/issues/15#issuecomment-265038193, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFQHZGXK3b6nEsJmnLRDRQHcIOJ2Yksks5rFMEcgaJpZM4LDpSZ.


cabelshrestha commented 7 years ago

Ok, I lied. That error is actually being thrown. And yes, I think we need to stop the compilation when this error occurs.

But, the 'foreverLoop' flag is not set to true still. Could you check on that?

mattunlv commented 7 years ago

done - just pushed the latest version

Matt

On Dec 5, 2016, at 6:42 PM, Cabel Shrestha notifications@github.com wrote:

Ok, I lied. That error is actually being thrown. And yes, I think we need to stop the compilation when this error occurs.

But, the 'foreverLoop' flag is not set to true still. Could you check on that?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/mattunlv/ProcessJ/issues/15#issuecomment-265044862, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFQHU01dWskVi17FBkLo9jXm-3yOIYWks5rFMulgaJpZM4LDpSZ.


cabelshrestha commented 7 years ago

Perfect. Closing this out. Thanks!

mattunlv commented 7 years ago

But was this actually the original problem? :-). I forget

Sent from my iPhone, which now again is better than Kelvin's.

On Dec 5, 2016, at 18:59, Cabel Shrestha notifications@github.com wrote:

Closed #15.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.

cabelshrestha commented 7 years ago

Yes, it was, for this particular issue#. :)

On Mon, Dec 5, 2016 at 9:13 PM, mattunlv notifications@github.com wrote:

But was this actually the original problem? :-). I forget

Sent from my iPhone, which now again is better than Kelvin's.

On Dec 5, 2016, at 18:59, Cabel Shrestha notifications@github.com wrote:

Closed #15.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/mattunlv/ProcessJ/issues/15#issuecomment-265049108, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAHA6fyFeOjjd57xRiKJmAXqXd-PLSrks5rFNLmgaJpZM4LDpSZ .