[Nice-commit] Nice/stdlib/nice/lang/inline ReferenceOp.java,1.1,1.2
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-24 23:40:13
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline
In directory sc8-pr-cvs1:/tmp/cvs-serv31803/F:/nice/stdlib/nice/lang/inline
Modified Files:
ReferenceOp.java
Log Message:
ReferenceOp generates efficient code when comparing with null.
Index: ReferenceOp.java
===================================================================
RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/ReferenceOp.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ReferenceOp.java 23 Mar 2003 00:05:49 -0000 1.1
--- ReferenceOp.java 24 Mar 2003 23:40:09 -0000 1.2
***************
*** 52,64 ****
Label _else = new Label(code);
Label _end = new Label(code);
! args[0].compile(comp, stack);
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNE(_else);
else
! code.emitGotoIfEq(_else);
code.emitPushBoolean(true);
code.emitGoto(_end);
--- 52,86 ----
Label _else = new Label(code);
Label _end = new Label(code);
+
+ if (args[0] instanceof QuoteExp &&
+ ((QuoteExp)args[0]).getType() == Type.nullType)
+ {
+ args[1].compile(comp, stack);
+ if (kind == Eq)
+ code.emitGotoIfNotNull(_else);
+ else
+ code.emitGotoIfNull(_else);
! }
! else if (args[1] instanceof QuoteExp &&
! ((QuoteExp)args[1]).getType() == Type.nullType)
! {
! args[0].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNotNull(_else);
! else
! code.emitGotoIfNull(_else);
! }
else
! {
! args[0].compile(comp, stack);
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNE(_else);
! else
! code.emitGotoIfEq(_else);
+ }
code.emitPushBoolean(true);
code.emitGoto(_end);
***************
*** 76,86 ****
Target stack = new StackTarget(Type.pointer_type);
! args[0].compile(comp, stack);
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfEq(to);
else
! code.emitGotoIfNE(to);
}
--- 98,131 ----
Target stack = new StackTarget(Type.pointer_type);
! if (args[0] instanceof QuoteExp &&
! ((QuoteExp)args[0]).getType() == Type.nullType)
! {
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNull(to);
! else
! code.emitGotoIfNotNull(to);
! }
! else if (args[1] instanceof QuoteExp &&
! ((QuoteExp)args[1]).getType() == Type.nullType)
! {
! args[0].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNull(to);
! else
! code.emitGotoIfNotNull(to);
!
! }
else
! {
! args[0].compile(comp, stack);
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfEq(to);
! else
! code.emitGotoIfNE(to);
!
! }
}
***************
*** 90,100 ****
Target stack = new StackTarget(Type.pointer_type);
! args[0].compile(comp, stack);
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNE(to);
else
! code.emitGotoIfEq(to);
}
--- 135,168 ----
Target stack = new StackTarget(Type.pointer_type);
! if (args[0] instanceof QuoteExp &&
! ((QuoteExp)args[0]).getType() == Type.nullType)
! {
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNotNull(to);
! else
! code.emitGotoIfNull(to);
! }
! else if (args[1] instanceof QuoteExp &&
! ((QuoteExp)args[1]).getType() == Type.nullType)
! {
! args[0].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNotNull(to);
! else
! code.emitGotoIfNull(to);
!
! }
else
! {
! args[0].compile(comp, stack);
! args[1].compile(comp, stack);
! if (kind == Eq)
! code.emitGotoIfNE(to);
! else
! code.emitGotoIfEq(to);
!
! }
}
|