コード例 #1
0
ファイル: BoolClass.cs プロジェクト: Kyky10/New-Inter
        private void Init()
        {
            Operations = new List <Operation>();
            Statements = new List <Statement>();
            Functions  = new List <Function>();

            Operations.Add(new Operation("&&", new Function("& a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt() % 2 == 1;
                    var b = arr[1].GetInt() % 2 == 1;

                    var newClass = new BoolClass(a && b);

                    return(newClass);
                }
            }));



            Operations.Add(new Operation("||", new Function("| a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt() % 2 == 1;
                    var b = arr[1].GetInt() % 2 == 1;

                    var newClass = new BoolClass(a || b);

                    return(newClass);
                }
            }));
        }
コード例 #2
0
ファイル: IntClass.cs プロジェクト: Kyky10/New-Inter
        private void Init()
        {
            Operations = new List <Operation>();
            Statements = new List <Statement>();
            Functions  = new List <Function>();

            Operations.Add(new Operation("==", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt();
                    var b = arr[1].GetInt();

                    var newClass = new BoolClass(a == b);

                    return(newClass);
                }
            }));

            Operations.Add(new Operation("!=", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt();
                    var b = arr[1].GetInt();

                    var newClass = new BoolClass(a != b);

                    return(newClass);
                }
            }));


            Operations.Add(new Operation("+", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt();
                    var b = arr[1].GetInt();

                    var newClass = new IntClass(a + b);

                    return(newClass);
                }
            }));



            Operations.Add(new Operation("-", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt();
                    var b = arr[1].GetInt();

                    var newClass = new IntClass(a - b);

                    return(newClass);
                }
            }));



            Operations.Add(new Operation(">", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt();
                    var b = arr[1].GetInt();

                    var newClass = new BoolClass(a > b);

                    return(newClass);
                }
            }));



            Operations.Add(new Operation("<", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt();
                    var b = arr[1].GetInt();

                    var newClass = new BoolClass(a < b);

                    return(newClass);
                }
            }));



            Operations.Add(new Operation("&", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt() % 2 == 1;
                    var b = arr[1].GetInt() % 2 == 1;

                    var newClass = new BoolClass(a && b);

                    return(newClass);
                }
            }));



            Operations.Add(new Operation("|", new Function("oper a, b:", Lib, Block)
            {
                Exec = o =>
                {
                    var arr = (object[])o;

                    if (arr.Length != 2)
                    {
                        return(null);
                    }

                    var a = arr[0].GetInt() % 2 == 1;
                    var b = arr[1].GetInt() % 2 == 1;

                    var newClass = new BoolClass(a || b);

                    return(newClass);
                }
            }));
        }