-
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.
use new-type binding for identifiers
- Loading branch information
Showing
29 changed files
with
163 additions
and
556 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
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
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,23 @@ | ||
use std::hash::Hash; | ||
|
||
use crate::{ast_node, util::symbol_map::interner_symbol_map::Symbol}; | ||
use crate::ast_node; | ||
|
||
ast_node! { | ||
typed struct Ident<TyInfo> { | ||
name: Symbol, | ||
typed struct Ident<TyInfo, IdentIdentifier> { | ||
binding: IdentIdentifier, | ||
} | ||
} | ||
|
||
impl<TyInfo> Hash for Ident<TyInfo> { | ||
impl<TyInfo, IdentIdentifier: Hash> Hash for Ident<TyInfo, IdentIdentifier> { | ||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { | ||
self.name.hash(state); | ||
self.binding.hash(state); | ||
} | ||
} | ||
|
||
impl<TyInfo> PartialEq for Ident<TyInfo> { | ||
impl<TyInfo, IdentIdentifier: PartialEq> PartialEq for Ident<TyInfo, IdentIdentifier> { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.name == other.name | ||
self.binding == other.binding | ||
} | ||
} | ||
|
||
impl<TyInfo> Eq for Ident<TyInfo> {} | ||
impl<TyInfo, IdentIdentifier: Eq> Eq for Ident<TyInfo, IdentIdentifier> {} |
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
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
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
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
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 was deleted.
Oops, something went wrong.
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,3 +1,9 @@ | ||
mod function; | ||
use index_vec::define_index_type; | ||
|
||
pub use function::FunctionIdx; | ||
define_index_type! {pub struct FunctionIdx = usize;} | ||
define_index_type! {pub struct ScopeIdx = usize;} | ||
define_index_type! {pub struct BindingIdx = usize;} | ||
|
||
/// A binding within a specific scope. | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
pub struct ScopedBinding(pub ScopeIdx, pub BindingIdx); |
Oops, something went wrong.