Ejemplo n.º 1
0
        public virtual FixedVariableTerm GetFixedVariableTerm(ExpressionMediator exm)
        {
            if (!allArgIsConst)
            {
                for (var i = 0; i < arguments.Length; i++)
                {
                    transporter[i] = arguments[i].GetIntValue(exm);
                }
            }
            var fp = new FixedVariableTerm(Identifier);

            if (transporter.Length >= 1)
            {
                fp.Index1 = transporter[0];
            }
            if (transporter.Length >= 2)
            {
                fp.Index2 = transporter[1];
            }
            if (transporter.Length >= 3)
            {
                fp.Index3 = transporter[2];
            }
            return(fp);
        }
Ejemplo n.º 2
0
        public Int64 GetArraySum(FixedVariableTerm p, Int64 index1, Int64 index2)
        {
            Int64 sum = 0;

            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                Int64[] dataArray = chara.DataIntegerArray[p.Identifier.VarCodeInt];
                //if (index1 == -1)
                //    index1 = 0;
                //if (index2 == -1)
                //    index2 = dataArray.Length;
                for (int i = (int)index1; i < (int)index2; i++)
                    sum += dataArray[i];
            }
            else
            {
                if (p.Identifier.IsArray1D)
                {
                    Int64[] dataArray = (Int64[])p.Identifier.GetArray();
                    for (int i = (int)index1; i < (int)index2; i++)
                        sum += dataArray[i];
                }
                else if (p.Identifier.IsArray2D)
                {
                    Int64[,] dataArray = (Int64[,])p.Identifier.GetArray();
                    for (int i = (int)index1; i < (int)index2; i++)
                        sum += dataArray[p.Index1, i];
                }
                else
                {
                    Int64[, ,] dataArray = (Int64[,,])p.Identifier.GetArray();
                    for (int i = (int)index1; i < (int)index2; i++)
                        sum += dataArray[p.Index1, p.Index2, i];
                }
            }

            return sum;
        }
Ejemplo n.º 3
0
        public Int64 FindElement(FixedVariableTerm p, Regex target, Int64 start, Int64 end, bool isExact, bool isLast)
        {
            string[] array;

            //指定値の配列要素の範囲外かのチェックは済んでるので、これだけでよい
            if (start >= end)
                return -1;

            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                array = chara.DataStringArray[p.Identifier.VarCodeInt];
            }
            else
            {
                array = (string[])p.Identifier.GetArray();
            }

            if (isLast)
            {
                for (int i = (int)end - 1; i >= (int)start; i--)
                {
                    if (isExact)
                    {
                        //Nullならないものと見なして飛ばす
                        if (array[i] == null)
                            continue;
                        Match match = target.Match(array[i]);
                        //正規表現に引っかかった文字列の長さ=元の文字列の長さなら完全一致
                        if (match.Success && array[i].Length == match.Length)
                            return (Int64)i;
                    }
                    else
                    {
                        //Nullならないものと見なして飛ばす
                        if (array[i] == null)
                            continue;
                        //部分一致なのでひっかかればOK
                        if (target.IsMatch(array[i]))
                            return (Int64)i;
                    }
                }
            }
            else
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    if (isExact)
                    {
                        //Nullならないものと見なして飛ばす
                        if (array[i] == null)
                            continue;
                        //正規表現に引っかかった文字列の長さ=元の文字列の長さなら完全一致
                        Match match = target.Match(array[i]);
                        if (match.Success && array[i].Length == match.Length)
                            return (Int64)i;
                    }
                    else
                    {
                        //Nullならないものと見なして飛ばす
                        if (array[i] == null)
                            continue;
                        //部分一致なのでひっかかればOK
                        if (target.IsMatch(array[i]))
                            return (Int64)i;
                    }
                }
            }
            return -1;
        }
