src/jdk/nashorn/internal/objects/NativeJSAdapter.java

Print this page




 129     public static final String __preventExtensions__ = "__preventExtensions__";
 130     /** isExtensible extensions operation */
 131     public static final String __isExtensible__      = "__isExtensible__";
 132     /** seal operation */
 133     public static final String __seal__              = "__seal__";
 134     /** isSealed extensions operation */
 135     public static final String __isSealed__          = "__isSealed__";
 136     /** freeze operation */
 137     public static final String __freeze__            = "__freeze__";
 138     /** isFrozen extensions operation */
 139     public static final String __isFrozen__          = "__isFrozen__";
 140 
 141     private final ScriptObject adaptee;
 142     private final boolean overrides;
 143 
 144     private static final MethodHandle IS_JSADAPTOR = findOwnMH("isJSAdaptor", boolean.class, Object.class, Object.class, MethodHandle.class, Object.class, ScriptFunction.class);
 145 
 146     // initialized by nasgen
 147     private static PropertyMap $nasgenmap$;
 148 
 149     static PropertyMap getInitialMap() {
 150         return $nasgenmap$;
 151     }
 152 
 153     NativeJSAdapter(final Object overrides, final ScriptObject adaptee, final ScriptObject proto, final PropertyMap map) {
 154         super(proto, map);
 155         this.adaptee = wrapAdaptee(adaptee);
 156         if (overrides instanceof ScriptObject) {
 157             this.overrides = true;
 158             final ScriptObject sobj = (ScriptObject)overrides;
 159             this.addBoundProperties(sobj);
 160         } else {
 161             this.overrides = false;
 162         }
 163     }
 164 
 165     private static ScriptObject wrapAdaptee(final ScriptObject adaptee) {
 166         return new JO(adaptee, JO.getInitialMap());
 167     }
 168 
 169     @Override
 170     public String getClassName() {
 171         return "JSAdapter";
 172     }


 560             break;
 561 
 562         default:
 563             //fallthru
 564         case 3:
 565             proto = args[0];
 566             overrides = args[1];
 567             adaptee = args[2];
 568             break;
 569         }
 570 
 571         if (!(adaptee instanceof ScriptObject)) {
 572             throw typeError("not.an.object", ScriptRuntime.safeToString(adaptee));
 573         }
 574 
 575         final Global global = Global.instance();
 576         if (proto != null && !(proto instanceof ScriptObject)) {
 577             proto = global.getJSAdapterPrototype();
 578         }
 579 
 580         return new NativeJSAdapter(overrides, (ScriptObject)adaptee, (ScriptObject)proto, getInitialMap());
 581     }
 582 
 583     @Override
 584     protected GuardedInvocation findNewMethod(final CallSiteDescriptor desc) {
 585         return findHook(desc, __new__, false);
 586     }
 587 
 588     @Override
 589     protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
 590         if (overrides && super.hasOwnProperty(desc.getNameToken(2))) {
 591             try {
 592                 final GuardedInvocation inv = super.findCallMethodMethod(desc, request);
 593                 if (inv != null) {
 594                     return inv;
 595                 }
 596             } catch (final Exception e) {
 597                 //ignored
 598             }
 599         }
 600 




 129     public static final String __preventExtensions__ = "__preventExtensions__";
 130     /** isExtensible extensions operation */
 131     public static final String __isExtensible__      = "__isExtensible__";
 132     /** seal operation */
 133     public static final String __seal__              = "__seal__";
 134     /** isSealed extensions operation */
 135     public static final String __isSealed__          = "__isSealed__";
 136     /** freeze operation */
 137     public static final String __freeze__            = "__freeze__";
 138     /** isFrozen extensions operation */
 139     public static final String __isFrozen__          = "__isFrozen__";
 140 
 141     private final ScriptObject adaptee;
 142     private final boolean overrides;
 143 
 144     private static final MethodHandle IS_JSADAPTOR = findOwnMH("isJSAdaptor", boolean.class, Object.class, Object.class, MethodHandle.class, Object.class, ScriptFunction.class);
 145 
 146     // initialized by nasgen
 147     private static PropertyMap $nasgenmap$;
 148 




 149     NativeJSAdapter(final Object overrides, final ScriptObject adaptee, final ScriptObject proto, final PropertyMap map) {
 150         super(proto, map);
 151         this.adaptee = wrapAdaptee(adaptee);
 152         if (overrides instanceof ScriptObject) {
 153             this.overrides = true;
 154             final ScriptObject sobj = (ScriptObject)overrides;
 155             this.addBoundProperties(sobj);
 156         } else {
 157             this.overrides = false;
 158         }
 159     }
 160 
 161     private static ScriptObject wrapAdaptee(final ScriptObject adaptee) {
 162         return new JO(adaptee, JO.getInitialMap());
 163     }
 164 
 165     @Override
 166     public String getClassName() {
 167         return "JSAdapter";
 168     }


 556             break;
 557 
 558         default:
 559             //fallthru
 560         case 3:
 561             proto = args[0];
 562             overrides = args[1];
 563             adaptee = args[2];
 564             break;
 565         }
 566 
 567         if (!(adaptee instanceof ScriptObject)) {
 568             throw typeError("not.an.object", ScriptRuntime.safeToString(adaptee));
 569         }
 570 
 571         final Global global = Global.instance();
 572         if (proto != null && !(proto instanceof ScriptObject)) {
 573             proto = global.getJSAdapterPrototype();
 574         }
 575 
 576         return new NativeJSAdapter(overrides, (ScriptObject)adaptee, (ScriptObject)proto, $nasgenmap$);
 577     }
 578 
 579     @Override
 580     protected GuardedInvocation findNewMethod(final CallSiteDescriptor desc) {
 581         return findHook(desc, __new__, false);
 582     }
 583 
 584     @Override
 585     protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
 586         if (overrides && super.hasOwnProperty(desc.getNameToken(2))) {
 587             try {
 588                 final GuardedInvocation inv = super.findCallMethodMethod(desc, request);
 589                 if (inv != null) {
 590                     return inv;
 591                 }
 592             } catch (final Exception e) {
 593                 //ignored
 594             }
 595         }
 596