예제 #1
0
        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
        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);
                }
            }));
        }