swc_core::common::input

Type Alias SourceFileInput

pub type SourceFileInput<'a> = StringInput<'a>;
Available on crate feature __common only.

Aliased Type§

struct SourceFileInput<'a> { /* private fields */ }

Implementations

§

impl<'a> StringInput<'a>

pub fn new(src: &'a str, start: BytePos, end: BytePos) -> StringInput<'a>

start and end can be arbitrary value, but start should be less than or equal to end.

swc get this value from [SourceMap] because code generator depends on some methods of [SourceMap]. If you are not going to use methods from [SourceMap], you may use any value.

pub fn as_str(&self) -> &str

pub fn bump_bytes(&mut self, n: usize)

pub fn start_pos(&self) -> BytePos

pub fn end_pos(&self) -> BytePos

Trait Implementations

§

impl<'a> Clone for StringInput<'a>

§

fn clone(&self) -> StringInput<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'a> From<&'a SourceFile> for StringInput<'a>

Creates an Input from SourceFile. This is an alias for

   StringInput::new(&fm.src, fm.start_pos, fm.end_pos)
§

fn from(fm: &'a SourceFile) -> StringInput<'a>

Converts to this type from the input type.
§

impl Input for StringInput<'_>

§

fn cur_pos(&mut self) -> BytePos

TODO(kdy1): Remove this?

§

fn cur(&mut self) -> Option<char>

§

fn peek(&mut self) -> Option<char>

§

fn peek_ahead(&mut self) -> Option<char>

§

unsafe fn bump(&mut self)

Safety Read more
§

fn cur_as_ascii(&mut self) -> Option<u8>

Returns None if it’s end of input or current character is not an ascii character.
§

fn is_at_start(&self) -> bool

§

fn last_pos(&self) -> BytePos

§

unsafe fn slice(&mut self, start: BytePos, end: BytePos) -> &str

Safety Read more
§

fn uncons_while<F>(&mut self, pred: F) -> &str
where F: FnMut(char) -> bool,

Takes items from stream, testing each one with predicate. returns the range of items which passed predicate.
§

fn find<F>(&mut self, pred: F) -> Option<BytePos>
where F: FnMut(char) -> bool,

This method modifies [last_pos()] and [cur_pos()].
§

unsafe fn reset_to(&mut self, to: BytePos)

Safety Read more
§

fn is_byte(&mut self, c: u8) -> bool

Implementors can override the method to make it faster. Read more
§

fn is_str(&self, s: &str) -> bool

Implementors can override the method to make it faster. Read more
§

fn eat_byte(&mut self, c: u8) -> bool

Implementors can override the method to make it faster. Read more