示例#1
0
        public override DynValue Eval(ScriptExecutionContext context)
        {
            DynValue v = m_Exp.Eval(context).ToScalar();

            switch (m_OpText)
            {
            case "not":
                return(DynValue.NewBoolean(!v.CastToBool()));

            case "#":
                return(v.GetLength());

            case "-":
            {
                double d;

                if (v.TryCastToNumber(out d))
                {
                    return(DynValue.NewNumber(-d));
                }

                throw new DynamicExpressionException("Attempt to perform arithmetic on non-numbers.");
            }

            default:
                throw new DynamicExpressionException("Unexpected unary operator '{0}'", m_OpText);
            }
        }
示例#2
0
        private void InvalidateData()
        {
            DynValue V = m_ValueStack.Peek();

            toolBack.Enabled = (m_ValueStack.Count > 1);

            lvMetaTable.BeginUpdate();
            lvProps.BeginUpdate();
            lvTableData.BeginUpdate();

            lvMetaTable.Items.Clear();
            lvProps.Items.Clear();
            txtString.Text = "";
            lvTableData.Items.Clear();
            lblData.Text        = "VALUE";
            lvTableData.Visible = false;
            txtString.Visible   = false;

            AddProperty("Ref ID#", V.ReferenceID.ToString("X8"));
            AddProperty("Read Only", V.ReadOnly);
            AddProperty("VM Type", V.Type);

            switch (V.Type)
            {
            case DataType.Nil:
                txtString.Visible = true;
                txtString.Text    = "Value is nil";
                break;

            case DataType.Boolean:
                txtString.Visible = true;
                txtString.Text    = V.Boolean.ToString();
                break;

            case DataType.Number:
                txtString.Visible = true;
                txtString.Text    = V.Boolean.ToString();
                break;

            case DataType.String:
                txtString.Visible = true;
                txtString.Text    = V.String.ToString();
                AddProperty("Raw Length", V.GetLength());
                break;

            case DataType.Function:
                lvTableData.Visible = true;
                lblData.Text        = "CLOSURE SCOPE";
                BuildFunctionTable(V);
                break;

            case DataType.Table:
                lvTableData.Visible = true;
                lblData.Text        = "TABLE CONTENTS";
                AddProperty("Raw Length", V.GetLength());
                BuildTableTable(lvTableData, V);
                break;

            case DataType.Tuple:
                lvTableData.Visible = true;
                lblData.Text        = "TUPLE";
                AddProperty("Count", V.Tuple.Length);
                BuildTupleTable(V);
                break;

            case DataType.ClrFunction:
                txtString.Visible = true;
                txtString.Text    = "Value is a CLR function.";
                break;

            case DataType.UserData:
                txtString.Visible = true;
                txtString.Text    = "Value is a CLR object (userdata).";
                break;

            case DataType.Thread:
                txtString.Visible = true;
                txtString.Text    = "Value is a coroutine.";
                break;

            default:
                break;
            }

            Colorize(lvMetaTable);
            Colorize(lvProps);
            Colorize(lvTableData);

            lvMetaTable.EndUpdate();
            lvProps.EndUpdate();
            lvTableData.EndUpdate();
        }