private Boolean CanExecute(JPF jpf, IServices services) { foreach (var condition in jpf.Conditions) { if (!condition.Boolean(services)) { return(false); } } return(true); }
private void AddIfElseBranches(If control, JPF jpf, JMP jmp) { Int32 endOfBlock = jmp.Index; while (true) { Int32 newJpfIndex = jpf.Index; JPF newJpf = _instructions[newJpfIndex] as JPF; if (newJpf == null || newJpf.Index > endOfBlock) { control.AddElse(jpf.Index, endOfBlock); return; } JMP newJmp = _instructions[newJpf.Index - 1] as JMP; if (newJmp == null) { if (newJpf.Index == endOfBlock) { // if-elseif without jmp _processed.Process(newJpf); control.AddIf(newJpfIndex, newJpf.Index); } else { // if-else without jmp control.AddElse(jpf.Index, endOfBlock); } return; } // Isn't our jump if (newJmp.Index != endOfBlock) { control.AddElse(jpf.Index, endOfBlock); return; } jpf = newJpf; jmp = newJmp; _processed.Process(jpf); _processed.TryProcess(jmp); control.AddIf(newJpfIndex, jpf.Index); if (jpf.Index == endOfBlock) { return; } } }
private Boolean TryMakeIf() { JPF jpf = _begin; JMP jmp = _instructions[_begin.Index - 1] as JMP; If control = new If(_instructions, _index, _begin.Index); _result.Add(control); if (jmp == null) { // There is no JMP instruction. Simple if {} return(true); } if (jmp.Index == jpf.Index) { // It isn't our jump, but an nested if. If { nested if{}<-} return(true); } if (jmp.Index < jpf.Index) { // It isn't our jump, but an nested loop. If { nested while{}<-} return(true); } if (jmp.Index < _index) { // It isn't our jump, but an nested goto. If { nested goto l;<-} return(true); } _processed.Process(jmp); AddIfElseBranches(control, jpf, jmp); return(true); }
private Boolean TryMakeGotoOrSkip() { var instruction = _instructions[_index]; if (instruction is JMP @goto && _processed.TryProcess(@goto)) { var control = new Goto(_instructions, _index, @goto.Index); _result.Add(control); return(true); } if (!(instruction is JPF jpf)) { return(true); } if (!_processed.TryProcess(jpf)) { return(true); } _begin = jpf; return(false); }