[Nice-commit] Nice/src/gnu/expr CheckContract.java,1.2,1.3
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-19 00:45:19
|
Update of /cvsroot/nice/Nice/src/gnu/expr
In directory sc8-pr-cvs1:/tmp/cvs-serv18292/F:/nice/src/gnu/expr
Modified Files:
CheckContract.java
Log Message:
Generating better bytecode for pre/post-conditions i.e. no duplicate checks whether assertions are turned on or not.
Index: CheckContract.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/expr/CheckContract.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CheckContract.java 24 Jan 2003 12:26:50 -0000 1.2
--- CheckContract.java 19 Mar 2003 00:45:16 -0000 1.3
***************
*** 41,56 ****
CodeAttr code = comp.getCode();
ClassExp currentClass = (ClassExp)comp.topLambda;
! code.preparePostcondition(currentClass.getAssertionEnabledField());
! for (int i = 0; i < pre.length; i++)
! pre[i].compileWithPosition(comp, Target.Ignore);
body.compileWithPosition(comp, target);
! code.startPostcondition();
! for (int i = 0; i < post.length; i++)
! post[i].compileWithPosition(comp, Target.Ignore);
!
! code.endPostcondition();
}
--- 41,67 ----
CodeAttr code = comp.getCode();
ClassExp currentClass = (ClassExp)comp.topLambda;
! code.preparePostcondition(currentClass.getAssertionEnabledField(), post.length>0);
! if (pre.length > 0)
! {
! code.startPrecondition();
! for (int i = 0; i < pre.length; i++)
! pre[i].compileWithPosition(comp, Target.Ignore);
! code.endPrecondition();
! }
body.compileWithPosition(comp, target);
+
+ if (post.length > 0)
+ {
+ code.startPostcondition();
+ for (int i = 0; i < post.length; i++)
+ post[i].compileWithPosition(comp, Target.Ignore);
! code.endPostcondition();
! }
! else
! code.pushRetType();
!
}
|