示例#1
0
        static LuaObject EvalUnaryExpression(UnaryExpression Expression, LuaContext Context)
        {
            LuaObject obj = EvalExpression(Expression.Expression, Context)[0];

            switch (Expression.Operation)
            {
            case UnaryOp.Invert:
                return(-(obj.AsNumber()));

            case UnaryOp.Length:
            {
                if (obj.Is(LuaType.table))
                {
                    return(obj.AsTable().Count);
                }
                else
                {
                    return(obj.AsString().Length);
                }
            }

            case UnaryOp.Negate:
                return(!(obj.AsBool()));

            default:
                throw new NotImplementedException();
            }
        }