ChangeSign() public method

public ChangeSign ( ) : void
return void
コード例 #1
0
        /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
        public virtual ExprNode MakeNP1(int opecode, ExprNode node1)
        {
            // 定数の最适化
            if (node1 != null && node1.GetOpecode() == Token.T_CONSTVAL)
            {
                ExprNode ret = null;
                switch (opecode)
                {
                    case Token.T_EXCRAMATION:
                    {
                        ret = MakeConstValNode(node1.GetValue().GetNotValue());
                        break;
                    }

                    case Token.T_TILDE:
                    {
                        ret = MakeConstValNode(node1.GetValue().GetBitNotValue());
                        break;
                    }

                    case Token.T_SHARP:
                    {
                        Variant val = new Variant(node1.GetValue());
                        CharacterCodeOf(val);
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_DOLLAR:
                    {
                        Variant val = new Variant(node1.GetValue());
                        CharacterCodeFrom(val);
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_UPLUS:
                    {
                        Variant val = new Variant(node1.GetValue());
                        val.ToNumber();
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_UMINUS:
                    {
                        Variant val = new Variant(node1.GetValue());
                        val.ChangeSign();
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_INT:
                    {
                        Variant val = new Variant(node1.GetValue());
                        val.ToInteger();
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_REAL:
                    {
                        Variant val = new Variant(node1.GetValue());
                        val.ToReal();
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_STRING:
                    {
                        Variant val = new Variant(node1.GetValue());
                        val.ToString();
                        ret = MakeConstValNode(val);
                        break;
                    }

                    case Token.T_OCTET:
                    {
                        Variant val = new Variant(node1.GetValue());
                        val.ToOctet();
                        ret = MakeConstValNode(val);
                        break;
                    }
                }
                // swtich
                if (ret != null)
                {
                    node1.Clear();
                    return ret;
                }
            }
            ExprNode node = new ExprNode();
            mNodeToDeleteVector.AddItem(node);
            node.SetOpecode(opecode);
            node.SetPosition(GetLexPos());
            node.Add(node1);
            return node;
        }