Skip to content

Commit f771d53

Browse files
committed
Rename Type::Unit to Type::Nominal (closes #38)
1 parent b7f1154 commit f771d53

12 files changed

Lines changed: 50 additions & 50 deletions

File tree

src/lir/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl Env {
357357
return Some(ty);
358358
}
359359
}
360-
if let Type::Unit(_, inner_ty) = ty {
360+
if let Type::Nominal(_, inner_ty) = ty {
361361
if let Some(ty) = self.get_type_of_associated_const(inner_ty, name) {
362362
return Some(ty);
363363
}
@@ -481,7 +481,7 @@ impl Env {
481481
return Some((constant, const_ty));
482482
}
483483
}
484-
if let Type::Unit(_unit_name, inner_ty) = ty {
484+
if let Type::Nominal(_unit_name, inner_ty) = ty {
485485
if let Some((constant, const_ty)) = self.get_associated_const(inner_ty, name) {
486486
// Memoize the associated constant.
487487
let expr_ty = constant.get_type(self).ok()?;

src/lir/expr/const_expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl GetType for ConstExpr {
639639
// Get the type of the value to get the member of.
640640
let val_type = val_type.simplify_until_concrete(env, false)?;
641641
match &val_type {
642-
Type::Unit(_unit_name, inner_ty) => {
642+
Type::Nominal(_unit_name, inner_ty) => {
643643
// Get the type of the field.
644644
env.get_type_of_associated_const(inner_ty, &as_symbol?)
645645
.ok_or(Error::MemberNotFound((*val.clone()).into(), *field.clone()))?

src/lir/expr/ops/arithmetic/addition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Add {
4949
(Type::Tuple(elems1), Type::Tuple(elems2)) => {
5050
Ok(Type::Tuple(elems1.into_iter().chain(elems2).collect()))
5151
}
52-
(Type::Unit(_, a), b) => self.return_type_from_types(&b, &a, env),
52+
(Type::Nominal(_, a), b) => self.return_type_from_types(&b, &a, env),
5353
_ => Err(Error::InvalidBinaryOpTypes(
5454
self.clone_box(),
5555
lhs.clone(),
@@ -110,10 +110,10 @@ impl BinaryOp for Add {
110110
output: &mut dyn AssemblyProgram,
111111
) -> Result<(), Error> {
112112
match (lhs.clone().simplify(env)?, rhs.clone().simplify(env)?) {
113-
(Type::Unit(_, a), b) => {
113+
(Type::Nominal(_, a), b) => {
114114
self.compile_types(&a, &b, env, output)?;
115115
}
116-
(a, Type::Unit(_, b)) => {
116+
(a, Type::Nominal(_, b)) => {
117117
self.compile_types(&a, &b, env, output)?;
118118
}
119119
(Type::Int, Type::Int)

src/lir/expr/ops/arithmetic/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl BinaryOp for Arithmetic {
151151
output.op(core_op);
152152
}
153153

154-
(Type::Unit(_name1, a_type), Type::Unit(_name2, b_type)) => {
154+
(Type::Nominal(_name1, a_type), Type::Nominal(_name2, b_type)) => {
155155
return self.compile_types(a_type, b_type, env, output);
156156
}
157157

@@ -182,7 +182,7 @@ impl BinaryOp for Arithmetic {
182182

183183
(Type::Int | Type::Float | Type::Cell, Type::Cell)
184184
| (Type::Cell, Type::Int | Type::Float) => Ok(true),
185-
(Type::Unit(name1, a_type), Type::Unit(name2, b_type)) => {
185+
(Type::Nominal(name1, a_type), Type::Nominal(name2, b_type)) => {
186186
// Make sure that the two units are the same.
187187
if name1 != name2 {
188188
return Ok(false);
@@ -261,7 +261,7 @@ impl BinaryOp for Arithmetic {
261261
// ));
262262
// }
263263
// }
264-
(Type::Unit(name1, a_type), Type::Unit(name2, b_type)) => {
264+
(Type::Nominal(name1, a_type), Type::Nominal(name2, b_type)) => {
265265
// Make sure that the two units are the same.
266266
if name1 != name2 {
267267
error!("{name1} is not {name2}");
@@ -282,7 +282,7 @@ impl BinaryOp for Arithmetic {
282282
));
283283
}
284284

285-
Type::Unit(name1, a_type)
285+
Type::Nominal(name1, a_type)
286286
}
287287
(a, b) => {
288288
error!("Unhandled case {a} {self} {b}");

src/lir/expr/ops/comparison.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl BinaryOp for Comparison {
4141
| (Type::Float, Self::GreaterThan, Type::Int)
4242
| (Type::Float, Self::GreaterThan, Type::Float) => Ok(true),
4343

44-
(Type::Unit(name1, a_type), _, Type::Unit(name2, b_type)) => {
44+
(Type::Nominal(name1, a_type), _, Type::Nominal(name2, b_type)) => {
4545
// Make sure that the two units are the same.
4646
if name1 != name2 {
4747
error!("Cannot apply {self} to {lhs} and {lhs}");
@@ -230,7 +230,7 @@ impl BinaryOp for Comparison {
230230
output.op(core_op);
231231
}
232232

233-
(Type::Unit(_name1, a_type), _, Type::Unit(_name2, b_type)) => {
233+
(Type::Nominal(_name1, a_type), _, Type::Nominal(_name2, b_type)) => {
234234
return self.compile_types(a_type, b_type, env, output);
235235
}
236236

src/lir/expr/ops/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl Put {
338338
}
339339
}
340340

341-
Type::Unit(_name, ty) => {
341+
Type::Nominal(_name, ty) => {
342342
Self::debug(addr, ty, env, output)?;
343343
// for ch in format!(" ({})", name).chars() {
344344
// output.op(CoreOp::Set(A, ch as u8 as i64));

src/lir/expr/procedure/poly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl TypeCheck for PolyProcedure {
248248
new_env.define_type(name, ty.clone());
249249
}
250250
None => {
251-
new_env.define_type(name, Type::Unit(name.clone(), Box::new(Type::None)));
251+
new_env.define_type(name, Type::Nominal(name.clone(), Box::new(Type::None)));
252252
}
253253
}
254254
}

src/lir/types/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl TypeCheck for Type {
4444
Self::Type(t) => t.type_check(env),
4545

4646
// Units are sound if their inner type is sound.
47-
Self::Unit(_unit_name, t) => t.type_check(env),
47+
Self::Nominal(_unit_name, t) => t.type_check(env),
4848

4949
// Symbols are sound if they are defined in the environment
5050
Self::Symbol(name) => {
@@ -135,7 +135,7 @@ impl TypeCheck for Type {
135135
ty_params
136136
.clone()
137137
.into_iter()
138-
.map(|p| (p.0.clone(), Type::Unit(p.0, Box::new(Type::Any))))
138+
.map(|p| (p.0.clone(), Type::Nominal(p.0, Box::new(Type::Any))))
139139
.collect(),
140140
);
141141
// Check the template type.
@@ -950,7 +950,7 @@ impl TypeCheck for ConstExpr {
950950
new_env.define_type(name, ty.clone());
951951
new_env.define_var(name, Mutability::Immutable, ty.clone(), false)?;
952952
} else {
953-
new_env.define_type(name, Type::Unit(name.clone(), Box::new(Type::None)))
953+
new_env.define_type(name, Type::Nominal(name.clone(), Box::new(Type::None)))
954954
}
955955
}
956956
// Check the template type.

src/lir/types/inference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl GetType for Expr {
315315
env.get_type_of_associated_const(&ty, &as_symbol?)
316316
.ok_or(Error::MemberNotFound(*val.clone(), field.clone()))?
317317
}
318-
Type::Unit(_unit_name, inner_ty) => {
318+
Type::Nominal(_unit_name, inner_ty) => {
319319
// Get the associated constant expression's type.
320320
env.get_type_of_associated_const(&inner_ty, &as_symbol?)
321321
.ok_or(Error::MemberNotFound(*val.clone(), field.clone()))?

0 commit comments

Comments
 (0)