forked from M-Labs/nac3
[core] add attributes to class string
This commit is contained in:
parent
c15062ab4c
commit
4bd5349381
@ -379,21 +379,29 @@ pub fn make_exception_fields(int32: Type, int64: Type, str: Type) -> Vec<(StrRef
|
|||||||
impl TopLevelDef {
|
impl TopLevelDef {
|
||||||
pub fn to_string(&self, unifier: &mut Unifier) -> String {
|
pub fn to_string(&self, unifier: &mut Unifier) -> String {
|
||||||
match self {
|
match self {
|
||||||
TopLevelDef::Class { name, ancestors, fields, methods, type_vars, .. } => {
|
TopLevelDef::Class {
|
||||||
|
name, ancestors, fields, methods, attributes, type_vars, ..
|
||||||
|
} => {
|
||||||
let fields_str = fields
|
let fields_str = fields
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(n, ty, _)| (n.to_string(), unifier.stringify(*ty)))
|
.map(|(n, ty, _)| (n.to_string(), unifier.stringify(*ty)))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
|
let attributes_str = attributes
|
||||||
|
.iter()
|
||||||
|
.map(|(n, ty, _)| (n.to_string(), unifier.stringify(*ty)))
|
||||||
|
.collect_vec();
|
||||||
|
|
||||||
let methods_str = methods
|
let methods_str = methods
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(n, ty, id)| (n.to_string(), unifier.stringify(*ty), *id))
|
.map(|(n, ty, id)| (n.to_string(), unifier.stringify(*ty), *id))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
format!(
|
format!(
|
||||||
"Class {{\nname: {:?},\nancestors: {:?},\nfields: {:?},\nmethods: {:?},\ntype_vars: {:?}\n}}",
|
"Class {{\nname: {:?},\nancestors: {:?},\nfields: {:?},\nattributes: {:?},\nmethods: {:?},\ntype_vars: {:?}\n}}",
|
||||||
name,
|
name,
|
||||||
ancestors.iter().map(|ancestor| ancestor.stringify(unifier)).collect_vec(),
|
ancestors.iter().map(|ancestor| ancestor.stringify(unifier)).collect_vec(),
|
||||||
fields_str.iter().map(|(a, _)| a).collect_vec(),
|
fields_str.iter().map(|(a, _)| a).collect_vec(),
|
||||||
|
attributes_str.iter().map(|(a, _)| a).collect_vec(),
|
||||||
methods_str.iter().map(|(a, b, _)| (a, b)).collect_vec(),
|
methods_str.iter().map(|(a, b, _)| (a, b)).collect_vec(),
|
||||||
type_vars.iter().map(|id| unifier.stringify(*id)).collect_vec(),
|
type_vars.iter().map(|id| unifier.stringify(*id)).collect_vec(),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user