Permalink
Browse files

Add support for > and print.

  • Loading branch information...
1 parent 496f4fb commit 288b163559301ec8a7cb36e19ab671cae18fcf73 @olabini olabini committed Jul 20, 2011
Showing with 29 additions and 0 deletions.
  1. +14 −0 src/main/seph/lang/IODefaultBehavior.java
  2. +15 −0 src/main/seph/lang/Number.java
@@ -27,6 +27,20 @@ public final static SephObject println(SThread thread, SephObject receiver) {
return Runtime.NIL;
}
+ @SephMethod
+ public final static SephObject print(SThread thread, SephObject receiver) {
+ SephObject asText = receiver.get("asText");
+ if(asText.isActivatable()) {
+ try {
+ asText = (SephObject)asText.activationFor(0, false).invokeExact(receiver, thread, (LexicalScope)null);
+ } catch(Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.print(((Text)asText).text());
+ return Runtime.NIL;
+ }
+
@Override
public SephObject get(String cellName) {
return seph.lang.bim.IODefaultBehaviorBase.get(cellName);
@@ -38,4 +38,19 @@ public final static SephObject lt(SephObject receiver, SephObject other) {
return Runtime.FALSE;
}
}
+
+ @SephMethod(name=">")
+ public final static SephObject gt(SephObject receiver, SephObject other) {
+ int res = ((Numeric)receiver).compare(other);
+ switch(res) {
+ case -3:
+ case -2:
+ return Runtime.NIL;
+ case -1:
+ case 0:
+ return Runtime.FALSE;
+ default:
+ return Runtime.TRUE;
+ }
+ }
}// Number

0 comments on commit 288b163

Please sign in to comment.