Skip to content

Commit 5013ece

Browse files
committed
Remove unecessary code and comments
1 parent e01b507 commit 5013ece

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

nova_vm/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,8 @@ impl PromiseConstructor {
231231
));
232232
}
233233

234-
// Get the first argument from the ArgumentsList
235234
let first_arg = arguments.get(0).bind(gc.nogc());
236235

237-
// Try to convert to Array to extract promises
238236
let Ok(promise_array) = Array::try_from(first_arg.unbind()) else {
239237
return Err(agent.throw_exception_with_static_message(
240238
ExceptionType::TypeError,
@@ -243,7 +241,6 @@ impl PromiseConstructor {
243241
));
244242
};
245243

246-
// Get the first promise from the array
247244
let array_slice = promise_array.as_slice(agent);
248245
if array_slice.is_empty() {
249246
return Err(agent.throw_exception_with_static_message(
@@ -261,7 +258,6 @@ impl PromiseConstructor {
261258
));
262259
};
263260

264-
// Convert Value to Promise
265261
let Value::Promise(promise_to_await) = first_element.unbind() else {
266262
return Err(agent.throw_exception_with_static_message(
267263
ExceptionType::TypeError,
@@ -270,62 +266,12 @@ impl PromiseConstructor {
270266
));
271267
};
272268

273-
// Check if the promise is already settled
274-
if let Some(result) = promise_to_await.try_get_result(agent, gc.nogc()) {
275-
// Promise is already settled, return its result
276-
match result {
277-
Ok(value) => {
278-
// Create a resolved promise with the value
279-
let result_capability = PromiseCapability::new(agent, gc.nogc());
280-
let result_promise = result_capability.promise().scope(agent, gc.nogc());
281-
result_capability
282-
.unbind()
283-
.resolve(agent, value.unbind(), gc.reborrow());
284-
return Ok(result_promise.get(agent).into_value());
285-
}
286-
Err(error) => {
287-
// Create a rejected promise with the error
288-
return Ok(Promise::new_rejected(
289-
agent,
290-
error.value().unbind(),
291-
gc.into_nogc(),
292-
)
293-
.into_value());
294-
}
295-
}
296-
}
297-
298-
// Promise is pending, we need to wait for it using await reaction
299-
// Create a promise capability for our result
300269
let result_capability = PromiseCapability::new(agent, gc.nogc());
301270
let result_promise = result_capability.promise().scope(agent, gc.nogc());
302271

303-
// For await reactions, we typically need an async executable and execution context
304-
// Since we're in Promise.all (not an async function), we'll use a simpler approach
305-
// and use regular promise reactions instead of await reactions
306-
307-
// Use inner_promise_then to wait for the promise
308-
// For simplicity, we'll use Empty handlers which will pass through the value
309272
let fulfill_handler = PromiseReactionHandler::Empty;
310273
let reject_handler = PromiseReactionHandler::Empty;
311274

312-
// Note: For a real await reaction, you would need:
313-
// 1. An AwaitReactionRecord with execution context and VM state
314-
// 2. A suspended VM that can be resumed
315-
// 3. An async executable (async function or module)
316-
317-
// Here's how you would create an await reaction (commented out as it requires more setup):
318-
/*
319-
let await_reaction_record = AwaitReactionRecord {
320-
vm: Some(suspended_vm), // Would need a suspended VM
321-
async_executable: Some(AsyncExecutable::AsyncFunction(async_function)), // Would need async function
322-
execution_context: Some(execution_context), // Would need execution context
323-
return_promise_capability: result_capability.clone(),
324-
};
325-
let await_reaction = agent.heap.create(await_reaction_record);
326-
let await_handler = PromiseReactionHandler::Await(await_reaction);
327-
*/
328-
329275
// For now, let's use a simpler approach that demonstrates the concept
330276
inner_promise_then(
331277
agent,

0 commit comments

Comments
 (0)