Ejemplo n.º 4
0
        public Int64 FindElement(FixedVariableTerm p, Int64 target, Int64 start, Int64 end, bool isExact, bool isLast)
        {
            Int64[] array;

            //指定値の配列要素の範囲外かのチェックは済んでるので、これだけでよい
            if (start >= end)
                return -1;

            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
            }
            else
                array = (Int64[])p.Identifier.GetArray();

            if (isLast)
            {
                for (int i = (int)end - 1; i >= (int)start; i--)
                {
                    if (target == array[i])
                        return (Int64)i;
                }
            }
            else
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    if (target == array[i])
                        return (Int64)i;
                }
            }
            return -1;
        }
Ejemplo n.º 5
0
 internal Int64 FindChara(VariableToken varID, Int64 elem64, Int64 word, Int64 startIndex, Int64 lastIndex, bool isLast)
 {
     if (startIndex >= lastIndex)
         return -1;
     FixedVariableTerm fvp = new FixedVariableTerm(varID);
     if(varID.IsArray1D)
         fvp.Index2 = elem64;
     else if (varID.IsArray2D)
     {
         fvp.Index2 = elem64 >> 32;
         fvp.Index3 = elem64 & 0x7FFFFFFF;
     }
     int count = varData.CharacterList.Count;
     if (isLast)
     {
         for (Int64 i = lastIndex - 1; i >= startIndex; i--)
         {
             fvp.Index1 = i;
             if (word == fvp.GetIntValue(null))
                 return i;
         }
     }
     else
     {
         for (Int64 i = startIndex; i < lastIndex; i++)
         {
             fvp.Index1 = i;
             if (word == fvp.GetIntValue(null))
                 return i;
         }
     }
     return -1;
 }
Ejemplo n.º 6
0
        public void SortArray(FixedVariableTerm p, SortOrder order, int start, int num)
        {
            if (order == SortOrder.UNDEF)
                order = SortOrder.ASCENDING;
            if (p.Identifier.IsInteger)
            {
                Int64[] array;
                if (p.Identifier.IsCharacterData)
                {
                    CharacterData chara = varData.CharacterList[(int)p.Index1];
                    array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
                }
                else
                {
                    array = (Int64[])p.Identifier.GetArray();
                }
                if (start >= array.Length)
                    throw new CodeEE("命令ARRAYSORTの第3引数(" + start.ToString() + ")が配列" + p.Identifier.Name + "の範囲を超えています");
                if (num <= 0)
                    num = array.Length - start;
                Int64[] temp = new Int64[num];
                Array.Copy(array, start, temp, 0, num);

                if (order == SortOrder.ASCENDING)
                    Array.Sort(temp);
                else if (order == SortOrder.DESENDING)
                    Array.Sort(temp, delegate(Int64 a, Int64 b) { return b.CompareTo(a); });
                Array.Copy(temp, 0, array, start, num);
            }
            else
            {
                string[] array;
                if (p.Identifier.IsCharacterData)
                {
                    CharacterData chara = varData.CharacterList[(int)p.Index1];
                    array = chara.DataStringArray[p.Identifier.VarCodeInt];
                }
                else
                {
                    array = (string[])p.Identifier.GetArray();
                }
                if (start >= array.Length)
                    throw new CodeEE("命令ARRAYSORTの第3引数(" + start.ToString() + ")が配列" + p.Identifier.Name + "の範囲を超えています");
                if (num <= 0)
                    num = array.Length - start;
                string[] temp = new string[num];
                Array.Copy(array, start, temp, 0, num);

                if (order == SortOrder.ASCENDING)
                    Array.Sort(temp);
                else if (order == SortOrder.DESENDING)
                    Array.Sort(temp, delegate(string a, string b) { return b.CompareTo(a); });
                Array.Copy(temp, 0, array, start, num);
            }
        }
