[Nice-commit] Nice/stdlib/nice/lang/inline BoolNotOp.java,1.1,1.2
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-20 19:40:08
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline
In directory sc8-pr-cvs1:/tmp/cvs-serv20786/F:/nice/stdlib/nice/lang/inline
Modified Files:
BoolNotOp.java
Log Message:
Next step in improving bytecode generation of operators, BoolNotOp implements and uses Branchable.
Index: BoolNotOp.java
===================================================================
RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/BoolNotOp.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BoolNotOp.java 18 Feb 2003 12:48:52 -0000 1.1
--- BoolNotOp.java 20 Mar 2003 19:40:04 -0000 1.2
***************
*** 22,26 ****
@author Daniel Bonniot
*/
! public class BoolNotOp extends Procedure1 implements Inlineable
{
private BoolNotOp()
--- 22,26 ----
@author Daniel Bonniot
*/
! public class BoolNotOp extends Procedure1 implements Inlineable, Branchable
{
private BoolNotOp()
***************
*** 40,48 ****
CodeAttr code = comp.getCode();
Target stack = new StackTarget(Type.boolean_type);
! args[0].compile(comp, stack);
! code.emitPushConstant(1, Type.int_type);
! code.emitXOr();
target.compileFromStack(comp, retType);
}
--- 40,130 ----
CodeAttr code = comp.getCode();
Target stack = new StackTarget(Type.boolean_type);
+ Branchable branchOp = args[0].getBranchable();
! if (branchOp != null)
! {
! branchOp.compileIfNot(comp, ((ApplyExp)args[0]).getArgs());
! code.emitPushBoolean(true);
! code.emitElse();
! code.emitPushBoolean(false);
! code.emitFi();
! }
! else
! {
! args[0].compile(comp, stack);
! code.emitPushConstant(1, Type.int_type);
! code.emitXOr();
! }
target.compileFromStack(comp, retType);
+ }
+
+ public void compileJump (Compilation comp, Expression[] args, Label to)
+ {
+ CodeAttr code = comp.getCode();
+ Target stack = new StackTarget(Type.boolean_type);
+ Branchable branchOp = args[0].getBranchable();
+
+ if (branchOp != null)
+ {
+ branchOp.compileJumpNot(comp, ((ApplyExp)args[0]).getArgs(), to);
+ }
+ else
+ {
+ args[0].compile(comp, stack);
+ code.emitGotoIfIntEqZero(to);
+ }
+ }
+
+ public void compileJumpNot (Compilation comp, Expression[] args, Label to)
+ {
+ CodeAttr code = comp.getCode();
+ Target stack = new StackTarget(Type.boolean_type);
+ Branchable branchOp = args[0].getBranchable();
+
+ if (branchOp != null)
+ {
+ branchOp.compileJump(comp, ((ApplyExp)args[0]).getArgs(), to);
+ }
+ else
+ {
+ args[0].compile(comp, stack);
+ code.emitGotoIfIntNeZero(to);
+ }
+
+ }
+
+ public void compileIf (Compilation comp, Expression[] args)
+ {
+ CodeAttr code = comp.getCode();
+ Target stack = new StackTarget(Type.boolean_type);
+ Branchable branchOp = args[0].getBranchable();
+ if (branchOp != null)
+ {
+ branchOp.compileIfNot(comp, ((ApplyExp)args[0]).getArgs());
+ }
+ else
+ {
+ args[0].compile(comp, stack);
+ code.emitIfIntZero();
+ }
+
+ }
+
+ public void compileIfNot (Compilation comp, Expression[] args)
+ {
+ CodeAttr code = comp.getCode();
+ Target stack = new StackTarget(Type.boolean_type);
+ Branchable branchOp = args[0].getBranchable();
+
+ if (branchOp != null)
+ {
+ branchOp.compileIf(comp, ((ApplyExp)args[0]).getArgs());
+ }
+ else
+ {
+ args[0].compile(comp, stack);
+ code.emitIfIntNotZero();
+ }
+
}
|