summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 23:30:31 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 23:30:31 +0200
commitf8c5dc596ca58bb02d60f35984a78e6f962820c9 (patch)
treeff7c2e8e431174ecfe680ed8a61f748b3ee66127
parent8e19452f3271e9c746ad00b1b93b8b3b1f687e4c (diff)
downloadrebel-f8c5dc596ca58bb02d60f35984a78e6f962820c9.tar
rebel-f8c5dc596ca58bb02d60f35984a78e6f962820c9.zip
rebel-lang: typing: change function names for expr types
Be explicit about that these functions handle types of AST expressions, rather than an explicit type specification.
-rw-r--r--crates/rebel-lang/src/typing.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/crates/rebel-lang/src/typing.rs b/crates/rebel-lang/src/typing.rs
index 6d8ee8b..eaf30bc 100644
--- a/crates/rebel-lang/src/typing.rs
+++ b/crates/rebel-lang/src/typing.rs
@@ -96,23 +96,23 @@ impl Type {
use ast::Expr::*;
Ok(match expr {
- Binary { left, op, right } => Self::binary_op_type(ctx, left, *op, right)?,
- Unary { op, expr } => Self::unary_op_type(ctx, *op, expr)?,
- Apply { expr, params } => Self::apply_type(ctx, expr, params)?,
+ Binary { left, op, right } => Self::binary_op_expr_type(ctx, left, *op, right)?,
+ Unary { op, expr } => Self::unary_op_expr_type(ctx, *op, expr)?,
+ Apply { expr, params } => Self::apply_expr_type(ctx, expr, params)?,
Method {
expr,
method,
params,
- } => Self::method_type(ctx, expr, method, params)?,
- Index { expr, index } => Self::index_type(ctx, expr, index)?,
- Field { expr, field } => Self::field_type(ctx, expr, field)?,
+ } => Self::method_expr_type(ctx, expr, method, params)?,
+ Index { expr, index } => Self::index_expr_type(ctx, expr, index)?,
+ Field { expr, field } => Self::field_expr_type(ctx, expr, field)?,
Paren(subexpr) => Self::ast_expr_type(ctx, subexpr)?,
- Path(path) => Self::path_type(ctx, path)?,
- Literal(lit) => Self::literal_type(ctx, lit)?,
+ Path(path) => Self::path_expr_type(ctx, path)?,
+ Literal(lit) => Self::literal_expr_type(ctx, lit)?,
})
}
- fn binary_op_type(
+ fn binary_op_expr_type(
ctx: &Context,
left: &ast::Expr<'_>,
op: ast::OpBinary,
@@ -161,7 +161,7 @@ impl Type {
})
}
- fn unary_op_type(ctx: &Context, op: ast::OpUnary, expr: &ast::Expr<'_>) -> Result<Type> {
+ fn unary_op_expr_type(ctx: &Context, op: ast::OpUnary, expr: &ast::Expr<'_>) -> Result<Type> {
use ast::OpUnary::*;
use Type::*;
@@ -174,7 +174,7 @@ impl Type {
})
}
- fn index_type(ctx: &Context, expr: &ast::Expr<'_>, index: &ast::Expr<'_>) -> Result<Type> {
+ fn index_expr_type(ctx: &Context, expr: &ast::Expr<'_>, index: &ast::Expr<'_>) -> Result<Type> {
use Type::*;
let expr_type = Self::ast_expr_type(ctx, expr)?;
@@ -189,7 +189,7 @@ impl Type {
Ok(*elem_type)
}
- fn apply_type(ctx: &Context, expr: &ast::Expr<'_>, params: &[ast::Expr]) -> Result<Type> {
+ fn apply_expr_type(ctx: &Context, expr: &ast::Expr<'_>, params: &[ast::Expr]) -> Result<Type> {
use Type::*;
let expr_type = Self::ast_expr_type(ctx, expr)?;
@@ -212,7 +212,7 @@ impl Type {
Ok(func.ret)
}
- fn method_type(
+ fn method_expr_type(
ctx: &Context,
expr: &ast::Expr<'_>,
method: &ast::Ident<'_>,
@@ -241,7 +241,11 @@ impl Type {
Ok(method.typ.ret.clone())
}
- fn field_type(ctx: &Context, expr: &ast::Expr<'_>, field: &ast::Ident<'_>) -> Result<Type> {
+ fn field_expr_type(
+ ctx: &Context,
+ expr: &ast::Expr<'_>,
+ field: &ast::Ident<'_>,
+ ) -> Result<Type> {
use Type::*;
let expr_type = Self::ast_expr_type(ctx, expr)?;
@@ -257,7 +261,7 @@ impl Type {
})
}
- fn path_type(ctx: &Context, path: &ast::Path<'_>) -> Result<Type> {
+ fn path_expr_type(ctx: &Context, path: &ast::Path<'_>) -> Result<Type> {
use Type::*;
if path.components == [ast::Ident { name: "_" }] {
@@ -286,7 +290,7 @@ impl Type {
}
}
- fn literal_type(ctx: &Context, lit: &ast::Literal<'_>) -> Result<Type> {
+ fn literal_expr_type(ctx: &Context, lit: &ast::Literal<'_>) -> Result<Type> {
use ast::Literal;
use Type::*;