Ejemplo n.º 7
0
        public Int64 GetMatchChara(FixedVariableTerm p, Int64 target, Int64 start, Int64 end)
        {
            CharacterData chara;
            Int64 ret = 0;

            //if (start == -1)
            //    start = 0;
            //if (end == -1)
            //    end = varData.CharacterList.Count;

            if (p.Identifier.IsArray2D)
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    Int64[,] array = chara.DataIntegerArray2D[p.Identifier.VarCodeInt];
                    if (array[p.Index2, p.Index3] == target)
                        ret++;
                }
            }
            else if (p.Identifier.IsArray1D)
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    Int64[] array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
                    if (array[p.Index2] == target)
                        ret++;
                }
            }
            else
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    if (chara.DataInteger[p.Identifier.VarCodeInt] == target)
                        ret++;
                }
            }
            return ret;
        }
Ejemplo n.º 8
0
        public void SetValueAllEachChara(FixedVariableTerm p, SingleTerm index, string srcValue, int start, int end)
        {
            if (!p.Identifier.IsString)
                throw new CodeEE("文字列型でない変数" + p.Identifier.Name + "に文字列型を代入しようとしました");
            if (p.Identifier.Readonly)
                throw new CodeEE("読み取り専用の変数" + p.Identifier.Name + "に代入しようとしました");
            if (p.Identifier.IsCalc)
            {
                if (p.Identifier.Code == VariableCode.WINDOW_TITLE)
                {
                    GlobalStatic.Console.SetWindowTitle(srcValue);
                    return;
                }
                //一応チェック済み
                //throw new ExeEE("READONLYでないCALC変数の代入処理が設定されていない");
                return;
            }
            if (varData.CharacterList.Count == 0)
                return;

            CharacterData chara = varData.CharacterList[0];
            Int64 indexNum = -1;

            if (p.Identifier.IsArray1D)
            {
                if (index.GetOperandType() == typeof(Int64))
                    indexNum = index.Int;
                else
                    indexNum = constant.KeywordToInteger(p.Identifier.Code, index.Str, 1);
                string[] array = chara.DataStringArray[p.Identifier.VarCodeInt];
                if (indexNum < 0 || indexNum >= array.Length)
                    throw new CodeEE("キャラクタ配列変数" + p.Identifier.Name + "の第2引数(" + indexNum.ToString() + ")は配列の範囲外です");
            }

            for (int i = start; i < end; i++)
            {
                chara = varData.CharacterList[i];
                if (p.Identifier.IsArray1D)
                    chara.DataStringArray[p.Identifier.VarCodeInt][indexNum] = srcValue;
                else
                    chara.DataString[p.Identifier.VarCodeInt] = srcValue;
            }
        }
Ejemplo n.º 9
0
 public void RemoveArray(FixedVariableTerm p, int start, int num)
 {
     if (p.Identifier.IsInteger)
     {
         Int64[] array;
         if (p.Identifier.IsCharacterData)
         {
             CharacterData chara = varData.CharacterList[(int)p.Index1];
             array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
         }
         else
         {
             array = (Int64[])p.Identifier.GetArray();
         }
         if (start >= array.Length)
             throw new CodeEE("命令ARRAYREMOVEの第2引数(" + start.ToString() + ")が配列" + p.Identifier.Name + "の範囲を超えています");
         if (num <= 0)
             num = array.Length;
         Int64[] temp = new Int64[array.Length];
         //array.CopyTo(temp, 0);
         //for (int i = 0; i < array.Length; i++)
         //    array[i] = 0;
         //Array.Clear(array, 0, array.Length);
         if (start > 0)
             //Array.Copy(array, 0, temp, 0, start);
             Buffer.BlockCopy(array, 0, temp, 0, start * 8);
         if ((start + num) < array.Length)
             //Array.Copy(array, (start + num), temp, start, (array.Length - (start + num)));
             Buffer.BlockCopy(array, (start + num) * 8, temp, start * 8, (array.Length - (start + num)) * 8);
         //temp.CopyTo(array, 0);
         Buffer.BlockCopy(temp, 0, array, 0, temp.Length * 8);
     }
     else
     {
         string[] arrays;
         if (p.Identifier.IsCharacterData)
         {
             CharacterData chara = varData.CharacterList[(int)p.Index1];
             arrays = chara.DataStringArray[p.Identifier.VarCodeInt];
         }
         else
         {
             arrays = (string[])p.Identifier.GetArray();
         }
         if (num <= 0)
             num = arrays.Length;
         string[] temps = new string[arrays.Length];
         //arrays.CopyTo(temps, 0);
         //for (int i = 0; i < arrays.Length; i++)
         //    arrays[i] = "";
         if (start > 0)
             Array.Copy(arrays, 0, temps, 0, start);
         if ((start + num) < arrays.Length)
             Array.Copy(arrays, (start + num), temps, start, (arrays.Length - (start + num)));
         temps.CopyTo(arrays, 0);
     }
 }
