|
80 | 80 | import com.oracle.truffle.js.nodes.function.JSFunctionCallNode; |
81 | 81 | import com.oracle.truffle.js.nodes.interop.ForeignObjectPrototypeNode; |
82 | 82 | import com.oracle.truffle.js.nodes.interop.ImportValueNode; |
| 83 | +import com.oracle.truffle.js.nodes.module.ReadImportBindingNode; |
83 | 84 | import com.oracle.truffle.js.runtime.Errors; |
84 | 85 | import com.oracle.truffle.js.runtime.JSArguments; |
85 | 86 | import com.oracle.truffle.js.runtime.JSConfig; |
|
98 | 99 | import com.oracle.truffle.js.runtime.builtins.JSFunction; |
99 | 100 | import com.oracle.truffle.js.runtime.builtins.JSFunctionData; |
100 | 101 | import com.oracle.truffle.js.runtime.builtins.JSFunctionObject; |
101 | | -import com.oracle.truffle.js.runtime.builtins.JSModuleNamespace; |
| 102 | +import com.oracle.truffle.js.runtime.builtins.JSModuleNamespaceObject; |
102 | 103 | import com.oracle.truffle.js.runtime.builtins.JSOrdinary; |
103 | 104 | import com.oracle.truffle.js.runtime.builtins.JSProxy; |
104 | 105 | import com.oracle.truffle.js.runtime.builtins.JSRegExp; |
|
108 | 109 | import com.oracle.truffle.js.runtime.java.JavaImporter; |
109 | 110 | import com.oracle.truffle.js.runtime.java.JavaPackage; |
110 | 111 | import com.oracle.truffle.js.runtime.objects.Accessor; |
| 112 | +import com.oracle.truffle.js.runtime.objects.ExportResolution; |
111 | 113 | import com.oracle.truffle.js.runtime.objects.JSDynamicObject; |
112 | 114 | import com.oracle.truffle.js.runtime.objects.JSObject; |
113 | 115 | import com.oracle.truffle.js.runtime.objects.JSObjectUtil; |
@@ -1179,6 +1181,26 @@ protected Object getValue(Object thisObj, Object receiver, Object defaultValue, |
1179 | 1181 | } |
1180 | 1182 | } |
1181 | 1183 |
|
| 1184 | + public static final class ModuleNamespacePropertyGetNode extends LinkedPropertyGetNode { |
| 1185 | + |
| 1186 | + private final Location location; |
| 1187 | + @Child ReadImportBindingNode readBindingNode; |
| 1188 | + |
| 1189 | + public ModuleNamespacePropertyGetNode(Property property, ReceiverCheckNode receiverCheck) { |
| 1190 | + super(receiverCheck); |
| 1191 | + assert JSProperty.isModuleNamespaceExport(property); |
| 1192 | + this.location = property.getLocation(); |
| 1193 | + this.readBindingNode = ReadImportBindingNode.create(); |
| 1194 | + } |
| 1195 | + |
| 1196 | + @Override |
| 1197 | + protected Object getValue(Object thisObj, Object receiver, Object defaultValue, PropertyGetNode root, boolean guard) { |
| 1198 | + JSModuleNamespaceObject store = (JSModuleNamespaceObject) receiverCheck.getStore(thisObj); |
| 1199 | + ExportResolution.Resolved exportResolution = (ExportResolution.Resolved) location.get(store, guard); |
| 1200 | + return readBindingNode.execute(exportResolution); |
| 1201 | + } |
| 1202 | + } |
| 1203 | + |
1182 | 1204 | public static final class UnspecializedPropertyGetNode extends LinkedPropertyGetNode { |
1183 | 1205 | public UnspecializedPropertyGetNode(ReceiverCheckNode receiverCheck) { |
1184 | 1206 | super(receiverCheck); |
@@ -1916,37 +1938,37 @@ private GetCacheNode createCachedPropertyNodeNotJSObject(Property property, Obje |
1916 | 1938 | } |
1917 | 1939 |
|
1918 | 1940 | private static GetCacheNode createSpecializationFromDataProperty(Property property, ReceiverCheckNode receiverCheck, JSContext context) { |
1919 | | - Property dataProperty = property; |
1920 | | - |
1921 | 1941 | if (property.getLocation() instanceof com.oracle.truffle.api.object.IntLocation) { |
1922 | | - return new IntPropertyGetNode(dataProperty, receiverCheck); |
| 1942 | + return new IntPropertyGetNode(property, receiverCheck); |
1923 | 1943 | } else if (property.getLocation() instanceof com.oracle.truffle.api.object.DoubleLocation) { |
1924 | | - return new DoublePropertyGetNode(dataProperty, receiverCheck); |
| 1944 | + return new DoublePropertyGetNode(property, receiverCheck); |
1925 | 1945 | } else if (property.getLocation() instanceof com.oracle.truffle.api.object.BooleanLocation) { |
1926 | | - return new BooleanPropertyGetNode(dataProperty, receiverCheck); |
| 1946 | + return new BooleanPropertyGetNode(property, receiverCheck); |
1927 | 1947 | } else if (property.getLocation() instanceof com.oracle.truffle.api.object.LongLocation) { |
1928 | | - return new LongPropertyGetNode(dataProperty, receiverCheck); |
| 1948 | + return new LongPropertyGetNode(property, receiverCheck); |
| 1949 | + } else if (JSProperty.isModuleNamespaceExport(property)) { |
| 1950 | + return new ModuleNamespacePropertyGetNode(property, receiverCheck); |
1929 | 1951 | } else if (JSProperty.isProxy(property)) { |
1930 | 1952 | if (isArrayLengthProperty(property)) { |
1931 | | - return new ArrayLengthPropertyGetNode(dataProperty, receiverCheck); |
| 1953 | + return new ArrayLengthPropertyGetNode(property, receiverCheck); |
1932 | 1954 | } else if (isFunctionLengthProperty(property)) { |
1933 | | - return new FunctionLengthPropertyGetNode(dataProperty, receiverCheck); |
| 1955 | + return new FunctionLengthPropertyGetNode(property, receiverCheck); |
1934 | 1956 | } else if (isFunctionNameProperty(property)) { |
1935 | | - return new FunctionNamePropertyGetNode(dataProperty, receiverCheck); |
| 1957 | + return new FunctionNamePropertyGetNode(property, receiverCheck); |
1936 | 1958 | } else if (isClassPrototypeProperty(property)) { |
1937 | | - return new ClassPrototypePropertyGetNode(dataProperty, receiverCheck, context); |
| 1959 | + return new ClassPrototypePropertyGetNode(property, receiverCheck, context); |
1938 | 1960 | } else if (isStringLengthProperty(property)) { |
1939 | | - return new StringObjectLengthPropertyGetNode(dataProperty, receiverCheck); |
| 1961 | + return new StringObjectLengthPropertyGetNode(property, receiverCheck); |
1940 | 1962 | } else if (isLazyRegexResultIndexProperty(property)) { |
1941 | | - return new LazyRegexResultIndexPropertyGetNode(dataProperty, receiverCheck); |
| 1963 | + return new LazyRegexResultIndexPropertyGetNode(property, receiverCheck); |
1942 | 1964 | } else if (isLazyNamedCaptureGroupProperty(property)) { |
1943 | 1965 | int groupIndex = ((JSRegExp.LazyNamedCaptureGroupProperty) JSProperty.getConstantProxy(property)).getGroupIndex(); |
1944 | | - return new LazyNamedCaptureGroupPropertyGetNode(dataProperty, receiverCheck, groupIndex, context); |
| 1966 | + return new LazyNamedCaptureGroupPropertyGetNode(property, receiverCheck, groupIndex, context); |
1945 | 1967 | } else { |
1946 | | - return new ProxyPropertyGetNode(dataProperty, receiverCheck); |
| 1968 | + return new ProxyPropertyGetNode(property, receiverCheck); |
1947 | 1969 | } |
1948 | 1970 | } else { |
1949 | | - return new ObjectPropertyGetNode(dataProperty, receiverCheck); |
| 1971 | + return new ObjectPropertyGetNode(property, receiverCheck); |
1950 | 1972 | } |
1951 | 1973 | } |
1952 | 1974 |
|
@@ -2018,8 +2040,6 @@ protected GetCacheNode createUndefinedPropertyNode(Object thisObj, Object store, |
2018 | 2040 | return new JSAdapterPropertyGetNode(createJSClassCheck(thisObj, depth)); |
2019 | 2041 | } else if (JSProxy.isJSProxy(store) && JSRuntime.isPropertyKey(key)) { |
2020 | 2042 | return createJSProxyCache(createJSClassCheck(thisObj, depth)); |
2021 | | - } else if (JSModuleNamespace.isJSModuleNamespace(store)) { |
2022 | | - return new UnspecializedPropertyGetNode(createJSClassCheck(thisObj, depth)); |
2023 | 2043 | } else { |
2024 | 2044 | return createUndefinedJSObjectPropertyNode(jsobject, depth); |
2025 | 2045 | } |
|
0 commit comments