MCPcopy Create free account
hub / github.com/PRQL/prql / load_std_lib

Function load_std_lib

prqlc/prqlc/src/semantic/mod.rs:64–83  ·  view source on GitHub ↗

Preferred way of injecting std module.

(module_tree: &mut pr::ModuleDef)

Source from the content-addressed store, hash-verified

62
63/// Preferred way of injecting std module.
64pub fn load_std_lib(module_tree: &mut pr::ModuleDef) {
65 if !module_tree.stmts.iter().any(|s| is_mod_def_for(s, NS_STD)) {
66 log::debug!("loading std.prql");
67 let _suppressed = debug::log_suppress();
68
69 let std_source = include_str!("std.prql");
70 match parser::parse_source(std_source, 0) {
71 Ok(stmts) => {
72 let stmt = pr::Stmt::new(pr::StmtKind::ModuleDef(pr::ModuleDef {
73 name: "std".to_string(),
74 stmts,
75 }));
76 module_tree.stmts.insert(0, stmt);
77 }
78 Err(errs) => {
79 panic!("std.prql failed to compile:\n{errs:?}");
80 }
81 }
82 }
83}
84
85pub fn is_ident_or_func_call(expr: &pl::Expr, name: &pr::Ident) -> bool {
86 match &expr.kind {

Callers 1

resolveFunction · 0.85

Calls 6

is_mod_def_forFunction · 0.85
log_suppressFunction · 0.85
iterMethod · 0.80
parse_sourceFunction · 0.50
ModuleDefClass · 0.50
insertMethod · 0.45

Tested by

no test coverage detected