Files
nixjit/docs/eval/eval.mmd
2025-09-14 17:39:57 +08:00

97 lines
3.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
flowchart TD
Start([EvalCtx::eval]) --> Eval[EvalContext::eval]
Eval --> AddNode[为本即将求值表达式分配 ValueId添加至图中]
AddNode --> CheckType{检查表达式类型}
CheckType -->|AttrSet| A_EvalKeys[强制求值所有键]
A_EvalKeys --> A_Construct[构造 AttrSet]
A_Construct --> End
A_EvalKeys -.->|eval| Eval
CheckType -->|List| L_Construct[构造列表]
L_Construct --> End
CheckType -->|HasAttr| HA_ForceAttrSet[强制求值 AttrSet]
HA_ForceAttrSet --> HA_ForceAttrPath[强制求值 AttrPath]
HA_ForceAttrPath --> HA_Result[求出结果]
HA_Result --> End
HA_ForceAttrSet -.->|eval| Eval
HA_ForceAttrPath -.->|eval| Eval
CheckType -->|BinOp| B_ForceLeft[强制求值左操作数]
B_ForceLeft --> B_ForceRight[强制求值右操作数]
B_ForceRight --> B_Apply[应用操作符]
B_Apply --> End
B_ForceLeft -.->|eval| Eval
B_ForceRight -.->|eval| Eval
CheckType -->|UnOp| U_ForceOperand[强制求值操作数]
U_ForceOperand --> U_Apply[应用操作符]
U_Apply --> End
U_ForceOperand -.->|eval| Eval
CheckType -->|Select| S_ForceAttrSet[强制求值 AttrSet]
S_ForceAttrSet --> S_ForceAttrPath[强制求值 AttrPath]
S_ForceAttrPath --> S_Result[获取结果]
S_Result --> End
S_ForceAttrSet -.->|eval| Eval
S_ForceAttrPath -.->|eval| Eval
CheckType -->|If| I_ForceCond[强制求值条件]
I_ForceCond --> I_Cond{判断条件}
I_Cond -->|true| I_Consq[返回 then]
I_Cond -->|false| I_Alter[返回 else]
I_Consq --> End
I_Alter --> End
I_ForceCond -.->|eval| Eval
CheckType -->|Call| C_RegArg[注册函数参数]
C_RegArg --> C_ForceBody[强制求值函数体]
C_ForceBody --> End
C_ForceBody -.->|eval| Eval
CheckType -->|With| W_ForceNameSpace[强制求值命名空间]
W_ForceNameSpace --> W_EnterWith[进入命名空间]
W_EnterWith --> W_ForceBody[强制求值表达式]
W_ForceBody --> W_ExitWith[退出命名空间]
W_ExitWith --> End
W_ForceNameSpace -.->|eval| Eval
W_ForceBody -.->|eval| Eval
CheckType -->|Assert| As_ForceCond[强制求值断言]
As_ForceCond --> As_Cond{判断断言}
As_Cond -->|true| As_ForceBody[强制求值表达式]
As_Cond -->|false| As_Throw[抛出 Catchable]
As_ForceBody --> End
As_ForceCond -.->|eval| Eval
As_ForceBody -.->|eval| Eval
CheckType -->|ConcatStrings| CS_ForceParts[强制求值所有字符串片段]
CS_ForceParts --> CS_Construct[构造字符串]
CS_Construct --> End
CS_ForceParts -.->|eval| Eval
CheckType -->|Const| Co_Construct[构造常量]
Co_Construct --> End
CheckType -->|Str| St_Construct[构造字符串]
St_Construct --> End
CheckType -->|Var| V_Lookup[动态查找变量]
V_Lookup --> End
CheckType -->|Arg| Ar_Lookup[查找参数]
Ar_Lookup --> End
CheckType -->|Func| F_Construct[构造函数]
F_Construct --> End
CheckType -->|StrictRef| SR_Eval[求值被引用表达式]
SR_Eval --> Eval
CheckType -->|LazyRef| LR_Resolve[解析动态变量引用]
LR_Resolve --> LR_Contruct[构造惰性引用]
LR_Contruct --> End
End([返回结果])