diff --git a/src/protocol/ast_printer.rs b/src/protocol/ast_printer.rs index 73f14dfd7e8a3552f0106030101aff683ceca2d6..a64b56f724bf3f8e7ccf788fa9e740f5628db24e 100644 --- a/src/protocol/ast_printer.rs +++ b/src/protocol/ast_printer.rs @@ -345,7 +345,7 @@ impl ASTWriter { } } } - Definition::Function(def) => { + Definition::Procedure(def) => { self.kv(indent).with_id(PREFIX_FUNCTION_ID, def.this.0.index) .with_s_key("DefinitionFunction"); @@ -354,8 +354,11 @@ impl ASTWriter { self.kv(indent3).with_s_key("PolyVar").with_identifier_val(&poly_var_id); } - self.kv(indent2).with_s_key("ReturnParserType") - .with_custom_val(|s| write_parser_type(s, heap, &def.return_type)); + self.kv(indent2).with_s_key("Kind").with_debug_val(&def.kind); + if let Some(parser_type) = &def.return_type { + self.kv(indent2).with_s_key("ReturnParserType") + .with_custom_val(|s| write_parser_type(s, heap, parser_type)); + } self.kv(indent2).with_s_key("Parameters"); for variable_id in &def.parameters { @@ -365,26 +368,6 @@ impl ASTWriter { self.kv(indent2).with_s_key("Body"); self.write_stmt(heap, def.body.upcast(), indent3); }, - Definition::Component(def) => { - self.kv(indent).with_id(PREFIX_COMPONENT_ID,def.this.0.index) - .with_s_key("DefinitionComponent"); - - self.kv(indent2).with_s_key("Name").with_identifier_val(&def.identifier); - self.kv(indent2).with_s_key("Variant").with_debug_val(&def.variant); - - self.kv(indent2).with_s_key("PolymorphicVariables"); - for poly_var_id in &def.poly_vars { - self.kv(indent3).with_s_key("PolyVar").with_identifier_val(&poly_var_id); - } - - self.kv(indent2).with_s_key("Parameters"); - for variable_id in &def.parameters { - self.write_variable(heap, *variable_id, indent3) - } - - self.kv(indent2).with_s_key("Body"); - self.write_stmt(heap, def.body.upcast(), indent3); - } } } @@ -782,19 +765,11 @@ impl ASTWriter { .with_s_key("CallExpr"); self.kv(indent2).with_s_key("UniqueId").with_disp_val(&expr.unique_id_in_definition); - let definition = &heap[expr.definition]; - match definition { - Definition::Component(definition) => { - self.kv(indent2).with_s_key("BuiltIn").with_disp_val(&false); - self.kv(indent2).with_s_key("Variant").with_debug_val(&definition.variant); - }, - Definition::Function(definition) => { - self.kv(indent2).with_s_key("BuiltIn").with_disp_val(&definition.builtin); - self.kv(indent2).with_s_key("Variant").with_s_val("Function"); - }, - _ => unreachable!() - } - self.kv(indent2).with_s_key("MethodName").with_identifier_val(definition.identifier()); + + let definition = &heap[expr.procedure]; + self.kv(indent2).with_s_key("BuiltIn").with_disp_val(&false); + self.kv(indent2).with_s_key("Variant").with_debug_val(&definition.kind); + self.kv(indent2).with_s_key("MethodName").with_identifier_val(&definition.identifier); self.kv(indent2).with_s_key("ParserType") .with_custom_val(|t| write_parser_type(t, heap, &expr.parser_type));