Skip to content

Commit 7b5fa0b

Browse files
committed
feat: added append half function method
1 parent d4a54a0 commit 7b5fa0b

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

compiler/astoir_hir/src/scope.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ impl HIRGlobalScopeStorage {
6161
)
6262
}
6363

64+
pub fn append_half_function<K: DiagnosticSpanOrigin>(
65+
&mut self,
66+
name: EntryKey,
67+
descriptor: HIRFunction,
68+
brctx: HIRBranchedContext,
69+
) -> DiagnosticResult<usize> {
70+
self.descriptors.push(descriptor);
71+
self.contexts.push(brctx);
72+
73+
self.scope.append(
74+
name,
75+
TypedGlobalScopeEntry::HalfImplFunction {
76+
descriptor_ind: self.scope.descriptor_counter,
77+
branch_ctx: self.scope.ctx_counter,
78+
},
79+
origin,
80+
)
81+
}
82+
6483
pub fn append_implless_function<K: DiagnosticSpanOrigin>(
6584
&mut self,
6685
name: EntryKey,

compiler/compiler_global_scope/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub struct GlobalScopeStorage<T: Hash, R: Hash> {
2424

2525
pub descriptor_counter: usize,
2626
pub impl_counter: usize,
27+
pub ctx_counter: usize,
2728
}
2829

2930
/// The global storage for every element inside of the scope.
@@ -44,6 +45,7 @@ impl<T: Clone + Hash + Eq, R: Clone + Hash + Eq> GlobalScopeStorage<T, R> {
4445
entries: vec![],
4546
descriptor_counter: 0,
4647
impl_counter: 0,
48+
ctx_counter: 0,
4749
}
4850
}
4951

@@ -59,6 +61,7 @@ impl<T: Clone + Hash + Eq, R: Clone + Hash + Eq> GlobalScopeStorage<T, R> {
5961

6062
if let GlobalStorageEntryType::Function { .. } = entry {
6163
self.descriptor_counter += 1;
64+
self.ctx_counter += 1;
6265
self.impl_counter += 1;
6366
}
6467

@@ -68,9 +71,15 @@ impl<T: Clone + Hash + Eq, R: Clone + Hash + Eq> GlobalScopeStorage<T, R> {
6871

6972
if let GlobalStorageEntryType::StructFunction { .. } = entry {
7073
self.descriptor_counter += 1;
74+
self.ctx_counter += 1;
7175
self.impl_counter += 1;
7276
}
7377

78+
if let GlobalStorageEntryType::HalfImplFunction { .. } = entry {
79+
self.descriptor_counter += 1;
80+
self.ctx_counter += 1;
81+
}
82+
7483
let parent_index = self.entries.len();
7584

7685
self.value_to_ind.insert(entry.clone(), parent_index);

0 commit comments

Comments
 (0)