Пример #1
0
 @Override
 public void defineOwnProperty(Context cx, Object key, ScriptableObject desc) {
   if (key instanceof String) {
     String name = (String) key;
     int info = findInstanceIdInfo(name);
     if (info != 0) {
       int id = (info & 0xFFFF);
       if (isAccessorDescriptor(desc)) {
         delete(id); // it will be replaced with a slot
       } else {
         int attr = (info >>> 16);
         Object value = getProperty(desc, "value");
         setInstanceIdValue(id, value == NOT_FOUND ? Undefined.instance : value);
         setAttributes(id, applyDescriptorToAttributeBitset(attr, desc));
         return;
       }
     }
     if (prototypeValues != null) {
       int id = prototypeValues.findId(name);
       if (id != 0) {
         if (isAccessorDescriptor(desc)) {
           prototypeValues.delete(id); // it will be replaced with a slot
         } else {
           int attr = prototypeValues.getAttributes(id);
           Object value = getProperty(desc, "value");
           prototypeValues.set(id, this, value == NOT_FOUND ? Undefined.instance : value);
           prototypeValues.setAttributes(id, applyDescriptorToAttributeBitset(attr, desc));
           return;
         }
       }
     }
   }
   super.defineOwnProperty(cx, key, desc);
 }
Пример #2
0
 @Override
 public void setAttributes(String name, int attributes) {
   ScriptableObject.checkValidAttributes(attributes);
   int info = findInstanceIdInfo(name);
   if (info != 0) {
     int currentAttributes = (info >>> 16);
     if (attributes != currentAttributes) {
       throw new RuntimeException("Change of attributes for this id is not supported");
     }
     return;
   }
   if (prototypeValues != null) {
     int id = prototypeValues.findId(name);
     if (id != 0) {
       prototypeValues.setAttributes(id, attributes);
       return;
     }
   }
   super.setAttributes(name, attributes);
 }