class Cosmo::Interpreter

Included Modules

Defined in:

cosmo/runtime/interpreter.cr

Constructors

Instance Method Summary

Instance methods inherited from module Cosmo::AST::Statement::Visitor(Cosmo::ValueType)

visit_block_stmt(stmt : Block) : R visit_block_stmt, visit_break_stmt(stmt : Break) : R visit_break_stmt, visit_case_stmt(stmt : Case) : R visit_case_stmt, visit_class_def_stmt(stmt : ClassDef) : R visit_class_def_stmt, visit_every_stmt(stmt : Every) : R visit_every_stmt, visit_fn_def_stmt(stmt : FunctionDef) : R visit_fn_def_stmt, visit_if_stmt(stmt : If) : R visit_if_stmt, visit_next_stmt(stmt : Next) : R visit_next_stmt, visit_return_stmt(stmt : Return) : R visit_return_stmt, visit_single_expr_stmt(stmt : SingleExpression) : R visit_single_expr_stmt, visit_throw_stmt(stmt : Throw) : R visit_throw_stmt, visit_try_catch_stmt(stmt : TryCatch) : R visit_try_catch_stmt, visit_unless_stmt(stmt : Unless) : R visit_unless_stmt, visit_until_stmt(stmt : Until) : R visit_until_stmt, visit_use_stmt(stmt : Use) : R visit_use_stmt, visit_while_stmt(stmt : While) : R visit_while_stmt

Instance methods inherited from module Cosmo::AST::Expression::Visitor(Cosmo::ValueType)

visit_binary_op_expr(expr : BinaryOp) : R visit_binary_op_expr, visit_cast_expr(expr : Cast) : R visit_cast_expr, visit_fn_call_expr(expr : FunctionCall) : R visit_fn_call_expr, visit_is_expr(expr : Is) : R visit_is_expr, visit_is_in_expr(expr : IsIn) : R visit_is_in_expr, visit_lambda_expr(expr : Lambda) : R visit_lambda_expr, visit_literal_expr(expr : Literal) : R visit_literal_expr, visit_multiple_assignment_expr(expr : MultipleAssignment) : R visit_multiple_assignment_expr, visit_property_assignment_expr(expr : PropertyAssignment) : R visit_property_assignment_expr, visit_range_literal_expr(expr : RangeLiteral) : R visit_range_literal_expr, visit_string_interpolation_expr(expr : StringInterpolation) : R visit_string_interpolation_expr, visit_table_literal_expr(expr : TableLiteral) : R visit_table_literal_expr, visit_ternary_op_expr(expr : TernaryOp) : R visit_ternary_op_expr, visit_this_expr(expr : This) : R visit_this_expr, visit_type_alias_expr(expr : TypeAlias) : R visit_type_alias_expr, visit_type_ref_expr(expr : TypeRef) : R visit_type_ref_expr, visit_unary_op_expr(expr : UnaryOp) : R visit_unary_op_expr, visit_var_assignment_expr(expr : VarAssignment) : R visit_var_assignment_expr, visit_var_declaration_expr(expr : VarDeclaration) : R visit_var_declaration_expr, visit_var_expr(expr : Var) : R visit_var_expr, visit_vector_literal_expr(expr : VectorLiteral) : R visit_vector_literal_expr

Constructor Detail

def self.new(output_ast : Bool, run_benchmarks : Bool) #

[View source]

Instance Method Detail

def add_object_value(token : Token, object : V, key : ValueType, value : ValueType) : V forall V #

[View source]
def call_meta_method(instance : ClassInstance, operand : ValueType, name : String, op_lexeme : String, op_token : Token, return_type_override : String | Nil = nil) : ValueType #

[View source]
def declare_intrinsic(type : String, ident : String, value : ValueType, visibility = Visibility::Public) : Nil #

[View source]
def delete_meta(key : String) : Nil #

[View source]
def end_recursion(level : UInt32 = 1) #

[View source]
def evaluate(expr : Expression::Base) : ValueType #

[View source]
def execute(stmt : Statement::Base) : ValueType #

[View source]
def execute_block(block : Statement::Base, block_scope : Scope, is_fn : Bool = false) : ValueType #

[View source]
def execute_main : Int64 | Nil #

Check if a "main" fn exists and call it


[View source]
def fake_ident(name : String, location : Location | Nil = nil) #

[View source]
def fake_typedef(name : String, location : Location | Nil = nil) #

