Skip to content

Commit e5dc9e3

Browse files
committed
Named arguments are better.
1 parent 6979300 commit e5dc9e3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/processor/instructions.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub enum Instruction {
7171
LoadGlobal(usize),
7272
CallFunction(usize, usize), // nb_args, nb_kwargs
7373
RaiseVarargs(u16),
74-
MakeFunction(bool, bool, bool, bool), // has_defaults, has_kwdefaults, has_annotations, has_closure
74+
MakeFunction { has_defaults: bool, has_kwdefaults: bool, has_annotations: bool, has_closure: bool },
7575
BuildConstKeyMap(usize),
7676
}
7777

@@ -158,7 +158,12 @@ impl<'a, I> Iterator for InstructionDecoder<I> where I: Iterator<Item=&'a u8> {
158158
125 => Instruction::StoreFast(oparg as usize),
159159
130 => Instruction::RaiseVarargs(self.read_argument() as u16),
160160
131 => Instruction::CallFunction(oparg as usize, 0),
161-
132 => Instruction::MakeFunction(oparg & 0x01 != 0, oparg & 0x02 != 0, oparg & 0x04 != 0, oparg & 0x08 != 0),
161+
132 => Instruction::MakeFunction {
162+
has_defaults: oparg & 0x01 != 0,
163+
has_kwdefaults: oparg & 0x02 != 0,
164+
has_annotations: oparg & 0x04 != 0,
165+
has_closure: oparg & 0x08 != 0,
166+
},
162167
156 => Instruction::BuildConstKeyMap(oparg as usize),
163168
144 => { self.arg_prefix = Some(self.read_argument()); Instruction::Nop },
164169
_ => panic!(format!("Opcode not supported: {:?}", (opcode, oparg))),

src/processor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ fn run_code<EP: EnvProxy>(state: &mut State<EP>, call_stack: &mut Vec<Frame>) ->
523523
}
524524
call_function(state, call_stack, &func, args, kwargs)
525525
},
526-
Instruction::MakeFunction(false, has_kwdefaults, false, false) => {
526+
Instruction::MakeFunction { has_defaults: false, has_kwdefaults, has_annotations: false, has_closure: false } => {
527527
// TODO: consume default arguments and annotations
528528
let obj = {
529529
let frame = call_stack.last_mut().unwrap();

0 commit comments

Comments
 (0)