final int findId(String name) { Object[] array = valueArray; if (array == null) { return obj.findPrototypeId(name); } int id = lastFoundId; if (name == array[(id - 1) * SLOT_SPAN + NAME_SLOT]) { return id; } id = obj.findPrototypeId(name); if (id != 0) { int nameSlot = (id - 1) * SLOT_SPAN + NAME_SLOT; // Make cache to work! array[nameSlot] = name; lastFoundId = id; } return id; }
final IdFunctionObject createPrecachedConstructor() { if (constructorId != 0) throw new IllegalStateException(); constructorId = obj.findPrototypeId("constructor"); if (constructorId == 0) { throw new IllegalStateException("No id for constructor property"); } obj.initPrototypeId(constructorId); if (constructor == null) { throw new IllegalStateException( obj.getClass().getName() + ".initPrototypeId() did not " + "initialize id=" + constructorId); } constructor.initFunction(obj.getClassName(), ScriptableObject.getTopLevelScope(obj)); constructor.markAsConstructor(obj); return constructor; }
final void initValue(int id, String name, Object value, int attributes) { if (!(1 <= id && id <= maxId)) throw new IllegalArgumentException(); if (name == null) throw new IllegalArgumentException(); if (value == NOT_FOUND) throw new IllegalArgumentException(); ScriptableObject.checkValidAttributes(attributes); if (obj.findPrototypeId(name) != id) throw new IllegalArgumentException(name); if (id == constructorId) { if (!(value instanceof IdFunctionObject)) { throw new IllegalArgumentException( "consructor should be initialized with IdFunctionObject"); } constructor = (IdFunctionObject) value; constructorAttrs = (short) attributes; return; } initSlot(id, name, value, attributes); }