MCPcopy Index your code
hub / github.com/RustPython/RustPython / _compile_symtable

Function _compile_symtable

crates/compiler/src/lib.rs:312–335  ·  view source on GitHub ↗
(
    source_file: SourceFile,
    mode: Mode,
)

Source from the content-addressed store, hash-verified

310}
311
312pub fn _compile_symtable(
313 source_file: SourceFile,
314 mode: Mode,
315) -> Result<symboltable::SymbolTable, CompileError> {
316 let res = match mode {
317 Mode::Exec | Mode::Single | Mode::BlockExpr => {
318 let ast = ruff_python_parser::parse_module(source_file.source_text())
319 .map_err(|e| CompileError::from_ruff_parse_error(e, &source_file))?;
320 symboltable::SymbolTable::scan_program(&ast.into_syntax(), source_file.clone())
321 }
322 Mode::Eval => {
323 let ast = ruff_python_parser::parse(
324 source_file.source_text(),
325 parser::Mode::Expression.into(),
326 )
327 .map_err(|e| CompileError::from_ruff_parse_error(e, &source_file))?;
328 symboltable::SymbolTable::scan_expr(
329 &ast.into_syntax().expect_expression(),
330 source_file.clone(),
331 )
332 }
333 };
334 res.map_err(|e| e.into_codegen_error(source_file.name().to_owned()).into())
335}
336
337#[test]
338fn test_compile() {

Callers 1

compile_symtableFunction · 0.85

Calls 5

into_codegen_errorMethod · 0.80
parseFunction · 0.50
cloneMethod · 0.45
to_ownedMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected