示例#1
0
        private static void CgExp(FuncInfo fi, Exp node, int a, int n)
        {
            switch (node)
            {
            case NilExp _:
                fi.EmitLoadNil(a, n);
                break;

            case FalseExp _:
                fi.EmitLoadBool(a, 0, 0);
                break;

            case TrueExp _:
                fi.EmitLoadBool(a, 1, 0);
                break;

            case IntegerExp integerExp:
                fi.EmitLoadK(a, integerExp.Val);
                break;

            case FloatExp floatExp:
                fi.EmitLoadK(a, floatExp.Val);
                break;

            case StringExp stringExp:
                fi.EmitLoadK(a, stringExp.Str);
                break;

            case ParensExp parensExp:
                CgExp(fi, parensExp.Exp, a, 1);
                break;

            case VarargExp varargExp:
                CgVarargExp(fi, varargExp, a, n);
                break;

            case FuncDefExp funcDefExp:
                CgFuncDefExp(fi, funcDefExp, a);
                break;

            case TableConstructorExp tableConstructorExp:
                CgTableConstructorExp(fi, tableConstructorExp, a);
                break;

            case UnopExp unopExp:
                CgUnopExp(fi, unopExp, a);
                break;

            case BinopExp binopExp:
                CgBinopExp(fi, binopExp, a);
                break;

            case ConcatExp concatExp:
                CgConcatExp(fi, concatExp, a);
                break;

            case NameExp nameExp:
                CgNameExp(fi, nameExp, a);
                break;

            case TableAccessExp tableAccessExp:
                CgTableAccessExp(fi, tableAccessExp, a);
                break;

            case FuncCallExp funcCallExp:
                CgFuncCallExp(fi, funcCallExp, a, n);
                break;
            }
        }