mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-15 05:41:08 +00:00
Remove libsolc crate
This commit is contained in:
@@ -48,8 +48,6 @@ pub use self::solc::version::Version as SolcVersion;
|
|||||||
pub use self::solc::Compiler;
|
pub use self::solc::Compiler;
|
||||||
pub use self::version::Version as ResolcVersion;
|
pub use self::version::Version as ResolcVersion;
|
||||||
pub use self::warning::Warning;
|
pub use self::warning::Warning;
|
||||||
#[cfg(target_os = "emscripten")]
|
|
||||||
pub mod libsolc;
|
|
||||||
#[cfg(not(target_os = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
pub mod test_utils;
|
pub mod test_utils;
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
//! The Solidity compiler library.
|
|
||||||
|
|
||||||
use crate::Compiler;
|
|
||||||
use crate::SoljsonCompiler;
|
|
||||||
use libc::{c_char, size_t};
|
|
||||||
use std::ffi::{CStr, CString};
|
|
||||||
use std::ptr;
|
|
||||||
|
|
||||||
static mut VERSION: Option<Box<CString>> = None;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn solidity_license() -> *const c_char {
|
|
||||||
let license = "This is the Revive license.";
|
|
||||||
CString::new(license).unwrap().into_raw()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn solidity_version() -> *const c_char {
|
|
||||||
let mut solc = SoljsonCompiler { version: None };
|
|
||||||
let version = solc
|
|
||||||
.version()
|
|
||||||
.map(|v| v.long)
|
|
||||||
.unwrap_or("unknown".to_owned());
|
|
||||||
// Store the string in a static variable
|
|
||||||
unsafe {
|
|
||||||
if VERSION.is_none() {
|
|
||||||
VERSION = Some(Box::new(CString::new(version).unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
VERSION.as_ref().map_or_else(std::ptr::null, |s| s.as_ptr())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn solidity_alloc(size: size_t) -> *mut c_char {
|
|
||||||
let buffer = vec![0u8; size].into_boxed_slice();
|
|
||||||
Box::into_raw(buffer) as *mut c_char
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn solidity_free(data: *mut c_char) {
|
|
||||||
if !data.is_null() {
|
|
||||||
unsafe {
|
|
||||||
CString::from_raw(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn solidity_compile(
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
_readContext: *mut libc::c_void,
|
|
||||||
) -> *mut c_char {
|
|
||||||
let input = unsafe { CStr::from_ptr(input).to_str().unwrap_or("") };
|
|
||||||
|
|
||||||
// Mock compilation process
|
|
||||||
let output = format!("Compiled output for: {}", input);
|
|
||||||
|
|
||||||
CString::new(output).unwrap().into_raw()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn solidity_reset() {}
|
|
||||||
@@ -19,16 +19,16 @@ use self::standard_json::output::Output as StandardJsonOutput;
|
|||||||
use self::version::Version;
|
use self::version::Version;
|
||||||
|
|
||||||
/// The first version of `solc` with the support of standard JSON interface.
|
/// The first version of `solc` with the support of standard JSON interface.
|
||||||
const FIRST_SUPPORTED_VERSION: semver::Version = semver::Version::new(0, 4, 12);
|
pub const FIRST_SUPPORTED_VERSION: semver::Version = semver::Version::new(0, 4, 12);
|
||||||
|
|
||||||
/// The first version of `solc`, where Yul codegen is considered robust enough.
|
/// The first version of `solc`, where Yul codegen is considered robust enough.
|
||||||
pub(crate) const FIRST_YUL_VERSION: semver::Version = semver::Version::new(0, 8, 0);
|
pub const FIRST_YUL_VERSION: semver::Version = semver::Version::new(0, 8, 0);
|
||||||
|
|
||||||
/// The first version of `solc`, where `--via-ir` codegen mode is supported.
|
/// The first version of `solc`, where `--via-ir` codegen mode is supported.
|
||||||
const FIRST_VIA_IR_VERSION: semver::Version = semver::Version::new(0, 8, 13);
|
pub const FIRST_VIA_IR_VERSION: semver::Version = semver::Version::new(0, 8, 13);
|
||||||
|
|
||||||
/// The last supported version of `solc`.
|
/// The last supported version of `solc`.
|
||||||
pub(crate) const LAST_SUPPORTED_VERSION: semver::Version = semver::Version::new(0, 8, 28);
|
pub const LAST_SUPPORTED_VERSION: semver::Version = semver::Version::new(0, 8, 28);
|
||||||
|
|
||||||
/// The Solidity compiler.
|
/// The Solidity compiler.
|
||||||
pub trait Compiler {
|
pub trait Compiler {
|
||||||
|
|||||||
Reference in New Issue
Block a user