pub struct TypedExpr {
pub kind: TypedExprKind,
pub resolved_type: ResolvedType,
pub span: Span,
}Expand description
A type-checked expression with resolved type information.
This struct represents an expression that has been validated by the type checker. It contains the expression kind, the resolved type, and the source span for error reporting.
§Examples
use alopex_sql::planner::typed_expr::{TypedExpr, TypedExprKind};
use alopex_sql::planner::types::ResolvedType;
use alopex_sql::ast::expr::Literal;
use alopex_sql::Span;
let expr = TypedExpr {
kind: TypedExprKind::Literal(Literal::Number("42".to_string())),
resolved_type: ResolvedType::Integer,
span: Span::default(),
};Fields§
§kind: TypedExprKindThe kind of expression.
resolved_type: ResolvedTypeThe resolved type of this expression.
span: SpanSource span for error reporting.
Implementations§
Source§impl TypedExpr
impl TypedExpr
Sourcepub fn new(kind: TypedExprKind, resolved_type: ResolvedType, span: Span) -> Self
pub fn new(kind: TypedExprKind, resolved_type: ResolvedType, span: Span) -> Self
Creates a new typed expression.
Sourcepub fn literal(lit: Literal, resolved_type: ResolvedType, span: Span) -> Self
pub fn literal(lit: Literal, resolved_type: ResolvedType, span: Span) -> Self
Creates a typed literal expression.
Sourcepub fn column_ref(
table: String,
column: String,
column_index: usize,
resolved_type: ResolvedType,
span: Span,
) -> Self
pub fn column_ref( table: String, column: String, column_index: usize, resolved_type: ResolvedType, span: Span, ) -> Self
Creates a typed column reference.
Sourcepub fn binary_op(
left: TypedExpr,
op: BinaryOp,
right: TypedExpr,
resolved_type: ResolvedType,
span: Span,
) -> Self
pub fn binary_op( left: TypedExpr, op: BinaryOp, right: TypedExpr, resolved_type: ResolvedType, span: Span, ) -> Self
Creates a typed binary operation.
Sourcepub fn unary_op(
op: UnaryOp,
operand: TypedExpr,
resolved_type: ResolvedType,
span: Span,
) -> Self
pub fn unary_op( op: UnaryOp, operand: TypedExpr, resolved_type: ResolvedType, span: Span, ) -> Self
Creates a typed unary operation.
Sourcepub fn function_call(
name: String,
args: Vec<TypedExpr>,
resolved_type: ResolvedType,
span: Span,
) -> Self
pub fn function_call( name: String, args: Vec<TypedExpr>, resolved_type: ResolvedType, span: Span, ) -> Self
Creates a typed function call.
Sourcepub fn cast(expr: TypedExpr, target_type: ResolvedType, span: Span) -> Self
pub fn cast(expr: TypedExpr, target_type: ResolvedType, span: Span) -> Self
Creates a typed cast expression.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypedExpr
impl RefUnwindSafe for TypedExpr
impl Send for TypedExpr
impl Sync for TypedExpr
impl Unpin for TypedExpr
impl UnwindSafe for TypedExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more