-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
232 additions
and
168 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use super::{AsCodeType, KotlinCodeOracle}; | ||
use crate::backend::CodeType; | ||
use crate::interface::Variant; | ||
|
||
#[derive(Debug)] | ||
pub(super) struct VariantCodeType { | ||
pub v: Variant, | ||
} | ||
|
||
impl CodeType for VariantCodeType { | ||
fn type_label(&self) -> String { | ||
KotlinCodeOracle.class_name(self.v.name()) | ||
} | ||
|
||
fn variant_label(&self) -> String { | ||
KotlinCodeOracle.enum_variant_name(self.v.name()) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
unreachable!(); | ||
} | ||
} | ||
|
||
impl AsCodeType for Variant { | ||
fn as_codetype(&self) -> Box<dyn CodeType> { | ||
Box::new(VariantCodeType { v: self.clone() }) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(super) struct ErrorVariantCodeType { | ||
pub v: Variant, | ||
} | ||
|
||
impl CodeType for ErrorVariantCodeType { | ||
fn type_label(&self) -> String { | ||
KotlinCodeOracle.error_name(self.v.name()) | ||
} | ||
|
||
fn variant_label(&self) -> String { | ||
KotlinCodeOracle.enum_variant_name(self.v.name()) | ||
} | ||
|
||
fn canonical_name(&self) -> String { | ||
unreachable!(); | ||
} | ||
} | ||
|
||
pub(super) struct ErrorVariantCodeTypeProvider { | ||
pub v: Variant, | ||
} | ||
|
||
impl AsCodeType for ErrorVariantCodeTypeProvider { | ||
fn as_codetype(&self) -> Box<dyn CodeType> { | ||
Box::new(ErrorVariantCodeType { v: self.v.clone() }) | ||
} | ||
} |
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
Oops, something went wrong.