Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ members = [
"noirc_errors",
"noirc_driver",
"acir",
"std_lib",
]
3 changes: 2 additions & 1 deletion noirc_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ edition = "2018"
noir_field = {path = "../noir_field"}
acir = {path = "../acir"}
noirc_errors = {path = "../noirc_errors"}
thiserror = "1.0.21"
thiserror = "1.0.21"
std_lib = {path = "../std_lib"}
11 changes: 4 additions & 7 deletions noirc_frontend/src/analyser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,13 @@ fn load_local_functions_into_symbol_table(ast: &Program, table: &mut SymbolTable
}

fn load_low_level_libraries_into_symbol_table(table: &mut SymbolTable) {

use std_lib::LIB_NOIR;
// Import std here
// XXX: Should be a better way to fetch the absolute path here.
// May have to wait until proper module dependency graph is added
let std_lib = std::fs::read_to_string("../../../std/lib.noir").unwrap();

//
// Parse and add low level functions into a symbol table
// We could define the AST for this in the host language
// XXX: We could alternatively define the AST for this in the host language

let mut parser = crate::Parser::with_input(&std_lib);
let mut parser = crate::Parser::with_input(&LIB_NOIR);
let (program) = parser.parse_program().unwrap();
let (checked_program, std_table) = check_program(program, true).unwrap();
// We do nothing with the checked program for two reasons: Every module should have a copy of std_lib
Expand Down
9 changes: 9 additions & 0 deletions std_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "std_lib"
version = "0.1.0"
authors = ["Kevaundray Wedderburn <kevtheappdev@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
File renamed without changes.
1 change: 1 addition & 0 deletions std_lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub const LIB_NOIR : &'static str = include_str!("lib.noir");