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
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ semver = { version = "1.0", features = ["serde"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1.0"
similar-asserts = "1"
solar-parse = { version = "=0.1.6", default-features = false }
solar-sema = { version = "=0.1.6", default-features = false }
solar = { package = "solar-compiler", version = "=0.1.6", default-features = false }
svm = { package = "svm-rs", version = "0.5", default-features = false }
tempfile = "3.20"
thiserror = "2"
Expand All @@ -70,7 +69,4 @@ tokio = { version = "1.47", features = ["rt-multi-thread"] }
snapbox = "0.6.21"

[patch.crates-io]
# solar-parse = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
# solar-sema = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
# solar-ast = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
# solar-interface = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
# solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar", branch = "main" }
3 changes: 1 addition & 2 deletions crates/compilers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ rayon.workspace = true
thiserror.workspace = true
path-slash.workspace = true
yansi.workspace = true
solar-parse.workspace = true
solar-sema.workspace = true
solar.workspace = true
futures-util = { workspace = true, optional = true }
tokio = { workspace = true, optional = true }

Expand Down
6 changes: 3 additions & 3 deletions crates/compilers/src/cache/iface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{parse_one_source, replace_source_content};
use solar_parse::{
use solar::parse::{
ast::{self, Span},
interface::diagnostics::EmittedDiagnostics,
};
Expand All @@ -21,8 +21,8 @@ pub(crate) fn interface_repr(content: &str, path: &Path) -> Result<String, Emitt
/// Preserves all libraries and interfaces.
pub(crate) fn interface_representation_ast(
content: &str,
sess: &solar_sema::interface::Session,
ast: &solar_parse::ast::SourceUnit<'_>,
sess: &solar::sema::interface::Session,
ast: &solar::parse::ast::SourceUnit<'_>,
) -> String {
let mut spans_to_remove: Vec<Span> = Vec::new();
for item in ast.items.iter() {
Expand Down
6 changes: 3 additions & 3 deletions crates/compilers/src/compilers/solc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,14 @@ impl SourceParser for SolParser {

fn new(config: &crate::ProjectPathsConfig) -> Self {
Self {
compiler: solar_sema::Compiler::new(Self::session_with_opts(
solar_sema::interface::config::Opts {
compiler: solar::sema::Compiler::new(Self::session_with_opts(
solar::sema::interface::config::Opts {
include_paths: config.include_paths.iter().cloned().collect(),
base_path: Some(config.root.clone()),
import_remappings: config
.remappings
.iter()
.map(|r| solar_sema::interface::config::ImportRemapping {
.map(|r| solar::sema::interface::config::ImportRemapping {
context: r.context.clone().unwrap_or_default(),
prefix: r.name.clone(),
path: r.path.clone(),
Expand Down
8 changes: 4 additions & 4 deletions crates/compilers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use foundry_compilers_core::error::{Result, SolcError, SolcIoError};
use output::sources::{VersionedSourceFile, VersionedSourceFiles};
use project::ProjectCompiler;
use semver::Version;
use solar_parse::{
use solar::parse::{
interface::{diagnostics::EmittedDiagnostics, source_map::FileName, Session},
Parser,
};
Expand Down Expand Up @@ -925,11 +925,11 @@ pub fn replace_source_content(
pub(crate) fn parse_one_source<R>(
content: &str,
path: &Path,
f: impl FnOnce(&Session, &solar_parse::ast::SourceUnit<'_>) -> R,
f: impl FnOnce(&Session, &solar::parse::ast::SourceUnit<'_>) -> R,
) -> Result<R, EmittedDiagnostics> {
let sess = Session::builder().with_buffer_emitter(Default::default()).build();
let res = sess.enter_sequential(|| -> solar_parse::interface::Result<_> {
let arena = solar_parse::ast::Arena::new();
let res = sess.enter_sequential(|| -> solar::parse::interface::Result<_> {
let arena = solar::parse::ast::Arena::new();
let filename = FileName::Real(path.to_path_buf());
let mut parser = Parser::from_source_code(&sess, &arena, filename, content.to_string())?;
let ast = parser.parse_file().map_err(|e| e.emit())?;
Expand Down
34 changes: 18 additions & 16 deletions crates/compilers/src/resolver/parse.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use foundry_compilers_core::utils;
use semver::VersionReq;
use solar_parse::{ast, interface::sym};
use solar_sema::interface;
use solar::{
parse::{ast, interface::sym},
sema::interface,
};
use std::{
ops::Range,
path::{Path, PathBuf},
};

/// Solidity parser.
///
/// Holds a [`solar_sema::Compiler`] that is used to parse sources incrementally.
/// Holds a [`solar::sema::Compiler`] that is used to parse sources incrementally.
/// After project compilation ([`Graph::resolve`]), this will contain all sources parsed by
/// [`Graph`].
///
Expand All @@ -20,13 +22,13 @@ use std::{
#[derive(derive_more::Debug)]
pub struct SolParser {
#[debug(ignore)]
pub(crate) compiler: solar_sema::Compiler,
pub(crate) compiler: solar::sema::Compiler,
}

impl Clone for SolParser {
fn clone(&self) -> Self {
Self {
compiler: solar_sema::Compiler::new(Self::session_with_opts(
compiler: solar::sema::Compiler::new(Self::session_with_opts(
self.compiler.sess().opts.clone(),
)),
}
Expand All @@ -35,24 +37,24 @@ impl Clone for SolParser {

impl SolParser {
/// Returns a reference to the compiler.
pub fn compiler(&self) -> &solar_sema::Compiler {
pub fn compiler(&self) -> &solar::sema::Compiler {
&self.compiler
}

/// Returns a mutable reference to the compiler.
pub fn compiler_mut(&mut self) -> &mut solar_sema::Compiler {
pub fn compiler_mut(&mut self) -> &mut solar::sema::Compiler {
&mut self.compiler
}

/// Consumes the parser and returns the compiler.
pub fn into_compiler(self) -> solar_sema::Compiler {
pub fn into_compiler(self) -> solar::sema::Compiler {
self.compiler
}

pub(crate) fn session_with_opts(
opts: solar_sema::interface::config::Opts,
) -> solar_sema::interface::Session {
let sess = solar_sema::interface::Session::builder()
opts: solar::sema::interface::config::Opts,
) -> solar::sema::interface::Session {
let sess = solar::sema::interface::Session::builder()
.with_buffer_emitter(Default::default())
.opts(opts)
.build();
Expand Down Expand Up @@ -137,8 +139,8 @@ impl SolData {
}

pub(crate) fn parse_from(
sess: &solar_sema::interface::Session,
s: &solar_sema::Source<'_>,
sess: &solar::sema::interface::Session,
s: &solar::sema::Source<'_>,
) -> Self {
let content = s.file.src.as_str();
let file = s.file.name.as_real().unwrap();
Expand Down Expand Up @@ -189,7 +191,7 @@ impl SolDataBuilder {
content: &str,
file: &Path,
ast: Result<
(&solar_sema::interface::Session, &solar_parse::ast::SourceUnit<'_>),
(&solar::sema::interface::Session, &solar::parse::ast::SourceUnit<'_>),
Option<String>,
>,
) -> SolData {
Expand All @@ -208,8 +210,8 @@ impl SolDataBuilder {

fn parse_from_ast(
&mut self,
sess: &solar_sema::interface::Session,
ast: &solar_parse::ast::SourceUnit<'_>,
sess: &solar::sema::interface::Session,
ast: &solar::parse::ast::SourceUnit<'_>,
) {
for item in ast.items.iter() {
let loc = sess.source_map().span_to_source(item.span).unwrap().1;
Expand Down
Loading