package com.oracle.truffle.js.runtime.builtins;
import java.util.Collections;
import java.util.List;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.js.lang.JavaScriptLanguage;
import com.oracle.truffle.js.runtime.Errors;
import com.oracle.truffle.js.runtime.objects.Null;
import com.oracle.truffle.js.runtime.objects.PropertyDescriptor;
public abstract class AbstractJSClass extends JSClass {
@TruffleBoundary
@Override
public Object getOwnHelper(DynamicObject store, Object thisObj, Object name, Node encapsulatingNode) {
throw Errors.createTypeErrorCannotGetProperty(JavaScriptLanguage.getCurrentJSRealm().getContext(), name, thisObj, false, encapsulatingNode);
}
@TruffleBoundary
@Override
public Object getOwnHelper(DynamicObject store, Object thisObj, long index, Node encapsulatingNode) {
throw Errors.createTypeErrorCannotGetProperty(JavaScriptLanguage.getCurrentJSRealm().getContext(), String.valueOf(index), thisObj, false, encapsulatingNode);
}
@Override
public Object getMethodHelper(DynamicObject store, Object thisObj, Object key, Node encapsulatingNode) {
return getHelper(store, thisObj, key, encapsulatingNode);
}
@Override
public Object getHelper(DynamicObject store, Object thisObj, Object key, Node encapsulatingNode) {
return getOwnHelper(store, thisObj, key, encapsulatingNode);
}
@Override
public Object getHelper(DynamicObject store, Object thisObj, long index, Node encapsulatingNode) {
return getOwnHelper(store, thisObj, index, encapsulatingNode);
}
@Override
public boolean hasOwnProperty(DynamicObject thisObj, Object key) {
throw Errors.createTypeErrorNotAnObject(thisObj);
}
@Override
public boolean hasOwnProperty(DynamicObject thisObj, long index) {
throw Errors.createTypeErrorNotAnObject(thisObj);
}
@Override
public boolean hasProperty(DynamicObject thisObj, Object key) {
return hasOwnProperty(thisObj, key);
}
@Override
public boolean hasProperty(DynamicObject thisObj, long index) {
return hasOwnProperty(thisObj, index);
}
@TruffleBoundary
@Override
public boolean set(DynamicObject thisObj, Object key, Object value, Object receiver, boolean isStrict, Node encapsulatingNode) {
throw Errors.createTypeErrorCannotSetProperty(key, thisObj, encapsulatingNode);
}
@TruffleBoundary
@Override
public boolean set(DynamicObject thisObj, long index, Object value, Object receiver, boolean isStrict, Node encapsulatingNode) {
throw Errors.createTypeErrorCannotSetProperty(String.valueOf(index), thisObj, encapsulatingNode);
}
@TruffleBoundary
@Override
public boolean delete(DynamicObject thisObj, Object key, boolean isStrict) {
throw Errors.createTypeErrorCannotDeletePropertyOf(key, thisObj);
}
@TruffleBoundary
@Override
public boolean delete(DynamicObject thisObj, long index, boolean isStrict) {
throw Errors.createTypeErrorCannotDeletePropertyOf(String.valueOf(index), thisObj);
}
@Override
public List<Object> getOwnPropertyKeys(DynamicObject thisObj, boolean strings, boolean symbols) {
return Collections.emptyList();
}
@Override
public boolean defineOwnProperty(DynamicObject thisObj, Object key, PropertyDescriptor desc, boolean doThrow) {
if (doThrow) {
throw Errors.createTypeErrorCannotSetProperty(key, thisObj, null);
}
return false;
}
@Override
public boolean preventExtensions(DynamicObject thisObj, boolean doThrow) {
throw Errors.createTypeErrorNotAnObject(thisObj);
}
@Override
public boolean isExtensible(DynamicObject thisObj) {
throw Errors.createTypeErrorNotAnObject(thisObj);
}
@Override
public boolean hasOnlyShapeProperties(DynamicObject obj) {
return false;
}
@Override
public boolean usesOrdinaryGetOwnProperty() {
return false;
}
@Override
public boolean usesOrdinaryIsExtensible() {
return false;
}
@Override
public DynamicObject getPrototypeOf(DynamicObject thisObj) {
return Null.instance;
}
@Override
public boolean setPrototypeOf(DynamicObject thisObj, DynamicObject newPrototype) {
return true;
}
@Override
public PropertyDescriptor getOwnProperty(DynamicObject thisObj, Object key) {
throw Errors.createTypeErrorNotAnObject(thisObj);
}
}