Пример #1
0
        internal ZCompilerResult(ZRoutine routine, ZRoutineCall[] calls, ZRoutineCode code, RoutineCompilationStatistics statistics)
        {
            if (routine == null)
            {
                throw new ArgumentNullException("routine");
            }

            if (calls == null)
            {
                throw new ArgumentNullException("calls");
            }

            if (code == null)
            {
                throw new ArgumentNullException("code");
            }

            if (statistics == null)
            {
                throw new ArgumentNullException("statistics");
            }

            this.Routine    = routine;
            this.Calls      = calls;
            this.Code       = code;
            this.Statistics = statistics;
        }
Пример #2
0
        public VariableView GetViewForLocal(ZRoutine routine, int localIndex)
        {
            var          index  = new KeyValuePair <int, int>(routine.Address, localIndex);
            VariableView result = null;

            localsViews.TryGetValue(index, out result);
            return(result);
        }
Пример #3
0
 private static DynamicMethod CreateDynamicMethod(ZRoutine routine)
 {
     return(new DynamicMethod(
                name: string.Format("{0:x4}_{1}_locals", routine.Address, routine.Locals.Length),
                returnType: typeof(ushort),
                parameterTypes: Types.Array <CompiledZMachine, byte[], ushort[], ushort[], int, ZRoutineCall[], int>(),
                owner: typeof(CompiledZMachine),
                skipVisibility: true));
 }
Пример #4
0
        private ControlFlowGraph(ZRoutine routine)
        {
            this.routine = routine;

            this.entry = new Block(isEntry: true);
            this.exit  = new Block(isExit: true);

            var instructions = new InstructionLinkedList(routine);

            this.codeBlocks = new List <CodeBlock>(BuildGraph(instructions));
        }
Пример #5
0
        public InstructionLinkedList(ZRoutine routine)
            : base(routine.Instructions)
        {
            this.addressToNodeMap = new IntegerMap <LinkedListNode <Instruction> >();

            var node = this.First;

            while (node != null)
            {
                addressToNodeMap.Add(node.Value.Address, node);
                node = node.Next;
            }
        }
Пример #6
0
        internal ZCompilerResult Compile(ZRoutine routine)
        {
            ZCompilerResult result;

            if (!compilationResults.TryGetValue(routine.Address, out result))
            {
                result = ZCompiler.Compile(routine, machine: this);

                compilationResults.Add(routine.Address, result);

                if (profiler != null)
                {
                    profiler.RoutineCompiled(result.Statistics);
                }
            }

            return(result);
        }
Пример #7
0
 internal RoutineCompilationStatistics(
     ZRoutine routine,
     int opcodeCount,
     int localCount,
     int size,
     TimeSpan compileTime,
     int calculatedLoadVariableCount,
     int calculatedStoreVariableCount,
     List <InstructionStatistics> instructionSizes)
 {
     this.routine     = routine;
     this.opcodeCount = opcodeCount;
     this.localCount  = localCount;
     this.size        = size;
     this.compileTime = compileTime;
     this.calculatedLoadVariableCount  = calculatedLoadVariableCount;
     this.calculatedStoreVariableCount = calculatedStoreVariableCount;
     this.instructionSizes             = new ReadOnlyCollection <InstructionStatistics>(instructionSizes);
 }
Пример #8
0
        internal ushort[] GetLocalArray(ZRoutine routine)
        {
            var result = localArrayPool.Count > 0
                ? localArrayPool.Pop()
                : new ushort[15];

            if (Version < 5)
            {
                var localCount = routine.Locals.Length;
                for (int i = 0; i < localCount; i++)
                {
                    var localValue = routine.Locals[i];
                    if (localValue > 0)
                    {
                        result[i] = localValue;
                    }
                }
            }

            return(result);
        }
Пример #9
0
 public ZRoutineCall(ZRoutine routine, CompiledZMachine machine)
 {
     this.Machine = machine;
     this.Routine = routine;
 }
Пример #10
0
 public static ZCompilerResult Compile(ZRoutine routine, CompiledZMachine machine)
 {
     return(new ZCompiler(routine, machine).Compile());
 }
Пример #11
0
 private ZCompiler(ZRoutine routine, CompiledZMachine machine, bool debugging = false)
 {
     this.routine   = routine;
     this.machine   = machine;
     this.debugging = debugging;
 }
 public DisassemblyRoutineHeaderLineViewModel(ZRoutine routine)
 {
     this.routine = routine;
 }
Пример #13
0
 public static ControlFlowGraph Build(ZRoutine routine)
 {
     return(new ControlFlowGraph(routine));
 }
Пример #14
0
 public void SetViewForLocal(ZRoutine routine, int localIndex, VariableView view)
 {
     SetViewForLocal(routine.Address, localIndex, view);
 }
Пример #15
0
 public RoutineNameChangedEventArgs(ZRoutine routine)
 {
     this.routine = routine;
 }
Пример #16
0
 public DisassemblyAddressGapLineViewModel(ZRoutine start, ZRoutine end)
 {
     this.start = start;
     this.end   = end;
 }