|
fn push_output( |
|
&mut self, |
|
flags: bytecode::CodeFlags, |
|
posonlyarg_count: u32, |
|
arg_count: u32, |
|
kwonlyarg_count: u32, |
|
obj_name: String, |
|
) { |
|
// First push the symbol table |
|
let table = self.push_symbol_table(); |
|
let scope_type = table.typ; |
|
|
|
// The key is the current position in the symbol table stack |
|
let key = self.symbol_table_stack.len() - 1; |
|
|
|
// Get the line number |
|
let lineno = self.get_source_line_number().get(); |
|
|
|
// Call enter_scope which does most of the work |
|
if let Err(e) = self.enter_scope(&obj_name, scope_type, key, lineno as u32) { |
|
// In the current implementation, push_output doesn't return an error, |
|
// so we panic here. This maintains the same behavior. |
|
panic!("enter_scope failed: {:?}", e); |
|
} |
|
|
|
// Override the values that push_output sets explicitly |
|
// enter_scope sets default values based on scope_type, but push_output |
|
// allows callers to specify exact values |
|
if let Some(info) = self.code_stack.last_mut() { |
|
info.flags = flags; |
|
info.metadata.argcount = arg_count; |
|
info.metadata.posonlyargcount = posonlyarg_count; |
|
info.metadata.kwonlyargcount = kwonlyarg_count; |
|
} |
|
} |
|
fn push_output( |
|
&mut self, |
|
flags: bytecode::CodeFlags, |
|
posonlyarg_count: u32, |
|
arg_count: u32, |
|
kwonlyarg_count: u32, |
|
obj_name: String, |
|
) -> CompileResult<()> { |
|
// First push the symbol table |
|
let table = self.push_symbol_table(); |
|
let scope_type = table.typ; |
|
|
|
// The key is the current position in the symbol table stack |
|
let key = self.symbol_table_stack.len() - 1; |
|
|
|
// Get the line number |
|
let lineno = self.get_source_line_number().get(); |
|
|
|
// Call enter_scope which does most of the work |
|
self.enter_scope(&obj_name, scope_type, key, lineno as u32)?; |
|
|
|
// Override the values that push_output sets explicitly |
|
// enter_scope sets default values based on scope_type, but push_output |
|
// allows callers to specify exact values |
|
if let Some(info) = self.code_stack.last_mut() { |
|
info.flags = flags; |
|
info.metadata.argcount = arg_count; |
|
info.metadata.posonlyargcount = posonlyarg_count; |
|
info.metadata.kwonlyargcount = kwonlyarg_count; |
|
} |
|
Ok(()) |
|
} |