private static Object getElem(Context cx, Scriptable target, long index) { if (index > Integer.MAX_VALUE) { String id = Long.toString(index); return ScriptRuntime.getObjectProp(target, id, cx); } else { return ScriptRuntime.getObjectIndex(target, (int)index, cx); } }
Object lhs = stack[stackTop]; if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]); stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg, cx, frame.scope); continue Loop;
/** * Version of getObjectElem when elem is a valid JS identifier name. */ public static Object getObjectProp(Object obj, String property, Context cx) { Scriptable sobj = toObjectOrNull(cx, obj); if (sobj == null) { throw undefReadError(obj, property); } return getObjectProp(sobj, property, cx); }
/** * @param scope the scope that should be used to resolve primitive prototype */ public static Object getObjectProp(Object obj, String property, Context cx, final Scriptable scope) { Scriptable sobj = toObjectOrNull(cx, obj, scope); if (sobj == null) { throw undefReadError(obj, property); } return getObjectProp(sobj, property, cx); }
/** * The typeof operator that correctly handles the undefined case */ public static String typeofName(Scriptable scope, String id) { Context cx = Context.getContext(); Scriptable val = bind(cx, scope, id); if (val == null) return "undefined"; return typeof(getObjectProp(val, id, cx)); }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } return ScriptRuntime.toUint32( ScriptRuntime.getObjectProp(obj, "length", cx)); }
@Override public Object get(Context cx) { switch (type) { case SPECIAL_NONE: return ScriptRuntime.getObjectProp(target, name, cx); case SPECIAL_PROTO: return target.getPrototype(); case SPECIAL_PARENT: return target.getParentScope(); default: throw Kit.codeBug(); } }
public static Object getObjectPropNoWarn(Object obj, String property, Context cx) { Scriptable sobj = toObjectOrNull(cx, obj); if (sobj == null) { throw undefReadError(obj, property); } if (obj instanceof XMLObject) { // TODO: fix as mentioned in note in method above getObjectProp(sobj, property, cx); } Object result = ScriptableObject.getProperty(sobj, property); if (result == Scriptable.NOT_FOUND) { return Undefined.instance; } return result; }
public static Object getObjectIndex(Object obj, double dblIndex, Context cx) { Scriptable sobj = toObjectOrNull(cx, obj); if (sobj == null) { throw undefReadError(obj, toString(dblIndex)); } int index = (int)dblIndex; if (index == dblIndex) { return getObjectIndex(sobj, index, cx); } else { String s = toString(dblIndex); return getObjectProp(sobj, s, cx); } }