From 581f371dcc50ba843f9094ce4df90a1656886037 Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Sat, 14 Dec 2024 22:33:39 -0600 Subject: [PATCH] Refactored trait methods AST representation to be included in trait AST --- src/ast/traits.rs | 11 ++++++++++- src/parser/parse_trait.rs | 11 ++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ast/traits.rs b/src/ast/traits.rs index 5cecba5b..fd0b7df1 100644 --- a/src/ast/traits.rs +++ b/src/ast/traits.rs @@ -1,4 +1,4 @@ -use super::Privacy; +use super::{Parameters, Privacy, Type}; use crate::source_files::Source; #[derive(Clone, Debug)] @@ -6,4 +6,13 @@ pub struct Trait { pub name: String, pub source: Source, pub privacy: Privacy, + pub methods: Vec, +} + +#[derive(Clone, Debug)] +pub struct TraitMethod { + pub name: String, + pub parameters: Parameters, + pub return_type: Type, + pub source: Source, } diff --git a/src/parser/parse_trait.rs b/src/parser/parse_trait.rs index 1e202793..47f993b8 100644 --- a/src/parser/parse_trait.rs +++ b/src/parser/parse_trait.rs @@ -4,19 +4,11 @@ use super::{ Parser, }; use crate::{ - ast::{Parameters, Privacy, Trait, Type}, + ast::{Parameters, Privacy, Trait, TraitMethod}, inflow::Inflow, - source_files::Source, token::{Token, TokenKind}, }; -pub struct TraitMethod { - pub name: String, - pub parameters: Parameters, - pub return_type: Type, - pub source: Source, -} - impl<'a, I: Inflow> Parser<'a, I> { pub fn parse_trait(&mut self, annotations: Vec) -> Result { let source = self.source_here(); @@ -51,6 +43,7 @@ impl<'a, I: Inflow> Parser<'a, I> { name, source, privacy, + methods, }) }