Exemplo n.º 1
0
        public override void Traverse(IMethodBody methodBody)
        {
            sourceEmitterOutput.WriteLine("");
            this.sourceEmitterOutput.WriteLine(MemberHelper.GetMethodSignature(methodBody.MethodDefinition,
                                                                               NameFormattingOptions.Signature | NameFormattingOptions.ReturnType | NameFormattingOptions.ParameterModifiers | NameFormattingOptions.ParameterName));
            sourceEmitterOutput.WriteLine("");
            if (this.pdbReader != null)
            {
                PrintScopes(methodBody);
            }
            else
            {
                PrintLocals(methodBody.LocalVariables);
            }

            this.cdfg = ControlAndDataFlowGraph <AiBasicBlock <Instruction>, Instruction> .GetControlAndDataFlowGraphFor(host, methodBody, this.pdbReader);

            this.cfgQueries = new ControlGraphQueries <AiBasicBlock <Instruction>, Instruction>(this.cdfg);
            SingleAssigner <AiBasicBlock <Instruction>, Instruction> .GetInSingleAssignmentForm(host.NameTable, this.cdfg, this.cfgQueries, this.pdbReader);

            this.valueMappings = new ValueMappings <Instruction>(this.host.PlatformType, new Z3Wrapper.Wrapper(host.PlatformType));
            AbstractInterpreter <AiBasicBlock <Instruction>, Instruction> .InterpretUsingAbstractValues(this.cdfg, this.cfgQueries, this.valueMappings);

            var numberOfBlocks = this.cdfg.BlockFor.Count;

            foreach (var block in this.cdfg.AllBlocks)
            {
                this.PrintBlock(block);
            }

            sourceEmitterOutput.WriteLine("**************************************************************");
            sourceEmitterOutput.WriteLine();
        }
Exemplo n.º 2
0
    public override void Traverse(IMethodBody methodBody) {
      sourceEmitterOutput.WriteLine("");
      this.sourceEmitterOutput.WriteLine(MemberHelper.GetMethodSignature(methodBody.MethodDefinition,
        NameFormattingOptions.Signature|NameFormattingOptions.ReturnType|NameFormattingOptions.ParameterModifiers|NameFormattingOptions.ParameterName));
      sourceEmitterOutput.WriteLine("");
      if (this.pdbReader != null)
        PrintScopes(methodBody);
      else
        PrintLocals(methodBody.LocalVariables);

      this.cdfg = ControlAndDataFlowGraph<AiBasicBlock<Instruction>, Instruction>.GetControlAndDataFlowGraphFor(host, methodBody, this.pdbReader);
      this.cfgQueries = new ControlGraphQueries<AiBasicBlock<Instruction>, Instruction>(this.cdfg);
      SingleAssigner<AiBasicBlock<Instruction>, Instruction>.GetInSingleAssignmentForm(host.NameTable, this.cdfg, this.cfgQueries, this.pdbReader);
      this.valueMappings = new ValueMappings<Instruction>(this.host.PlatformType, new Z3Wrapper.Wrapper(host.PlatformType));
      AbstractInterpreter<AiBasicBlock<Instruction>, Instruction>.InterpretUsingAbstractValues(this.cdfg, this.cfgQueries, this.valueMappings);

      var numberOfBlocks = this.cdfg.BlockFor.Count;

      foreach (var block in this.cdfg.AllBlocks) {
        this.PrintBlock(block);
      }

      sourceEmitterOutput.WriteLine("**************************************************************");
      sourceEmitterOutput.WriteLine();
    }
Exemplo n.º 3
0
        protected virtual Dictionary <string, string> GetValueMap()
        {
            var dict = new Dictionary <string, string>();

            string[] parts = ValueMappings.Split(':');

            string[] pair;
            foreach (var p in parts)
            {
                pair = p.Split('=');
                if (pair.Length == 2 && !dict.ContainsKey(pair[0]))
                {
                    dict.Add(pair[0], pair[1]);
                }
            }

            return(dict);
        }
Exemplo n.º 4
0
        public string GetValueMapped(string text)
        {
            if (!string.IsNullOrEmpty(ValueMappings) && ValueMappings.Contains("="))
            {
                var dict = GetValueMap();
                if (HasComparison() && dict.Count > 0)
                {
                    var comparison = dict.First();

                    bool   greater = comparison.Key.Contains(">");
                    string key     = comparison.Key.Replace(">", "").Replace("<", "");
                    float  val     = GetNumValue(text, 0.0f);
                    float  limit   = GetNumValue(key, 0.0f);

                    if (greater)
                    {
                        if (limit >= val)
                        {
                            text = comparison.Value;
                        }
                    }

                    if (!greater)
                    {
                        if (limit <= val)
                        {
                            text = comparison.Value;
                        }
                    }
                }
                else if (dict.ContainsKey(text))
                {
                    text = dict[text];
                }
            }

            return(text);
        }
Exemplo n.º 5
0
 public virtual bool HasComparison()
 {
     return(!string.IsNullOrEmpty(ValueMappings) && (ValueMappings.Contains("<=") || ValueMappings.Contains(">=")));
 }