mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 11:51:06 +00:00
Fmt
This commit is contained in:
@@ -17,15 +17,18 @@ pub extern "C" fn solidity_license() -> *const c_char {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn solidity_version() -> *const c_char {
|
pub extern "C" fn solidity_version() -> *const c_char {
|
||||||
let mut solc = SoljsonCompiler { version: None };
|
let mut solc = SoljsonCompiler { version: None };
|
||||||
let version = solc.version().map(|v| v.long).unwrap_or("unknown".to_owned());
|
let version = solc
|
||||||
// Store the string in a static variable
|
.version()
|
||||||
unsafe {
|
.map(|v| v.long)
|
||||||
|
.unwrap_or("unknown".to_owned());
|
||||||
|
// Store the string in a static variable
|
||||||
|
unsafe {
|
||||||
if VERSION.is_none() {
|
if VERSION.is_none() {
|
||||||
VERSION = Some(Box::new(CString::new(version).unwrap()));
|
VERSION = Some(Box::new(CString::new(version).unwrap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSION.as_ref().map_or_else(std::ptr::null, |s| s.as_ptr())
|
VERSION.as_ref().map_or_else(std::ptr::null, |s| s.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -46,7 +49,15 @@ pub extern "C" fn solidity_free(data: *mut c_char) {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn solidity_compile(
|
pub extern "C" fn solidity_compile(
|
||||||
input: *const c_char,
|
input: *const c_char,
|
||||||
_readCallback: Option<extern "C" fn(*mut libc::c_void, *const c_char, *const c_char, *mut *mut c_char, *mut *mut c_char)>,
|
_readCallback: Option<
|
||||||
|
extern "C" fn(
|
||||||
|
*mut libc::c_void,
|
||||||
|
*const c_char,
|
||||||
|
*const c_char,
|
||||||
|
*mut *mut c_char,
|
||||||
|
*mut *mut c_char,
|
||||||
|
),
|
||||||
|
>,
|
||||||
_readContext: *mut libc::c_void,
|
_readContext: *mut libc::c_void,
|
||||||
) -> *mut c_char {
|
) -> *mut c_char {
|
||||||
let input = unsafe { CStr::from_ptr(input).to_str().unwrap_or("") };
|
let input = unsafe { CStr::from_ptr(input).to_str().unwrap_or("") };
|
||||||
@@ -58,5 +69,4 @@ pub extern "C" fn solidity_compile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn solidity_reset() {
|
pub extern "C" fn solidity_reset() {}
|
||||||
}
|
|
||||||
|
|||||||
@@ -103,7 +103,9 @@ impl Process for NativeProcess {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| anyhow::anyhow!("{:?} stdin getting error", executable))?
|
.ok_or_else(|| anyhow::anyhow!("{:?} stdin getting error", executable))?
|
||||||
.write_all(input_json.as_slice())
|
.write_all(input_json.as_slice())
|
||||||
.map_err(|error| anyhow::anyhow!("{:?} stdin writing error: {:?}", executable, error))?;
|
.map_err(|error| {
|
||||||
|
anyhow::anyhow!("{:?} stdin writing error: {:?}", executable, error)
|
||||||
|
})?;
|
||||||
let output = process.wait_with_output().map_err(|error| {
|
let output = process.wait_with_output().map_err(|error| {
|
||||||
anyhow::anyhow!("{:?} subprocess output error: {:?}", executable, error)
|
anyhow::anyhow!("{:?} subprocess output error: {:?}", executable, error)
|
||||||
})?;
|
})?;
|
||||||
@@ -114,8 +116,8 @@ impl Process for NativeProcess {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let output: Output =
|
let output: Output = revive_common::deserialize_from_slice(output.stdout.as_slice())
|
||||||
revive_common::deserialize_from_slice(output.stdout.as_slice()).map_err(|error| {
|
.map_err(|error| {
|
||||||
anyhow::anyhow!(
|
anyhow::anyhow!(
|
||||||
"{:?} subprocess output parsing error: {}",
|
"{:?} subprocess output parsing error: {}",
|
||||||
executable,
|
executable,
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ impl SolcCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Compiler for SolcCompiler {
|
impl Compiler for SolcCompiler {
|
||||||
/// Compiles the Solidity `--standard-json` input into Yul IR.
|
/// Compiles the Solidity `--standard-json` input into Yul IR.
|
||||||
fn standard_json(
|
fn standard_json(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut input: StandardJsonInput,
|
mut input: StandardJsonInput,
|
||||||
pipeline: Pipeline,
|
pipeline: Pipeline,
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ use crate::compiler::solc::SolcCompiler;
|
|||||||
use crate::compiler::standard_json::input::settings::optimizer::Optimizer as SolcStandardJsonInputSettingsOptimizer;
|
use crate::compiler::standard_json::input::settings::optimizer::Optimizer as SolcStandardJsonInputSettingsOptimizer;
|
||||||
use crate::compiler::standard_json::input::settings::selection::Selection as SolcStandardJsonInputSettingsSelection;
|
use crate::compiler::standard_json::input::settings::selection::Selection as SolcStandardJsonInputSettingsSelection;
|
||||||
use crate::compiler::standard_json::input::Input as SolcStandardJsonInput;
|
use crate::compiler::standard_json::input::Input as SolcStandardJsonInput;
|
||||||
|
use crate::compiler::standard_json::output::contract::evm::bytecode::Bytecode;
|
||||||
use crate::compiler::standard_json::output::contract::evm::bytecode::DeployedBytecode;
|
use crate::compiler::standard_json::output::contract::evm::bytecode::DeployedBytecode;
|
||||||
use crate::compiler::standard_json::output::Output as SolcStandardJsonOutput;
|
use crate::compiler::standard_json::output::Output as SolcStandardJsonOutput;
|
||||||
use crate::compiler::Compiler;
|
use crate::compiler::Compiler;
|
||||||
use crate::project::Project;
|
use crate::project::Project;
|
||||||
use crate::compiler::standard_json::output::contract::evm::bytecode::Bytecode;
|
|
||||||
use crate::warning::Warning;
|
use crate::warning::Warning;
|
||||||
|
|
||||||
static PVM_BLOB_CACHE: Lazy<Mutex<HashMap<CachedBlob, Vec<u8>>>> = Lazy::new(Default::default);
|
static PVM_BLOB_CACHE: Lazy<Mutex<HashMap<CachedBlob, Vec<u8>>>> = Lazy::new(Default::default);
|
||||||
@@ -214,8 +214,11 @@ pub fn build_yul(source_code: &str) -> anyhow::Result<()> {
|
|||||||
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM);
|
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM);
|
||||||
let optimizer_settings = revive_llvm_context::OptimizerSettings::none();
|
let optimizer_settings = revive_llvm_context::OptimizerSettings::none();
|
||||||
|
|
||||||
let project =
|
let project = Project::try_from_yul_string::<SolcCompiler>(
|
||||||
Project::try_from_yul_string::<SolcCompiler>(PathBuf::from("test.yul").as_path(), source_code, None)?;
|
PathBuf::from("test.yul").as_path(),
|
||||||
|
source_code,
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
let _build = project.compile(optimizer_settings, false, None)?;
|
let _build = project.compile(optimizer_settings, false, None)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user