Example #1
0
 public Operation(Vector Op1, byte Op2, char Op)
 {
     op1    = Op1;
     op2    = new Vector();
     op     = Op;
     op1loc = 255;
     op2loc = Op2;
     args   = ArgsToUse.Right;
 }
Example #2
0
 public Operation(byte Op1, Vector Op2, char Op)
 {
     op1    = new Vector();
     op2    = Op2;
     op     = Op;
     op1loc = Op1;
     op2loc = 255;
     args   = ArgsToUse.Left;
 }
Example #3
0
 public Operation(Vector Op1, Vector Op2, char Op)
 {
     op1    = Op1;
     op2    = Op2;
     op     = Op;
     op1loc = 255;
     op2loc = 255;
     args   = ArgsToUse.None;
 }
Example #4
0
 public Operation(byte Op1, byte Op2, char Op)
 {
     op1    = new Vector();
     op2    = new Vector();
     op     = Op;
     op1loc = Op1;
     op2loc = Op2;
     args   = ArgsToUse.Both;
 }
Example #5
0
 public Operation(byte Op1,byte Op2,char Op)
 {
     op1=new Vector();
     op2=new Vector();
     op=Op;
     op1loc=Op1;
     op2loc=Op2;
     args=ArgsToUse.Both;
 }
Example #6
0
 public Operation(Vector Op1,byte Op2,char Op)
 {
     op1=Op1;
     op2=new Vector();
     op=Op;
     op1loc=255;
     op2loc=Op2;
     args=ArgsToUse.Right;
 }
Example #7
0
 public Operation(byte Op1,Vector Op2,char Op)
 {
     op1=new Vector();
     op2=Op2;
     op=Op;
     op1loc=Op1;
     op2loc=255;
     args=ArgsToUse.Left;
 }
Example #8
0
 public Operation(Vector Op1,Vector Op2,char Op)
 {
     op1=Op1;
     op2=Op2;
     op=Op;
     op1loc=255;
     op2loc=255;
     args=ArgsToUse.None;
 }
Example #9
0
        public static Operation DeepOp(ref VectorMatch vm, byte depth)
        {
            if (depth > 254)
            {
                throw new OptimizationException("Code generater: Too deep recursion");
            }
            int    count = 0; int maxcount = 0; int pos = 0;
            string s = vm.calc;

            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                case '(':
                    count++;
                    if (count > maxcount)
                    {
                        maxcount = count;
                    }
                    break;

                case ')': count--; break;
                }
            }
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                case '(':
                    count++;
                    if (count == maxcount)
                    {
                        ArgsToUse atu = ArgsToUse.None;
                        int       b   = 2;
                        if (s[i + 1] != '$')
                        {
                            atu |= ArgsToUse.Left; b--;
                        }
                        if (s[i + 3] != '$')
                        {
                            atu |= ArgsToUse.Right; b--;
                        }
                        Operation o = new Operation();
                        switch (atu)
                        {
                        case ArgsToUse.None:
                            o = new Operation(vm.pArguments[pos], vm.pArguments[pos + 1], s[i + 2]);
                            break;

                        case ArgsToUse.Left:
                            o = new Operation(GetRegister(s[i + 1]), vm.pArguments[pos], s[i + 2]);
                            //Registers[GetRegister(s[i+1])].contains=depth;
                            break;

                        case ArgsToUse.Right:
                            o = new Operation(vm.pArguments[pos], GetRegister(s[i + 3]), s[i + 2]);
                            break;

                        case ArgsToUse.Both:
                            o = new Operation(GetRegister(s[i + 3]), GetRegister(s[i + 1]), s[i + 2]);
                            //Registers[GetRegister(s[i+1])].contains=depth;
                            break;
                        }
                        Vector[] vs = new Vector[vm.pArguments.Length - b];
                        int      c  = 0;
                        for (int a = 0; a < vm.pArguments.Length; a++)
                        {
                            if (a == c && b > 0)
                            {
                                continue;
                            }
                            if (a == c + 1 && b > 1)
                            {
                                continue;
                            }
                            vs[c++] = vm.pArguments[a];
                        }
                        vm.pArguments = vs;
                        vm.calc       = s.Remove(i, 5);
                        vm.calc       = vm.calc.Insert(i, "" + (char)depth);
                        return(o);
                    }
                    break;

                case ')': count--; break;

                case '$':
                    pos++;
                    break;
                }
            }
            throw new OptimizationException("Code generater: No operation to perform");
        }