X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FArrayImpl.java;h=84b33d1a2c406d1cb8da5a5079b54374d7d3fc9a;hb=8235361e8601ae7b36ab707058de3b52225d15a2;hp=37403bdbf0089402630f2b8deac2ea27e6e38f9c;hpb=b32cea3f3e272ab00899d134d75a8bd7bcf6c8c0;p=org.ibex.core.git diff --git a/src/org/xwt/js/ArrayImpl.java b/src/org/xwt/js/ArrayImpl.java index 37403bd..84b33d1 100644 --- a/src/org/xwt/js/ArrayImpl.java +++ b/src/org/xwt/js/ArrayImpl.java @@ -21,11 +21,49 @@ class ArrayImpl extends JS.Obj { for(int i=0; i '9') return Integer.MIN_VALUE; return Integer.parseInt(s); } - public Object get(Object key) throws JS.Exn { - // FIXME: HACK! - if (key.equals("cascade")) return org.xwt.Trap.cascadeFunction; - if (key.equals("trapee")) return org.xwt.Trap.currentTrapee(); + + public Object callMethod(Object method, JS.Array args,boolean justChecking) { + if(method.equals("push")) { + if(justChecking) return Boolean.TRUE; + for(int i=0;i 0) { + Object o = vec.elementAt(0); + vec.removeElementAt(0); + return o; + } else { + return null; + } + } + if(method.equals("unshift")) { + if(justChecking) return Boolean.TRUE; + // FEATURE: could be optimized a bit with some help from Vec + for(int i=0;i=0;i--) + vec.addElement(oldVec.elementAt(i)); + return this; + } + + private Object slice(JS.Array args) { + int length = length(); + int start = JS.toInt(args.length() < 1 ? null : args.elementAt(0)); + int end = args.length() < 2 ? length : JS.toInt(args.elementAt(1)); + if(start < 0) start = length+start; + if(end < 0) end = length+end; + if(start < 0) start = 0; + if(end < 0) end = 0; + if(start > length) start = length; + if(end > length) end = length; + JS.Array a = new JS.Array(end-start); + for(int i=0;i oldLength) start = oldLength; + if(deleteCount < 0) deleteCount = 0; + if(deleteCount > oldLength-start) deleteCount = oldLength-start; + int newLength = oldLength - deleteCount + newCount; + int lengthChange = newLength - oldLength; + JS.Array ret = new JS.Array(deleteCount); + for(int i=0;i 0) { + setSize(newLength); + for(int i=newLength-1;i>=start+newCount;i--) + setElementAt(elementAt(i-lengthChange),i); + } else if(lengthChange < 0) { + for(int i=start+newCount;i