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 static void Main()
    {
        var context = new Context();

        context.TerminalExpressionArgs = new TerminalExpression[] {
            new TerminalExpression(1),
            new TerminalExpression(2)
        };

        AbstractInterpreter[] interpreters = new AbstractInterpreter[] {
            new TerminalExpression(3),
            new NonTerminalExpression()
            {
                BinaryOperation = (a, b) => a * b
            }
        };
        Assert.Equal(6, interpreters[0].Interpret(context));
        Assert.Equal(8, interpreters[1].Interpret(context));

        TestRunner.Print();
    }
Exemplo n.º 3
0
 private JavaExecutor()
 {
     ///后面可以根据需要动态加载其他类型的解释器
     _interpreter = new NativeInterpreter();
 }