22 lines
832 B
Rust
22 lines
832 B
Rust
use crate::semantic_analysis::analysis_context::AnalysisContext;
|
|
use crate::semantic_analysis::type_info::TypeInfo;
|
|
|
|
pub fn get_name_for_type<'ctx>(type_info: &TypeInfo, ctx: &'ctx AnalysisContext) -> &'ctx str {
|
|
match type_info {
|
|
TypeInfo::Any => "Any",
|
|
TypeInfo::Function(_function_type_info) => {
|
|
todo!()
|
|
}
|
|
TypeInfo::Instance(instance_type_info) => {
|
|
let class_symbol_id = instance_type_info.class_symbol_id();
|
|
let class_symbol = &ctx.symbols()[class_symbol_id];
|
|
class_symbol.declared_name()
|
|
}
|
|
TypeInfo::String => "String",
|
|
TypeInfo::Int => "Int",
|
|
TypeInfo::Double => "Double",
|
|
TypeInfo::Void => "Void",
|
|
TypeInfo::__Error => panic!("TypeInfo::__Error should never be shown to the user."),
|
|
}
|
|
}
|