Ejemplo n.º 10
0
        public void SetValueAll(FixedVariableTerm p, string srcValue, int start, int end)
        {
            //呼び出し元で判定済み
            //if (!p.Identifier.IsString)
            //    throw new CodeEE("文字列型でない変数" + p.Identifier.Name + "に文字列型を代入しようとしました");
            //if (p.Identifier.Readonly)
            //    throw new CodeEE("読み取り専用の変数" + p.Identifier.Name + "に代入しようとしました");
            if (p.Identifier.IsCalc)
            {
                if (p.Identifier.Code == VariableCode.WINDOW_TITLE)
                {
                    GlobalStatic.Console.SetWindowTitle(srcValue);
                    return;
                }
                return;
                //一応チェック済み
                //throw new ExeEE("READONLYでないCALC変数の代入処理が設定されていない");
            }

            //else if (p.Identifier.IsCharacterData)
            //{
            //    CharacterData chara = varData.CharacterList[(int)p.Index1];

            //    if (p.Identifier.IsArray2D)
            //    {
            //        string[,] array = chara.DataStringArray2D[p.Identifier.VarCodeInt];
            //        int a1 = array.GetLength(0);
            //        int a2 = array.GetLength(1);
            //        for (int i = 0; i < a1; i++)
            //            for (int j = 0; j < a2; j++)
            //                array[i, j] = srcValue;
            //    }
            //    else if (p.Identifier.IsArray1D)
            //    {
            //        if (start != 0 || end != p.Identifier.GetLength())
            //            p.IsArrayRangeValid((Int64)start, (Int64)end, "VARSET", 3L, 4L);
            //        string[] array = chara.DataStringArray[p.Identifier.VarCodeInt];
            //        for (int i = start; i < end; i++)
            //            array[i] = srcValue;
            //        return;
            //    }
            //    else
            //    {
            //        chara.DataString[p.Identifier.VarCodeInt] = srcValue;
            //        return;
            //    }
            //}
            //else if (!p.Identifier.IsArray1D && !p.Identifier.IsArray2D && !p.Identifier.IsArray3D)
            //{
            //    varData.DataString[p.Identifier.VarCodeInt] = srcValue;
            //    return;
            //}
            else
            {
                if (p.Identifier.IsArray1D)
                {
                    if (start != 0 || end != p.Identifier.GetLength())
                        p.IsArrayRangeValid((Int64)start, (Int64)end, "VARSET", 3L, 4L);
                    else if (p.Identifier.IsCharacterData)
                        p.Identifier.CheckElement(new Int64[] { p.Index1, p.Index2 });
                }
                else if (p.Identifier.IsCharacterData)
                {
                    if (p.Identifier.IsArray2D)
                        p.Identifier.CheckElement(new Int64[] { p.Index1, p.Index2, p.Index3 });
                    else
                        p.Identifier.CheckElement(new Int64[] { p.Index1 });
                }
                //string[]  array = (string[])p.Identifier.GetArray();
                //for (int i = start; i < end; i++)
                //    array[i] = srcValue;
                p.Identifier.SetValueAll(srcValue, start, end, (int)p.Index1);
                return;
            }
            //else if (p.Identifier.IsArray3D)
            //{
            //    //string[, ,] a3 = varData.DataStringArray3D[p.Identifier.VarCodeInt];
            //    //int length1 = a3.GetLength(0);
            //    //int length2 = a3.GetLength(1);
            //    //int length3 = a3.GetLength(2);
            //    //for (int x = 0; x < length1; x++)
            //    //    for (int y = 0; y < length2; y++)
            //    //        for (int z = 0; z < length3; z++)
            //    //            a3[x, y, z] = srcValue;
            //    p.Identifier.SetValueAll(srcValue, start, end);
            //    return;
            //}
            //else if (p.Identifier.IsArray2D)
            //{
            //    //string[,] a2 = varData.DataStringArray2D[p.Identifier.VarCodeInt];
            //    //int length1 = a2.GetLength(0);
            //    //int length2 = a2.GetLength(1);
            //    //for (int x = 0; x < length1; x++)
            //    //    for (int y = 0; y < length2; y++)
            //    //        a2[x, y] = srcValue;
            //    p.Identifier.SetValueAll(srcValue, start, end);
            //    return;
            //}
        }
