insert symbol on functiondecl
return ident from parse_fn_proto
This commit is contained in:
parent
7cea2452d1
commit
30ce12988d
|
@ -2592,7 +2592,10 @@ pub mod ast_gen {
|
||||||
/// fn IDENTIFIER () -> TYPENAME
|
/// fn IDENTIFIER () -> TYPENAME
|
||||||
/// fn IDENTIFIER ( PARAMETER_LIST ,? )
|
/// fn IDENTIFIER ( PARAMETER_LIST ,? )
|
||||||
/// fn IDENTIFIER ( PARAMETER_LIST ,? ) -> TYPENAME
|
/// fn IDENTIFIER ( PARAMETER_LIST ,? ) -> TYPENAME
|
||||||
fn parse_fn_proto(&mut self, tokens: &mut TokenIterator) -> ParseResult<Index> {
|
fn parse_fn_proto(
|
||||||
|
&mut self,
|
||||||
|
tokens: &mut TokenIterator,
|
||||||
|
) -> ParseResult<(Index, intern::Index)> {
|
||||||
let loc = tokens.current_source_location();
|
let loc = tokens.current_source_location();
|
||||||
let _ = tokens.eat_token(Token::Fn).ok_or(ErrorInfo {
|
let _ = tokens.eat_token(Token::Fn).ok_or(ErrorInfo {
|
||||||
error: ParseError::ExpectedToken(Token::Fn),
|
error: ParseError::ExpectedToken(Token::Fn),
|
||||||
|
@ -2617,8 +2620,10 @@ pub mod ast_gen {
|
||||||
tokens.current_source_location(),
|
tokens.current_source_location(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
let decl =
|
||||||
|
self.ast.push_fn_proto(ident, return_type, parameters, loc);
|
||||||
|
|
||||||
return Ok(self.ast.push_fn_proto(ident, return_type, parameters, loc));
|
Ok((decl, ident))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_fn_inner(&mut self, tokens: &mut TokenIterator) -> ParseResult<Index> {
|
fn parse_fn_inner(&mut self, tokens: &mut TokenIterator) -> ParseResult<Index> {
|
||||||
|
@ -2627,7 +2632,7 @@ pub mod ast_gen {
|
||||||
|
|
||||||
self.push_scope(func, intern::Index::invalid());
|
self.push_scope(func, intern::Index::invalid());
|
||||||
|
|
||||||
let proto = self.parse_fn_proto(tokens).map_err(|e| {
|
let (proto, ident) = self.parse_fn_proto(tokens).map_err(|e| {
|
||||||
self.pop_scope();
|
self.pop_scope();
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
@ -2640,6 +2645,13 @@ pub mod ast_gen {
|
||||||
|
|
||||||
self.ast.set_fn_decl(func, proto, body, loc);
|
self.ast.set_fn_decl(func, proto, body, loc);
|
||||||
|
|
||||||
|
self.syms.insert_symbol(
|
||||||
|
self.current_scope(),
|
||||||
|
ident,
|
||||||
|
SymbolKind::Function,
|
||||||
|
func,
|
||||||
|
);
|
||||||
|
|
||||||
Ok(func)
|
Ok(func)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue