Skip to content

Commit

Permalink
Fix some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed Dec 6, 2021
1 parent 19b8f9e commit 9828673
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 41 deletions.
4 changes: 0 additions & 4 deletions boa/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ pub struct RegExp {
/// Regex matcher.
matcher: Regex,

/// Update last_index, set if global or sticky flags are set.
use_last_index: bool,

/// Flag 's' - dot matches newline characters.
dot_all: bool,

Expand Down Expand Up @@ -340,7 +337,6 @@ impl RegExp {

let regexp = RegExp {
matcher,
use_last_index: global || sticky,
dot_all,
global,
ignore_case,
Expand Down
6 changes: 0 additions & 6 deletions boa/src/bytecompiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ pub struct ByteCompiler {
code_block: CodeBlock,
literals_map: HashMap<Literal, u32>,
names_map: HashMap<JsString, u32>,
functions_map: HashMap<JsString, u32>,
jump_info: Vec<JumpControlInfo>,
top_level: bool,
}

impl ByteCompiler {
Expand All @@ -75,9 +73,7 @@ impl ByteCompiler {
code_block: CodeBlock::new(name, 0, strict, false),
literals_map: HashMap::new(),
names_map: HashMap::new(),
functions_map: HashMap::new(),
jump_info: Vec::new(),
top_level: true,
}
}

Expand Down Expand Up @@ -1492,9 +1488,7 @@ impl ByteCompiler {
code_block: code,
literals_map: HashMap::new(),
names_map: HashMap::new(),
functions_map: HashMap::new(),
jump_info: Vec::new(),
top_level: false,
};

let mut has_rest_parameter = false;
Expand Down
4 changes: 0 additions & 4 deletions boa/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,17 +1061,13 @@ impl Context {
compiler.compile_statement_list(&statement_list, true);
let code_block = compiler.finish();

let environment = self.get_current_environment().clone();
let fp = self.vm.stack.len();
let global_object = self.global_object().into();

self.vm.push_frame(CallFrame {
prev: None,
code: Gc::new(code_block),
this: global_object,
pc: 0,
fp,
environment,
catch: Vec::new(),
finally_return: FinallyReturn::None,
finally_jump: Vec::new(),
Expand Down
18 changes: 2 additions & 16 deletions boa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,7 @@ pub fn parse<T: AsRef<[u8]>>(src: T, strict_mode: bool) -> StdResult<StatementLi
#[cfg(test)]
pub(crate) fn forward<T: AsRef<[u8]>>(context: &mut Context, src: T) -> String {
let src_bytes: &[u8] = src.as_ref();

// Setup executor
let expr = match parse(src_bytes, false) {
Ok(res) => res,
Err(e) => {
return format!(
"Uncaught {}",
context.construct_syntax_error(e.to_string()).display()
);
}
};
let result = expr.run(context).map_or_else(
let result = context.eval(src_bytes).map_or_else(
|e| format!("Uncaught {}", e.display()),
|v| v.display().to_string(),
);
Expand All @@ -133,10 +122,7 @@ pub(crate) fn forward_val<T: AsRef<[u8]>>(context: &mut Context, src: T) -> JsRe
let main_timer = BoaProfiler::global().start_event("Main", "Main");

let src_bytes: &[u8] = src.as_ref();
// Setup executor
let result = parse(src_bytes, false)
.map_err(|e| context.construct_syntax_error(e.to_string()))
.and_then(|expr| expr.run(context));
let result = context.eval(src_bytes);

#[cfg(feature = "vm")]
context.vm.pop_frame();
Expand Down
4 changes: 1 addition & 3 deletions boa/src/vm/call_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
//! This module will provides everything needed to implement the CallFrame
use super::CodeBlock;
use crate::{environment::lexical_environment::Environment, JsValue};
use crate::JsValue;
use gc::Gc;

#[derive(Debug)]
pub struct CallFrame {
pub(crate) prev: Option<Box<Self>>,
pub(crate) code: Gc<CodeBlock>,
pub(crate) pc: usize,
pub(crate) fp: usize,
pub(crate) this: JsValue,
pub(crate) environment: Environment,
pub(crate) catch: Vec<CatchAddresses>,
pub(crate) finally_return: FinallyReturn,
pub(crate) finally_jump: Vec<Option<u32>>,
Expand Down
10 changes: 2 additions & 8 deletions boa/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl CodeBlock {
///
/// Does not check if read happens out-of-bounds.
pub unsafe fn read_unchecked<T: Readable>(&self, offset: usize) -> T {
// This has to be an unaligned read because we can't gurantee that
// This has to be an unaligned read because we can't guarantee that
// the types are aligned.
self.code.as_ptr().add(offset).cast::<T>().read_unaligned()
}
Expand Down Expand Up @@ -363,9 +363,7 @@ impl std::fmt::Display for CodeBlock {

#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub struct JsVmFunction {
inner: (),
}
pub struct JsVmFunction {}

impl JsVmFunction {
#[allow(clippy::new_ret_no_self)]
Expand Down Expand Up @@ -588,8 +586,6 @@ impl JsObject {
code,
this: this.clone(),
pc: 0,
fp: context.vm.stack.len(),
environment: local_env,
catch: Vec::new(),
finally_return: FinallyReturn::None,
finally_jump: Vec::new(),
Expand Down Expand Up @@ -752,8 +748,6 @@ impl JsObject {
code,
this,
pc: 0,
fp: context.vm.stack.len(),
environment: local_env,
catch: Vec::new(),
finally_return: FinallyReturn::None,
finally_jump: Vec::new(),
Expand Down

0 comments on commit 9828673

Please sign in to comment.