Ejemplo n.º 11
0
        public Int64 GetMaxArrayChara(FixedVariableTerm p, Int64 start, Int64 end, bool isMax)
        {
            CharacterData chara;

            Int64 ret;
            if (p.Identifier.IsArray2D)
            {
                ret = varData.CharacterList[(int)start].DataIntegerArray2D[p.Identifier.VarCodeInt][p.Index2, p.Index3];
                for (int i = (int)start + 1; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    Int64[,] array = chara.DataIntegerArray2D[p.Identifier.VarCodeInt];
                    if (isMax)
                    {
                        if (array[p.Index2, p.Index3] > ret)
                            ret = array[p.Index2, p.Index3];
                    }
                    else
                    {
                        if (array[p.Index2, p.Index3] < ret)
                            ret = array[p.Index2, p.Index3];
                    }
                }
            }
            else if (p.Identifier.IsArray1D)
            {
                ret = varData.CharacterList[(int)start].DataIntegerArray[p.Identifier.VarCodeInt][p.Index2];
                for (int i = (int)start + 1; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    Int64[] array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
                    if (isMax)
                    {
                        if (array[p.Index2] > ret)
                            ret = array[p.Index2];
                    }
                    else
                    {
                        if (array[p.Index2] < ret)
                            ret = array[p.Index2];
                    }
                }
            }
            else
            {
                ret = varData.CharacterList[(int)start].DataInteger[p.Identifier.VarCodeInt];
                for (int i = (int)start + 1; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    if (isMax)
                    {
                        if (chara.DataInteger[p.Identifier.VarCodeInt] > ret)
                            ret = chara.DataInteger[p.Identifier.VarCodeInt];
                    }
                    else
                    {
                        if (chara.DataInteger[p.Identifier.VarCodeInt] < ret)
                            ret = chara.DataInteger[p.Identifier.VarCodeInt];
                    }
                }
            }
            return ret;
        }
Ejemplo n.º 12
0
        public Int64 GetMaxArray(FixedVariableTerm p, Int64 start, Int64 end, bool isMax)
        {
            Int64[] array;
            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
            }
            else
                array = (Int64[])p.Identifier.GetArray();

            Int64 ret = array[start];
            for (int i = (int)start + 1; i < (int)end; i++)
            {
                if (isMax)
                {
                    if (array[i] > ret)
                        ret = array[i];
                }
                else
                {
                    if (array[i] < ret)
                        ret = array[i];
                }
            }
            return ret;
        }
