Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecmascript): Fill out Value enum #113

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nova_vm/src/builtin_strings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-0
[object Arguments]
[object Array]
[object Boolean]
[object Date]
Expand Down
20 changes: 20 additions & 0 deletions nova_vm/src/ecmascript/builtins/ecmascript_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ pub(crate) fn make_constructor(
// 2. Else,
// a. Set F.[[Construct]] to the definition specified in 10.3.2.
}
Function::BuiltinGeneratorFunction => todo!(),
Function::BuiltinConstructorFunction => todo!(),
Function::BuiltinPromiseResolveFunction => todo!(),
Function::BuiltinPromiseRejectFunction => todo!(),
Function::BuiltinPromiseCollectorFunction => todo!(),
Function::BuiltinProxyRevokerFunction => todo!(),
Function::ECMAScriptAsyncFunction => todo!(),
Function::ECMAScriptAsyncGeneratorFunction => todo!(),
Function::ECMAScriptConstructorFunction => todo!(),
Function::ECMAScriptGeneratorFunction => todo!(),
}
// 5. If prototype is not present, then
let prototype = prototype.unwrap_or_else(|| {
Expand Down Expand Up @@ -685,6 +695,16 @@ pub(crate) fn set_function_name(
function.name = Some(name);
// 7. Return UNUSED.
}
Function::BuiltinGeneratorFunction => todo!(),
Function::BuiltinConstructorFunction => todo!(),
Function::BuiltinPromiseResolveFunction => todo!(),
Function::BuiltinPromiseRejectFunction => todo!(),
Function::BuiltinPromiseCollectorFunction => todo!(),
Function::BuiltinProxyRevokerFunction => todo!(),
Function::ECMAScriptAsyncFunction => todo!(),
Function::ECMAScriptAsyncGeneratorFunction => todo!(),
Function::ECMAScriptConstructorFunction => todo!(),
Function::ECMAScriptGeneratorFunction => todo!(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ impl FunctionPrototype {
);
Ok(Value::from_string(agent, initial_name))
}
Function::BuiltinGeneratorFunction => todo!(),
Function::BuiltinConstructorFunction => todo!(),
Function::BuiltinPromiseResolveFunction => todo!(),
Function::BuiltinPromiseRejectFunction => todo!(),
Function::BuiltinPromiseCollectorFunction => todo!(),
Function::BuiltinProxyRevokerFunction => todo!(),
Function::ECMAScriptAsyncFunction => todo!(),
Function::ECMAScriptAsyncGeneratorFunction => todo!(),
Function::ECMAScriptConstructorFunction => todo!(),
Function::ECMAScriptGeneratorFunction => todo!(),
}

// NOTE: NativeFunction means the following string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ impl ObjectPrototype {
Value::Null => Ok(BUILTIN_STRING_MEMORY._object_Null_.into_value()),
// 9. Else if O has a [[BooleanData]] internal slot, let builtinTag be "Boolean".
// 17. Return the string-concatenation of "[object ", tag, and "]".
Value::Boolean(_) => Ok(BUILTIN_STRING_MEMORY._object_Boolean_.into_value()),
Value::Boolean(_) | Value::BooleanObject => {
Ok(BUILTIN_STRING_MEMORY._object_Boolean_.into_value())
}
// 6. Else if O has a [[ParameterMap]] internal slot, let builtinTag be "Arguments".
Value::Arguments => Ok(BUILTIN_STRING_MEMORY._object_Arguments_.into_value()),
// 11. Else if O has a [[StringData]] internal slot, let builtinTag be "String".
Value::String(_) | Value::SmallString(_) => {
Value::String(_) | Value::SmallString(_) | Value::StringObject => {
Ok(BUILTIN_STRING_MEMORY._object_String_.into_value())
}
// 10. Else if O has a [[NumberData]] internal slot, let builtinTag be "Number".
Value::Number(_) | Value::Integer(_) | Value::Float(_) => {
Value::Number(_) | Value::Integer(_) | Value::Float(_) | Value::NumberObject => {
Ok(BUILTIN_STRING_MEMORY._object_Error_.into_value())
}
Value::Object(_) => todo!(),
Expand All @@ -162,9 +165,13 @@ impl ObjectPrototype {
Value::BoundFunction(_) | Value::BuiltinFunction(_) | Value::ECMAScriptFunction(_) => {
Ok(BUILTIN_STRING_MEMORY._object_Function_.into_value())
}
// TODO: Check for [[Call]] slot of Proxy
Value::Proxy => todo!(),
// TODO: Check for [[Call]] slot of EmbedderObject
Value::EmbedderObject => todo!(),
// 13. Else if O has a [[RegExpMatcher]] internal slot, let builtinTag be "RegExp".
Value::RegExp(_) => Ok(BUILTIN_STRING_MEMORY._object_RegExp_.into_value()),
Value::Symbol(_) | Value::BigInt(_) | Value::SmallBigInt(_) | Value::ArrayBuffer(_) => {
_ => {
// 14. Else, let builtinTag be "Object".
let builtin_tag = BUILTIN_STRING_MEMORY.Object;
// 3. Let O be ! ToObject(this value).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ impl FunctionEnvironmentIndex {
.unwrap();
data.ecmascript_function.home_object.is_some()
}
Function::BuiltinGeneratorFunction => todo!(),
Function::BuiltinConstructorFunction => todo!(),
Function::BuiltinPromiseResolveFunction => todo!(),
Function::BuiltinPromiseRejectFunction => todo!(),
Function::BuiltinPromiseCollectorFunction => todo!(),
Function::BuiltinProxyRevokerFunction => todo!(),
Function::ECMAScriptAsyncFunction => todo!(),
Function::ECMAScriptAsyncGeneratorFunction => todo!(),
Function::ECMAScriptConstructorFunction => todo!(),
Function::ECMAScriptGeneratorFunction => todo!(),
}
}

Expand All @@ -327,6 +337,16 @@ impl FunctionEnvironmentIndex {
.unwrap();
data.ecmascript_function.home_object
}
Function::BuiltinGeneratorFunction => todo!(),
Function::BuiltinConstructorFunction => todo!(),
Function::BuiltinPromiseResolveFunction => todo!(),
Function::BuiltinPromiseRejectFunction => todo!(),
Function::BuiltinPromiseCollectorFunction => todo!(),
Function::BuiltinProxyRevokerFunction => todo!(),
Function::ECMAScriptAsyncFunction => todo!(),
Function::ECMAScriptAsyncGeneratorFunction => todo!(),
Function::ECMAScriptConstructorFunction => todo!(),
Function::ECMAScriptGeneratorFunction => todo!(),
};
// 2. If home is undefined, return undefined.
let Some(home) = home else {
Expand Down
4 changes: 2 additions & 2 deletions nova_vm/src/ecmascript/execution/realm/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ use super::RealmIdentifier;

#[derive(Debug, Clone)]
pub(crate) struct Intrinsics {
object_index_base: ObjectIndex,
builtin_function_index_base: BuiltinFunctionIndex,
pub(crate) object_index_base: ObjectIndex,
pub(crate) builtin_function_index_base: BuiltinFunctionIndex,
}

/// Enumeration of intrinsics intended to be used as the \[\[Prototype\]\] value of
Expand Down
Loading