Skip to content

Commit

Permalink
hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Wuerker committed Nov 17, 2022
1 parent 7f57fce commit 2286ff0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions crates/codegen/src/yul/isel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mod inst_order;
mod test;

pub use contract::{lower_contract, lower_contract_deployable};
pub use test::lower_test;
pub use function::lower_function;
3 changes: 2 additions & 1 deletion crates/codegen/src/yul/isel/test.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use fe_mir::ir::FunctionId;
use super::context::Context;
use fe_analyzer::namespace::items::FunctionId;
use yultsur::{yul, *};
use crate::{
db::CodegenDb,
};

pub fn lower_test(db: &dyn CodegenDb, test: FunctionId) -> yul::Object {
let mut context = Context::default();
let test = db.mir_lowered_func_signature(test);
context.function_dependency.insert(test);

let dep_constants = context.resolve_constant_dependency(db);
Expand Down
16 changes: 8 additions & 8 deletions crates/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub use fe_codegen::db::{CodegenDb, Db};
//use fe_codegen::yul::runtime::RuntimeProvider;

use fe_analyzer::namespace::items::{IngotId, IngotMode, ModuleId};
use fe_analyzer::namespace::items::{IngotId, IngotMode, ModuleId, FunctionId};
use fe_analyzer::AnalyzerDb;
use fe_analyzer::{context::Analysis, namespace::items::ContractId};
use fe_common::db::Upcast;
Expand Down Expand Up @@ -68,13 +68,8 @@ pub fn compile_test_file(
let diags = module.diagnostics(db);

if diags.is_empty() {
// let test_functions = module.all_functions(db);
// let yul_fns = test_functions
// .iter()
// .map(|test| {
// })
// .collect();

let test = compile_test_to_yul(db, module.all_functions(db)[0]);
compile_to_evm("test", &test, optimize);
Err(CompileError(diags))
} else {
Err(CompileError(diags))
Expand Down Expand Up @@ -223,6 +218,11 @@ fn compile_to_yul(db: &mut Db, contract: ContractId) -> String {
yul_contract.to_string().replace('"', "\\\"")
}

fn compile_test_to_yul(db: &mut Db, test: FunctionId) -> String {
let yul_test = fe_codegen::yul::isel::lower_test(db, test);
yul_test.to_string().replace('"', "\\\"")
}

#[cfg(feature = "solc-backend")]
fn compile_to_evm(name: &str, yul_object: &str, optimize: bool) -> String {
match fe_yulc::compile_single_contract(name, yul_object, optimize) {
Expand Down
3 changes: 3 additions & 0 deletions crates/test-files/fixtures/ingots/basic_ingot/tests.fe
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn test_1() {
revert
}

0 comments on commit 2286ff0

Please sign in to comment.