Nice/stdlib/nice/lang/inline Instanceof.java,1.5,1.6
Arjan Boeijink <[email protected]>
| Newsgroups | gmane.comp.lang.nice.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4762/F:/nice/stdlib/nice/lang/inline
Modified Files:
Instanceof.java
Log Message:
Implemented instanceof on option types.
Index: Instanceof.java
===================================================================
RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/Instanceof.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Instanceof.java 11 Aug 2004 09:06:04 -0000 1.5
--- Instanceof.java 9 Mar 2005 14:47:48 -0000 1.6
***************
*** 29,38 ****
public class Instanceof extends Procedure2 implements Inlineable
{
public static Instanceof create(String param)
{
return instance;
}
! public final static Instanceof instance = new Instanceof();
public void compile (ApplyExp exp, Compilation comp, Target target)
--- 29,49 ----
public class Instanceof extends Procedure2 implements Inlineable
{
+ private final boolean option;
+
public static Instanceof create(String param)
{
+ if ("option".equals(param))
+ return optionInstance;
+
return instance;
}
! private Instanceof(boolean option)
! {
! this.option = option;
! }
!
! public final static Instanceof instance = new Instanceof(false);
! public final static Instanceof optionInstance = new Instanceof(true);
public void compile (ApplyExp exp, Compilation comp, Target target)
***************
*** 73,84 ****
sure it is not null.
*/
! code.emitIfNull();
! code.emitPushBoolean(false);
! code.emitElse();
! code.emitPushBoolean(true);
! code.emitFi();
}
else
! code.emitInstanceof(type);
}
--- 84,114 ----
sure it is not null.
*/
! if (option)
! code.emitPushBoolean(true);
! else
! {
! code.emitIfNull();
! code.emitPushBoolean(false);
! code.emitElse();
! code.emitPushBoolean(true);
! code.emitFi();
! }
}
else
! {
! if (option)
! {
! code.emitDup();
! code.emitIfNull();
! code.emitPop(1);
! code.emitPushBoolean(true);
! code.emitElse();
! }
!
! code.emitInstanceof(type);
!
! if (option)
! code.emitFi();
! }
}
***************
*** 87,94 ****
--- 117,136 ----
gnu.bytecode.CodeAttr code = comp.getCode();
+ if (option)
+ {
+ code.emitDup();
+ code.emitIfNull();
+ code.emitPop(1);
+ code.emitPushBoolean(true);
+ code.emitElse();
+ }
+
type.compile(comp, Target.pushObject);
value.compile(comp, Target.pushObject);
code.emitInvoke
(ClassType.make("java.lang.Class").getDeclaredMethod("isInstance", 1));
+
+ if (option)
+ code.emitFi();
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click