-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create
AstMetadata
trait to reduce generics
- Loading branch information
Showing
32 changed files
with
369 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
use super::*; | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
ast_node! { | ||
typed struct Assign<TyInfo, FnIdentifier, IdentIdentifier> { | ||
binding: IdentIdentifier, | ||
value: Box<Expression<TyInfo, FnIdentifier, IdentIdentifier>>, | ||
ast_node2! { | ||
Assign<M> { | ||
binding: M::IdentIdentifier, | ||
value: Box<Expression<M>>, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
use super::*; | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
ast_node! { | ||
typed struct Block<TyInfo, FnIdentifier, IdentIdentifier> { | ||
statements: Vec<Statement<TyInfo, FnIdentifier, IdentIdentifier>>, | ||
ast_node2! { | ||
Block<M> { | ||
statements: Vec<Statement<M>>, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
ast_node! { | ||
typed struct Boolean<TyInfo> { | ||
ast_node2! { | ||
Boolean<M> { | ||
value: bool, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
use super::*; | ||
|
||
ast_node! { | ||
typed struct Call<TyInfo, FnIdentifier, IdentIdentifier> { | ||
name: FnIdentifier, | ||
args: Vec<Expression<TyInfo, FnIdentifier, IdentIdentifier>>, | ||
ast_node2! { | ||
Call<M> { | ||
name: M::FnIdentifier, | ||
args: Vec<Expression<M>>, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,23 +1,28 @@ | ||
use std::hash::Hash; | ||
|
||
use crate::ast_node; | ||
use crate::{ast_node2, repr::ast::base::AstMetadata}; | ||
|
||
ast_node! { | ||
typed struct Ident<TyInfo, IdentIdentifier> { | ||
binding: IdentIdentifier, | ||
ast_node2! { | ||
Ident<M> { | ||
binding: M::IdentIdentifier, | ||
span, | ||
ty_info, | ||
} | ||
} | ||
|
||
impl<TyInfo, IdentIdentifier: Hash> Hash for Ident<TyInfo, IdentIdentifier> { | ||
impl<M: AstMetadata<IdentIdentifier: Hash>> Hash for Ident<M> { | ||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { | ||
self.binding.hash(state); | ||
} | ||
} | ||
|
||
impl<TyInfo, IdentIdentifier: PartialEq> PartialEq for Ident<TyInfo, IdentIdentifier> { | ||
impl<M: AstMetadata<IdentIdentifier: PartialEq>> PartialEq for Ident<M> | ||
where | ||
M::IdentIdentifier: PartialEq, | ||
{ | ||
fn eq(&self, other: &Self) -> bool { | ||
self.binding == other.binding | ||
} | ||
} | ||
|
||
impl<TyInfo, IdentIdentifier: Eq> Eq for Ident<TyInfo, IdentIdentifier> {} | ||
impl<M: AstMetadata> Eq for Ident<M> where M::IdentIdentifier: Eq {} |
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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
use super::*; | ||
|
||
ast_node! { | ||
typed struct If<TyInfo, FnIdentifier, IdentIdentifier> { | ||
condition: Box<Expression<TyInfo, FnIdentifier, IdentIdentifier>>, | ||
success: Block<TyInfo, FnIdentifier, IdentIdentifier>, | ||
otherwise: Option<Block<TyInfo, FnIdentifier, IdentIdentifier>>, | ||
ast_node2! { | ||
If<M> { | ||
condition: Box<Expression<M>>, | ||
success: Block<M>, | ||
otherwise: Option<Block<M>>, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
ast_node! { | ||
typed struct Integer<TyInfo> { | ||
ast_node2! { | ||
Integer<M> { | ||
value: i64, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
use crate::ast_node; | ||
use crate::ast_node2; | ||
|
||
use super::*; | ||
|
||
ast_node! { | ||
typed struct Loop<TyInfo, FnIdentifier, IdentIdentifier> { | ||
body: Block<TyInfo, FnIdentifier, IdentIdentifier>, | ||
ast_node2! { | ||
Loop<M> { | ||
body: Block<M>, | ||
span, | ||
ty_info, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
use crate::{ast_node, repr::ty::Ty}; | ||
use crate::{ast_node2, repr::ty::Ty}; | ||
|
||
use super::*; | ||
|
||
ast_node! { | ||
struct Function<TyInfo, FnIdentifier, IdentIdentifier> { | ||
name: FnIdentifier, | ||
parameters: Vec<(IdentIdentifier, Ty)>, | ||
ast_node2! { | ||
Function<M> { | ||
name: M::FnIdentifier, | ||
parameters: Vec<(M::IdentIdentifier, Ty)>, | ||
return_ty: Ty, | ||
body: Block<TyInfo, FnIdentifier, IdentIdentifier>, | ||
body: Block<M>, | ||
span, | ||
} | ||
} |
Oops, something went wrong.