Ejemplo n.º 13
0
        public Int64 GetMatchChara(FixedVariableTerm p, string target, Int64 start, Int64 end)
        {
            CharacterData chara;
            Int64 ret = 0;
            bool targetIsNullOrEmpty = string.IsNullOrEmpty(target);

            if (p.Identifier.IsArray2D)
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    string[,] array = chara.DataStringArray2D[p.Identifier.VarCodeInt];
                    if (array[p.Index2, p.Index3] == target)
                        ret++;
                }
            }
            if (p.Identifier.IsArray1D)
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    string[] array = chara.DataStringArray[p.Identifier.VarCodeInt];
                    if ((array[p.Index2] == target) || (targetIsNullOrEmpty && string.IsNullOrEmpty(array[p.Index2])))
                        ret++;
                }
            }
            else
            {
                for (int i = (int)start; i < (int)end; i++)
                {
                    chara = varData.CharacterList[i];
                    if ((chara.DataString[p.Identifier.VarCodeInt] == target) || (targetIsNullOrEmpty && string.IsNullOrEmpty(chara.DataString[p.Identifier.VarCodeInt])))
                        ret++;
                }
            }
            return ret;
        }
Ejemplo n.º 14
0
 public Int64 GetArraySumChara(FixedVariableTerm p, Int64 index1, Int64 index2)
 {
     Int64 sum = 0;
     CharacterData chara;
     if (p.Identifier.IsArray1D)
     {
         Int64[] dataArray;
         for (int i = (int)index1; i < (int)index2; i++)
         {
             chara = varData.CharacterList[i];
             dataArray = chara.DataIntegerArray[p.Identifier.VarCodeInt];
             sum += dataArray[p.Index2];
         }
     }
     else
     {
         for (int i = (int)index1; i < (int)index2; i++)
         {
             chara = varData.CharacterList[i];
             sum += chara.DataInteger[p.Identifier.VarCodeInt];
         }
     }
     return sum;
 }
Ejemplo n.º 15
0
        public void ShiftArray(FixedVariableTerm p, int shift, Int64 def, int start, int num)
        {
            Int64[] array;
            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
            }
            else
            {
                array = (Int64[])p.Identifier.GetArray();
            }

            if (start >= array.Length)
                throw new CodeEE("命令ARRAYREMOVEの第4引数(" + start.ToString() + ")が配列" + p.Identifier.Name + "の範囲を超えています");

            if (num == -1)
                num = array.Length - start;
            if ((start + num) > array.Length)
                num = array.Length - start;

            if (Math.Abs(shift) >= array.Length && start == 0 && num >= array.Length)
            {
                for (int i = 0; i < array.Length; i++)
                    array[i] = def;
                return;
            }

            int sourceStart = 0;
            int destStart = start + shift;
            int length = num - Math.Abs(shift);
            if (shift < 0)
            {
                sourceStart = -shift;
                destStart = start;
            }
            Int64[] temp = new Int64[num];
            //array.CopyTo(temp, 0);
            Buffer.BlockCopy(array, start * 8, temp, 0, 8 * num);

            //これを満たすのはshift > 0であることは自明
            if (sourceStart == 0)
            {
                if (length > 0)
                    for (int i = start; i < (start + shift); i++)
                        array[i] = def;
                else
                {
                    for (int i = start; i < (start + num); i++)
                        array[i] = def;
                    return;
                }
            }
            else
            {
                if (length > 0)
                    for (int i = (start + length); i < (start + num); i++)
                        array[i] = def;
                else
                {
                    for (int i = start; i < (start + num); i++)
                        array[i] = def;
                    return;
                }
            }

            //if (start > 0)
            //    //Array.Copy(temp, 0, array, 0, start);
            //    Buffer.BlockCopy(temp, 0, array, 0, 8 * start);

            if (length > 0)
                //Array.Copy(temp, sourceStart, array, destStart, length);
                Buffer.BlockCopy(temp, sourceStart * 8, array, destStart * 8, length * 8);

            //if ((start + num) < array.Length)
            //    //Array.Copy(temp, (start + num), array, (start + num), array.Length - (start + num));
            //    Buffer.BlockCopy(temp, (start + num) * 8, array, (start + num) * 8, (array.Length - (start + num)) * 8);
        }
