Example #1
0
        public SymbolicMap createMap(BaseBlock b)
        {
            var m = new SymbolicMap();

            foreach (var line in b.Enumerate())
            {
                //if ((line.Operation == Operation.Plus))
                {
                    if (line.RightOperand == null)
                    {
                        //константа
                        if (line.LeftOperand is NumericValue)
                        {
                            VariableValue newValue = new VariableValue();
                            AffineExpr    affe     = new AffineExpr();
                            affe.value     = (line.LeftOperand as NumericValue).Value;
                            newValue.value = affe;
                            newValue.type  = VariableValueType.NAA;
                            m.variableTable[line.Destination as IdentificatorValue] = newValue;
                        }
                        //одна переменная в левой части
                        else
                        {
                            m = TransferFunc(line, m);
                        }
                    }
                    // в правой части выражения две переменные
                    else
                    {
                        m = TransferFunc(line, m);
                    }
                }
            }

            return(m);
        }
Example #2
0
        private AffineExpr ComputeAffineExpr(IThreeAddressCode s, SymbolicMap m)
        {
            AffineExpr res = new AffineExpr();

            res.constants = new List <int>();
            res.variables = new List <IdentificatorValue>();

            if (s.LeftOperand is NumericValue)
            {
                res.constants.Add((s.LeftOperand as NumericValue).Value);
            }
            else
            {
                res.variables.Add(s.LeftOperand as IdentificatorValue);

                if (IsAffineExpressible(s))
                {
                    if (m.variableTable.ContainsKey(s.LeftOperand as IdentificatorValue))
                    {
                        if (m.variableTable[s.LeftOperand as IdentificatorValue].value.constants != null)
                        {
                            if ((s.LeftOperand as IdentificatorValue).ToString()[0] == '$')
                            {
                                foreach (var v in m.variableTable[s.LeftOperand as IdentificatorValue].value.constants)
                                {
                                    res.constants.Add(v);
                                }
                            }
                        }
                    }
                }
            }

            if (s.RightOperand != null)
            {
                if (s.RightOperand is NumericValue)
                {
                    res.constants.Add((s.RightOperand as NumericValue).Value);
                }
                else
                {
                    res.variables.Add(s.RightOperand as IdentificatorValue);

                    if (IsAffineExpressible(s))
                    {
                        if (m.variableTable.ContainsKey(s.RightOperand as IdentificatorValue))
                        {
                            if (m.variableTable[s.RightOperand as IdentificatorValue].value.constants != null)
                            {
                                if ((s.RightOperand as IdentificatorValue).ToString()[0] == '$')
                                {
                                    foreach (var v in m.variableTable[s.RightOperand as IdentificatorValue].value.constants)
                                    {
                                        res.constants.Add(v);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(res);
        }