mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 06:31:02 +00:00
experimental: support for debug info (#118)
Signed-off-by: wpt967 <matt.aw@parity.io> Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -19,12 +19,20 @@ impl Comment {
|
||||
let end_position = input.find(Self::END).unwrap_or(input.len());
|
||||
let input = &input[..end_position];
|
||||
|
||||
let length = end_position + Self::END.len();
|
||||
let lines = input.matches('\n').count();
|
||||
let length = (end_position + Self::END.len())
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
let lines = input
|
||||
.matches('\n')
|
||||
.count()
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
let columns = match input.rfind('\n') {
|
||||
Some(new_line) => end_position - (new_line + 1),
|
||||
None => end_position,
|
||||
};
|
||||
}
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
|
||||
Token::new(Location::new(lines, columns), Lexeme::Comment, length)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ impl Comment {
|
||||
/// Returns the comment's length, including the trimmed whitespace around it.
|
||||
pub fn parse(input: &str) -> Token {
|
||||
let end_position = input.find(Self::END).unwrap_or(input.len());
|
||||
let length = end_position + Self::END.len();
|
||||
let length = (end_position + Self::END.len())
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
|
||||
Token::new(Location::new(1, 1), Lexeme::Comment, length)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,10 @@ impl Identifier {
|
||||
let end = input.find(Self::cannot_continue).unwrap_or(input.len());
|
||||
|
||||
let inner = input[..end].to_string();
|
||||
let length = inner.len();
|
||||
let length = inner
|
||||
.len()
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
|
||||
if let Some(token) = Keyword::parse(inner.as_str()) {
|
||||
return Some(token);
|
||||
|
||||
@@ -58,6 +58,9 @@ impl Keyword {
|
||||
if length != input.len() {
|
||||
return None;
|
||||
}
|
||||
let length = length
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
|
||||
Some(Token::new(Location::new(0, length), lexeme, length))
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ impl Integer {
|
||||
return None;
|
||||
};
|
||||
|
||||
let length = length
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
|
||||
let token = Token::new(
|
||||
Location::new(0, length),
|
||||
Lexeme::Literal(Literal::Integer(value)),
|
||||
|
||||
@@ -69,6 +69,9 @@ impl String {
|
||||
.to_owned();
|
||||
|
||||
let literal = Self::new(string, is_hex_string);
|
||||
let length = length
|
||||
.try_into()
|
||||
.expect("the YUL should be of reasonable size");
|
||||
|
||||
Some(Token::new(
|
||||
Location::new(0, length),
|
||||
|
||||
Reference in New Issue
Block a user