Sign in

    oboard/moonbit-eval/interpreter does not have a README file

    RuntimeFunction

    新的函数类型定义 - 统一的上下文访问

    ClosureInterpreter

    pub(all) struct ClosureInterpreter {
    extern_fns : Map[String, (RuntimeFunctionContext) ->
    RuntimeValue
    ]
    embedded_fns : Map[String, (RuntimeFunctionContext) ->
    RuntimeValue
    ]
    embedded_methods : Map[String, Map[String, (RuntimeFunctionContext) ->
    RuntimeValue
    ]]
    fn_aliases : Map[String, String]
    env :
    RuntimeEnvironment

    type_definitions : Map[String,
    TypeDecl
    ]
    struct_methods : Map[String, Map[String,
    Func
    ]]
    type_environments : Array[TypeEnvironment]
    }
    支持引用系统和泛型的解释器

    ClosureInterpreter::add_embedded_fn

    ClosureInterpreter::add_embedded_method

    fn ClosureInterpreter::add_embedded_method(self : ClosureInterpreter, type_name : String, method_name : String, f : (RuntimeFunctionContext) ->
    RuntimeValue
    ) -> Unit

    ClosureInterpreter::add_extern_fn

    ClosureInterpreter::bind_function_parameters

    支持所有参数类型:位置参数、标签参数、可选参数、问号可选参数、丢弃参数

    ClosureInterpreter::bind_function_parameters_runtime

    ClosureInterpreter::constants_equal

    检查两个常量是否相等

    ClosureInterpreter::constants_equal_expr

    检查两个表达式是否相等(用于构造函数匹配)

    ClosureInterpreter::define_struct_method

    fn ClosureInterpreter::define_struct_method(self : ClosureInterpreter, type_name : String, method_name : String, func :
    Func
    ) -> Unit

    ClosureInterpreter::execute_function_call

    处理用户定义函数的调用,包括作用域管理和参数绑定

    ClosureInterpreter::execute_match

    执行match表达式的模式匹配

    ClosureInterpreter::execute_match_runtime

    执行match表达式的模式匹配(返回RuntimeValue)

    ClosureInterpreter::find_variable

    在解释器中查找变量

    ClosureInterpreter::get_function_type_string

    fn ClosureInterpreter::get_function_type_string(self : ClosureInterpreter, value :
    RuntimeValue
    ) -> String
    将RuntimeValue转换为字符串表示(带解释器支持,用于正确的类型推导)

    ClosureInterpreter::is_known_function

    fn ClosureInterpreter::is_known_function(self : ClosureInterpreter, name : String) -> Bool
    检查函数是否为已知函数(存在于任何函数映射中)

    ClosureInterpreter::new

    fn ClosureInterpreter::new(core? : Bool) -> ClosureInterpreter

    ClosureInterpreter::pattern_matches

    检查值是否匹配模式

    ClosureInterpreter::pattern_to_value

    将模式转换为值(用于范围匹配)

    ClosureInterpreter::pop_scope

    fn ClosureInterpreter::pop_scope(self : ClosureInterpreter) -> Unit
    销毁当前作用域

    ClosureInterpreter::push_scope

    fn ClosureInterpreter::push_scope(self : ClosureInterpreter) -> Unit
    创建新的作用域

    ClosureInterpreter::set_mutable_variable

    fn ClosureInterpreter::set_mutable_variable(self : ClosureInterpreter, name : String, value :
    RuntimeValue
    ) -> Unit
    设置可变变量

    ClosureInterpreter::set_variable

    fn ClosureInterpreter::set_variable(self : ClosureInterpreter, name : String, value :
    RuntimeValue
    ) -> Unit
    设置不可变变量

    ClosureInterpreter::top_visit

    ClosureInterpreter::update_variable

    fn ClosureInterpreter::update_variable(self : ClosureInterpreter, name : String, new_value :
    RuntimeValue
    ) -> Unit
    在可变变量数组中查找并更新指定变量

    ClosureInterpreter::value_in_range

    检查值是否在范围内

    ClosureInterpreter::visit

    新的优化版本:直接返回 RuntimeValue

    RuntimeFunctionContext

    pub(all) struct RuntimeFunctionContext {
    context : ClosureInterpreter
    arguments : Array[
    RuntimeArgument
    ]
    }
    Runtime函数执行上下文 - 统一所有函数的执行环境

    TypeEnvironment

    pub struct TypeEnvironment {
    type_bindings : Map[String, String]
    parent : TypeEnvironment?
    }
    泛型类型环境 - 跟踪类型变量绑定

    compare

    fn[T : Compare + Eq] compare(left : T, right : T, op : String) ->
    Constant

    eval_double_op

    fn eval_double_op(left : Double, right : Double, op : String) ->
    Constant

    eval_float_op

    fn eval_float_op(left : Double, right : Double, op : String) ->
    Constant

    eval_int64_op

    fn eval_int64_op(left : Int64, right : Int64, op : String) ->
    Constant

    eval_int_op

    fn eval_int_op(left : Int, right : Int, op : String) ->
    Constant

    eval_uint64_op

    fn eval_uint64_op(left : UInt64, right : UInt64, op : String) ->
    Constant

    eval_uint_op

    fn eval_uint_op(left : UInt, right : UInt, op : String) ->
    Constant

    int_embedded_code

    is_comparison_op

    fn is_comparison_op(op : String) -> Bool

    string_embedded_code