Пример #1
0
        private void ExtractRand()
        {
            d_randStateSet = new HashSet <object>();

            foreach (var state in new List <State>(AllStates))
            {
                foreach (Instruction i in state.Instructions)
                {
                    InstructionRand r = i as InstructionRand;

                    if (r != null)
                    {
                        Expression expr = new Expression("rand()");
                        expr.Compile(null, null);

                        if (Options.Instance.Validate)
                        {
                            ((InstructionRand)expr.Instructions[0]).Seed = r.Seed;
                        }

                        State rs = new State(r, expr, RawC.State.Flags.None);

                        if (AddState(d_randStateSet, rs))
                        {
                            d_randStates.Add(rs);
                        }
                    }
                }
            }
        }
Пример #2
0
        protected override string Translate(InstructionRand instruction, CLike.Context context)
        {
            var val = base.Translate(instruction, context);

            if (val == null)
            {
                val = "Cdn.Math.rand";
            }

            return(val);
        }
Пример #3
0
        protected override string Translate(InstructionRand instruction, CLike.Context context)
        {
            string val = base.Translate(instruction, context);

            if (val == null)
            {
                val = "CDN_MATH_RAND()";
            }

            return(val);
        }
Пример #4
0
        protected virtual string Translate(InstructionRand instruction, Context context)
        {
            string val = null;

            if (context.Program.StateTable.Contains(instruction))
            {
                var item = context.Program.StateTable[instruction];

                val = String.Format("{0}[{1}]",
                                    context.This(context.Program.StateTable),
                                    item.AliasOrIndex);
            }

            return(val);
        }