Skip to content

Commit d6226b1

Browse files
committed
Remove unecessary code and comments
1 parent 625a093 commit d6226b1

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
@@ -238,10 +238,8 @@ impl PromiseConstructor {
238238
));
239239
}
240240

241-
// Get the first argument from the ArgumentsList
242241
let first_arg = arguments.get(0).bind(gc.nogc());
243242

244-
// Try to convert to Array to extract promises
245243
let Ok(promise_array) = Array::try_from(first_arg.unbind()) else {
246244
return Err(agent.throw_exception_with_static_message(
247245
ExceptionType::TypeError,
@@ -250,7 +248,6 @@ impl PromiseConstructor {
250248
));
251249
};
252250

253-
// Get the first promise from the array
254251
let array_slice = promise_array.as_slice(agent);
255252
if array_slice.is_empty() {
256253
return Err(agent.throw_exception_with_static_message(
@@ -268,7 +265,6 @@ impl PromiseConstructor {
268265
));
269266
};
270267

271-
// Convert Value to Promise
272268
let Value::Promise(promise_to_await) = first_element.unbind() else {
273269
return Err(agent.throw_exception_with_static_message(
274270
ExceptionType::TypeError,
@@ -277,62 +273,12 @@ impl PromiseConstructor {
277273
));
278274
};
279275

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

310-
// For await reactions, we typically need an async executable and execution context
311-
// Since we're in Promise.all (not an async function), we'll use a simpler approach
312-
// and use regular promise reactions instead of await reactions
313-
314-
// Use inner_promise_then to wait for the promise
315-
// For simplicity, we'll use Empty handlers which will pass through the value
316279
let fulfill_handler = PromiseReactionHandler::Empty;
317280
let reject_handler = PromiseReactionHandler::Empty;
318281

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

0 commit comments

Comments
 (0)