lazy evaluation

67 views
Skip to first unread message

Joanna Eriksson

unread,
Feb 26, 2014, 2:20:32 PM2/26/14
to proglang-c...@googlegroups.com
When trying to do the && and || evaluation we always get zero. Is there something wrong in our code?

labelcount = labelcount + 1;
int label1 = labelcount;
compileExp(p.exp_1, arg);
System.out.println("ifeq " + "AndFALSE" + label1);
compileExp(p.exp_2, arg);
System.out.println("ifeq " + "AndFALSE" + label1);
System.out.println("bipush 1");
System.out.println("goto AndTRUE" + label1);
System.out.println("AndFALSE" + label1 + ":");
System.out.println("bipush 0");
System.out.println("AndTRUE" + label1 + ":");

Aarne Ranta

unread,
Feb 26, 2014, 3:33:03 PM2/26/14
to proglang-c...@googlegroups.com
Have you tested printing separately each of

  true
  true && true
  true || false
  false || true

  Aarne.

Joanna Eriksson

unread,
Feb 26, 2014, 4:04:28 PM2/26/14
to proglang-c...@googlegroups.com
Sorry if I was a bit unprecise. We have tried all kinds of combination and it only fails then the uninitialize variable j occurs in the expression as in good15.cc because it tries to evaluate it even if it shouldn't, that's why we think the problem is in the and function (the or function doesn't do it lazy either). Giving the following error:

Exception in thread "main" java.lang.VerifyError: (class: good15, method: main signature: ()I) Accessing value from uninitialized register 2
Reply all
Reply to author
Forward
0 new messages