class Kaze::Resolver

Overview

The resolver. Resolves variable locations so that the interpreter can know exactly where a variable is, and what it is. Also checks for semantic errors like self-assignment in variable definitions and returns outside a function.

Included Modules

Defined in:

resolver.cr

Constructors

Instance Method Summary

Instance methods inherited from module Kaze::Stmt::Visitor

visit_block_stmt(stmt : Block) : VG visit_block_stmt, visit_break_stmt(stmt : Break) : VG visit_break_stmt, visit_class_stmt(stmt : Class) : VG visit_class_stmt, visit_expression_stmt(stmt : Expression) : VG visit_expression_stmt, visit_function_stmt(stmt : Function) : VG visit_function_stmt, visit_if_stmt(stmt : If) : VG visit_if_stmt, visit_return_stmt(stmt : Return) : VG visit_return_stmt, visit_var_stmt(stmt : Var) : VG visit_var_stmt, visit_while_stmt(stmt : While) : VG visit_while_stmt

Instance methods inherited from module Kaze::Expr::Visitor

visit_assign_expr(expr : Assign) : VG visit_assign_expr, visit_binary_expr(expr : Binary) : VG visit_binary_expr, visit_call_expr(expr : Call) : VG visit_call_expr, visit_get_expr(expr : Get) : VG visit_get_expr, visit_grouping_expr(expr : Grouping) : VG visit_grouping_expr, visit_lambda_expr(expr : Lambda) : VG visit_lambda_expr, visit_literal_expr(expr : Literal) : VG visit_literal_expr, visit_logical_expr(expr : Logical) : VG visit_logical_expr, visit_self_expr(expr : Self) : VG visit_self_expr, visit_set_expr(expr : Set) : VG visit_set_expr, visit_super_expr(expr : Super) : VG visit_super_expr, visit_ternary_expr(expr : Ternary) : VG visit_ternary_expr, visit_unary_expr(expr : Unary) : VG visit_unary_expr, visit_variable_expr(expr : Variable) : VG visit_variable_expr

Constructor Detail

def self.new(interpreter : Interpreter) #

[View source]

Instance Method Detail

def resolve(statements : Array(Stmt)) #

[View source]
def resolve(stmt : Stmt) #

[View source]
def resolve(expr : Expr) #

[View source]
def resolve(statement : Stmt | Expr | Nil) #

[View source]
def visit_assign_expr(expr : Expr::Assign) : Nil #

[View source]
def visit_binary_expr(expr : Expr::Binary) : Nil #

[View source]
def visit_block_stmt(stmt : Stmt::Block) : Nil #

[View source]
def visit_break_stmt(stmt : Stmt::Break) : Nil #

[View source]
def visit_call_expr(expr : Expr::Call) : Nil #

[View source]
def visit_class_stmt(stmt : Stmt::Class) : Nil #

[View source]
def visit_expression_stmt(stmt : Stmt::Expression) : Nil #

[View source]
def visit_function_stmt(stmt : Stmt::Function) : Nil #

[View source]
def visit_get_expr(expr : Expr::Get) : Nil #

[View source]
def visit_grouping_expr(expr : Expr::Grouping) : Nil #

[View source]
def visit_if_stmt(stmt : Stmt::If) : Nil #

[View source]
def visit_lambda_expr(expr : Expr::Lambda) : Nil #

[View source]
def visit_literal_expr(expr : Expr::Literal) : Nil #

[View source]
def visit_logical_expr(expr : Expr::Logical) : Nil #

[View source]
def visit_return_stmt(stmt : Stmt::Return) : Nil #

[View source]
def visit_self_expr(expr : Expr::Self) : Nil #

[View source]
def visit_set_expr(expr : Expr::Set) : Nil #

[View source]
def visit_super_expr(expr : Expr::Super) : Nil #

[View source]
def visit_ternary_expr(expr : Expr::Ternary) : Nil #

[View source]
def visit_unary_expr(expr : Expr::Unary) : Nil #

[View source]
def visit_var_stmt(stmt : Stmt::Var) : Nil #

The variable isn't resolved if it is named _. That is due to the _ variables not creating any variable definition. This is useful to evaluate expressions since Kaze doesn't support expression statements in most cases.


[View source]
def visit_variable_expr(expr : Expr::Variable) : Nil #

[View source]
def visit_while_stmt(stmt : Stmt::While) : Nil #

[View source]