Skip to content

Commit 548095d

Browse files
committed
Move Symbol to common
We want to use the same definition in the fast interpreter.
1 parent 6779542 commit 548095d

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

nib-core/src/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66

77
use anyhow::anyhow;
88
use thiserror::Error;
9+
use internment::Intern;
910

1011
#[derive(Debug, Clone, PartialEq)]
1112
pub struct Metadata {
@@ -190,3 +191,5 @@ impl Display for Name {
190191
pub fn align_int(value: usize, alignment: usize) -> usize {
191192
(value + (alignment - 1)) & !(alignment - 1)
192193
}
194+
195+
pub type Symbol = Intern<String>;

nib-core/src/treewalker.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ use libffi::middle::{Cif, CodePtr};
1515

1616
use crate::{
1717
common::{Error, Metadata, Name, Result},
18-
core::{Arity, Lambda, desugar, desugar_expression},
18+
core::{desugar, desugar_expression, Arity, Lambda},
1919
parser::{parse_declarations, parse_expression},
2020
treewalker::evaluate::Environment,
2121
};
22+
use crate::common::Symbol;
2223

2324
mod evaluate;
2425
mod foreign;
2526
mod prims;
2627
mod tests;
2728

28-
type Symbol = Intern<String>;
29-
3029
#[derive(Debug, Clone)]
3130
pub struct Runtime {
3231
metadata: HashMap<String, Metadata>,

nib-core/src/treewalker/evaluate.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ use log::info;
1010
use crate::{
1111
ast::Literal,
1212
common::{Name, Result},
13-
core::{Arity, Binder, Binding, Expression, Lambda, Module, free_vars},
14-
treewalker::{CType, Closure, Code, Runtime, Symbol, Value, new_ref},
13+
core::{free_vars, Arity, Binder, Binding, Expression, Lambda, Module},
14+
treewalker::{new_ref, CType, Closure, Code, Runtime, Value},
1515
};
16+
use crate::common::Symbol;
1617

1718
impl Runtime {
1819
pub(super) fn evaluate(&mut self, code: &mut Module, env: &mut Environment) -> Result<()> {

nib-core/src/treewalker/prims.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::ops::{Shl, Shr};
22
use std::os::raw::c_void;
33

4-
use crate::common::{Error, Name, Result};
4+
use crate::common::{Error, Name, Result, Symbol};
55
use crate::core::Arity;
6-
use crate::treewalker::{Runtime, Symbol, Value};
6+
use crate::treewalker::{Runtime, Value};
77

88
impl Runtime {
99
pub(super) fn register_primitives(&mut self) -> Result<()> {

0 commit comments

Comments
 (0)