-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2054 from fzyzcjy/feat/12190
Support `&dyn Trait`
- Loading branch information
Showing
155 changed files
with
19,987 additions
and
43,950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
frb_codegen/src/library/codegen/generator/codec/sse/encode_to_enum.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use itertools::Itertools; | ||
|
||
pub(super) fn generate_encode_to_enum(enum_name: &str, variants: &[VariantInfo]) -> String { | ||
let variants = (variants.iter()) | ||
.map(|variant| { | ||
format!( | ||
"if (self is {ty_name}) {{ | ||
return {enum_name}.{enum_variant_name}(self{extra_code}); | ||
}} | ||
", | ||
ty_name = variant.ty_name, | ||
enum_variant_name = variant.enum_variant_name, | ||
extra_code = variant.extra_code, | ||
) | ||
}) | ||
.join(""); | ||
|
||
format!( | ||
" | ||
(() {{ | ||
{variants} | ||
throw Exception('not reachable'); | ||
}})() | ||
" | ||
) | ||
} | ||
|
||
pub(crate) struct VariantInfo { | ||
pub enum_variant_name: String, | ||
pub ty_name: String, | ||
pub extra_code: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod encode_to_enum; | ||
pub(crate) mod lang; | ||
pub(crate) mod misc; | ||
pub(crate) mod ty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub(crate) mod pack; | ||
pub(crate) mod proxied_type; | ||
pub(crate) mod trait_def_info; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
use crate::codegen::ir::early_generator::proxied_type::IrEarlyGeneratorProxiedType; | ||
use crate::codegen::ir::early_generator::trait_def_info::IrEarlyGeneratorTraitDefInfo; | ||
use crate::codegen::ir::hir::flat::pack::HirFlatPack; | ||
use crate::codegen::ir::mir::ty::MirType; | ||
|
||
#[derive(Debug, Clone, Default, serde::Serialize)] | ||
pub(crate) struct IrEarlyGeneratorPack { | ||
pub hir_flat_pack: HirFlatPack, | ||
pub proxied_types: Vec<IrEarlyGeneratorProxiedType>, | ||
pub trait_def_infos: Vec<IrEarlyGeneratorTraitDefInfo>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
frb_codegen/src/library/codegen/ir/early_generator/trait_def_info.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use crate::codegen::ir::mir::ty::delegate::MirTypeDelegateDynTraitVariant; | ||
use crate::utils::namespace::{Namespace, NamespacedName}; | ||
|
||
#[derive(Debug, Clone, serde::Serialize, PartialEq, Eq, Hash)] | ||
pub(crate) struct IrEarlyGeneratorTraitDefInfo { | ||
pub trait_def_name: NamespacedName, | ||
pub delegate_namespace: Namespace, | ||
pub variants: Vec<MirTypeDelegateDynTraitVariant>, | ||
} |
Oops, something went wrong.