| 20 | import org.dynjs.exception.ThrowException; |
| 21 | |
| 22 | public class DynObject implements JSObject, Map<String, Object> { |
| 23 | |
| 24 | private String className; |
| 25 | private JSObject prototype = null; |
| 26 | |
| 27 | private final Map<String, PropertyDescriptor> properties = new LinkedHashMap<>(); |
| 28 | private boolean extensible = true; |
| 29 | private ExternalIndexedData externalIndexedData; |
| 30 | |
| 31 | // Used by globalObject constructor and for ShadowObjectLinker |
| 32 | public DynObject() { |
| 33 | setClassName("Object"); |
| 34 | setExtensible(true); |
| 35 | } |
| 36 | |
| 37 | // Copy constructor |
| 38 | public DynObject(DynObject parent) { |
| 39 | this.className = parent.className; |
| 40 | this.prototype = parent.prototype; |
| 41 | this.properties.putAll( parent.properties ); |
| 42 | this.extensible = parent.extensible; |
| 43 | this.externalIndexedData = parent.externalIndexedData; |
| 44 | |
| 45 | } |
| 46 | |
| 47 | public DynObject(GlobalContext globalContext) { |
| 48 | this(); |
| 49 | setPrototype(globalContext.getObjectPrototype()); |
| 50 | } |
| 51 | |
| 52 | // ------------------------------------------------------------------------ |
| 53 | // JSObject |
| 54 | // ------------------------------------------------------------------------ |
| 55 | |
| 56 | @Override |
| 57 | public JSObject getPrototype() { |
| 58 | return this.prototype; |
| 59 | } |
| 60 | |
| 61 | public void setPrototype(final JSObject prototype) { |
| 62 | this.prototype = prototype; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public String getClassName() { |
| 67 | return this.className; |
| 68 | } |
| 69 | |
| 70 | public void setClassName(String className) { |
| 71 | this.className = className; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean isExtensible() { |
| 76 | return extensible; |
| 77 | } |
| 78 | |
| 79 | public void setExtensible(boolean extensible) { |
nothing calls this directly
no outgoing calls
no test coverage detected