Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: shruti2522 <[email protected]>
  • Loading branch information
shruti2522 committed Jun 3, 2024
1 parent c0fd91d commit 54ace97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kclvm/sema/src/advanced_resolver/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,4 +1309,4 @@ impl<'ctx> AdvancedResolver<'ctx> {
}
}
}
}
}
11 changes: 10 additions & 1 deletion kclvm/sema/src/core/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ impl SymbolData {
SymbolKind::Decorator => {
self.decorators.remove(id.get_id());
}
SymbolKind::Function => {
self.functions.remove(id.get_id());
}
}
}

Expand Down Expand Up @@ -802,7 +805,12 @@ impl SymbolData {
Some(symbol_ref)
}

pub fn alloc_function_symbol(&mut self, func: FunctionSymbol, node_key: NodeKey) -> SymbolRef {
pub fn alloc_function_symbol(
&mut self,
func: FunctionSymbol,
node_key: NodeKey,
pkg_name: String,
) -> SymbolRef {
self.symbols_info.symbol_pos_set.insert(func.end.clone());
let symbol_id = self.functions.insert(func);
let symbol_ref = SymbolRef {
Expand All @@ -816,6 +824,7 @@ impl SymbolData {
.symbol_node_map
.insert(symbol_ref, node_key);
self.functions.get_mut(symbol_id).unwrap().id = Some(symbol_ref);
self.insert_package_symbol(symbol_ref, pkg_name);
symbol_ref
}

Expand Down
7 changes: 2 additions & 5 deletions kclvm/sema/src/namer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use crate::builtin::{
use crate::core::global_state::GlobalState;
use crate::core::package::{ModuleInfo, PackageInfo};
use crate::core::symbol::{
PackageSymbol, SymbolRef, FunctionSymbol, BUILTIN_FUNCTION_PACKAGE, BUILTIN_STR_PACKAGE,
FunctionSymbol, PackageSymbol, SymbolRef, BUILTIN_FUNCTION_PACKAGE, BUILTIN_STR_PACKAGE,
};
use crate::resolver::scope::NodeKey;
use indexmap::IndexSet;
Expand All @@ -59,7 +59,6 @@ mod node;
pub const BUILTIN_SYMBOL_PKG_PATH: &str = "@builtin";

pub struct Namer<'ctx> {
gs: &'ctx mut GlobalState,
gs: &'ctx mut GlobalState,
ctx: NamerContext<'ctx>,
}
Expand All @@ -86,7 +85,6 @@ impl<'ctx> NamerContext<'ctx> {
}

impl<'ctx> Namer<'ctx> {
fn new(program: &'ctx Program, gs: &'ctx mut GlobalState) -> Self {
fn new(program: &'ctx Program, gs: &'ctx mut GlobalState) -> Self {
Self {
ctx: NamerContext {
Expand All @@ -101,7 +99,6 @@ impl<'ctx> Namer<'ctx> {
}

// serial namer pass
pub fn find_symbols(program: &'ctx Program, gs: &'ctx mut GlobalState) {
pub fn find_symbols(program: &'ctx Program, gs: &'ctx mut GlobalState) {
let mut namer = Self::new(program, gs);
namer.ctx.current_package_info = Some(PackageInfo::new(
Expand Down Expand Up @@ -400,4 +397,4 @@ mod tests {
);
}
}
}
}

0 comments on commit 54ace97

Please sign in to comment.