Skip to content

Commit

Permalink
Implement WIP Ascii JsString
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Nov 3, 2023
1 parent dd05f53 commit 89ca28e
Show file tree
Hide file tree
Showing 125 changed files with 2,422 additions and 2,527 deletions.
26 changes: 6 additions & 20 deletions boa_cli/src/debug/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ fn flowgraph(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> Js
let mut direction = Direction::LeftToRight;
if let Some(arguments) = args.get(1) {
if let Some(arguments) = arguments.as_object() {
format = flowgraph_parse_format_option(&arguments.get(js_string!("format"), context)?)?;
direction = flowgraph_parse_direction_option(
&arguments.get(js_string!("direction"), context)?,
)?;
format = flowgraph_parse_format_option(&arguments.get("format", context)?)?;
direction = flowgraph_parse_direction_option(&arguments.get("direction", context)?)?;
} else if value.is_string() {
format = flowgraph_parse_format_option(value)?;
} else {
Expand Down Expand Up @@ -173,21 +171,9 @@ fn traceable(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult<JsV

pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
ObjectInitializer::new(context)
.function(
NativeFunction::from_fn_ptr(flowgraph),
js_string!("flowgraph"),
1,
)
.function(
NativeFunction::from_fn_ptr(bytecode),
js_string!("bytecode"),
1,
)
.function(NativeFunction::from_fn_ptr(trace), js_string!("trace"), 1)
.function(
NativeFunction::from_fn_ptr(traceable),
js_string!("traceable"),
2,
)
.function(NativeFunction::from_fn_ptr(flowgraph), "flowgraph", 1)
.function(NativeFunction::from_fn_ptr(bytecode), "bytecode", 1)
.function(NativeFunction::from_fn_ptr(trace), "trace", 1)
.function(NativeFunction::from_fn_ptr(traceable), "traceable", 2)
.build()
}
10 changes: 2 additions & 8 deletions boa_cli/src/debug/gc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use boa_engine::{
js_string, object::ObjectInitializer, Context, JsObject, JsResult, JsValue, NativeFunction,
};
use boa_engine::{object::ObjectInitializer, Context, JsObject, JsResult, JsValue, NativeFunction};

/// Trigger garbage collection.
fn collect(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue> {
Expand All @@ -10,10 +8,6 @@ fn collect(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue>

pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
ObjectInitializer::new(context)
.function(
NativeFunction::from_fn_ptr(collect),
js_string!("collect"),
0,
)
.function(NativeFunction::from_fn_ptr(collect), "collect", 0)
.build()
}
5 changes: 2 additions & 3 deletions boa_cli/src/debug/limits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use boa_engine::{
js_string,
object::{FunctionObjectBuilder, ObjectInitializer},
property::Attribute,
Context, JsArgs, JsNativeError, JsObject, JsResult, JsValue, NativeFunction,
Expand Down Expand Up @@ -56,13 +55,13 @@ pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
.build();
ObjectInitializer::new(context)
.accessor(
js_string!("loop"),
"loop",
Some(get_loop),
Some(set_loop),
Attribute::WRITABLE | Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE,
)
.accessor(
js_string!("recursion"),
"recursion",
Some(get_recursion),
Some(set_recursion),
Attribute::WRITABLE | Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE,
Expand Down
18 changes: 9 additions & 9 deletions boa_cli/src/debug/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Allow lint so it, doesn't warn about `JsResult<>` unneeded return on functions.
#![allow(clippy::unnecessary_wraps)]

use boa_engine::{js_string, object::ObjectInitializer, property::Attribute, Context, JsObject};
use boa_engine::{object::ObjectInitializer, property::Attribute, Context, JsObject};

mod function;
mod gc;
Expand All @@ -22,37 +22,37 @@ fn create_boa_object(context: &mut Context<'_>) -> JsObject {

ObjectInitializer::new(context)
.property(
js_string!("function"),
"function",
function_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
js_string!("object"),
"object",
object_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
js_string!("shape"),
"shape",
shape_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
js_string!("optimizer"),
"optimizer",
optimizer_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
js_string!("gc"),
"gc",
gc_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
js_string!("realm"),
"realm",
realm_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
js_string!("limits"),
"limits",
limits_module,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
Expand All @@ -64,7 +64,7 @@ pub(crate) fn init_boa_debug_object(context: &mut Context<'_>) {
let boa_object = create_boa_object(context);
context
.register_global_property(
js_string!("$boa"),
"$boa",
boa_object,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
Expand Down
2 changes: 1 addition & 1 deletion boa_cli/src/debug/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ fn id(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue> {

pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
ObjectInitializer::new(context)
.function(NativeFunction::from_fn_ptr(id), js_string!("id"), 1)
.function(NativeFunction::from_fn_ptr(id), "id", 1)
.build()
}
5 changes: 2 additions & 3 deletions boa_cli/src/debug/optimizer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use boa_engine::{
js_string,
object::{FunctionObjectBuilder, ObjectInitializer},
optimizer::OptimizerOptions,
property::Attribute,
Expand Down Expand Up @@ -72,13 +71,13 @@ pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
.build();
ObjectInitializer::new(context)
.accessor(
js_string!("constantFolding"),
"constantFolding",
Some(get_constant_folding),
Some(set_constant_folding),
Attribute::WRITABLE | Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE,
)
.accessor(
js_string!("statistics"),
"statistics",
Some(get_statistics),
Some(set_statistics),
Attribute::WRITABLE | Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE,
Expand Down
6 changes: 2 additions & 4 deletions boa_cli/src/debug/realm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use boa_engine::{
js_string, object::ObjectInitializer, Context, JsObject, JsResult, JsValue, NativeFunction,
};
use boa_engine::{object::ObjectInitializer, Context, JsObject, JsResult, JsValue, NativeFunction};

/// Creates a new ECMAScript Realm and returns the global object of the realm.
fn create(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue> {
Expand All @@ -11,6 +9,6 @@ fn create(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue>

pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
ObjectInitializer::new(context)
.function(NativeFunction::from_fn_ptr(create), js_string!("create"), 0)
.function(NativeFunction::from_fn_ptr(create), "create", 0)
.build()
}
6 changes: 3 additions & 3 deletions boa_cli/src/debug/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ fn same(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult<JsValue>

pub(super) fn create_object(context: &mut Context<'_>) -> JsObject {
ObjectInitializer::new(context)
.function(NativeFunction::from_fn_ptr(id), js_string!("id"), 1)
.function(NativeFunction::from_fn_ptr(r#type), js_string!("type"), 1)
.function(NativeFunction::from_fn_ptr(same), js_string!("same"), 2)
.function(NativeFunction::from_fn_ptr(id), "id", 1)
.function(NativeFunction::from_fn_ptr(r#type), "type", 1)
.function(NativeFunction::from_fn_ptr(same), "same", 2)
.build()
}
Loading

0 comments on commit 89ca28e

Please sign in to comment.