mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}() and having to check those first, and then making another Optional from the unwrapped value: completion.has_value() ? completion.value() : Optional<Value> {} // ^^^^^^^^^^^^^^^^^^ // Implicit creation of non-empty Optional<Value> This way we need to unwrap the optional ourselves, but can easily pass it to something else as well. This is in anticipation of the AST using completions :^)
This commit is contained in:
parent
b39aede8fe
commit
85f0fc2b83
15 changed files with 55 additions and 57 deletions
|
@ -1629,10 +1629,10 @@ ThrowCompletionOr<Value> ClassExpression::class_definition_evaluation(Interprete
|
|||
instance_fields.append(move(*class_field_definition_ptr));
|
||||
} else if (element.class_element_kind() == ClassElement::ElementKind::StaticInitializer) {
|
||||
// We use Completion to hold the ClassStaticBlockDefinition Record.
|
||||
VERIFY(element_value.has<Completion>() && element_value.get<Completion>().has_value());
|
||||
auto element_object = element_value.get<Completion>().value();
|
||||
VERIFY(is<ECMAScriptFunctionObject>(element_object.as_object()));
|
||||
static_elements.append(static_cast<ECMAScriptFunctionObject*>(&element_object.as_object()));
|
||||
VERIFY(element_value.has<Completion>() && element_value.get<Completion>().value().has_value());
|
||||
auto& element_object = element_value.get<Completion>().value()->as_object();
|
||||
VERIFY(is<ECMAScriptFunctionObject>(element_object));
|
||||
static_elements.append(static_cast<ECMAScriptFunctionObject*>(&element_object));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue