diff --git a/compiler/src/libqjs/parse.rs b/compiler/src/libqjs/parse.rs index 2b8c4d7..403ac64 100644 --- a/compiler/src/libqjs/parse.rs +++ b/compiler/src/libqjs/parse.rs @@ -21,8 +21,8 @@ pub mod opcodes { #[derive(Debug)] pub struct QuickJSBinary { - pub version: u8, - pub checksum: u32, + pub _version: u8, + pub _checksum: u32, pub atoms: Vec, pub root_mod: Module, } @@ -42,8 +42,8 @@ impl QuickJSBinary { Ok(( bin, QuickJSBinary { - version, - checksum, + _version: version, + _checksum: checksum, atoms, root_mod, }, @@ -164,8 +164,8 @@ pub enum JsValue { /// array body; `raw` is the extra trailing value stored as `.raw` /// (`Undefined` when the template has no raw form). TemplateObject { - cooked: Vec, - raw: Box, + _cooked: Vec, + _raw: Box, }, Function(Function), FnById(usize), @@ -240,8 +240,8 @@ impl JsValue { ( bin, Self::TemplateObject { - cooked, - raw: Box::new(raw), + _cooked: cooked, + _raw: Box::new(raw), }, ) } @@ -271,16 +271,16 @@ pub enum FuncKind { #[derive(Debug)] pub struct FunctionFlags { - pub has_prototype: bool, - pub has_simple_param_list: bool, - pub is_derived_class_constructor: bool, - pub need_home_object: bool, - pub func_kind: FuncKind, - pub new_target_allowed: bool, - pub super_call_allowed: bool, - pub super_allowed: bool, - pub arguments_allowed: bool, - pub backtrace_barrier: bool, + pub _has_prototype: bool, + pub _has_simple_param_list: bool, + pub _is_derived_class_constructor: bool, + pub _need_home_object: bool, + pub _func_kind: FuncKind, + pub _new_target_allowed: bool, + pub _super_call_allowed: bool, + pub _super_allowed: bool, + pub _arguments_allowed: bool, + pub _backtrace_barrier: bool, pub has_debug: bool, } @@ -291,16 +291,16 @@ impl FunctionFlags { Ok(( bin, Self { - has_prototype: raw & (1 << 0) != 0, - has_simple_param_list: raw & (1 << 1) != 0, - is_derived_class_constructor: raw & (1 << 2) != 0, - need_home_object: raw & (1 << 3) != 0, - func_kind: FuncKind::try_from_primitive((raw >> 4) & 0b11).unwrap(), - new_target_allowed: raw & (1 << 6) != 0, - super_call_allowed: raw & (1 << 7) != 0, - super_allowed: raw & (1 << 8) != 0, - arguments_allowed: raw & (1 << 9) != 0, - backtrace_barrier: raw & (1 << 10) != 0, + _has_prototype: raw & (1 << 0) != 0, + _has_simple_param_list: raw & (1 << 1) != 0, + _is_derived_class_constructor: raw & (1 << 2) != 0, + _need_home_object: raw & (1 << 3) != 0, + _func_kind: FuncKind::try_from_primitive((raw >> 4) & 0b11).unwrap(), + _new_target_allowed: raw & (1 << 6) != 0, + _super_call_allowed: raw & (1 << 7) != 0, + _super_allowed: raw & (1 << 8) != 0, + _arguments_allowed: raw & (1 << 9) != 0, + _backtrace_barrier: raw & (1 << 10) != 0, has_debug: raw & (1 << 11) != 0, }, )) @@ -326,9 +326,9 @@ pub enum VarKind { #[derive(Debug)] pub struct VarDefFlags { - pub kind: VarKind, - pub is_const: bool, - pub is_lexical: bool, + pub _kind: VarKind, + pub _is_const: bool, + pub _is_lexical: bool, pub is_captured: bool, } @@ -344,9 +344,9 @@ impl VarDefFlags { Ok(( bin, Self { - kind, - is_const, - is_lexical, + _kind: kind, + _is_const: is_const, + _is_lexical: is_lexical, is_captured, }, )) @@ -355,11 +355,11 @@ impl VarDefFlags { #[derive(Debug)] pub struct VarDef { - pub name: AtomRef, - pub scope_level: usize, - pub scope_next_plus_1: usize, - pub flags: VarDefFlags, - pub var_ref_idx: Option, + pub _name: AtomRef, + pub _scope_level: usize, + pub _scope_next_plus_1: usize, + pub _flags: VarDefFlags, + pub _var_ref_idx: Option, } impl VarDef { @@ -379,11 +379,11 @@ impl VarDef { Ok(( bin, Self { - name, - scope_level, - scope_next_plus_1, - flags, - var_ref_idx, + _name: name, + _scope_level: scope_level, + _scope_next_plus_1: scope_next_plus_1, + _flags: flags, + _var_ref_idx: var_ref_idx, }, )) } @@ -405,9 +405,9 @@ pub enum ClosureKind { #[derive(Debug)] pub struct ClosureVarFlags { pub closure_kind: ClosureKind, - pub is_const: bool, + pub _is_const: bool, pub is_lexical: bool, - pub var_kind: VarKind, + pub _var_kind: VarKind, } impl ClosureVarFlags { @@ -424,9 +424,9 @@ impl ClosureVarFlags { bin, Self { closure_kind, - is_const, + _is_const: is_const, is_lexical, - var_kind, + _var_kind: var_kind, }, )) } @@ -434,7 +434,7 @@ impl ClosureVarFlags { #[derive(Debug)] pub struct ClosureVar { - pub name: AtomRef, + pub _name: AtomRef, pub var_idx: usize, pub flags: ClosureVarFlags, } @@ -448,7 +448,7 @@ impl ClosureVar { Ok(( bin, Self { - name, + _name: name, var_idx, flags, }, @@ -487,7 +487,7 @@ pub enum ImmOperand { /// (the scope chain entry point, FORMAT.md ยง3.3). NpopU16 { npop: u16, - scope: u16, + _scope: u16, }, /// Jump. The wire value is a signed offset from the operand /// field's own position; `target` is already resolved. @@ -501,21 +501,21 @@ pub enum ImmOperand { }, AtomU16 { atom: AtomRef, - arg: u16, + _arg: u16, }, AtomLabelU8 { - atom: AtomRef, - target: usize, - arg: u8, + _atom: AtomRef, + _target: usize, + _arg: u8, }, AtomLabelU16 { - atom: AtomRef, - target: usize, - arg: u16, + _atom: AtomRef, + _target: usize, + _arg: u16, }, LabelU16 { - target: usize, - arg: u16, + _target: usize, + _arg: u16, }, } @@ -618,7 +618,7 @@ fn parse_bytecode(code: &[u8]) -> IResult<&[u8], Vec> { opcodes::OpFmt::Npop => ImmOperand::Npop(u16_at(0)), opcodes::OpFmt::NpopU16 => ImmOperand::NpopU16 { npop: u16_at(0), - scope: u16_at(2), + _scope: u16_at(2), }, opcodes::OpFmt::Loc => ImmOperand::Loc(u16_at(0)), opcodes::OpFmt::Arg => ImmOperand::Arg(u16_at(0)), @@ -639,21 +639,21 @@ fn parse_bytecode(code: &[u8]) -> IResult<&[u8], Vec> { }, opcodes::OpFmt::AtomU16 => ImmOperand::AtomU16 { atom: AtomRef::from_code_u32(u32_at(0)), - arg: u16_at(4), + _arg: u16_at(4), }, opcodes::OpFmt::AtomLabelU8 => ImmOperand::AtomLabelU8 { - atom: AtomRef::from_code_u32(u32_at(0)), - target: jump(atom_label_base, u32_at(4) as i32 as i64), - arg: u8_at(8), + _atom: AtomRef::from_code_u32(u32_at(0)), + _target: jump(atom_label_base, u32_at(4) as i32 as i64), + _arg: u8_at(8), }, opcodes::OpFmt::AtomLabelU16 => ImmOperand::AtomLabelU16 { - atom: AtomRef::from_code_u32(u32_at(0)), - target: jump(atom_label_base, u32_at(4) as i32 as i64), - arg: u16_at(8), + _atom: AtomRef::from_code_u32(u32_at(0)), + _target: jump(atom_label_base, u32_at(4) as i32 as i64), + _arg: u16_at(8), }, opcodes::OpFmt::LabelU16 => ImmOperand::LabelU16 { - target: jump(pc + 1, u32_at(0) as i32 as i64), - arg: u16_at(4), + _target: jump(pc + 1, u32_at(0) as i32 as i64), + _arg: u16_at(4), }, }; @@ -671,18 +671,18 @@ fn parse_bytecode(code: &[u8]) -> IResult<&[u8], Vec> { #[derive(Debug)] pub struct Function { - pub flags: FunctionFlags, - pub is_strict_mode: bool, + pub _flags: FunctionFlags, + pub _is_strict_mode: bool, pub name: AtomRef, pub arg_count: usize, /// Num locals pub var_count: usize, /// Parameters before the first default or rest, this is Function.prototype.length - pub defined_arg_count: usize, - pub stack_size: usize, - pub var_ref_count: usize, + pub _defined_arg_count: usize, + pub _stack_size: usize, + pub _var_ref_count: usize, /// arguments first, then locals - pub var_defs: Vec, + pub _var_defs: Vec, pub closure_vars: Vec, pub cpool: Vec, /// LLM GENERATED, TENTATIVE @@ -728,15 +728,15 @@ impl Function { Ok(( bin, Self { - flags, - is_strict_mode: strict_mode == 1, + _flags: flags, + _is_strict_mode: strict_mode == 1, name, arg_count, var_count, - defined_arg_count, - stack_size, - var_ref_count, - var_defs, + _defined_arg_count: defined_arg_count, + _stack_size: stack_size, + _var_ref_count: var_ref_count, + _var_defs: var_defs, closure_vars, cpool, byte_code, @@ -747,12 +747,12 @@ impl Function { #[derive(Debug)] pub struct Module { - pub name: AtomRef, - pub import_modules: Vec, - pub exports: Vec, - pub star_exports: Vec, - pub imports: Vec, - pub has_top_level_await: bool, + pub _name: AtomRef, + pub _import_modules: Vec, + pub _exports: Vec, + pub _star_exports: Vec, + pub _imports: Vec, + pub _has_top_level_await: bool, pub root_fn: Function, } @@ -780,12 +780,12 @@ impl Module { Ok(( bin, Self { - name, - import_modules, - exports, - star_exports, - imports, - has_top_level_await: has_tla == 1, + _name: name, + _import_modules: import_modules, + _exports: exports, + _star_exports: star_exports, + _imports: imports, + _has_top_level_await: has_tla == 1, root_fn, }, )) @@ -795,7 +795,7 @@ impl Module { #[derive(Debug)] pub enum ExportInfo { /// All exports except aliases and star exports - Local { var_idx: usize, name: AtomRef }, + Local { _var_idx: usize, _name: AtomRef }, /// Alias exports, has `from`, eg: export { a } from "./dep.js"; Alias, } @@ -808,7 +808,7 @@ impl ExportInfo { 0 => { let (bin, var_idx) = leb128(bin)?; let (bin, name) = AtomRef::parse(bin)?; - (bin, Self::Local { var_idx, name }) + (bin, Self::Local { _var_idx: var_idx, _name: name }) } 1 => (bin, Self::Alias), _ => unreachable!(), @@ -820,9 +820,9 @@ impl ExportInfo { #[derive(Debug)] pub struct ImportInfo { - pub var_idx: usize, - pub name: AtomRef, - pub req_module_idx: usize, + pub _var_idx: usize, + pub _name: AtomRef, + pub _req_module_idx: usize, } impl ImportInfo { @@ -834,9 +834,9 @@ impl ImportInfo { Ok(( bin, Self { - var_idx, - name, - req_module_idx, + _var_idx: var_idx, + _name: name, + _req_module_idx: req_module_idx, }, )) }