solar_interface

Struct Session

Source
pub struct Session {
    pub dcx: DiagCtxt,
    pub evm_version: EvmVersion,
    pub language: Language,
    pub stop_after: Option<CompilerStage>,
    pub emit: BTreeSet<CompilerOutput>,
    pub out_dir: Option<PathBuf>,
    pub dump: Option<Dump>,
    pub pretty_json: bool,
    pub jobs: NonZeroUsize,
    /* private fields */
}
Expand description

Information about the current compiler session.

Fields§

§dcx: DiagCtxt

The diagnostics context.

§evm_version: EvmVersion

EVM version.

§language: Language

Source code language.

§stop_after: Option<CompilerStage>

Stop execution after the given compiler stage.

§emit: BTreeSet<CompilerOutput>

Types of output to emit.

§out_dir: Option<PathBuf>

Output directory.

§dump: Option<Dump>

Internal state to dump to stdout.

§pretty_json: bool

Pretty-print any JSON output.

§jobs: NonZeroUsize

Number of threads to use. Already resolved to a non-zero value.

Implementations§

Source§

impl Session

Source

pub fn new(dcx: DiagCtxt, source_map: Arc<SourceMap>) -> Self

Creates a new session with the given diagnostics context and source map.

Source

pub fn empty(dcx: DiagCtxt) -> Self

Creates a new session with the given diagnostics context and an empty source map.

Source

pub fn builder() -> SessionBuilder

Creates a new session builder.

Source

pub fn emitted_diagnostics(&self) -> Option<Result<(), EmittedDiagnostics>>

Returns Err with the printed diagnostics if any errors have been emitted.

Returns None if the underlying emitter is not a human buffer emitter created with with_buffer_emitter.

Source

pub fn source_map(&self) -> &SourceMap

Returns a reference to the source map.

Source

pub fn clone_source_map(&self) -> Arc<SourceMap>

Clones the source map.

Source

pub fn stop_after(&self, stage: CompilerStage) -> bool

Returns true if compilation should stop after the given stage.

Source

pub fn is_sequential(&self) -> bool

Returns true if parallelism is not enabled.

Source

pub fn is_parallel(&self) -> bool

Returns true if parallelism is enabled.

Source

pub fn do_emit(&self, output: CompilerOutput) -> bool

Returns true if the given output should be emitted.

Source

pub fn spawn(&self, f: impl FnOnce() + Send + 'static)

Spawns the given closure on the thread pool or executes it immediately if parallelism is not enabled.

Source

pub fn join<A, B, RA, RB>(&self, oper_a: A, oper_b: B) -> (RA, RB)
where A: FnOnce() -> RA + Send, B: FnOnce() -> RB + Send, RA: Send, RB: Send,

Takes two closures and potentially runs them in parallel. It returns a pair of the results from those closures.

Source

pub fn scope<'scope, OP, R>(&self, op: OP) -> R
where OP: FnOnce(Scope<'_, 'scope>) -> R + Send, R: Send,

Executes the given closure in a fork-join scope.

See rayon::scope for more details.

Source

pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R

Sets up session globals on the current thread if they doesn’t exist already and then executes the given closure.

This also calls SessionGlobals::with_source_map.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more