Skip to content

Commit c55ffad

Browse files
committed
fix: fixed HIR
1 parent 0e62c74 commit c55ffad

7 files changed

Lines changed: 24 additions & 268 deletions

File tree

compiler/astoir_hir/src/ctx.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
33
use std::collections::{HashMap, HashSet};
44

5-
use compiler_typing::{storage::TypeStorage, tree::Type};
5+
use compiler_typing::{TypedGlobalScope, tree::Type};
66
use compiler_utils::{hash::SelfHash, utils::indexed::IndexStorage};
77
use diagnostics::{
88
DiagnosticResult, DiagnosticSpanOrigin,
99
builders::{make_cannot_find_func, make_cannot_find_var, make_doesnt_exist_in_era},
1010
};
1111

12-
use crate::{nodes::HIRNode, storage::GlobalScopeStorage, structs::HIRStructContainer};
12+
use crate::{nodes::HIRNode, structs::HIRStructContainer};
1313

1414
pub type HIRFunction = (Option<Type>, Vec<(u64, Type)>, String);
1515

@@ -278,8 +278,7 @@ pub struct HIRContext {
278278
pub function_contexts: Vec<Option<HIRBranchedContext>>,
279279
pub static_variables: IndexStorage<Type>,
280280
pub struct_func_impls: HashMap<usize, HIRStructContainer>,
281-
pub type_storage: TypeStorage,
282-
pub global_scope: GlobalScopeStorage,
281+
pub global_scope: TypedGlobalScope,
283282
}
284283

285284
#[derive(PartialEq)]
@@ -293,11 +292,10 @@ impl HIRContext {
293292
return HIRContext {
294293
functions: IndexStorage::new(),
295294
static_variables: IndexStorage::new(),
296-
type_storage: TypeStorage::new().unwrap(),
297295
function_contexts: vec![],
298296
function_declarations: vec![],
299297
struct_func_impls: HashMap::new(),
300-
global_scope: GlobalScopeStorage::new(),
298+
global_scope: TypedGlobalScope::new(),
301299
};
302300
}
303301

compiler/astoir_hir/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
pub mod ctx;
55
pub mod nodes;
66
pub mod resolve;
7-
pub mod storage;
87
pub mod structs;

compiler/astoir_hir/src/nodes.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl HIRNode {
316316
return Ok(self.clone());
317317
}
318318

319-
if self_type.can_transmute(&t, &context.type_storage) {
319+
if self_type.can_transmute(&t, &context.global_scope) {
320320
match &self.kind {
321321
HIRNodeKind::IntegerLiteral { value, int_type: _ } => {
322322
return Ok(self.with(HIRNodeKind::IntegerLiteral {
@@ -326,7 +326,7 @@ impl HIRNode {
326326
}
327327

328328
HIRNodeKind::ArrayVariableInitializerValue { vals } => {
329-
if can_transmute_inner(&self_type, &t, &context.type_storage) {
329+
if can_transmute_inner(&self_type, &t, &context.global_scope) {
330330
let mut new_vals = vec![];
331331
let inner = t.get_inner_type();
332332

@@ -346,7 +346,7 @@ impl HIRNode {
346346
}
347347

348348
HIRNodeKind::ArrayVariableInitializerValueSameValue { size, val } => {
349-
if can_transmute_inner(&self_type, &t, &context.type_storage) {
349+
if can_transmute_inner(&self_type, &t, &context.global_scope) {
350350
let new_val = Box::new(val.use_as(
351351
context,
352352
curr_ctx,
@@ -355,12 +355,12 @@ impl HIRNode {
355355
var_origin,
356356
)?);
357357

358-
return Ok(
359-
self.with(HIRNodeKind::ArrayVariableInitializerValueSameValue {
358+
return Ok(self.with(
359+
HIRNodeKind::ArrayVariableInitializerValueSameValue {
360360
size: *size,
361361
val: new_val,
362-
}),
363-
);
362+
},
363+
));
364364
}
365365
}
366366

@@ -379,23 +379,23 @@ impl HIRNode {
379379
return Err(make_diff_type(
380380
origin,
381381
&"unnamed".to_string(),
382-
&t.faulty_lowering_generic(&context.type_storage),
382+
&t.faulty_lowering_generic(&context.global_scope),
383383
&self
384384
.get_node_type(context, curr_ctx)
385385
.unwrap()
386-
.faulty_lowering_generic(&context.type_storage),
386+
.faulty_lowering_generic(&context.global_scope),
387387
v,
388388
)
389389
.into());
390390
}
391391

392392
return Err(make_diff_type_val(
393393
origin,
394-
&t.faulty_lowering_generic(&context.type_storage),
394+
&t.faulty_lowering_generic(&context.global_scope),
395395
&self
396396
.get_node_type(context, curr_ctx)
397397
.unwrap()
398-
.faulty_lowering_generic(&context.type_storage),
398+
.faulty_lowering_generic(&context.global_scope),
399399
)
400400
.into());
401401
}

compiler/astoir_hir/src/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn resolve_to_type<K: DiagnosticSpanOrigin>(
2929
return Err(make_req_type_kind(origin, &"field-having".to_string()).into());
3030
}
3131

32-
for field in destination.get_fields(&context.type_storage) {
32+
for field in destination.get_fields(&context.global_scope) {
3333
let identity = SelfHash { hash: field };
3434

3535
if !fields.contains_key(&identity) {
@@ -39,7 +39,7 @@ pub fn resolve_to_type<K: DiagnosticSpanOrigin>(
3939
let val = fields[&identity].clone();
4040

4141
let field_data = destination
42-
.get_field(&context.type_storage, field)?
42+
.get_field(&context.global_scope, field)?
4343
.1
4444
.resolve(&destination);
4545

compiler/astoir_hir/src/storage.rs

Lines changed: 0 additions & 241 deletions
This file was deleted.

0 commit comments

Comments
 (0)