-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grant Wuerker
committed
May 16, 2024
1 parent
70fca41
commit 733bb32
Showing
22 changed files
with
712 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use fe_driver2::DriverDataBase; | ||
|
||
#[test] | ||
fn check_std_lib() { | ||
let mut driver = DriverDataBase::default(); | ||
let std_ingot = library2::std_lib_input_ingot(&mut driver); | ||
driver.run_on_ingot(std_ingot); | ||
|
||
let diags = driver.format_diags(); | ||
if !diags.is_empty() { | ||
panic!("{diags}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "fe-library2" | ||
version = "0.23.0" | ||
authors = ["The Fe Developers <[email protected]>"] | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
repository = "https://github.com/ethereum/fe" | ||
|
||
[dependencies] | ||
include_dir = "0.7.2" | ||
common = { path = "../common2", package = "fe-common2" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("cargo:rerun-if-changed=./std"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use std::collections::BTreeSet; | ||
|
||
pub use ::include_dir; | ||
use common::{ | ||
input::{IngotKind, Version}, | ||
InputDb, InputFile, InputIngot, | ||
}; | ||
use include_dir::{include_dir, Dir}; | ||
|
||
pub const STD: Dir = include_dir!("$CARGO_MANIFEST_DIR/std"); | ||
|
||
fn std_src_input_files(db: &mut dyn InputDb, ingot: InputIngot) -> BTreeSet<InputFile> { | ||
static_dir_files(&STD) | ||
.into_iter() | ||
.map(|(path, content)| InputFile::new(db, ingot, path.into(), content.into())) | ||
.collect() | ||
} | ||
|
||
pub fn std_lib_input_ingot(db: &mut dyn InputDb) -> InputIngot { | ||
let ingot = InputIngot::new( | ||
db, | ||
"/", | ||
IngotKind::Std, | ||
Version::new(0, 0, 0), | ||
BTreeSet::default(), | ||
); | ||
|
||
let input_files = std_src_input_files(db, ingot); | ||
let root_file = input_files | ||
.iter() | ||
.find(|file| file.path(db).ends_with("lib.fe")) | ||
.unwrap() | ||
.to_owned(); | ||
|
||
ingot.set_root_file(db, root_file); | ||
ingot.set_files(db, input_files); | ||
|
||
ingot | ||
} | ||
|
||
pub fn static_dir_files(dir: &'static Dir) -> Vec<(&'static str, &'static str)> { | ||
fn add_files(dir: &'static Dir, accum: &mut Vec<(&'static str, &'static str)>) { | ||
accum.extend(dir.files().map(|file| { | ||
( | ||
file.path().to_str().unwrap(), | ||
file.contents_utf8().expect("non-utf8 static file"), | ||
) | ||
})); | ||
|
||
for sub_dir in dir.dirs() { | ||
add_files(sub_dir, accum) | ||
} | ||
} | ||
|
||
let mut files = vec![]; | ||
add_files(dir, &mut files); | ||
files | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! The Fe standard library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! Basic numeric functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//! Basic integer functionality. | ||
|
||
pub type isize = i256 | ||
pub type usize = u256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! Integer extension. | ||
|
||
extern { | ||
fn u8_u16_extend(_ x: u8) -> u16 | ||
fn u8_u32_extend(_ x: u8) -> u32 | ||
fn u8_u64_extend(_ x: u8) -> u64 | ||
fn u8_u128_extend(_ x: u8) -> u128 | ||
fn u8_u256_extend(_ x: u8) -> u256 | ||
fn u16_u32_extend(_ x: u16) -> u32 | ||
fn u16_u64_extend(_ x: u16) -> u64 | ||
fn u16_u128_extend(_ x: u16) -> u128 | ||
fn u16_u256_extend(_ x: u16) -> u256 | ||
fn u32_u64_extend(_ x: u32) -> u64 | ||
fn u32_u128_extend(_ x: u32) -> u128 | ||
fn u32_u256_extend(_ x: u32) -> u256 | ||
fn u64_u128_extend(_ x: u64) -> u128 | ||
fn u64_u256_extend(_ x: u64) -> u256 | ||
fn u128_u256_extend(_ x: u128) -> u256 | ||
fn i8_i16_extend(_ x: i8) -> i16 | ||
fn i8_i32_extend(_ x: i8) -> i32 | ||
fn i8_i64_extend(_ x: i8) -> i64 | ||
fn i8_i128_extend(_ x: i8) -> i128 | ||
fn i8_i256_extend(_ x: i8) -> i256 | ||
fn i16_i32_extend(_ x: i16) -> i32 | ||
fn i16_i64_extend(_ x: i16) -> i64 | ||
fn i16_i128_extend(_ x: i16) -> i128 | ||
fn i16_i256_extend(_ x: i16) -> i256 | ||
fn i32_i64_extend(_ x: i32) -> i64 | ||
fn i32_i128_extend(_ x: i32) -> i128 | ||
fn i32_i256_extend(_ x: i32) -> i256 | ||
fn i64_i128_extend(_ x: i64) -> i128 | ||
fn i64_i256_extend(_ x: i64) -> i256 | ||
fn i128_i256_extend(_ x: i128) -> i256 | ||
} | ||
|
||
pub trait Extend<Out> { | ||
fn extend(self) -> Out | ||
} | ||
|
||
impl Extend<u16> for u8 { fn extend(self) -> u16 { u8_u16_extend(self) } } | ||
impl Extend<u32> for u8 { fn extend(self) -> u32 { u8_u32_extend(self) } } | ||
impl Extend<u64> for u8 { fn extend(self) -> u64 { u8_u64_extend(self) } } | ||
impl Extend<u128> for u8 { fn extend(self) -> u128 { u8_u128_extend(self) } } | ||
impl Extend<u256> for u8 { fn extend(self) -> u256 { u8_u256_extend(self) } } | ||
impl Extend<u32> for u16 { fn extend(self) -> u32 { u16_u32_extend(self) } } | ||
impl Extend<u64> for u16 { fn extend(self) -> u64 { u16_u64_extend(self) } } | ||
impl Extend<u128> for u16 { fn extend(self) -> u128 { u16_u128_extend(self) } } | ||
impl Extend<u256> for u16 { fn extend(self) -> u256 { u16_u256_extend(self) } } | ||
impl Extend<u64> for u32 { fn extend(self) -> u64 { u32_u64_extend(self) } } | ||
impl Extend<u128> for u32 { fn extend(self) -> u128 { u32_u128_extend(self) } } | ||
impl Extend<u256> for u32 { fn extend(self) -> u256 { u32_u256_extend(self) } } | ||
impl Extend<u128> for u64 { fn extend(self) -> u128 { u64_u128_extend(self) } } | ||
impl Extend<u256> for u64 { fn extend(self) -> u256 { u64_u256_extend(self) } } | ||
impl Extend<u256> for u128 { fn extend(self) -> u256 { u128_u256_extend(self) } } | ||
impl Extend<i16> for i8 { fn extend(self) -> i16 { i8_i16_extend(self) } } | ||
impl Extend<i32> for i8 { fn extend(self) -> i32 { i8_i32_extend(self) } } | ||
impl Extend<i64> for i8 { fn extend(self) -> i64 { i8_i64_extend(self) } } | ||
impl Extend<i128> for i8 { fn extend(self) -> i128 { i8_i128_extend(self) } } | ||
impl Extend<i256> for i8 { fn extend(self) -> i256 { i8_i256_extend(self) } } | ||
impl Extend<i32> for i16 { fn extend(self) -> i32 { i16_i32_extend(self) } } | ||
impl Extend<i64> for i16 { fn extend(self) -> i64 { i16_i64_extend(self) } } | ||
impl Extend<i128> for i16 { fn extend(self) -> i128 { i16_i128_extend(self) } } | ||
impl Extend<i256> for i16 { fn extend(self) -> i256 { i16_i256_extend(self) } } | ||
impl Extend<i64> for i32 { fn extend(self) -> i64 { i32_i64_extend(self) } } | ||
impl Extend<i128> for i32 { fn extend(self) -> i128 { i32_i128_extend(self) } } | ||
impl Extend<i256> for i32 { fn extend(self) -> i256 { i32_i256_extend(self) } } | ||
impl Extend<i128> for i64 { fn extend(self) -> i128 { i64_i128_extend(self) } } | ||
impl Extend<i256> for i64 { fn extend(self) -> i256 { i64_i256_extend(self) } } | ||
impl Extend<i256> for i128 { fn extend(self) -> i256 { i128_i256_extend(self) } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! Integer operations. |
Oops, something went wrong.