Ejemplo n.º 16
0
        public Int64 GetInRangeArray(FixedVariableTerm p, Int64 min, Int64 max, Int64 start, Int64 end)
        {
            Int64[] array;
            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                array = chara.DataIntegerArray[p.Identifier.VarCodeInt];
            }
            else
                array = (Int64[])p.Identifier.GetArray();
            Int64 ret = 0;
            for (int i = (int)start; i < (int)end; i++)
                if (array[i] >= min && array[i] < max)
                    ret++;

            return ret;
        }
Ejemplo n.º 17
0
        public void ShiftArray(FixedVariableTerm p, int shift, string def, int start, int num)
        {
            string[] arrays;
            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                arrays = chara.DataStringArray[p.Identifier.VarCodeInt];
            }
            else
            {
                arrays = (string[])p.Identifier.GetArray();
            }

            if (start >= arrays.Length)
                throw new CodeEE("命令ARRAYREMOVEの第4引数(" + start.ToString() + ")が配列" + p.Identifier.Name + "の範囲を超えています");

            //for (int i = 0; i < arrays.Length; i++)
            //    arrays[i] = "";
            //Array.Clear(arrays, 0, arrays.Length);

            if (num == -1)
                num = arrays.Length - start;
            if ((start + num) > arrays.Length)
                num = arrays.Length - start;

            if (Math.Abs(shift) >= arrays.Length && start == 0 && num >= arrays.Length)
            {
                for (int i = 0; i < arrays.Length; i++)
                    arrays[i] = def;
                return;
            }

            //if (start > 0)
            //    Array.Copy(temps, 0, arrays, 0, start);

            int sourceStart = 0;
            int destStart = start + shift;
            int length = num - Math.Abs(shift);
            if (shift < 0)
            {
                sourceStart = -shift;
                destStart = start;
            }
            string[] temps = new string[num];
            Array.Copy(arrays, start, temps, 0, num);

            if (destStart > start)
            {
                if (length > 0)
                    for (int i = start; i < (start + shift); i++)
                        arrays[i] = def;
                else
                {
                    for (int i = start; i < (start + num); i++)
                        arrays[i] = def;
                    return;
                }
            }
            else
            {
                if (length > 0)
                    for (int i = (start + length); i < (start + num); i++)
                        arrays[i] = def;
                else
                {
                    for (int i = start; i < (start + num); i++)
                        arrays[i] = def;
                    return;
                }
            }

            if (length > 0)
                Array.Copy(temps, sourceStart, arrays, destStart, length);
            //if ((start + num) < arrays.Length)
            //    Array.Copy(temps, (start + num), arrays, (start + num), arrays.Length - (start + num));
        }
Ejemplo n.º 18
0
 public FixedVariableTerm GetFixedVariableTerm(ExpressionMediator exm)
 {
     if (!allArgIsConst)
         for (int i = 0; i < arguments.Length; i++)
             transporter[i] = arguments[i].GetIntValue(exm);
     FixedVariableTerm fp = new FixedVariableTerm(Identifier);
     if (transporter.Length >= 1)
         fp.Index1 = transporter[0];
     if (transporter.Length >= 2)
         fp.Index2 = transporter[1];
     if (transporter.Length >= 3)
         fp.Index3 = transporter[2];
     return fp;
 }
Ejemplo n.º 19
0
        public Int64 GetMatch(FixedVariableTerm p, string target, Int64 start, Int64 end)
        {
            string[] array;
            bool targetIsNullOrEmpty = string.IsNullOrEmpty(target);
            if (p.Identifier.IsCharacterData)
            {
                CharacterData chara = varData.CharacterList[(int)p.Index1];
                array = chara.DataStringArray[p.Identifier.VarCodeInt];
            }
            else
                array = (string[])p.Identifier.GetArray();
            Int64 ret = 0;
            for (int i = (int)start; i < (int)end; i++)
                if ((array[i] == target) || (targetIsNullOrEmpty && string.IsNullOrEmpty(array[i])))
                    ret++;

            return ret;
        }