MCPcopy Create free account
hub / github.com/GNOME/gjs / resolve_impl

Method resolve_impl

gjs/module.cpp:167–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165 // JSClass operations
166
167 GJS_JSAPI_RETURN_CONVENTION
168 bool resolve_impl(JSContext* cx, JS::HandleObject module, JS::HandleId id,
169 bool* resolved) {
170 JS::RootedObject lexical(cx, JS_ExtensibleLexicalEnvironment(module));
171 if (!lexical) {
172 *resolved = false;
173 return true; // nothing imported yet
174 }
175
176 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> maybe_desc(cx);
177 JS::RootedObject holder(cx);
178 if (!JS_GetPropertyDescriptorById(cx, lexical, id, &maybe_desc,
179 &holder))
180 return false;
181 if (maybe_desc.isNothing())
182 return true;
183
184 /* The property is present in the lexical environment. This should not
185 * be supported according to ES6. For compatibility with earlier GJS, we
186 * treat it as if it were a real property, but warn about it. */
187
188 gjs_warn_deprecated_once_per_callsite(
189 cx, GjsDeprecationMessageId::ModuleExportedLetOrConst,
190 {gjs_debug_id(id), m_name.get()});
191
192 JS::Rooted<JS::PropertyDescriptor> desc(cx, maybe_desc.value());
193 return JS_DefinePropertyById(cx, module, id, desc);
194 }
195
196 GJS_JSAPI_RETURN_CONVENTION
197 static bool resolve(JSContext* cx, JS::HandleObject module, JS::HandleId id,

Callers 1

resolveMethod · 0.45

Calls 4

gjs_debug_idFunction · 0.85
getMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected