Skip to content

Commit

Permalink
Merge pull request #94 from xiyuzhai/main
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
xiyuzhai authored Jun 9, 2024
2 parents 3c95f38 + 6fbf8ca commit 5f93247
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 50 deletions.
11 changes: 6 additions & 5 deletions crates/hir/husky-hir-eager-expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl ToHirEager for SemExprIdx {
return_ty,
ref unveil_output_ty_signature,
unveil_assoc_fn_path,
opd_sem_expr_idx,
opd,
..
} => {
let db = builder.db();
Expand All @@ -313,12 +313,13 @@ impl ToHirEager for SemExprIdx {
unveil_output_ty_signature.instantiation(),
db,
),
opd: opd_sem_expr_idx.to_hir_eager(builder),
opd: opd.to_hir_eager(builder),
return_ty: HirType::from_eth(return_ty, db).unwrap(),
}
}
SemExprData::Unwrap {
opd_sem_expr_idx, ..
opd: opd_sem_expr_idx,
..
} => HirEagerExprData::Unwrap {
opd: opd_sem_expr_idx.to_hir_eager(builder),
},
Expand All @@ -328,7 +329,7 @@ impl ToHirEager for SemExprIdx {
unreachable!()
}
SemExprData::FunctionRitchieCall {
function_sem_expr_idx,
function: function_sem_expr_idx,
ref template_arguments,
ref ritchie_parameter_argument_matches,
..
Expand Down Expand Up @@ -442,7 +443,7 @@ impl ToHirEager for SemExprIdx {
},
SemExprData::MethodApplication { .. } => todo!(),
SemExprData::MethodFnCall {
self_argument_sem_expr_idx,
self_argument: self_argument_sem_expr_idx,
self_contract,
ident_token,
ref dispatch,
Expand Down
17 changes: 9 additions & 8 deletions crates/hir/husky-hir-lazy-expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,29 +225,30 @@ impl ToHirLazy for SemExprIdx {
SemExprData::Unveil {
ref unveil_output_ty_signature,
unveil_assoc_fn_path,
opd_sem_expr_idx,
opd,
..
} => HirLazyExprData::Unveil {
unveil_assoc_fn_path,
instantiation: HirInstantiation::from_eth(
unveil_output_ty_signature.instantiation(),
builder.db(),
),
opd_hir_expr_idx: opd_sem_expr_idx.to_hir_lazy(builder),
opd_hir_expr_idx: opd.to_hir_lazy(builder),
},
SemExprData::Unwrap {
opd_sem_expr_idx, ..
opd: opd_sem_expr_idx,
..
} => HirLazyExprData::Unwrap {
opd_hir_expr_idx: opd_sem_expr_idx.to_hir_lazy(builder),
},
SemExprData::FunctionApplication {
function_sem_expr_idx: _,
argument_sem_expr_idx: _,
function: _,
argument: _,
} => {
todo!()
}
SemExprData::FunctionRitchieCall {
function_sem_expr_idx,
function: function_sem_expr_idx,
ref ritchie_parameter_argument_matches,
..
} => {
Expand Down Expand Up @@ -317,7 +318,7 @@ impl ToHirLazy for SemExprIdx {
parameter_ty_items: _,
rpar_regional_token_idx: _,
light_arrow_token: _,
return_ty_sem_expr_idx: _,
return_ty: _,
} => todo!(),
SemExprData::Field {
self_argument: owner,
Expand Down Expand Up @@ -364,7 +365,7 @@ impl ToHirLazy for SemExprIdx {
todo!()
}
SemExprData::MethodFnCall {
self_argument_sem_expr_idx,
self_argument: self_argument_sem_expr_idx,
ident_token,
ref dispatch,
ref ritchie_parameter_argument_matches,
Expand Down
26 changes: 13 additions & 13 deletions crates/semantics/husky-sem-expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,24 @@ pub enum SemExprData {
opr_regional_token_idx: RegionalTokenIdx,
},
Unveil {
opd_sem_expr_idx: SemExprIdx,
opd: SemExprIdx,
opr_regional_token_idx: RegionalTokenIdx,
unveil_output_ty_signature: TraitForTypeAssocTypeEtherealSignature,
unveil_assoc_fn_path: TraitForTypeItemPath,
return_ty: EthTerm,
},
Unwrap {
opd_sem_expr_idx: SemExprIdx,
opd: SemExprIdx,
opr_regional_token_idx: RegionalTokenIdx,
// unwrap_method_path: TraitForTypeItemPath,
// instantiation: FlyInstantiation,
},
FunctionApplication {
function_sem_expr_idx: SemExprIdx,
argument_sem_expr_idx: SemExprIdx,
function: SemExprIdx,
argument: SemExprIdx,
},
FunctionRitchieCall {
function_sem_expr_idx: SemExprIdx,
function: SemExprIdx,
ritchie_ty_kind: RitchieTypeKind,
template_arguments: Option<SemaTemplateArgumentList>,
lpar_regional_token_idx: RegionalTokenIdx,
Expand All @@ -192,7 +192,7 @@ pub enum SemExprData {
light_arrow_token: Option<LightArrowRegionalToken>,
/// it's guaranteed that `return_ty_expr` is some if and only if
/// `light_arrow_token` is some
return_ty_sem_expr_idx: Option<SemExprIdx>,
return_ty: Option<SemExprIdx>,
},
Field {
self_argument: SemExprIdx,
Expand All @@ -211,7 +211,7 @@ pub enum SemExprData {
rpar_regional_token_idx: RegionalTokenIdx,
},
MethodFnCall {
self_argument_sem_expr_idx: SemExprIdx,
self_argument: SemExprIdx,
self_contract: Contract,
dot_regional_token_idx: RegionalTokenIdx,
ident_token: IdentRegionalToken,
Expand All @@ -223,7 +223,7 @@ pub enum SemExprData {
rpar_regional_token_idx: RegionalTokenIdx,
},
MethodGnCall {
self_argument_sem_expr_idx: SemExprIdx,
self_argument: SemExprIdx,
dot_regional_token_idx: RegionalTokenIdx,
ident_token: IdentRegionalToken,
method_dynamic_dispatch: FlyMethodDynamicDispatch,
Expand Down Expand Up @@ -1280,7 +1280,7 @@ impl<'a> SemExprBuilder<'a> {
parameter_ty_items,
rpar_regional_token_idx,
light_arrow_token,
return_ty_sem_expr_idx,
return_ty: return_ty_sem_expr_idx,
}),
Ok(self.term_menu().ty0().into()),
)
Expand Down Expand Up @@ -1536,8 +1536,8 @@ impl<'a> SemExprBuilder<'a> {
SemExprData::Unveil { .. } => todo!(),
SemExprData::Unwrap { .. } => todo!(),
SemExprData::FunctionApplication {
function_sem_expr_idx,
argument_sem_expr_idx,
function: function_sem_expr_idx,
argument: argument_sem_expr_idx,
} => {
// todo: implicit arguments
self.calc_explicit_application_expr_term(
Expand Down Expand Up @@ -1610,7 +1610,7 @@ impl<'a> SemExprBuilder<'a> {
SemExprData::Ritchie {
ritchie_kind,
ref parameter_ty_items,
return_ty_sem_expr_idx,
return_ty: return_ty_sem_expr_idx,
..
} => {
let mut params: Vec<FlyRitchieParameter> = vec![];
Expand Down Expand Up @@ -1672,7 +1672,7 @@ impl<'a> SemExprBuilder<'a> {
ref parameter_ty_items,
rpar_regional_token_idx,
light_arrow_token,
return_ty_sem_expr_idx,
return_ty: return_ty_sem_expr_idx,
} => todo!(),
SemExprData::NestedBlock {
lcurl_regional_token_idx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ impl<'a> SemExprBuilder<'a> {
);
(
Ok(SemExprData::FunctionApplication {
function_sem_expr_idx,
argument_sem_expr_idx,
function: function_sem_expr_idx,
argument: argument_sem_expr_idx,
}),
ty_result,
)
Expand All @@ -49,8 +49,8 @@ impl<'a> SemExprBuilder<'a> {
self.build_sem_expr(argument_syn_expr_idx, ExpectAnyDerived);
(
Ok(SemExprData::FunctionApplication {
function_sem_expr_idx,
argument_sem_expr_idx,
function: function_sem_expr_idx,
argument: argument_sem_expr_idx,
}),
Err(OriginalSemExprTypeError::ExpectedCurryButGotRitchieInstead.into()),
)
Expand Down
8 changes: 4 additions & 4 deletions crates/semantics/husky-sem-expr/src/expr/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'a> SemExprBuilder<'a> {
};
(
Ok(SemExprData::FunctionRitchieCall {
function_sem_expr_idx,
function: function_sem_expr_idx,
ritchie_ty_kind,
template_arguments: template_arguments.map(|_| todo!()),
lpar_regional_token_idx,
Expand Down Expand Up @@ -79,8 +79,8 @@ impl<'a> SemExprBuilder<'a> {
};
(
Ok(SemExprData::FunctionApplication {
function_sem_expr_idx,
argument_sem_expr_idx,
function: function_sem_expr_idx,
argument: argument_sem_expr_idx,
}),
Ok(return_ty),
)
Expand Down Expand Up @@ -124,7 +124,7 @@ impl<'a> SemExprBuilder<'a> {
let ritchie_ty_kind = function_expectation_outcome.ritchie_ty_kind();
let return_ty = function_expectation_outcome.return_ty();
let data = SemExprData::FunctionRitchieCall {
function_sem_expr_idx,
function: function_sem_expr_idx,
ritchie_ty_kind,
template_arguments: template_arguments.map(|_| todo!()),
lpar_regional_token_idx,
Expand Down
2 changes: 1 addition & 1 deletion crates/semantics/husky-sem-expr/src/expr/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<'a> SemExprBuilder<'a> {
};
(
Ok(SemExprData::MethodFnCall {
self_argument_sem_expr_idx,
self_argument: self_argument_sem_expr_idx,
self_contract: signature.self_value_parameter.contract,
dot_regional_token_idx,
ident_token,
Expand Down
4 changes: 2 additions & 2 deletions crates/semantics/husky-sem-expr/src/expr/suffix/unveil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a> SemExprBuilder<'a> {
);
(
Ok(SemExprData::Unveil {
opd_sem_expr_idx,
opd: opd_sem_expr_idx,
opr_regional_token_idx,
unveil_output_ty_signature,
unveil_assoc_fn_path,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl<'a> SemExprBuilder<'a> {
let ty_term = unveil_output_ty_signature.ty_term().into();
(
Ok(SemExprData::Unveil {
opd_sem_expr_idx,
opd: opd_sem_expr_idx,
opr_regional_token_idx,
unveil_assoc_fn_path: unveil_assoc_fn_path(
&unveil_output_ty_signature,
Expand Down
2 changes: 1 addition & 1 deletion crates/semantics/husky-sem-expr/src/expr/suffix/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'a> SemExprBuilder<'a> {
} => match refined_ty_path {
Left(PreludeTypePath::Option | PreludeTypePath::Result) => (
Ok(SemExprData::Unwrap {
opd_sem_expr_idx,
opd: opd_sem_expr_idx,
opr_regional_token_idx,
// unwrap_method_path: todo!(),
// instantiation: todo!(),
Expand Down
1 change: 1 addition & 0 deletions crates/semantics/husky-sem-expr/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ pub mod analysis;
pub mod codespan;
pub mod range;
pub mod region;
pub mod visitor;

use crate::*;
14 changes: 7 additions & 7 deletions crates/semantics/husky-sem-expr/src/helpers/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,22 +386,22 @@ impl<'a> SemExprRangeCalculator<'a> {
..
}
| SemExprData::Unveil {
opd_sem_expr_idx,
opd: opd_sem_expr_idx,
opr_regional_token_idx,
..
}
| SemExprData::Unwrap {
opd_sem_expr_idx,
opd: opd_sem_expr_idx,
opr_regional_token_idx,
..
} => self[opd_sem_expr_idx]
.to(RegionalTokenIdxRangeEnd::new_after(*opr_regional_token_idx)),
SemExprData::FunctionApplication {
function_sem_expr_idx,
argument_sem_expr_idx,
function: function_sem_expr_idx,
argument: argument_sem_expr_idx,
} => self[function_sem_expr_idx].join(self[argument_sem_expr_idx]),
SemExprData::FunctionRitchieCall {
function_sem_expr_idx,
function: function_sem_expr_idx,
rpar_regional_token_idx,
..
} => self[function_sem_expr_idx].to(RegionalTokenIdxRangeEnd::new_after(
Expand All @@ -413,7 +413,7 @@ impl<'a> SemExprRangeCalculator<'a> {
..
} => todo!(),
SemExprData::MethodFnCall {
self_argument_sem_expr_idx,
self_argument: self_argument_sem_expr_idx,
rpar_regional_token_idx,
..
} => self[self_argument_sem_expr_idx].to(RegionalTokenIdxRangeEnd::new_after(
Expand Down Expand Up @@ -496,7 +496,7 @@ impl<'a> SemExprRangeCalculator<'a> {
SemExprData::Ritchie {
ritchie_kind_regional_token_idx,
rpar_regional_token_idx,
return_ty_sem_expr_idx: return_ty_expr,
return_ty: return_ty_expr,
..
} => match return_ty_expr {
Some(return_ty_expr) => RegionalTokenIdxRange::new(
Expand Down
Loading

0 comments on commit 5f93247

Please sign in to comment.