[View source]
def file_path : String #

[View source]
def globals : Cosmo::Scope #

[View source]
def interpret(source : String, file_path : String) : ValueType #

[View source]
def max_recursion_depth=(max_recursion_depth : UInt32) #

[View source]
def meta : Hash(String, Cosmo::ClassInstance | String) #

[View source]
def resolve(expr : Expression::Base, depth : UInt32) : Nil #

[View source]
def scope : Scope #

[View source]
def set_meta(key : String, value : MetaType | Nil) : Nil #

[View source]
def start_recursion(token : Token) #

[View source]
def visit_access_expr(expr : Expression::Access) : ValueType #

[View source]
def visit_binary_op_expr(expr : Expression::BinaryOp) : ValueType #

[View source]
def visit_block_stmt(stmt : Statement::Block) : ValueType #

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

[View source]
def visit_case_stmt(stmt : Statement::Case) : ValueType #

[View source]
def visit_cast_expr(expr : Expression::Cast) : ValueType #

[View source]
def visit_class_def_stmt(stmt : Statement::ClassDef) : ValueType #
Description copied from module Cosmo::AST::Statement::Visitor(Cosmo::ValueType)

abstract def visit_enum_def_stmt(stmt : EnumDef) : R


[View source]
def visit_compound_assignment_expr(expr : Expression::CompoundAssignment) : ValueType #

[View source]
def visit_every_stmt(stmt : Statement::Every) : Nil #

[View source]
def visit_fn_call_expr(expr : Expression::FunctionCall) : ValueType #

[View source]
def visit_fn_def_stmt(stmt : Statement::FunctionDef) : ValueType #

[View source]
def visit_if_stmt(stmt : Statement::If) : ValueType #

[View source]
def visit_index_expr(expr : Expression::Index) : ValueType #

[View source]
def visit_is_expr(expr : Expression::Is) : Bool #

[View source]
def visit_is_in_expr(expr : Expression::IsIn) : Bool #

[View source]
def visit_lambda_expr(expr : Expression::Lambda) : ValueType #

[View source]
def visit_literal_expr(expr : Expression::Literal) : ValueType #

[View source]
def visit_multiple_assignment_expr(expr : Expression::MultipleAssignment) : Array(ValueType) #

[View source]
def visit_multiple_declaration_expr(expr : Expression::MultipleDeclaration) : Array(ValueType) #

[View source]
def visit_new_expr(expr : Expression::New) : ClassInstance #

[View source]
def visit_next_stmt(stmt : Statement::Next) : Nil #

[View source]
def visit_property_assignment_expr(expr : Expression::PropertyAssignment) : ValueType #

[View source]
def visit_range_literal_expr(expr : Expression::RangeLiteral) : RangeType #

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

[View source]
def visit_single_expr_stmt(stmt : Statement::SingleExpression) : ValueType #

[View source]
def visit_string_interpolation_expr(expr : Expression::StringInterpolation) : ValueType #

[View source]
def visit_table_literal_expr(expr : Expression::TableLiteral) : Hash(ValueType, ValueType) #

[View source]
def visit_ternary_op_expr(expr : Expression::TernaryOp) : ValueType #

[View source]
def visit_this_expr(expr : Expression::This) : ClassInstance #

[View source]
def visit_throw_stmt(stmt : Statement::Throw) : Nil #

[View source]
def visit_try_catch_stmt(stmt : Statement::TryCatch) : Nil #

[View source]
def visit_type_alias_expr(expr : Expression::TypeAlias) : Nil #

[View source]
def visit_type_ref_expr(expr : Expression::TypeRef) : Type #

[View source]
def visit_unary_op_expr(expr : Expression::UnaryOp) : ValueType #

[View source]
def visit_unless_stmt(stmt : Statement::Unless) : ValueType #

[View source]
def visit_until_stmt(stmt : Statement::Until) : Nil #

[View source]
def visit_use_stmt(stmt : Statement::Use) : Nil #

[View source]
def visit_var_assignment_expr(expr : Expression::VarAssignment) : ValueType #

[View source]
def visit_var_declaration_expr(expr : Expression::VarDeclaration) : ValueType #

[View source]
def visit_var_expr(expr : Expression::Var) : ValueType #

[View source]
def visit_vector_literal_expr(expr : Expression::VectorLiteral) : Array(ValueType) #

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

[View source]
def within_fn : Bool #

[View source]
def within_fn=(within_fn : Bool) #

[View source]